From 22cf3f82e85d5fde2deab31e8871a61ae6b50adc Mon Sep 17 00:00:00 2001
From: mateuswetah
Date: Mon, 25 Jul 2022 11:04:35 -0300
Subject: [PATCH] Updates enabled state on vuex even for Metadata inside
sections.
---
.../components/edition/item-edition-form.vue | 63 ++++++++++---------
.../lists/collection-metadata-list.vue | 4 +-
.../metadata-types/compound/Compound.vue | 6 ++
.../js/store/modules/metadata/actions.js | 18 ++++--
.../js/store/modules/metadata/mutations.js | 19 ++++--
src/views/admin/pages/lists/metadata-page.vue | 26 ++++++--
6 files changed, 90 insertions(+), 46 deletions(-)
diff --git a/src/views/admin/components/edition/item-edition-form.vue b/src/views/admin/components/edition/item-edition-form.vue
index 0acaebbd3..ea5da86b7 100644
--- a/src/views/admin/components/edition/item-edition-form.vue
+++ b/src/views/admin/components/edition/item-edition-form.vue
@@ -270,14 +270,6 @@
{{ collapseAll ? $i18n.get('label_collapse_all') : $i18n.get('label_expand_all') }}
-
-
-
-
-
-
+
+
+
+
+
+
-
+
+
+
+
@@ -1697,7 +1700,7 @@ export default {
if (isPreviouslyFocusedOnCompoundMetadatum || this.isCurrentlyFocusedOnCompoundMetadatum)
eventBusItemMetadata.$emit('focusPreviousChildMetadatum');
-
+ console.log(this.isOnFirstMetadatumOfCompoundNavigation, this.isOnLastMetadatumOfCompoundNavigation)
if ( !this.isCurrentlyFocusedOnCompoundMetadatum || (this.isCurrentlyFocusedOnCompoundMetadatum && this.isOnFirstMetadatumOfCompoundNavigation) )
this.setMetadatumFocus({ index: this.focusedMetadatum - 1, scrollIntoView: true });
},
@@ -1709,7 +1712,7 @@ export default {
this.setMetadatumFocus({ index: this.focusedMetadatum + 1, scrollIntoView: true });
},
setMetadatumFocus({ index = 0, scrollIntoView = false }) {
-
+
const previousIndex = this.focusedMetadatum;
this.focusedMetadatum = index;
diff --git a/src/views/admin/components/lists/collection-metadata-list.vue b/src/views/admin/components/lists/collection-metadata-list.vue
index d25978b17..bdb38996c 100644
--- a/src/views/admin/components/lists/collection-metadata-list.vue
+++ b/src/views/admin/components/lists/collection-metadata-list.vue
@@ -271,7 +271,7 @@
'is-compact-item': !isCollapseOpen(metadatum.id),
'not-sortable-item': metadatum.id == undefined || openedMetadatumId != '' || isUpdatingMetadataOrder || metadataNameFilterString != '' || hasSomeMetadataTypeFilterApplied || isUpdatingMetadatum,
'not-focusable-item': openedMetadatumId == metadatum.id,
- 'disabled-metadatum': metadatum.enabled == false,
+ 'disabled-metadatum': metadataSection.enabled == false || metadatum.enabled == false,
'inherited-metadatum': metadatum.inherited,
'child-metadatum': metadatum.parent > 0
}">
@@ -575,7 +575,7 @@ export default {
this.collectionId = this.$route.params.collectionId;
this.isLoadingMetadataSections = true;
- this.fetchMetadataSections({ collectionId: this.collectionId, isContextEdit: true })
+ this.fetchMetadataSections({ collectionId: this.collectionId, isContextEdit: true, includeDisabled: true })
.then(() => {
this.isLoadingMetadataSections = false;
})
diff --git a/src/views/admin/components/metadata-types/compound/Compound.vue b/src/views/admin/components/metadata-types/compound/Compound.vue
index dc797859f..569f44b21 100644
--- a/src/views/admin/components/metadata-types/compound/Compound.vue
+++ b/src/views/admin/components/metadata-types/compound/Compound.vue
@@ -377,6 +377,12 @@
else if ((this.focusedChildMetadatum - 1) >= 0)
this.setMetadatumChildFocus({ groupIndex: this.focusedGroupMetadatum, childIndex: this.focusedChildMetadatum - 1, scrollIntoView: true })
}
+
+ // This keeps the navigation going on when no child input exists
+ if (this.childItemMetadataGroups.length === 0) {
+ eventBusItemMetadata.$emit('isOnFirstMetadatumOfCompoundNavigation', true);
+ eventBusItemMetadata.$emit('isOnLastMetadatumOfCompoundNavigation', true);
+ }
},
focusNextChildMetadatum() {
diff --git a/src/views/admin/js/store/modules/metadata/actions.js b/src/views/admin/js/store/modules/metadata/actions.js
index 56bebd19c..40c6cabbe 100644
--- a/src/views/admin/js/store/modules/metadata/actions.js
+++ b/src/views/admin/js/store/modules/metadata/actions.js
@@ -198,14 +198,14 @@ export const cleanMetadata = ({commit}) => {
commit('cleanMetadata');
};
-export const updateCollectionMetadataOrder = ({ commit }, {collectionId, metadataOrder, metadataSectionId }) => {
+export const updateCollectionMetadataOrder = ({ commit }, { collectionId, metadataOrder, metadataSectionId }) => {
return new Promise((resolve, reject) => {
axios.tainacan.patch('/collections/' + collectionId + '/metadata_section/' + metadataSectionId + '/metadata_order?context=edit', {
metadata_order: metadataOrder
}).then(res => {
commit('collection/setCollection', res.data, { root: true });
- commit('updateMetadataOrderFromCollection', res.data.metadata_order);
+ commit('updateCollectionMetadataOrder', { metadataOrder: res.data.metadata_order, metadataSectionId: metadataSectionId });
resolve(res.data);
}).catch(error => {
reject(error.response);
@@ -294,10 +294,18 @@ export const updateMetadatumMappers = ({commit}, metadatumMappers) => {
};
// METADATA SECTIONS
-export const fetchMetadataSections = ({commit}, { collectionId, isContextEdit }) => {
+export const fetchMetadataSections = ({commit}, { collectionId, isContextEdit, includeDisabled }) => {
+
+ let endpoint = '/collection/' + collectionId + '/metadata-sections?';
+
+ if (isContextEdit)
+ endpoint += 'context=edit&'
+
+ if (includeDisabled)
+ endpoint += 'include_disabled=true'
return new Promise((resolve, reject) => {
- axios.tainacan.get('/collection/' + collectionId + '/metadata-sections' + (isContextEdit ? '?context=edit' : ''))
+ axios.tainacan.get(endpoint)
.then((res) => {
let metadataSections = res.data;
commit('setMetadataSections', metadataSections);
@@ -381,7 +389,7 @@ export const updateCollectionMetadataSectionsOrder = ({ commit }, {collectionId,
metadata_section_order: metadataSectionsOrder
}).then(res => {
commit('collection/setCollection', res.data, { root: true });
- commit('updateMetadataSectionsOrderFromCollection', res.data.metadata_sections_order);
+ commit('updateMetadataSectionsOrderFromCollection', res.data.metadata_section_order);
resolve(res.data);
}).catch(error => {
reject(error.response);
diff --git a/src/views/admin/js/store/modules/metadata/mutations.js b/src/views/admin/js/store/modules/metadata/mutations.js
index c803adf55..b47f61b4d 100644
--- a/src/views/admin/js/store/modules/metadata/mutations.js
+++ b/src/views/admin/js/store/modules/metadata/mutations.js
@@ -69,11 +69,22 @@ export const setMetadata = (state, metadata) => {
state.metadata = metadata;
}
-export const updateMetadataOrderFromCollection = (state, metadataOrder) => {
- for (let i = 0; i < state.metadata.length; i++) {
- let updatedMetadatumIndex = metadataOrder.findIndex(aMetadatum => aMetadatum.id == state.metadata[i].id);
+export const updateCollectionMetadataOrder = (state, { metadataOrder, metadataSectionId }) => {
+
+ for (let i = 0; i < metadataOrder.length; i++) {
+
+ // First updates state.metadata
+ let updatedMetadatumIndex = state.metadata.findIndex((aMetadatum) => aMetadatum.id == metadataOrder[i]['id']);
if (updatedMetadatumIndex >= 0)
- state.metadata[i].enabled = metadataOrder[updatedMetadatumIndex].enabled;
+ state.metadata[i].enabled = metadataOrder[updateCollectionMetadataOrder].enabled;
+
+ // Then updates state.metadataSections[x].metadata_object_list
+ const existingSectionIndex = state.metadataSections.findIndex((aMetadataSection) => aMetadataSection.id == metadataSectionId);
+ if (existingSectionIndex >= 0) {
+ const updatedMetadatumIndexInsideSection = state.metadataSections[existingSectionIndex]['metadata_object_list'].findIndex((aMetadatum) => { return !!aMetadatum['id'] && (aMetadatum.id == metadataOrder[i]['id']) });
+ if (updatedMetadatumIndexInsideSection >= 0)
+ state.metadataSections[existingSectionIndex]['metadata_object_list'][updatedMetadatumIndexInsideSection].enabled = metadataOrder[i].enabled;
+ }
}
}
diff --git a/src/views/admin/pages/lists/metadata-page.vue b/src/views/admin/pages/lists/metadata-page.vue
index 6d6289808..71b170e51 100644
--- a/src/views/admin/pages/lists/metadata-page.vue
+++ b/src/views/admin/pages/lists/metadata-page.vue
@@ -215,7 +215,7 @@ export default {
display: flex;
align-items: center;
justify-content: space-between;
- padding: 0.5em 1em 0.5em 4em;
+ padding: 0.5em 1em 0.5em 2em;
.header-item {
margin-left: 0.75rem;
@@ -277,10 +277,6 @@ export default {
margin: 0;
padding-right: 0em;
}
- @media screen and (max-width: 1216px) {
- padding-right: 1em;
- }
-
&.metadata-area-receive {
border: 1px dashed var(--tainacan-gray4);
}
@@ -294,6 +290,10 @@ export default {
margin-left: 1.5em;
padding-right: 1em;
min-height: 330px;
+
+ .active-metadata-area {
+ margin-left: 0.5rem;
+ }
}
.active-metadatum-item,
@@ -333,6 +333,8 @@ export default {
}
&.active-metadata-sections-item {
+ padding-left: 0;
+ margin-top: 1rem;
border-bottom: 1px solid var(--tainacan-gray3);
.metadatum-name {
@@ -427,6 +429,10 @@ export default {
&.disabled-metadatum:not(.not-sortable-item),
&.disabled-metadatum:not(.not-sortable-item):hover {
color: var(--tainacan-gray3);
+
+ .metadatum-name {
+ opacity: 0.7;
+ }
.label-details, .not-saved {
color: var(--tainacan-gray3) !important;
}
@@ -487,4 +493,14 @@ export default {
}
}
}
+
+ .repository-level-page {
+ .tainacan-form.sub-header {
+ padding-left: 2.75em !important;
+ }
+ .active-metadata-sections-area,
+ .active-metadata-area {
+ margin-left: 0px !important;
+ }
+ }