mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-24 00:23:50 +00:00
Allow Pick*Type to submit the form when selection an entity, and apply inside Event
This commit is contained in:
@@ -25,7 +25,9 @@ function loadDynamicPicker(element) {
|
||||
null : [ JSON.parse(input.value) ]
|
||||
)
|
||||
suggested = JSON.parse(el.dataset.suggested),
|
||||
as_id = parseInt(el.dataset.asId) === 1;
|
||||
as_id = parseInt(el.dataset.asId) === 1,
|
||||
submit_on_adding_new_entity = parseInt(el.dataset.submitOnAddingNewEntity) === 1
|
||||
label = el.dataset.label;
|
||||
|
||||
if (!isMultiple) {
|
||||
if (input.value === '[]'){
|
||||
@@ -40,6 +42,7 @@ function loadDynamicPicker(element) {
|
||||
':picked="picked" ' +
|
||||
':uniqid="uniqid" ' +
|
||||
':suggested="notPickedSuggested" ' +
|
||||
':label="label" ' +
|
||||
'@addNewEntity="addNewEntity" ' +
|
||||
'@removeEntity="removeEntity"></pick-entity>',
|
||||
components: {
|
||||
@@ -51,8 +54,10 @@ function loadDynamicPicker(element) {
|
||||
types: JSON.parse(el.dataset.types),
|
||||
picked: picked === null ? [] : picked,
|
||||
uniqid: el.dataset.uniqid,
|
||||
suggested: suggested,
|
||||
as_id: as_id,
|
||||
suggested,
|
||||
as_id,
|
||||
submit_on_adding_new_entity,
|
||||
label,
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@@ -92,6 +97,10 @@ function loadDynamicPicker(element) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this.submit_on_adding_new_entity) {
|
||||
input.form.submit();
|
||||
}
|
||||
},
|
||||
removeEntity({entity}) {
|
||||
if (-1 === this.suggested.findIndex(e => e.type === entity.type && e.id === entity.id)) {
|
||||
|
@@ -56,6 +56,10 @@ export default {
|
||||
suggested: {
|
||||
type: Array,
|
||||
default: []
|
||||
},
|
||||
label: {
|
||||
type: String,
|
||||
required: false,
|
||||
}
|
||||
},
|
||||
emits: ['addNewEntity', 'removeEntity'],
|
||||
@@ -80,6 +84,10 @@ export default {
|
||||
};
|
||||
},
|
||||
translatedListOfTypes() {
|
||||
if (this.label !== '') {
|
||||
return this.label;
|
||||
}
|
||||
|
||||
let trans = [];
|
||||
this.types.forEach(t => {
|
||||
if (this.$props.multiple) {
|
||||
|
Reference in New Issue
Block a user