mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
get options and display selected
This commit is contained in:
parent
a88acd34fd
commit
4d12796289
@ -28,17 +28,18 @@ import Confirm from './components/Confirm.vue';
|
|||||||
export default {
|
export default {
|
||||||
name: 'App',
|
name: 'App',
|
||||||
components: {
|
components: {
|
||||||
Banner,
|
//Banner,
|
||||||
PersonsAssociated,
|
//StickyNav,
|
||||||
Requestor,
|
//PersonsAssociated,
|
||||||
|
//Requestor,
|
||||||
SocialIssue,
|
SocialIssue,
|
||||||
Referrer,
|
//Referrer, // fait foirer socialissues
|
||||||
Resources,
|
//Resources,
|
||||||
Comment,
|
//Comment,
|
||||||
Confirm,
|
//Confirm,
|
||||||
},
|
},
|
||||||
computed: mapState([
|
computed: mapState([
|
||||||
'accompanyingCourse'
|
'accompanyingCourse', 'socialIssueOptions'
|
||||||
])
|
])
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
@ -146,6 +146,25 @@ const postResource = (id, payload, method) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
const postSocialIssue = (id, body, method) => {
|
||||||
|
console.log('body + method', body, method);
|
||||||
|
const url = `/api/1.0/person/accompanying-course/${id}/socialissue.json`;
|
||||||
|
return fetch(url, {
|
||||||
|
method: method,
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json;charset=utf-8'
|
||||||
|
},
|
||||||
|
body: JSON.stringify(body)
|
||||||
|
})
|
||||||
|
.then(response => {
|
||||||
|
if (response.ok) { return response.json(); }
|
||||||
|
throw Error('Error with request resource response');
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
export {
|
export {
|
||||||
getAccompanyingCourse,
|
getAccompanyingCourse,
|
||||||
patchAccompanyingCourse,
|
patchAccompanyingCourse,
|
||||||
@ -154,4 +173,5 @@ export {
|
|||||||
postParticipation,
|
postParticipation,
|
||||||
postRequestor,
|
postRequestor,
|
||||||
postResource,
|
postResource,
|
||||||
|
postSocialIssue
|
||||||
};
|
};
|
||||||
|
@ -3,19 +3,22 @@
|
|||||||
<h2><a name="section-30"></a>{{ $t('social_issue.title') }}</h2>
|
<h2><a name="section-30"></a>{{ $t('social_issue.title') }}</h2>
|
||||||
|
|
||||||
<div class="my-4">
|
<div class="my-4">
|
||||||
<!--label for="selectIssues">{{ $t('social_issue.label') }}</label-->
|
<!--label for="selectIssues">{{ $t('social_issue.label') }}</label
|
||||||
|
name="selectIssues"
|
||||||
|
-->
|
||||||
<VueMultiselect
|
<VueMultiselect
|
||||||
name="selectIssues"
|
:close-on-select="false"
|
||||||
v-model="selected"
|
:allow-empty="true"
|
||||||
track-by="id"
|
:show-labels="false"
|
||||||
label="text"
|
track-by="id"
|
||||||
:placeholder="$t('social_issue.label')"
|
label="text"
|
||||||
:multiple="true"
|
:multiple="true"
|
||||||
:searchable="true"
|
:searchable="false"
|
||||||
:close-on-select="false"
|
:placeholder="$t('social_issue.label')"
|
||||||
:allow-empty="true"
|
@update:model-value="updateSocialIssues"
|
||||||
:show-labels="false"
|
:model-value="value"
|
||||||
:options="options">
|
:options="options"
|
||||||
|
>
|
||||||
</VueMultiselect>
|
</VueMultiselect>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -23,31 +26,31 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import VueMultiselect from 'vue-multiselect'
|
import VueMultiselect from 'vue-multiselect';
|
||||||
import { getSocialIssues } from '../api'
|
import { getSocialIssues } from '../api';
|
||||||
|
import { mapState, mapActions } from 'vuex';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "SocialIssue",
|
name: "SocialIssue",
|
||||||
components: { VueMultiselect },
|
components: { VueMultiselect },
|
||||||
data () {
|
|
||||||
return {
|
|
||||||
selected: null,
|
|
||||||
options: []
|
|
||||||
}
|
|
||||||
},
|
|
||||||
computed: {
|
computed: {
|
||||||
|
...mapState({
|
||||||
|
value: state => state.accompanyingCourse.socialIssues,
|
||||||
|
options: state => state.socialIssueOptions,
|
||||||
|
})
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.getOptions();
|
this.getOptions();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getOptions() {
|
getOptions() {
|
||||||
getSocialIssues().then(socialIssues => new Promise((resolve, reject) => {
|
getSocialIssues().then(elements => new Promise((resolve, reject) => {
|
||||||
console.log('socialIssues', socialIssues);
|
console.log('get socialIssues', elements.results);
|
||||||
this.options = socialIssues.results;
|
this.$store.commit('setSocialIssueOptions', elements.results);
|
||||||
resolve();
|
resolve();
|
||||||
})).catch(error => this.$store.commit('catchError', error));
|
})).catch(error => this.$store.commit('catchError', error));
|
||||||
},
|
},
|
||||||
|
...mapActions(['updateSocialIssues'])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -5,7 +5,8 @@ import { getAccompanyingCourse,
|
|||||||
confirmAccompanyingCourse,
|
confirmAccompanyingCourse,
|
||||||
postParticipation,
|
postParticipation,
|
||||||
postRequestor,
|
postRequestor,
|
||||||
postResource } from '../api';
|
postResource,
|
||||||
|
postSocialIssue } from '../api';
|
||||||
|
|
||||||
const debug = process.env.NODE_ENV !== 'production';
|
const debug = process.env.NODE_ENV !== 'production';
|
||||||
const id = window.accompanyingCourseId;
|
const id = window.accompanyingCourseId;
|
||||||
@ -19,6 +20,7 @@ let initPromise = getAccompanyingCourse(id)
|
|||||||
},
|
},
|
||||||
state: {
|
state: {
|
||||||
accompanyingCourse: accompanying_course,
|
accompanyingCourse: accompanying_course,
|
||||||
|
socialIssueOptions: [],
|
||||||
errorMsg: []
|
errorMsg: []
|
||||||
},
|
},
|
||||||
getters: {
|
getters: {
|
||||||
@ -76,6 +78,13 @@ let initPromise = getAccompanyingCourse(id)
|
|||||||
postFirstComment(state, comment) {
|
postFirstComment(state, comment) {
|
||||||
console.log('### mutation: postFirstComment', comment);
|
console.log('### mutation: postFirstComment', comment);
|
||||||
state.accompanyingCourse.initialComment = comment;
|
state.accompanyingCourse.initialComment = comment;
|
||||||
|
},
|
||||||
|
updateSocialIssues(state, value) {
|
||||||
|
state.accompanyingCourse.socialIssues = value;
|
||||||
|
},
|
||||||
|
setSocialIssueOptions(state, value) {
|
||||||
|
console.log('## mutation: setSocialIssueOptions', value);
|
||||||
|
state.socialIssueOptions = value;
|
||||||
},
|
},
|
||||||
confirmAccompanyingCourse(state, response) {
|
confirmAccompanyingCourse(state, response) {
|
||||||
//console.log('### mutation: confirmAccompanyingCourse: response', response);
|
//console.log('### mutation: confirmAccompanyingCourse: response', response);
|
||||||
@ -174,7 +183,14 @@ let initPromise = getAccompanyingCourse(id)
|
|||||||
resolve();
|
resolve();
|
||||||
})).catch((error) => { commit('catchError', error) });
|
})).catch((error) => { commit('catchError', error) });
|
||||||
},
|
},
|
||||||
|
updateSocialIssues({ commit }, payload) {
|
||||||
|
//postSocialIssue(id, { type: "social_issue", id: payload.id }, payload.method)
|
||||||
|
//.then(response => new Promise((resolve, reject) => {
|
||||||
|
// console.log('response', response);
|
||||||
|
commit('updateSocialIssues', payload);
|
||||||
|
// resolve();
|
||||||
|
//})).catch((error) => { commit('catchError', error) });
|
||||||
|
},
|
||||||
confirmAccompanyingCourse({ commit }) {
|
confirmAccompanyingCourse({ commit }) {
|
||||||
console.log('## action: confirmAccompanyingCourse');
|
console.log('## action: confirmAccompanyingCourse');
|
||||||
confirmAccompanyingCourse(id)
|
confirmAccompanyingCourse(id)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user