Updates compound child metadata communication.
This commit is contained in:
parent
9543af5645
commit
4cfc213229
|
@ -223,7 +223,7 @@
|
||||||
</a>
|
</a>
|
||||||
<a
|
<a
|
||||||
v-if="metadataSection.current_user_can_delete"
|
v-if="metadataSection.current_user_can_delete"
|
||||||
:disabled="metadataSection.metadata_object_list.length"
|
:disabled="metadataSection.metadata_object_list.length > 0"
|
||||||
:style="{ visibility: metadataSection.collection_id != collectionId || metadataSection.id === 'default_section' || metadataSection.metadata_object_list.length ? 'hidden' : 'visible' }"
|
:style="{ visibility: metadataSection.collection_id != collectionId || metadataSection.id === 'default_section' || metadataSection.metadata_object_list.length ? 'hidden' : 'visible' }"
|
||||||
@click.prevent="removeMetadataSection(metadataSection)">
|
@click.prevent="removeMetadataSection(metadataSection)">
|
||||||
<span
|
<span
|
||||||
|
|
|
@ -75,6 +75,7 @@
|
||||||
:is-focused="(focusedGroupMetadatum === groupIndex) && (focusedChildMetadatum === childIndex)"
|
:is-focused="(focusedGroupMetadatum === groupIndex) && (focusedChildMetadatum === childIndex)"
|
||||||
:is-metadata-navigation="isMetadataNavigation"
|
:is-metadata-navigation="isMetadataNavigation"
|
||||||
:enumerate-metadatum="enumerateMetadatum ? ( enumerateMetadatum + ( childItemMetadataGroups.length > 1 ? ( '.' + (Number(groupIndex) + 1) ) : '' ) + '.' + (Number(childIndex) + 1) ) : false"
|
:enumerate-metadatum="enumerateMetadatum ? ( enumerateMetadatum + ( childItemMetadataGroups.length > 1 ? ( '.' + (Number(groupIndex) + 1) ) : '' ) + '.' + (Number(childIndex) + 1) ) : false"
|
||||||
|
@input="($event) => $emitter.emit('updateValueFromCompound', $event)"
|
||||||
@change-collapse="onChangeCollapse($event, groupIndex, childIndex)"
|
@change-collapse="onChangeCollapse($event, groupIndex, childIndex)"
|
||||||
@touchstart="isMetadataNavigation ? setMetadatumChildFocus({ groupIndex: groupIndex, childIndex: childIndex, scrollIntoView: false }): ''"
|
@touchstart="isMetadataNavigation ? setMetadatumChildFocus({ groupIndex: groupIndex, childIndex: childIndex, scrollIntoView: false }): ''"
|
||||||
@mousedown="isMetadataNavigation ? setMetadatumChildFocus({ groupIndex: groupIndex, childIndex: childIndex, scrollIntoView: false }) : ''"
|
@mousedown="isMetadataNavigation ? setMetadatumChildFocus({ groupIndex: groupIndex, childIndex: childIndex, scrollIntoView: false }) : ''"
|
||||||
|
|
|
@ -286,6 +286,7 @@
|
||||||
this.performValueChange();
|
this.performValueChange();
|
||||||
}, 800),
|
}, 800),
|
||||||
performValueChange() {
|
performValueChange() {
|
||||||
|
|
||||||
// Compound metadata do not emit values, only their children.
|
// Compound metadata do not emit values, only their children.
|
||||||
if (this.metadatumComponent == 'tainacan-compound')
|
if (this.metadatumComponent == 'tainacan-compound')
|
||||||
return;
|
return;
|
||||||
|
@ -305,7 +306,7 @@
|
||||||
currentValues = this.values.map(term => term.value)
|
currentValues = this.values.map(term => term.value)
|
||||||
else
|
else
|
||||||
currentValues = this.values;
|
currentValues = this.values;
|
||||||
|
|
||||||
if (Array.isArray(currentValues)) {
|
if (Array.isArray(currentValues)) {
|
||||||
for (let value of currentValues) {
|
for (let value of currentValues) {
|
||||||
let foundIndex = this.itemMetadatum.value.findIndex(element => value == element.id);
|
let foundIndex = this.itemMetadatum.value.findIndex(element => value == element.id);
|
||||||
|
@ -338,7 +339,6 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If none is the case, the value is update request is sent to the API
|
// If none is the case, the value is update request is sent to the API
|
||||||
this.$emit('input', {
|
this.$emit('input', {
|
||||||
itemId: this.itemMetadatum.item.id,
|
itemId: this.itemMetadatum.item.id,
|
||||||
|
|
|
@ -3,9 +3,11 @@ import { mapActions } from 'vuex';
|
||||||
export const itemMetadataMixin = {
|
export const itemMetadataMixin = {
|
||||||
created() {
|
created() {
|
||||||
this.$emitter.on('removeCompoundGroup', this.removeItemMetadataGroup);
|
this.$emitter.on('removeCompoundGroup', this.removeItemMetadataGroup);
|
||||||
|
this.$emitter.on('updateValueFromCompound', this.updateItemMetadataValue);
|
||||||
},
|
},
|
||||||
beforeDestroy() {
|
beforeDestroy() {
|
||||||
this.$emitter.off('removeCompoundGroup', this.removeItemMetadataGroup);
|
this.$emitter.off('removeCompoundGroup', this.removeItemMetadataGroup);
|
||||||
|
this.$emitter.off('updateValueFromCompound', this.updateItemMetadataValue);
|
||||||
},
|
},
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
|
@ -33,11 +35,11 @@ export const itemMetadataMixin = {
|
||||||
'deleteItemMetadataGroup',
|
'deleteItemMetadataGroup',
|
||||||
'deleteGroupFromItemSubmissionMetadatum'
|
'deleteGroupFromItemSubmissionMetadatum'
|
||||||
]),
|
]),
|
||||||
updateItemMetadataValue({ itemId, metadatumId, values, parentMetaId, parentId }){
|
updateItemMetadataValue({ itemId, metadatumId, values, parentMetaId, parentId }) {
|
||||||
|
|
||||||
if (itemId) {
|
if (itemId) {
|
||||||
|
|
||||||
this.isUpdatingValues = true;;
|
this.isUpdatingValues = true;
|
||||||
|
|
||||||
if (values.length > 0 && values[0] && values[0].value) {
|
if (values.length > 0 && values[0] && values[0].value) {
|
||||||
let onlyValues = values.map((aValueObject) => aValueObject.value);
|
let onlyValues = values.map((aValueObject) => aValueObject.value);
|
||||||
|
@ -94,7 +96,7 @@ export const itemMetadataMixin = {
|
||||||
// In the item submission, we don't want to block submission or clear errors before a re-submission is performed,
|
// In the item submission, we don't want to block submission or clear errors before a re-submission is performed,
|
||||||
// as the validation depends on a single server-side request. Thus, we do not update error arary here.
|
// as the validation depends on a single server-side request. Thus, we do not update error arary here.
|
||||||
|
|
||||||
this.isUpdatingValues = false;;
|
this.isUpdatingValues = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -115,7 +117,7 @@ export const itemMetadataMixin = {
|
||||||
},
|
},
|
||||||
removeItemMetadataGroup({ itemId, metadatumId, parentMetaId, parentMetadatum }) {
|
removeItemMetadataGroup({ itemId, metadatumId, parentMetaId, parentMetadatum }) {
|
||||||
|
|
||||||
this.isUpdatingValues = true;;
|
this.isUpdatingValues = true;
|
||||||
|
|
||||||
if (itemId && metadatumId && parentMetaId) {
|
if (itemId && metadatumId && parentMetaId) {
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@
|
||||||
background-color: var(--tainacan-red1);
|
background-color: var(--tainacan-red1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
a[disabled] {
|
a[disabled="true"] {
|
||||||
opacity: 0.5;
|
opacity: 0.5;
|
||||||
user-select: none;
|
user-select: none;
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
|
|
Loading…
Reference in New Issue