mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-24 00:23:50 +00:00
Add new option "as_id" to Pick*DynamicType
This option will make the app return a single id of the entity in data, and not the entity json.
This commit is contained in:
@@ -24,7 +24,8 @@ function loadDynamicPicker(element) {
|
||||
(input.value === '[]' || input.value === '') ?
|
||||
null : [ JSON.parse(input.value) ]
|
||||
)
|
||||
suggested = JSON.parse(el.dataset.suggested)
|
||||
suggested = JSON.parse(el.dataset.suggested),
|
||||
as_id = parseInt(el.dataset.asId) === 1;
|
||||
|
||||
if (!isMultiple) {
|
||||
if (input.value === '[]'){
|
||||
@@ -50,7 +51,8 @@ function loadDynamicPicker(element) {
|
||||
types: JSON.parse(el.dataset.types),
|
||||
picked: picked === null ? [] : picked,
|
||||
uniqid: el.dataset.uniqid,
|
||||
suggested: suggested
|
||||
suggested: suggested,
|
||||
as_id: as_id,
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@@ -69,7 +71,12 @@ function loadDynamicPicker(element) {
|
||||
return el.type === entity.type && el.id === entity.id;
|
||||
})) {
|
||||
this.picked.push(entity);
|
||||
input.value = JSON.stringify(this.picked);
|
||||
if (!as_id) {
|
||||
input.value = JSON.stringify(this.picked);
|
||||
} else {
|
||||
const ids = this.picked.map(el => el.id);
|
||||
input.value = ids.join(',');
|
||||
}
|
||||
console.log(entity)
|
||||
}
|
||||
} else {
|
||||
@@ -78,7 +85,11 @@ function loadDynamicPicker(element) {
|
||||
})) {
|
||||
this.picked.splice(0, this.picked.length);
|
||||
this.picked.push(entity);
|
||||
input.value = JSON.stringify(this.picked[0]);
|
||||
if (!as_id) {
|
||||
input.value = JSON.stringify(this.picked[0]);
|
||||
} else {
|
||||
input.value = this.picked.map(el => el.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
Reference in New Issue
Block a user