Adjustments to new logic of creating and removing groups into item metadata

This commit is contained in:
mateuswetah 2020-05-07 15:54:12 -03:00
parent 73d0c7311d
commit 66f7c1da9a
2 changed files with 19 additions and 11 deletions

View File

@ -255,22 +255,29 @@
value: '',
value_as_html: '',
value_as_string: '',
collapse: false
collapse: true
};
newEmptyGroup.push(childObject)
}
}
this.isCreatingGroup = true;
this.childItemMetadataGroups.push(newEmptyGroup);
this.isCreatingGroup = false;
});
},
removeGroup(groupIndex) {
this.isRemovingGroup = true;
eventBusItemMetadata.$emit('remove_group', {
itemId: this.itemMetadatum.item.id,
metadatumId: this.itemMetadatum.metadatum.id,
parentMetaId: this.itemMetadatum.value[groupIndex][0].parent_meta_id
});
if (this.itemMetadatum.value && this.itemMetadatum.value[groupIndex] && this.itemMetadatum.value[groupIndex][0]) {
this.isRemovingGroup = true;
eventBusItemMetadata.$emit('remove_group', {
itemId: this.itemMetadatum.item.id,
metadatumId: this.itemMetadatum.metadatum.id,
parentMetaId: this.itemMetadatum.value[groupIndex][0].parent_meta_id
});
} else {
this.childItemMetadataGroups.splice(groupIndex, 1);
}
}
}
}

View File

@ -102,6 +102,7 @@ export const setSingleMetadatum = (state, itemMetadatum) => {
} else {
currentParentValues.push([childMetadatumValue])
}
} else {
let currrentChildMetadatumIndex = currentParentValues.findIndex((metadatumValue) => metadatumValue.parent_meta_id == itemMetadatum.parent_meta_id && metadatumValue.metadatum_id == itemMetadatum.metadatum.id);
if (currrentChildMetadatumIndex >= 0)
@ -131,7 +132,7 @@ export const deleteChildItemMetadata = (state, { parentMetadatumId, parentMetaId
if (currentChildMetadataGroupIndex >= 0)
currentParentValues.splice(currentChildMetadataGroupIndex, 1);
currentParent.value = currentParentValues;
currentParent.value = JSON.parse(JSON.stringify(currentParentValues));
Vue.set(state.itemMetadata, parentIndex, currentParent);
}
}