mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-04 22:04:59 +00:00
FIX [review] implement changes based on review
This commit is contained in:
@@ -23,12 +23,7 @@ function loadDynamicPicker(element) {
|
||||
(input.value === '[]' || input.value === '') ?
|
||||
null : [ JSON.parse(input.value) ]
|
||||
)
|
||||
suggested = JSON.parse('[' + el.dataset.suggested + ']');
|
||||
// suggested = suggested[0];
|
||||
|
||||
console.log(typeof suggested)
|
||||
// console.log(el.dataset.suggested)
|
||||
console.log('suggested', typeof suggested[0])
|
||||
suggested = JSON.parse(el.dataset.suggested);
|
||||
|
||||
if (!isMultiple) {
|
||||
if (input.value === '[]'){
|
||||
@@ -58,13 +53,18 @@ function loadDynamicPicker(element) {
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
addNewEntity(entity) {
|
||||
addNewEntity({entity, isSuggested = false}) {
|
||||
if (this.multiple) {
|
||||
if (!this.picked.some(el => {
|
||||
return el.type === entity.type && el.id === entity.id;
|
||||
})) {
|
||||
this.picked.push(entity);
|
||||
input.value = JSON.stringify(this.picked);
|
||||
console.log(entity)
|
||||
if (isSuggested) {
|
||||
const indexToRemove = this.suggested.findIndex(e => e.id === entity.id)
|
||||
this.suggested.splice(indexToRemove, 1);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!this.picked.some(el => {
|
||||
@@ -76,9 +76,12 @@ function loadDynamicPicker(element) {
|
||||
}
|
||||
}
|
||||
},
|
||||
removeEntity(entity) {
|
||||
removeEntity({entity, isSuggested = false}) {
|
||||
this.picked = this.picked.filter(e => !(e.type === entity.type && e.id === entity.id));
|
||||
input.value = JSON.stringify(this.picked);
|
||||
if (isSuggested) {
|
||||
this.suggested.push(entity);
|
||||
}
|
||||
},
|
||||
}
|
||||
})
|
||||
|
Reference in New Issue
Block a user