fix input value for radio selection in AddPersons modal

selected value is different for radio or checkbox
for radio value is an object, for checkbox vaue is an array of objects
This commit is contained in:
Mathieu Jaumotte 2021-05-17 22:17:08 +02:00
parent e0dc0a8fdb
commit 5b635fbe58
2 changed files with 13 additions and 5 deletions

View File

@ -104,7 +104,7 @@ export default {
},
addNewPersons({ selected, modal }) {
console.log('@@@ CLICK button addNewPersons', selected);
this.$store.dispatch('addRequestor', selected);
this.$store.dispatch('addRequestor', selected.shift());
this.$refs.addPersons.resetSearch(); // to cast child method
modal.showModal = false;
}

View File

@ -2,9 +2,12 @@
<div class="list-item" :class="{ checked: isChecked }">
<div class="container">
<input v-model="selected"
:type="type"
:value="item" />
<input
v-bind:type="type"
v-model="selected"
name="item"
v-bind:id="item"
v-bind:value="setValueIfType(item, type)" />
</div>
<suggestion-person
@ -48,7 +51,12 @@ export default {
},
isChecked() {
return (this.search.selected.indexOf(this.item) === -1) ? false : true;
}
},
},
methods: {
setValueIfType(value, type) {
return (type === 'radio')? [value] : value;
}
}
};
</script>