vue accompanyingcourse: ending referrer subcomponent

This commit is contained in:
2021-06-30 11:59:54 +02:00
parent 196f709065
commit d3ac8d8ceb
3 changed files with 66 additions and 43 deletions

View File

@@ -1,42 +1,43 @@
<template>
<div class="vue-component">
<h2><a name="section-40"></a>{{ $t('referrer.title') }}</h2>
<div class="my-4">
<label for="" class="">
{{ $t('referrer.label') }}
</label>
<VueMultiselect
track-by="id"
label="text"
:multiple="false"
:searchable="true"
:placeholder="$t('referrer.placeholder')"
@update:model-value="updateReferrer"
:model-value="value"
:options="options">
</VueMultiselect>
<ul class="record_actions">
<li>
<button
class="sc-button bt-create"
type="button"
name="button"
@click="assignMe">
{{ $t('referrer.assign_me') }}
</button>
</li>
</ul>
</div>
</div>
<div class="vue-component">
<h2><a name="section-40"></a>{{ $t('referrer.title') }}</h2>
<div class="my-4">
<label for="" class="">
{{ $t('referrer.label') }}
</label>
<VueMultiselect
name="selectReferrer"
label="text"
track-by="id"
v-bind:multiple="false"
v-bind:searchable="true"
v-bind:placeholder="$t('referrer.placeholder')"
v-model="value"
v-bind:options="options"
@select="updateReferrer">
</VueMultiselect>
<ul class="record_actions">
<li>
<button
class="sc-button bt-create"
type="button"
name="button"
@click="assignMe">
{{ $t('referrer.assign_me') }}
</button>
</li>
</ul>
</div>
</div>
</template>
<script>
import VueMultiselect from 'vue-multiselect';
import { getUsers } from '../api';
import { getUsers, whoami } from '../api';
import { mapState } from 'vuex';
export default {
@@ -58,19 +59,20 @@ export default {
methods: {
getOptions() {
getUsers().then(response => new Promise((resolve, reject) => {
console.log(response);
this.options = response.results;
resolve();
})).catch(er => this.$store.commit('catchError'), error);
}));
},
updateReferrer(value) {
this.$store.dispatch('updateReferrer', this.transformValue(value));
},
transformValue(value) {
let payload = value;
return { payload, body, method };
//console.log('value', value);
this.$store.dispatch('updateReferrer', value);
},
assignMe() {
console.log('assign me');
//console.log('assign me');
whoami().then(me => new Promise((resolve, reject) => {
this.$store.dispatch('updateReferrer', me);
resolve();
}));
}
}
}