vue_activity: removing v-model in a multiselect (try to fix warning in console)

This commit is contained in:
Mathieu Jaumotte 2021-10-13 09:54:50 +02:00
parent 2d0895b83d
commit 7c21818f00

View File

@ -1,12 +1,12 @@
<template> <template>
<teleport to="#social-issues-acc"> <teleport to="#social-issues-acc">
<div class="mb-3 row"> <div class="mb-3 row">
<div class="col-4"> <div class="col-4">
<label class="col-form-label">{{ $t('activity.social_issues') }}</label> <label class="col-form-label">{{ $t('activity.social_issues') }}</label>
</div> </div>
<div class="col-8"> <div class="col-8">
<check-social-issue <check-social-issue
v-for="issue in socialIssuesList" v-for="issue in socialIssuesList"
v-bind:key="issue.id" v-bind:key="issue.id"
@ -14,7 +14,7 @@
v-bind:selection="socialIssuesSelected" v-bind:selection="socialIssuesSelected"
@updateSelected="updateIssuesSelected"> @updateSelected="updateIssuesSelected">
</check-social-issue> </check-social-issue>
<div class="my-3"> <div class="my-3">
<VueMultiselect <VueMultiselect
name="otherIssues" name="otherIssues"
@ -28,16 +28,15 @@
v-bind:taggable="false" v-bind:taggable="false"
v-bind:multiple="false" v-bind:multiple="false"
v-bind:searchable="true" v-bind:searchable="true"
v-bind:allow-empty="true" v-bind:allow-empty="true"
v-bind:show-labels="false" v-bind:show-labels="false"
v-bind:loading="issueIsLoading" v-bind:loading="issueIsLoading"
v-bind:placeholder="$t('activity.choose_other_social_issue')" v-bind:placeholder="$t('activity.choose_other_social_issue')"
v-bind:options="socialIssuesOther" v-bind:options="socialIssuesOther"
v-model="value"
@select="addIssueInList"> @select="addIssueInList">
</VueMultiselect> </VueMultiselect>
</div> </div>
</div> </div>
</div> </div>
@ -46,11 +45,11 @@
<label class="col-form-label">{{ $t('activity.social_actions') }}</label> <label class="col-form-label">{{ $t('activity.social_actions') }}</label>
</div> </div>
<div class="col-8"> <div class="col-8">
<div v-if="actionIsLoading === true"> <div v-if="actionIsLoading === true">
<i class="chill-green fa fa-circle-o-notch fa-spin fa-lg"></i> <i class="chill-green fa fa-circle-o-notch fa-spin fa-lg"></i>
</div> </div>
<check-social-action <check-social-action
v-if="socialIssuesSelected.length || socialActionsSelected.length" v-if="socialIssuesSelected.length || socialActionsSelected.length"
v-for="action in socialActionsList" v-for="action in socialActionsList"
@ -59,19 +58,18 @@
v-bind:selection="socialActionsSelected" v-bind:selection="socialActionsSelected"
@updateSelected="updateActionsSelected"> @updateSelected="updateActionsSelected">
</check-social-action> </check-social-action>
<span v-else class="inline-choice chill-no-data-statement mt-3"> <span v-else class="inline-choice chill-no-data-statement mt-3">
{{ $t('activity.select_first_a_social_issue') }} {{ $t('activity.select_first_a_social_issue') }}
</span> </span>
</div> </div>
</div> </div>
</teleport> </teleport>
</template> </template>
<script> <script>
import { readonly } from 'vue';
import VueMultiselect from 'vue-multiselect'; import VueMultiselect from 'vue-multiselect';
import CheckSocialIssue from './SocialIssuesAcc/CheckSocialIssue.vue'; import CheckSocialIssue from './SocialIssuesAcc/CheckSocialIssue.vue';
import CheckSocialAction from './SocialIssuesAcc/CheckSocialAction.vue'; import CheckSocialAction from './SocialIssuesAcc/CheckSocialAction.vue';
@ -113,7 +111,7 @@ export default {
this.issueIsLoading = true; this.issueIsLoading = true;
getSocialIssues().then(response => new Promise((resolve, reject) => { getSocialIssues().then(response => new Promise((resolve, reject) => {
this.$store.commit('updateIssuesOther', response.results); this.$store.commit('updateIssuesOther', response.results);
/* Add in list the issues already associated (if not yet listed) /* Add in list the issues already associated (if not yet listed)
*/ */
this.socialIssuesSelected.forEach(issue => { this.socialIssuesSelected.forEach(issue => {
@ -121,34 +119,34 @@ export default {
this.$store.commit('addIssueInList', issue); this.$store.commit('addIssueInList', issue);
} }
}, this); }, this);
/* Remove from multiselect the issues that are not yet in checkbox list /* Remove from multiselect the issues that are not yet in checkbox list
*/ */
this.socialIssuesList.forEach(issue => { this.socialIssuesList.forEach(issue => {
this.$store.commit('removeIssueInOther', issue); this.$store.commit('removeIssueInOther', issue);
}, this); }, this);
/* Filter issues /* Filter issues
*/ */
this.$store.commit('filterList', 'issues'); this.$store.commit('filterList', 'issues');
/* Add in list the actions already associated (if not yet listed) /* Add in list the actions already associated (if not yet listed)
*/ */
this.socialActionsSelected.forEach(action => { this.socialActionsSelected.forEach(action => {
this.$store.commit('addActionInList', action); this.$store.commit('addActionInList', action);
}, this); }, this);
/* Filter issues /* Filter issues
*/ */
this.$store.commit('filterList', 'actions'); this.$store.commit('filterList', 'actions');
this.issueIsLoading = false; this.issueIsLoading = false;
resolve(); resolve();
})); }));
}, },
methods: { methods: {
/* When choosing an issue in multiselect, add it in checkboxes (as selected), /* When choosing an issue in multiselect, add it in checkboxes (as selected),
remove it from multiselect, and add socialActions concerned remove it from multiselect, and add socialActions concerned
*/ */
addIssueInList(value) { addIssueInList(value) {
@ -171,30 +169,30 @@ export default {
//console.log('updateActionsSelected', actions); //console.log('updateActionsSelected', actions);
this.$store.dispatch('updateActionsSelected', actions); this.$store.dispatch('updateActionsSelected', actions);
}, },
/* Add socialActions concerned: after reset, loop on each issue selected /* Add socialActions concerned: after reset, loop on each issue selected
to get social actions concerned to get social actions concerned
*/ */
updateActionsList() { updateActionsList() {
//console.log('updateActionsList'); //console.log('updateActionsList');
this.resetActionsList(); this.resetActionsList();
this.socialIssuesSelected.forEach(item => { this.socialIssuesSelected.forEach(item => {
this.actionIsLoading = true; this.actionIsLoading = true;
getSocialActionByIssue(item.id) getSocialActionByIssue(item.id)
.then(actions => new Promise((resolve, reject) => { .then(actions => new Promise((resolve, reject) => {
actions.results.forEach(action => { actions.results.forEach(action => {
this.$store.commit('addActionInList', action); this.$store.commit('addActionInList', action);
}, this); }, this);
this.$store.commit('filterList', 'actions'); this.$store.commit('filterList', 'actions');
this.actionIsLoading = false; this.actionIsLoading = false;
resolve(); resolve();
})); }));
}, this); }, this);
}, },
/* Reset socialActions List: flush list and restore selected actions /* Reset socialActions List: flush list and restore selected actions
*/ */
resetActionsList() { resetActionsList() {
this.$store.commit('resetActionsList'); this.$store.commit('resetActionsList');