Prevents breaking form hooks when theme is not updated. Bulk edition second select now automatically selects when only one option is available.

This commit is contained in:
Mateus Machado Luna 2018-09-04 16:25:48 -03:00
parent 94144763ed
commit f6ad2f3275
4 changed files with 15 additions and 7 deletions

View File

@ -25,11 +25,13 @@
<template
v-for="(metadatum, index) in metadata">
<option
:key="index"
v-if="metadatum.id"
:value="metadatum.id">
{{ metadatum.name }}
</option>
<option
:key="index"
v-if="index === Object.keys(metadata).length-1"
value="status">
{{ $i18n.get('label_status') }}
@ -42,6 +44,7 @@
v-if="bulkEditionProcedures[criterion] &&
bulkEditionProcedures[criterion].metadatumID"
:disabled="!!bulkEditionProcedures[criterion].action"
:value="bulkEditionProcedures[criterion].action ? bulkEditionProcedures[criterion].action : undefined"
class="tainacan-bulk-edition-field tainacan-bulk-edition-field-not-last"
:placeholder="$i18n.get('instruction_select_a_action')"
@input="addToBulkEditionProcedures($event, 'action', criterion)">
@ -57,7 +60,6 @@
<option
v-for="(edtAct, key) in editionActionsForNotMultiple"
:value="edtAct"
:selected="Object.keys(editionActionsForNotMultiple).length === 1"
:key="key">
{{ edtAct }}
</option>
@ -533,11 +535,19 @@
return found ? found : {};
},
addToBulkEditionProcedures(value, key, criterion){
if(Array.isArray(value)){
value = value[0];
}
this.$set(this.bulkEditionProcedures[criterion], `${key}`, value);
if (key == 'metadatumID') {
if (this.getMetadataByID(this.bulkEditionProcedures[criterion].metadatumID).multiple != 'yes') {
let value = Object.values(this.editionActionsForNotMultiple)[0];
this.addToBulkEditionProcedures(value, 'action', criterion);
}
}
}
},
}

View File

@ -65,7 +65,7 @@ export const formHooks = {
];
// Gets data from existing extra form hooks
for (let position of positions) {
if (this.formHooks[entity][position] && this.formHooks[entity][position] != undefined) {
if (this.formHooks[entity] && this.formHooks[entity][position] && this.formHooks[entity][position] != undefined) {
let formElement = document.getElementById('form-' + entity + '-' + position);
if (formElement) {
for (let element of formElement.elements) {
@ -95,7 +95,7 @@ export const formHooks = {
];
// Gets data from existing extra form hooks
for (let position of positions) {
if (this.formHooks[entity][position] && this.formHooks[entity][position] != undefined) {
if (this.formHooks[entity] && this.formHooks[entity][position] && this.formHooks[entity][position] != undefined) {
let formElement = document.getElementById('form-' + entity + '-' + position);
if (formElement) {

View File

@ -110,8 +110,7 @@ export const ThemeItemsListing = new Vue({
},
render: h => h(ThemeItemsList),
beforeMount () {
console.log("oie")
//if (this.$el.attributes['collection-id'] != undefined)
if (this.$el.attributes['collection-id'] != undefined)
this.collectionId = this.$el.attributes['collection-id'].value;
if (this.$el.attributes['default-view-mode'] != undefined)
this.defaultViewMode = this.$el.attributes['default-view-mode'].value;

View File

@ -20,7 +20,6 @@
export default {
name: "ThemeItemsList",
created() {
console.log("oi")
this.$userPrefs.init();
}
}