when option uniq is true, display message if you select multiple suggestions

This commit is contained in:
Mathieu Jaumotte 2021-05-10 19:13:50 +02:00
parent f7c08f02c2
commit 040884a039
4 changed files with 11 additions and 2 deletions

View File

@ -91,6 +91,7 @@ export default {
},
addNewPersons({ selected, modal }) {
console.log('@@@ CLICK button addNewPersons', selected);
this.$refs.addPersons.checkUniq();
selected.forEach(function(item) {
this.$store.dispatch('addRequestor', item);
}, this

View File

@ -6,7 +6,7 @@ const parametersToString = ({ query, options }) => {
options.type.forEach(function(type) {
types += '&type[]=' + type;
});
return 'q=' + query + types + '&uniq=' + options.uniq;
return 'q=' + query + types;
};
/*

View File

@ -71,6 +71,7 @@
@click.prevent="$emit('addNewPersons', { selected, modal })">
<i class="fa fa-plus fa-fw"></i>{{ $t('action.add')}}
</button>
{{ $t(checkUniq) }}
</template>
</modal>
@ -144,6 +145,12 @@ export default {
},
options() {
return this.options;
},
checkUniq() {
if (this.options.uniq === true && this.selectedCounter > 1) {
return "error_only_one_person";
}
return '';
}
},
methods: {

View File

@ -11,7 +11,8 @@ const personMessages = {
type_user: "TMS",
type_thirdparty: "Tiers",
type_household: "Ménage"
}
},
error_only_one_person: "Une seule personne peut être sélectionnée !"
}
};