get SocialIssues List in multiselect

This commit is contained in:
Mathieu Jaumotte 2021-05-19 22:20:16 +02:00
parent f548121312
commit 9da4c1ebeb
3 changed files with 37 additions and 3 deletions

View File

@ -43,7 +43,7 @@ export default {
<style lang="scss" scoped> <style lang="scss" scoped>
div.vue-component { div.vue-component {
padding: 1.5em; padding: 1.5em 0;
margin: 2em 0; margin: 2em 0;
border: 2px dotted lightgrey; border: 2px dotted lightgrey;
border-radius: 10px; border-radius: 10px;

View File

@ -13,6 +13,18 @@ const getAccompanyingCourse = (id) => {
}); });
}; };
/*
* Endpoint
*/
const getSocialIssues = () => {
const url = `/api/1.0/person/social-work/social-issue.json`;
return fetch(url)
.then(response => {
if (response.ok) { return response.json(); }
throw Error('Error with request resource response');
});
};
/* /*
* Endpoint v.2 chill_api_single_accompanying_course__entity * Endpoint v.2 chill_api_single_accompanying_course__entity
* method PATCH, patch AccompanyingCourse Instance * method PATCH, patch AccompanyingCourse Instance
@ -121,6 +133,7 @@ const postResource = (id, payload, method) => {
export { export {
getAccompanyingCourse, getAccompanyingCourse,
getSocialIssues,
patchAccompanyingCourse, patchAccompanyingCourse,
postParticipation, postParticipation,
postRequestor, postRequestor,

View File

@ -3,12 +3,18 @@
<h3>{{ $t('social_issue.title') }}</h3> <h3>{{ $t('social_issue.title') }}</h3>
<div> <div>
<label for="selectIssues">{{ $t('social_issue.label') }}</label> <!--label for="selectIssues">{{ $t('social_issue.label') }}</label-->
<VueMultiselect <VueMultiselect
name="selectIssues" name="selectIssues"
v-model="selected" v-model="selected"
track-by="id"
label="text"
:placeholder="$t('social_issue.label')"
:multiple="true" :multiple="true"
:searchable="true"
:close-on-select="false" :close-on-select="false"
:allow-empty="true"
:show-labels="false"
:options="options"> :options="options">
</VueMultiselect> </VueMultiselect>
</div> </div>
@ -18,6 +24,7 @@
<script> <script>
import VueMultiselect from 'vue-multiselect' import VueMultiselect from 'vue-multiselect'
import { getSocialIssues } from '../api'
export default { export default {
name: "SocialIssue", name: "SocialIssue",
@ -25,8 +32,22 @@ export default {
data () { data () {
return { return {
selected: null, selected: null,
options: ['list', 'of', 'options'] options: []
} }
},
computed: {
},
mounted() {
this.getOptions();
},
methods: {
getOptions() {
getSocialIssues().then(socialIssues => new Promise((resolve, reject) => {
console.log('socialIssues', socialIssues);
this.options = socialIssues.results;
resolve();
})).catch(error => this.$store.commit('catchError', error));
},
} }
} }
</script> </script>