Renames most of metadatum objects as itemMetadatum when it comes from item itemMetadata endpoint. #17.
This commit is contained in:
parent
3a290bd970
commit
e9812ea0cb
|
@ -480,9 +480,9 @@
|
||||||
</span>
|
</span>
|
||||||
</a>
|
</a>
|
||||||
<tainacan-form-item
|
<tainacan-form-item
|
||||||
v-for="(metadatum, index) of metadatumList"
|
v-for="(itemMetadatum, index) of metadatumList"
|
||||||
:key="index"
|
:key="index"
|
||||||
:metadatum="metadatum"
|
:item-metadatum="itemMetadatum"
|
||||||
:is-collapsed="metadataCollapses[index]"
|
:is-collapsed="metadataCollapses[index]"
|
||||||
@changeCollapse="onChangeCollapse($event, index)"/>
|
@changeCollapse="onChangeCollapse($event, index)"/>
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
:is="'tainacan-form-item'"
|
:is="'tainacan-form-item'"
|
||||||
v-for="(child, index) in children"
|
v-for="(child, index) in children"
|
||||||
:key="index"
|
:key="index"
|
||||||
:metadatum="child"
|
:item-metadatum="child"
|
||||||
:is-collapsed="childrenMetadataCollapses[index]"
|
:is-collapsed="childrenMetadataCollapses[index]"
|
||||||
@changeCollapse="onChangeCollapse($event, index)"/>
|
@changeCollapse="onChangeCollapse($event, index)"/>
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@
|
||||||
import { mapActions } from 'vuex';
|
import { mapActions } from 'vuex';
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
metadatum: Object,
|
itemMetadatum: Object,
|
||||||
value: [String, Number, Array],
|
value: [String, Number, Array],
|
||||||
disabled: false
|
disabled: false
|
||||||
},
|
},
|
||||||
|
@ -44,18 +44,18 @@
|
||||||
'fetchChildrenMetadata'
|
'fetchChildrenMetadata'
|
||||||
]),
|
]),
|
||||||
createChildInputs() {
|
createChildInputs() {
|
||||||
if (this.metadatum.metadatum &&
|
if (this.itemMetadatum.metadatum &&
|
||||||
this.metadatum.metadatum.metadata_type_options &&
|
this.itemMetadatum.metadatum.metadata_type_options &&
|
||||||
this.metadatum.metadatum.metadata_type_options.children_objects.length > 0
|
this.itemMetadatum.metadatum.metadata_type_options.children_objects.length > 0
|
||||||
) {
|
) {
|
||||||
for (let child of this.metadatum.metadatum.metadata_type_options.children_objects) {
|
for (let child of this.itemMetadatum.metadatum.metadata_type_options.children_objects) {
|
||||||
this.children.push({
|
this.children.push({
|
||||||
parent_meta_id: this.metadatum.value[child.id] ? this.metadatum.value[child.id].parent_meta_id : 0,
|
parent_meta_id: this.itemMetadatum.value[child.id] ? this.itemMetadatum.value[child.id].parent_meta_id : 0,
|
||||||
item: this.metadatum.item,
|
item: this.itemMetadatum.item,
|
||||||
metadatum: child,
|
metadatum: child,
|
||||||
value: this.metadatum.value[child.id] ? this.metadatum.value[child.id].value : [],
|
value: this.itemMetadatum.value[child.id] ? this.itemMetadatum.value[child.id].value : [],
|
||||||
value_as_html: this.metadatum.value[child.id] ? this.metadatum.value[child.id].value_as_html : '',
|
value_as_html: this.itemMetadatum.value[child.id] ? this.itemMetadatum.value[child.id].value_as_html : '',
|
||||||
value_as_string: this.metadatum.value[child.id] ? this.metadatum.value[child.id].value_as_string : ''
|
value_as_string: this.itemMetadatum.value[child.id] ? this.itemMetadatum.value[child.id].value_as_string : ''
|
||||||
});
|
});
|
||||||
this.childrenMetadataCollapses.push(true);
|
this.childrenMetadataCollapses.push(true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<b-input
|
<b-input
|
||||||
:id="metadatum.metadatum.metadata_type_object.component + '-' + metadatum.metadatum.slug"
|
:id="itemMetadatum.metadatum.metadata_type_object.component + '-' + itemMetadatum.metadatum.slug"
|
||||||
:disabled="disabled"
|
:disabled="disabled"
|
||||||
class="input"
|
class="input"
|
||||||
:class="{'is-danger': isInvalidDate && dateValue}"
|
:class="{'is-danger': isInvalidDate && dateValue}"
|
||||||
|
@ -41,7 +41,7 @@
|
||||||
export default {
|
export default {
|
||||||
mixins: [ dateInter ],
|
mixins: [ dateInter ],
|
||||||
props: {
|
props: {
|
||||||
metadatum: Object,
|
itemMetadatum: Object,
|
||||||
value: [String, Number, Array],
|
value: [String, Number, Array],
|
||||||
disabled: false,
|
disabled: false,
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<template>
|
<template>
|
||||||
<b-input
|
<b-input
|
||||||
:disabled="disabled"
|
:disabled="disabled"
|
||||||
:id="metadatum.metadatum.metadata_type_object.component + '-' + metadatum.metadatum.slug"
|
:id="itemMetadatum.metadatum.metadata_type_object.component + '-' + itemMetadatum.metadatum.slug"
|
||||||
:value="value"
|
:value="value"
|
||||||
@input="onInput($event)"
|
@input="onInput($event)"
|
||||||
@blur="onBlur"
|
@blur="onBlur"
|
||||||
|
@ -13,14 +13,14 @@
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
metadatum: Object,
|
itemMetadatum: Object,
|
||||||
value: [String, Number, Array],
|
value: [String, Number, Array],
|
||||||
disabled: false,
|
disabled: false,
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
getStep() {
|
getStep() {
|
||||||
if (this.metadatum && this.metadatum.metadatum.metadata_type_options && this.metadatum.metadatum.metadata_type_options.step)
|
if (this.itemMetadatum && this.itemMetadatum.metadatum.metadata_type_options && this.itemMetadatum.metadatum.metadata_type_options.step)
|
||||||
return this.metadatum.metadatum.metadata_type_options.step;
|
return this.itemMetadatum.metadatum.metadata_type_options.step;
|
||||||
else
|
else
|
||||||
return 0.01;
|
return 0.01;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
<template>
|
<template>
|
||||||
<div :class="{ 'is-flex': metadatum.metadatum.multiple != 'yes' || maxtags != undefined }">
|
<div :class="{ 'is-flex': itemMetadatum.metadatum.multiple != 'yes' || maxtags != undefined }">
|
||||||
<b-taginput
|
<b-taginput
|
||||||
expanded
|
expanded
|
||||||
:disabled="disabled"
|
:disabled="disabled"
|
||||||
:id="metadatum.metadatum.metadata_type_object.component + '-' + metadatum.metadatum.slug"
|
:id="itemMetadatum.metadatum.metadata_type_object.component + '-' + itemMetadatum.metadatum.slug"
|
||||||
:value="selected"
|
:value="selected"
|
||||||
size="is-small"
|
size="is-small"
|
||||||
icon="magnify"
|
icon="magnify"
|
||||||
@input="onInput"
|
@input="onInput"
|
||||||
@blur="onBlur"
|
@blur="onBlur"
|
||||||
:data="options"
|
:data="options"
|
||||||
:maxtags="maxtags != undefined ? maxtags : (metadatum.metadatum.multiple == 'yes' || allowNew === true ? 100 : 1)"
|
:maxtags="maxtags != undefined ? maxtags : (itemMetadatum.metadatum.multiple == 'yes' || allowNew === true ? 100 : 1)"
|
||||||
autocomplete
|
autocomplete
|
||||||
attached
|
attached
|
||||||
:placeholder="$i18n.get('instruction_type_existing_item')"
|
:placeholder="$i18n.get('instruction_type_existing_item')"
|
||||||
|
@ -50,7 +50,7 @@
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
metadatum: Object,
|
itemMetadatum: Object,
|
||||||
maxtags: undefined,
|
maxtags: undefined,
|
||||||
disabled: false,
|
disabled: false,
|
||||||
allowNew: true,
|
allowNew: true,
|
||||||
|
@ -71,10 +71,10 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.collectionId = ( this.metadatum && this.metadatum.metadatum.metadata_type_options && this.metadatum.metadatum.metadata_type_options.collection_id ) ? this.metadatum.metadatum.metadata_type_options.collection_id : '';
|
this.collectionId = ( this.itemMetadatum && this.itemMetadatum.metadatum.metadata_type_options && this.itemMetadatum.metadatum.metadata_type_options.collection_id ) ? this.itemMetadatum.metadatum.metadata_type_options.collection_id : '';
|
||||||
if (this.metadatum.value && (Array.isArray( this.metadatum.value ) ? this.metadatum.value.length > 0 : true )) {
|
if (this.itemMetadatum.value && (Array.isArray( this.itemMetadatum.value ) ? this.itemMetadatum.value.length > 0 : true )) {
|
||||||
let query = qs.stringify({ postin: ( Array.isArray( this.metadatum.value ) ) ? this.metadatum.value : [ this.metadatum.value ] });
|
let query = qs.stringify({ postin: ( Array.isArray( this.itemMetadatum.value ) ) ? this.itemMetadatum.value : [ this.itemMetadatum.value ] });
|
||||||
query += this.metadatum.metadatum.metadata_type_options.search ? '&fetch_only_meta=' + this.metadatum.metadatum.metadata_type_options.search : '';
|
query += this.itemMetadatum.metadatum.metadata_type_options.search ? '&fetch_only_meta=' + this.itemMetadatum.metadatum.metadata_type_options.search : '';
|
||||||
axios.get('/collection/' + this.collectionId + '/items?' + query + '&nopaging=1&fetch_only=title,thumbnail')
|
axios.get('/collection/' + this.collectionId + '/items?' + query + '&nopaging=1&fetch_only=title,thumbnail')
|
||||||
.then( res => {
|
.then( res => {
|
||||||
if (res.data.items) {
|
if (res.data.items) {
|
||||||
|
@ -125,7 +125,7 @@
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// There is already one value set and is not multiple
|
// There is already one value set and is not multiple
|
||||||
if (this.selected.length > 0 && this.metadatum.metadatum.multiple === 'no')
|
if (this.selected.length > 0 && this.itemMetadatum.metadatum.multiple === 'no')
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (this.searchQuery !== '') {
|
if (this.searchQuery !== '') {
|
||||||
|
@ -162,7 +162,7 @@
|
||||||
getItemLabel(item) {
|
getItemLabel(item) {
|
||||||
let label = '';
|
let label = '';
|
||||||
for (let m in item.metadata) {
|
for (let m in item.metadata) {
|
||||||
if (item.metadata[m].id == this.metadatum.metadatum.metadata_type_options.search)
|
if (item.metadata[m].id == this.itemMetadatum.metadatum.metadata_type_options.search)
|
||||||
label = item.metadata[m].value_as_string;
|
label = item.metadata[m].value_as_string;
|
||||||
}
|
}
|
||||||
if (label != '' && label != item.title && item.title != '')
|
if (label != '' && label != item.title && item.title != '')
|
||||||
|
@ -175,13 +175,13 @@
|
||||||
getQueryString( search ) {
|
getQueryString( search ) {
|
||||||
let query = [];
|
let query = [];
|
||||||
|
|
||||||
if (this.metadatum.metadatum.metadata_type_options &&
|
if (this.itemMetadatum.metadatum.metadata_type_options &&
|
||||||
this.metadatum.metadatum.metadata_type_options.search)
|
this.itemMetadatum.metadatum.metadata_type_options.search)
|
||||||
{
|
{
|
||||||
query['metaquery'] = [];
|
query['metaquery'] = [];
|
||||||
|
|
||||||
query['metaquery'][0] = {
|
query['metaquery'][0] = {
|
||||||
key: this.metadatum.metadatum.metadata_type_options.search,
|
key: this.itemMetadatum.metadatum.metadata_type_options.search,
|
||||||
value: search,
|
value: search,
|
||||||
compare: 'LIKE'
|
compare: 'LIKE'
|
||||||
}
|
}
|
||||||
|
@ -190,7 +190,7 @@
|
||||||
query['search'] = search;
|
query['search'] = search;
|
||||||
}
|
}
|
||||||
query['fetch_only'] = 'title,thumbnail';
|
query['fetch_only'] = 'title,thumbnail';
|
||||||
query['fetch_only_meta'] = this.metadatum.metadatum.metadata_type_options.search;
|
query['fetch_only_meta'] = this.itemMetadatum.metadatum.metadata_type_options.search;
|
||||||
query['perpage'] = 12;
|
query['perpage'] = 12;
|
||||||
query['paged'] = this.page;
|
query['paged'] = this.page;
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<b-select
|
<b-select
|
||||||
expanded
|
expanded
|
||||||
:disabled="disabled"
|
:disabled="disabled"
|
||||||
:id="metadatum.metadatum.metadata_type_object.component + '-' + metadatum.metadatum.slug"
|
:id="itemMetadatum.metadatum.metadata_type_object.component + '-' + itemMetadatum.metadatum.slug"
|
||||||
:placeholder="$i18n.get('label_selectbox_init')"
|
:placeholder="$i18n.get('label_selectbox_init')"
|
||||||
:value="value"
|
:value="value"
|
||||||
@input="onSelected($event)">
|
@input="onSelected($event)">
|
||||||
|
@ -21,14 +21,14 @@
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
metadatum: Object,
|
itemMetadatum: Object,
|
||||||
value: [String, Number, Array],
|
value: [String, Number, Array],
|
||||||
disabled: false,
|
disabled: false,
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
getOptions(){
|
getOptions(){
|
||||||
if (this.metadatum && this.metadatum.metadatum.metadata_type_options && this.metadatum.metadatum.metadata_type_options.options ) {
|
if (this.itemMetadatum && this.itemMetadatum.metadatum.metadata_type_options && this.itemMetadatum.metadatum.metadata_type_options.options ) {
|
||||||
const metadata = this.metadatum.metadatum.metadata_type_options.options;
|
const metadata = this.itemMetadatum.metadatum.metadata_type_options.options;
|
||||||
return ( metadata ) ? metadata.split("\n") : [];
|
return ( metadata ) ? metadata.split("\n") : [];
|
||||||
}
|
}
|
||||||
return [];
|
return [];
|
||||||
|
|
|
@ -17,37 +17,37 @@
|
||||||
show: 500,
|
show: 500,
|
||||||
hide: 300,
|
hide: 300,
|
||||||
},
|
},
|
||||||
content: metadatum.metadatum.name,
|
content: itemMetadatum.metadatum.name,
|
||||||
autoHide: false,
|
autoHide: false,
|
||||||
placement: 'auto-end'
|
placement: 'auto-end'
|
||||||
}"
|
}"
|
||||||
class="label">
|
class="label">
|
||||||
{{ metadatum.metadatum.name }}
|
{{ itemMetadatum.metadatum.name }}
|
||||||
</label>
|
</label>
|
||||||
<span
|
<span
|
||||||
v-if="metadatum.metadatum.required == 'yes'"
|
v-if="itemMetadatum.metadatum.required == 'yes'"
|
||||||
class="required-metadatum-asterisk"
|
class="required-metadatum-asterisk"
|
||||||
:class="metadatumTypeMessage">
|
:class="metadatumTypeMessage">
|
||||||
*
|
*
|
||||||
</span>
|
</span>
|
||||||
<span class="metadata-type">
|
<span class="metadata-type">
|
||||||
({{ metadatum.metadatum.metadata_type_object.name }})
|
({{ itemMetadatum.metadatum.metadata_type_object.name }})
|
||||||
</span>
|
</span>
|
||||||
<help-button
|
<help-button
|
||||||
:title="metadatum.metadatum.name"
|
:title="itemMetadatum.metadatum.name"
|
||||||
:message="metadatum.metadatum.description"/>
|
:message="itemMetadatum.metadatum.description"/>
|
||||||
</span>
|
</span>
|
||||||
<transition name="filter-item">
|
<transition name="filter-item">
|
||||||
<div
|
<div
|
||||||
v-show="isCollapsed || metadatumTypeMessage == 'is-danger'"
|
v-show="isCollapsed || metadatumTypeMessage == 'is-danger'"
|
||||||
v-if="isTextInputComponent( metadatum.metadatum.metadata_type_object.component )">
|
v-if="isTextInputComponent( itemMetadatum.metadatum.metadata_type_object.component )">
|
||||||
<component
|
<component
|
||||||
:is="metadatum.metadatum.metadata_type_object.component"
|
:is="itemMetadatum.metadatum.metadata_type_object.component"
|
||||||
v-model="inputs[0]"
|
v-model="inputs[0]"
|
||||||
:metadatum="metadatum"
|
:item-metadatum="itemMetadatum"
|
||||||
@input="changeValue()"
|
@input="changeValue()"
|
||||||
@blur="performValueChange()"/>
|
@blur="performValueChange()"/>
|
||||||
<template v-if="metadatum.metadatum.multiple == 'yes' && inputs.length > 1">
|
<template v-if="itemMetadatum.metadatum.multiple == 'yes' && inputs.length > 1">
|
||||||
<transition-group
|
<transition-group
|
||||||
name="filter-item"
|
name="filter-item"
|
||||||
class="multiple-inputs">
|
class="multiple-inputs">
|
||||||
|
@ -55,9 +55,9 @@
|
||||||
<component
|
<component
|
||||||
v-if="index > 0"
|
v-if="index > 0"
|
||||||
:key="index"
|
:key="index"
|
||||||
:is="metadatum.metadatum.metadata_type_object.component"
|
:is="itemMetadatum.metadatum.metadata_type_object.component"
|
||||||
v-model="inputs[index]"
|
v-model="inputs[index]"
|
||||||
:metadatum="metadatum"
|
:item-metadatum="itemMetadatum"
|
||||||
@input="changeValue()"
|
@input="changeValue()"
|
||||||
@blur="performValueChange()"/>
|
@blur="performValueChange()"/>
|
||||||
<a
|
<a
|
||||||
|
@ -74,7 +74,7 @@
|
||||||
</template>
|
</template>
|
||||||
</transition-group>
|
</transition-group>
|
||||||
</template>
|
</template>
|
||||||
<template v-if="metadatum.metadatum.multiple == 'yes'">
|
<template v-if="itemMetadatum.metadatum.multiple == 'yes'">
|
||||||
<a
|
<a
|
||||||
@click="addInput"
|
@click="addInput"
|
||||||
class="is-block add-link">
|
class="is-block add-link">
|
||||||
|
@ -89,11 +89,11 @@
|
||||||
<transition name="filter-item">
|
<transition name="filter-item">
|
||||||
<div
|
<div
|
||||||
v-show="isCollapsed"
|
v-show="isCollapsed"
|
||||||
v-if="!isTextInputComponent( metadatum.metadatum.metadata_type_object.component )">
|
v-if="!isTextInputComponent( itemMetadatum.metadatum.metadata_type_object.component )">
|
||||||
<component
|
<component
|
||||||
:is="metadatum.metadatum.metadata_type_object.component"
|
:is="itemMetadatum.metadatum.metadata_type_object.component"
|
||||||
v-model="inputs"
|
v-model="inputs"
|
||||||
:metadatum="metadatum"
|
:item-metadatum="itemMetadatum"
|
||||||
@input="changeValue()"
|
@input="changeValue()"
|
||||||
@blur="performValueChange()"/>
|
@blur="performValueChange()"/>
|
||||||
</div>
|
</div>
|
||||||
|
@ -107,7 +107,7 @@
|
||||||
export default {
|
export default {
|
||||||
name: 'TainacanFormItem',
|
name: 'TainacanFormItem',
|
||||||
props: {
|
props: {
|
||||||
metadatum: Object,
|
itemMetadatum: Object,
|
||||||
isCollapsed: true
|
isCollapsed: true
|
||||||
},
|
},
|
||||||
data(){
|
data(){
|
||||||
|
@ -123,9 +123,9 @@
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.createInputs();
|
this.createInputs();
|
||||||
eventBusItemMetadata.$on('updateErrorMessageOf#' + this.metadatum.metadatum.id, (errors) => {
|
eventBusItemMetadata.$on('updateErrorMessageOf#' + this.itemMetadatum.metadatum.id, (errors) => {
|
||||||
let updatedErrorMessage = '';
|
let updatedErrorMessage = '';
|
||||||
if (errors && this.metadatum.metadatum.id == errors.metadatum_id && errors.errors) {
|
if (errors && this.itemMetadatum.metadatum.id == errors.metadatum_id && errors.errors) {
|
||||||
for (let error of errors.errors) {
|
for (let error of errors.errors) {
|
||||||
for (let index of Object.keys(error))
|
for (let index of Object.keys(error))
|
||||||
updatedErrorMessage += error[index] + '\n';
|
updatedErrorMessage += error[index] + '\n';
|
||||||
|
@ -135,7 +135,7 @@
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
beforeDestroy() {
|
beforeDestroy() {
|
||||||
eventBusItemMetadata.$off('updateErrorMessageOf#' + this.metadatum.metadatum.id);
|
eventBusItemMetadata.$off('updateErrorMessageOf#' + this.itemMetadatum.metadatum.id);
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
changeValue: _.debounce(function() {
|
changeValue: _.debounce(function() {
|
||||||
|
@ -145,52 +145,52 @@
|
||||||
if (this.inputs && this.inputs.length > 0 && this.inputs[0] && this.inputs[0].value) {
|
if (this.inputs && this.inputs.length > 0 && this.inputs[0] && this.inputs[0].value) {
|
||||||
let terms = this.inputs.map(term => term.value)
|
let terms = this.inputs.map(term => term.value)
|
||||||
|
|
||||||
if (this.metadatum.value instanceof Array){
|
if (this.itemMetadatum.value instanceof Array) {
|
||||||
let equal = [];
|
let equal = [];
|
||||||
|
|
||||||
for (let meta of terms) {
|
for (let meta of terms) {
|
||||||
let foundIndex = this.metadatum.value.findIndex(element => meta == element.id);
|
let foundIndex = this.itemMetadatum.value.findIndex(element => meta == element.id);
|
||||||
if (foundIndex >= 0)
|
if (foundIndex >= 0)
|
||||||
equal.push(this.metadatum.value[foundIndex]);
|
equal.push(this.itemMetadatum.value[foundIndex]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (equal.length == terms.length && this.metadatum.value.length <= equal.length)
|
if (equal.length == terms.length && this.itemMetadatum.value.length <= equal.length)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else if (this.metadatum.value.constructor.name == 'Object') {
|
} else if (this.itemMetadatum.value.constructor.name == 'Object') {
|
||||||
|
|
||||||
if (this.metadatum.value.id == this.inputs)
|
if (this.itemMetadatum.value.id == this.inputs)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
} else if (this.metadatum.value instanceof Array) {
|
} else if (this.itemMetadatum.value instanceof Array) {
|
||||||
|
|
||||||
let equal = [];
|
let equal = [];
|
||||||
|
|
||||||
for (let meta of this.inputs) {
|
for (let meta of this.inputs) {
|
||||||
let foundIndex = this.metadatum.value.findIndex(element => meta == element.id);
|
let foundIndex = this.itemMetadatum.value.findIndex(element => meta == element.id);
|
||||||
|
|
||||||
if (foundIndex >= 0)
|
if (foundIndex >= 0)
|
||||||
equal.push(this.metadatum.value[foundIndex]);
|
equal.push(this.itemMetadatum.value[foundIndex]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (equal.length == this.inputs.length && this.metadatum.value.length <= equal.length)
|
if (equal.length == this.inputs.length && this.itemMetadatum.value.length <= equal.length)
|
||||||
return;
|
return;
|
||||||
} else if (this.inputs && this.inputs.length == 1 && this.inputs[0] == this.metadatum.value) {
|
} else if (this.inputs && this.inputs.length == 1 && this.inputs[0] == this.itemMetadatum.value) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
eventBusItemMetadata.$emit('input', {
|
eventBusItemMetadata.$emit('input', {
|
||||||
itemId: this.metadatum.item.id,
|
itemId: this.itemMetadatum.item.id,
|
||||||
metadatumId: this.metadatum.metadatum.id,
|
metadatumId: this.itemMetadatum.metadatum.id,
|
||||||
values: this.inputs ? this.inputs : '',
|
values: this.inputs ? this.inputs : '',
|
||||||
parentMetaId: this.metadatum.parent_meta_id
|
parentMetaId: this.itemMetadatum.parent_meta_id
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
createInputs() {
|
createInputs() {
|
||||||
if (this.metadatum.value instanceof Array)
|
if (this.itemMetadatum.value instanceof Array)
|
||||||
this.inputs = this.metadatum.value.slice(0); // This way we garantee this.inputs is a copy of the contents of this.metadatum.value, instead of a reference to it
|
this.inputs = this.itemMetadatum.value.slice(0); // This way we garantee this.inputs is a copy of the contents of this.itemMetadatum.value, instead of a reference to it
|
||||||
else
|
else
|
||||||
this.metadatum.value == null || this.metadatum.value == undefined ? this.inputs = [] : this.inputs.push(this.metadatum.value);
|
this.itemMetadatum.value == null || this.itemMetadatum.value == undefined ? this.inputs = [] : this.inputs.push(this.itemMetadatum.value);
|
||||||
},
|
},
|
||||||
addInput(){
|
addInput(){
|
||||||
this.inputs.push('');
|
this.inputs.push('');
|
||||||
|
|
|
@ -101,7 +101,7 @@
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
metadatum: [Number,String],
|
itemMetadatum: [Number,String],
|
||||||
taxonomyId: [Number,String],
|
taxonomyId: [Number,String],
|
||||||
value: [ Array, Boolean, Number ],
|
value: [ Array, Boolean, Number ],
|
||||||
componentType: ''
|
componentType: ''
|
||||||
|
@ -117,8 +117,8 @@
|
||||||
parentTermName: '',
|
parentTermName: '',
|
||||||
isAddingNewTerm: false,
|
isAddingNewTerm: false,
|
||||||
isFetchingParentTerms: false,
|
isFetchingParentTerms: false,
|
||||||
metadatumId: this.metadatum.metadatum.id,
|
metadatumId: this.itemMetadatum.metadatum.id,
|
||||||
itemId: this.metadatum.item.id,
|
itemId: this.itemMetadatum.item.id,
|
||||||
formErrors: {},
|
formErrors: {},
|
||||||
parentTermSearchQuery: '',
|
parentTermSearchQuery: '',
|
||||||
parentTermSearchOffset: 0
|
parentTermSearchOffset: 0
|
||||||
|
@ -227,7 +227,7 @@
|
||||||
let id = res.id ? res.id : res.data.id;
|
let id = res.id ? res.id : res.data.id;
|
||||||
let val = this.value;
|
let val = this.value;
|
||||||
|
|
||||||
if (!Array.isArray(val) && this.metadatum.metadatum.multiple === 'no') {
|
if (!Array.isArray(val) && this.itemMetadatum.metadatum.multiple === 'no') {
|
||||||
axios.patch(`/item/${this.itemId}/metadata/${this.metadatumId}`, {
|
axios.patch(`/item/${this.itemId}/metadata/${this.metadatumId}`, {
|
||||||
values: id,
|
values: id,
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
|
|
|
@ -8,12 +8,12 @@
|
||||||
:allow-select-to-create="allowSelectToCreate"
|
:allow-select-to-create="allowSelectToCreate"
|
||||||
:allow-new="allowNew"
|
:allow-new="allowNew"
|
||||||
:taxonomy-id="taxonomyId"
|
:taxonomy-id="taxonomyId"
|
||||||
:metadatum="metadatum.metadatum"/>
|
:item-metadatum="itemMetadatum"/>
|
||||||
<add-new-term
|
<add-new-term
|
||||||
v-if="allowNew"
|
v-if="allowNew"
|
||||||
:component-type="getComponent"
|
:component-type="getComponent"
|
||||||
:taxonomy-id="taxonomyId"
|
:taxonomy-id="taxonomyId"
|
||||||
:metadatum="metadatum"
|
:item-metadatum="itemMetadatum"
|
||||||
:value="valueComponent"
|
:value="valueComponent"
|
||||||
@newTerm="reload"/>
|
@newTerm="reload"/>
|
||||||
</div>
|
</div>
|
||||||
|
@ -32,7 +32,7 @@
|
||||||
AddNewTerm
|
AddNewTerm
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
metadatum: Object,
|
itemMetadatum: Object,
|
||||||
value: [ Number, String, Array, Object ],
|
value: [ Number, String, Array, Object ],
|
||||||
disabled: false,
|
disabled: false,
|
||||||
forcedComponentType: '',
|
forcedComponentType: '',
|
||||||
|
@ -52,11 +52,11 @@
|
||||||
getComponent() {
|
getComponent() {
|
||||||
if (this.forcedComponentType)
|
if (this.forcedComponentType)
|
||||||
return this.forcedComponentType;
|
return this.forcedComponentType;
|
||||||
else if(this.metadatum.metadatum &&
|
else if(this.itemMetadatum.metadatum &&
|
||||||
this.metadatum.metadatum.metadata_type_options &&
|
this.itemMetadatum.metadatum.metadata_type_options &&
|
||||||
this.metadatum.metadatum.metadata_type_options.input_type
|
this.itemMetadatum.metadatum.metadata_type_options.input_type
|
||||||
)
|
)
|
||||||
return this.metadatum.metadatum.metadata_type_options.input_type;
|
return this.itemMetadatum.metadatum.metadata_type_options.input_type;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
|
@ -64,13 +64,13 @@
|
||||||
this.$emit('input', val);
|
this.$emit('input', val);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created(){
|
created() {
|
||||||
const metadata_type_options = this.metadatum.metadatum.metadata_type_options;
|
const metadata_type_options = this.itemMetadatum.metadatum.metadata_type_options;
|
||||||
|
|
||||||
this.taxonomyId = metadata_type_options.taxonomy_id;
|
this.taxonomyId = metadata_type_options.taxonomy_id;
|
||||||
this.taxonomy = metadata_type_options.taxonomy;
|
this.taxonomy = metadata_type_options.taxonomy;
|
||||||
|
|
||||||
if (metadata_type_options && metadata_type_options.allow_new_terms && this.metadatum.item)
|
if (metadata_type_options && metadata_type_options.allow_new_terms && this.itemMetadatum.item)
|
||||||
this.allowNew = metadata_type_options.allow_new_terms == 'yes';
|
this.allowNew = metadata_type_options.allow_new_terms == 'yes';
|
||||||
|
|
||||||
this.getTermsId();
|
this.getTermsId();
|
||||||
|
@ -78,16 +78,16 @@
|
||||||
methods: {
|
methods: {
|
||||||
getTermsId() {
|
getTermsId() {
|
||||||
let values = [];
|
let values = [];
|
||||||
if (this.value && this.metadatum.metadatum && this.getComponent != 'tainacan-taxonomy-tag-input') {
|
if (this.value && this.itemMetadatum.metadatum && this.getComponent != 'tainacan-taxonomy-tag-input') {
|
||||||
values = this.value.map(term => term.id)
|
values = this.value.map(term => term.id)
|
||||||
this.valueComponent = (values.length >= 0 && this.metadatum.metadatum && this.metadatum.metadatum.multiple === 'no') ? values[0] : values;
|
this.valueComponent = (values.length >= 0 && this.itemMetadatum.metadatum && this.itemMetadatum.metadatum.multiple === 'no') ? values[0] : values;
|
||||||
} else if (this.value && this.metadatum.metadatum && this.getComponent == 'tainacan-taxonomy-tag-input') {
|
} else if (this.value && this.itemMetadatum.metadatum && this.getComponent == 'tainacan-taxonomy-tag-input') {
|
||||||
values = this.value.map((term) => { return { label: term.name, value: term.id } });
|
values = this.value.map((term) => { return { label: term.name, value: term.id } });
|
||||||
this.valueComponent = values;
|
this.valueComponent = values;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
reload($event) {
|
reload($event) {
|
||||||
if ($event.taxonomyId == this.taxonomyId && $event.metadatumId == this.metadatum.metadatum.id) {
|
if ($event.taxonomyId == this.taxonomyId && $event.metadatumId == this.itemMetadatum.metadatum.id) {
|
||||||
this.valueComponent = $event.values;
|
this.valueComponent = $event.values;
|
||||||
this.$emit('update-taxonomy-inputs', $event)
|
this.$emit('update-taxonomy-inputs', $event)
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
</p>
|
</p>
|
||||||
<div
|
<div
|
||||||
class="metadata-taxonomy-list"
|
class="metadata-taxonomy-list"
|
||||||
:id="metadatum.metadata_type_object.component + '-' + metadatum.slug">
|
:id="itemMetadatum.metadatum.metadata_type_object.component + '-' + itemMetadatum.metadatum.slug">
|
||||||
<template v-for="(option, index) in options">
|
<template v-for="(option, index) in options">
|
||||||
<b-checkbox
|
<b-checkbox
|
||||||
:key="index"
|
:key="index"
|
||||||
|
@ -69,12 +69,11 @@
|
||||||
import CheckboxRadioModal from '../../modals/checkbox-radio-modal.vue';
|
import CheckboxRadioModal from '../../modals/checkbox-radio-modal.vue';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|
||||||
props: {
|
props: {
|
||||||
value: [ Number, String, Array ],
|
value: [ Number, String, Array ],
|
||||||
disabled: false,
|
disabled: false,
|
||||||
taxonomyId: Number,
|
taxonomyId: Number,
|
||||||
metadatum: Object
|
itemMetadatum: Object
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
@ -105,7 +104,7 @@
|
||||||
|
|
||||||
this.getTermsFromTaxonomy();
|
this.getTermsFromTaxonomy();
|
||||||
this.$parent.$on('update-taxonomy-inputs', ($event) => {
|
this.$parent.$on('update-taxonomy-inputs', ($event) => {
|
||||||
if ($event.taxonomyId == this.taxonomyId && $event.metadatumId == this.metadatum.id) {
|
if ($event.taxonomyId == this.taxonomyId && $event.metadatumId == this.itemMetadatum.metadatum.id) {
|
||||||
this.offset = 0;
|
this.offset = 0;
|
||||||
this.getTermsFromTaxonomy();
|
this.getTermsFromTaxonomy();
|
||||||
}
|
}
|
||||||
|
@ -192,12 +191,12 @@
|
||||||
parent: 0,
|
parent: 0,
|
||||||
taxonomy_id: this.taxonomyId,
|
taxonomy_id: this.taxonomyId,
|
||||||
selected: !this.value ? [] : this.value,
|
selected: !this.value ? [] : this.value,
|
||||||
metadatumId: this.metadatum.id,
|
metadatumId: this.itemMetadatum.metadatum.id,
|
||||||
taxonomy: this.taxonomy,
|
taxonomy: this.taxonomy,
|
||||||
collectionId: this.metadatum.collection_id,
|
collectionId: this.itemMetadatum.metadatum.collection_id,
|
||||||
isTaxonomy: true,
|
isTaxonomy: true,
|
||||||
query: '',
|
query: '',
|
||||||
metadatum: this.metadatum,
|
metadatum: this.itemMetadatum.metadatum,
|
||||||
isCheckbox: true
|
isCheckbox: true
|
||||||
},
|
},
|
||||||
events: {
|
events: {
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
<div class="metadata-taxonomy-list">
|
<div class="metadata-taxonomy-list">
|
||||||
<b-radio
|
<b-radio
|
||||||
:disabled="disabled"
|
:disabled="disabled"
|
||||||
:id="metadatum.metadata_type_object.component + '-' + metadatum.slug"
|
:id="itemMetadatum.metadatum.metadata_type_object.component + '-' + itemMetadatum.metadatum.slug"
|
||||||
v-model="checked"
|
v-model="checked"
|
||||||
@input="onChecked('')"
|
@input="onChecked('')"
|
||||||
:native-value="''"
|
:native-value="''"
|
||||||
|
@ -40,7 +40,7 @@
|
||||||
{{ $i18n.get('clear_radio') }}
|
{{ $i18n.get('clear_radio') }}
|
||||||
</b-radio>
|
</b-radio>
|
||||||
<template
|
<template
|
||||||
:id="metadatum.metadata_type_object.component + '-' + metadatum.slug"
|
:id="itemMetadatum.metadatum.metadata_type_object.component + '-' + itemMetadatum.metadatum.slug"
|
||||||
v-for="(option, index) in options">
|
v-for="(option, index) in options">
|
||||||
<b-radio
|
<b-radio
|
||||||
:disabled="disabled"
|
:disabled="disabled"
|
||||||
|
@ -82,7 +82,7 @@
|
||||||
value: [ Number, String, Array ],
|
value: [ Number, String, Array ],
|
||||||
disabled: false,
|
disabled: false,
|
||||||
taxonomyId: Number,
|
taxonomyId: Number,
|
||||||
metadatum: Object
|
itemMetadatum: Object
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
@ -110,7 +110,7 @@
|
||||||
created() {
|
created() {
|
||||||
this.getTermsFromTaxonomy();
|
this.getTermsFromTaxonomy();
|
||||||
this.$parent.$on('update-taxonomy-inputs', ($event) => {
|
this.$parent.$on('update-taxonomy-inputs', ($event) => {
|
||||||
if ($event.taxonomyId == this.taxonomyId && $event.metadatumId == this.metadatum.id) {
|
if ($event.taxonomyId == this.taxonomyId && $event.metadatumId == this.itemMetadatum.metadatum.id) {
|
||||||
this.offset = 0;
|
this.offset = 0;
|
||||||
this.getTermsFromTaxonomy();
|
this.getTermsFromTaxonomy();
|
||||||
}
|
}
|
||||||
|
@ -201,12 +201,12 @@
|
||||||
parent: 0,
|
parent: 0,
|
||||||
taxonomy_id: this.taxonomyId,
|
taxonomy_id: this.taxonomyId,
|
||||||
selected: !this.value ? [] : this.value,
|
selected: !this.value ? [] : this.value,
|
||||||
metadatumId: this.metadatum.id,
|
metadatumId: this.itemMetadatum.id,
|
||||||
taxonomy: this.taxonomy,
|
taxonomy: this.taxonomy,
|
||||||
collectionId: this.metadatum.collection_id,
|
collectionId: this.itemMetadatum.collection_id,
|
||||||
isTaxonomy: true,
|
isTaxonomy: true,
|
||||||
query: '',
|
query: '',
|
||||||
metadatum: this.metadatum,
|
metadatum: this.itemMetadatum,
|
||||||
isCheckbox: false
|
isCheckbox: false
|
||||||
},
|
},
|
||||||
events: {
|
events: {
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
<b-taginput
|
<b-taginput
|
||||||
expanded
|
expanded
|
||||||
:disabled="disabled"
|
:disabled="disabled"
|
||||||
:id="metadatumComponentId"
|
:id="itemMetadatum.metadatum.metadata_type_object.component + '-' + itemMetadatum.metadatum.slug"
|
||||||
size="is-small"
|
size="is-small"
|
||||||
icon="magnify"
|
icon="magnify"
|
||||||
:allow-new="false"
|
:allow-new="false"
|
||||||
|
@ -44,7 +44,7 @@
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
metadatumComponentId: '',
|
itemMetadatum: Object,
|
||||||
value: [ Number, String, Array ],
|
value: [ Number, String, Array ],
|
||||||
allowNew: true,
|
allowNew: true,
|
||||||
taxonomyId: Number,
|
taxonomyId: Number,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<template>
|
<template>
|
||||||
<b-input
|
<b-input
|
||||||
:disabled="disabled"
|
:disabled="disabled"
|
||||||
:id="metadatum.metadatum.metadata_type_object.component + '-' + metadatum.metadatum.slug"
|
:id="itemMetadatum.metadatum.metadata_type_object.component + '-' + itemMetadatum.metadatum.slug"
|
||||||
:value="value"
|
:value="value"
|
||||||
@input="onInput($event)"
|
@input="onInput($event)"
|
||||||
@blur="onBlur"/>
|
@blur="onBlur"/>
|
||||||
|
@ -10,7 +10,7 @@
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
metadatum: Object,
|
itemMetadatum: Object,
|
||||||
value: [String, Number, Array],
|
value: [String, Number, Array],
|
||||||
disabled: false
|
disabled: false
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<template>
|
<template>
|
||||||
<b-input
|
<b-input
|
||||||
:disabled="disabled"
|
:disabled="disabled"
|
||||||
:id="metadatum.metadatum.metadata_type_object.component + '-' + metadatum.metadatum.slug"
|
:id="itemMetadatum.metadatum.metadata_type_object.component + '-' + itemMetadatum.metadatum.slug"
|
||||||
:value="value"
|
:value="value"
|
||||||
@input="onInput($event)"
|
@input="onInput($event)"
|
||||||
@blur="onBlur"
|
@blur="onBlur"
|
||||||
|
@ -11,7 +11,7 @@
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
metadatum: Object,
|
itemMetadatum: Object,
|
||||||
value: [String, Number, Array],
|
value: [String, Number, Array],
|
||||||
disabled: false
|
disabled: false
|
||||||
},
|
},
|
||||||
|
|
|
@ -91,7 +91,7 @@
|
||||||
:class="{'is-field-history': bulkEditionProcedures[criterion].isDone}"
|
:class="{'is-field-history': bulkEditionProcedures[criterion].isDone}"
|
||||||
:disabled="bulkEditionProcedures[criterion].isDone"
|
:disabled="bulkEditionProcedures[criterion].isDone"
|
||||||
:is="getMetadataByID(bulkEditionProcedures[criterion].metadatumID).metadata_type_object.component"
|
:is="getMetadataByID(bulkEditionProcedures[criterion].metadatumID).metadata_type_object.component"
|
||||||
:metadatum="{metadatum: getMetadataByID(bulkEditionProcedures[criterion].metadatumID)}"
|
:item-metadatum="{metadatum: getMetadataByID(bulkEditionProcedures[criterion].metadatumID)}"
|
||||||
class="tainacan-bulk-edition-field"
|
class="tainacan-bulk-edition-field"
|
||||||
@input="addToBulkEditionProcedures($event, 'oldValue', criterion)"
|
@input="addToBulkEditionProcedures($event, 'oldValue', criterion)"
|
||||||
/>
|
/>
|
||||||
|
@ -112,7 +112,7 @@
|
||||||
:class="{'is-field-history': bulkEditionProcedures[criterion].isDone}"
|
:class="{'is-field-history': bulkEditionProcedures[criterion].isDone}"
|
||||||
:disabled="bulkEditionProcedures[criterion].isDone"
|
:disabled="bulkEditionProcedures[criterion].isDone"
|
||||||
:is="getMetadataByID(bulkEditionProcedures[criterion].metadatumID).metadata_type_object.component"
|
:is="getMetadataByID(bulkEditionProcedures[criterion].metadatumID).metadata_type_object.component"
|
||||||
:metadatum="{metadatum: getMetadataByID(bulkEditionProcedures[criterion].metadatumID)}"
|
:item-metadatum="{metadatum: getMetadataByID(bulkEditionProcedures[criterion].metadatumID)}"
|
||||||
class="tainacan-bulk-edition-field tainacan-bulk-edition-field-not-last"
|
class="tainacan-bulk-edition-field tainacan-bulk-edition-field-not-last"
|
||||||
@input="addToBulkEditionProcedures($event, 'newValue', criterion)"
|
@input="addToBulkEditionProcedures($event, 'newValue', criterion)"
|
||||||
/>
|
/>
|
||||||
|
@ -170,7 +170,7 @@
|
||||||
:class="{'is-field-history': bulkEditionProcedures[criterion].isDone}"
|
:class="{'is-field-history': bulkEditionProcedures[criterion].isDone}"
|
||||||
:disabled="bulkEditionProcedures[criterion].isDone || bulkEditionProcedures[criterion].isExecuting"
|
:disabled="bulkEditionProcedures[criterion].isDone || bulkEditionProcedures[criterion].isExecuting"
|
||||||
:is="getMetadataByID(bulkEditionProcedures[criterion].metadatumID).metadata_type_object.component"
|
:is="getMetadataByID(bulkEditionProcedures[criterion].metadatumID).metadata_type_object.component"
|
||||||
:metadatum="{metadatum: getMetadataByID(bulkEditionProcedures[criterion].metadatumID)}"
|
:item-metadatum="{metadatum: getMetadataByID(bulkEditionProcedures[criterion].metadatumID)}"
|
||||||
class="tainacan-bulk-edition-field tainacan-bulk-edition-field-last"
|
class="tainacan-bulk-edition-field tainacan-bulk-edition-field-last"
|
||||||
@input="addToBulkEditionProcedures($event, 'newValue', criterion)"
|
@input="addToBulkEditionProcedures($event, 'newValue', criterion)"
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -7,9 +7,10 @@ export const sendMetadatum = ( { commit }, { item_id, metadatum_id, values }) =>
|
||||||
values: values
|
values: values
|
||||||
})
|
})
|
||||||
.then( res => {
|
.then( res => {
|
||||||
commit('setSingleMetadata', { item_id: item_id, metadatum_id: metadatum_id, values: values });
|
const metadatum = res.data
|
||||||
|
commit('setSingleMetadatum', metadatum);
|
||||||
commit('setLastUpdated');
|
commit('setLastUpdated');
|
||||||
resolve( res.data );
|
resolve( metadatum );
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
reject( error);
|
reject( error);
|
||||||
|
|
|
@ -62,26 +62,27 @@ export const cleanMetadata = (state) => {
|
||||||
state.metadata = [];
|
state.metadata = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
export const setSingleMetadatum = (state, metadatum) => {
|
export const setSingleMetadatum = (state, itemMetadatum) => {
|
||||||
if (metadatum.metadatum.parent > 0) {
|
|
||||||
let index = state.metadata.findIndex(itemMetadata => itemMetadata.metadatum.id === metadatum.metadatum.id);
|
if (itemMetadatum.metadatum.parent <= 0) {
|
||||||
|
let index = state.metadata.findIndex(anItemMetadatum => anItemMetadatum.metadatum.id == itemMetadatum.metadatum.id);
|
||||||
if (index >= 0)
|
if (index >= 0)
|
||||||
Vue.set( state.metadata, index, metadatum );
|
Vue.set( state.metadata, index, itemMetadatum );
|
||||||
else
|
else
|
||||||
state.metadata.push( metadatum );
|
state.metadata.push( itemMetadatum );
|
||||||
} else {
|
} else {
|
||||||
let parentIndex = state.metadata.findIndex(itemMetadata => itemMetadata.metadatum.id === metadatum.metadatum.id);
|
|
||||||
|
let parentIndex = state.metadata.findIndex(anItemMetadatum => anItemMetadatum.metadatum.id == itemMetadatum.metadatum.parent);
|
||||||
|
|
||||||
if (parentIndex >= 0) {
|
if (parentIndex >= 0) {
|
||||||
let currentParent = state.metadata[parentIndex];
|
let currentParent = state.metadata[parentIndex];
|
||||||
currentParent.value[metadatum.metadatum.id] = {
|
currentParent.value[itemMetadatum.metadatum.id] = {
|
||||||
parent_meta_id: metadatum.value[child.id] ? metadatum.value[child.id].parent_meta_id : 0,
|
parent_meta_id: itemMetadatum.parent_meta_id ? itemMetadatum.parent_meta_id : 0,
|
||||||
value: metadatum.value[child.id] ? metadatum.value[child.id].value : [],
|
value: itemMetadatum.value ? itemMetadatum.value : [],
|
||||||
value_as_html: metadatum.value[child.id] ? metadatum.value[child.id].value_as_html : '',
|
value_as_html: itemMetadatum.value_as_html ? itemMetadatum.value_as_html : '',
|
||||||
value_as_string: metadatum.value[child.id] ? metadatum.value[child.id].value_as_string : ''
|
value_as_string: itemMetadatum.value_as_string ? itemMetadatum.value_as_string : ''
|
||||||
};
|
};
|
||||||
Vue.set(state.metadata, parentIndex, currentParent);
|
Vue.set(state.metadata, parentIndex, currentParent);
|
||||||
console.log(state.metadata)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -202,19 +202,19 @@
|
||||||
<!-- Metadata -------------------------------- -->
|
<!-- Metadata -------------------------------- -->
|
||||||
<div class="metadata-area">
|
<div class="metadata-area">
|
||||||
<div
|
<div
|
||||||
v-for="(metadatum, index) of metadatumList"
|
v-for="(itemMetadatum, index) of metadatumList"
|
||||||
:key="index"
|
:key="index"
|
||||||
class="field">
|
class="field">
|
||||||
<label class="label">{{ metadatum.metadatum.name }}</label>
|
<label class="label">{{ itemMetadatum.metadatum.name }}</label>
|
||||||
<div
|
<div
|
||||||
:class="{
|
:class="{
|
||||||
'metadata-type-textarea': metadatum.metadatum.metadata_type_object.component == 'tainacan-textarea',
|
'metadata-type-textarea': itemMetadatum.metadatum.metadata_type_object.component == 'tainacan-textarea',
|
||||||
'metadata-type-compound': metadatum.metadatum.metadata_type_object.component == 'tainacan-compound'
|
'metadata-type-compound': itemMetadatum.metadatum.metadata_type_object.component == 'tainacan-compound'
|
||||||
}"
|
}"
|
||||||
class="content">
|
class="content">
|
||||||
<component
|
<component
|
||||||
:is="metadatum.metadatum.metadata_type_object.component == 'tainacan-compound' ? 'div' : 'p'"
|
:is="itemMetadatum.metadatum.metadata_type_object.component == 'tainacan-compound' ? 'div' : 'p'"
|
||||||
v-html="metadatum.value_as_html != '' ? metadatum.value_as_html : `<span class='has-text-gray is-italic'>` + $i18n.get('label_value_not_informed') + `</span>`"/>
|
v-html="itemMetadatum.value_as_html != '' ? itemMetadatum.value_as_html : `<span class='has-text-gray is-italic'>` + $i18n.get('label_value_not_informed') + `</span>`"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue