diff --git a/src/views/admin/js/axios.js b/src/views/admin/js/axios.js
index a267632c4..9c26d51ee 100644
--- a/src/views/admin/js/axios.js
+++ b/src/views/admin/js/axios.js
@@ -9,7 +9,8 @@ const i18nGet = function (key) {
return (string !== undefined && string !== null && string !== '' ) ? string : "ERROR: Invalid i18n key!";
};
-const tainacanErrorHandler = function(error){
+const tainacanErrorHandler = function(error) {
+ console.log(error)
if (error.response && error.response.status) {
// The request was made and the server responded with a status code
// that falls out of the range of 2xx
diff --git a/src/views/gutenberg-blocks/blocks/item-submission-form/item-submission/item-submission-form.vue b/src/views/gutenberg-blocks/blocks/item-submission-form/item-submission/item-submission-form.vue
index 198b35754..9c078875b 100644
--- a/src/views/gutenberg-blocks/blocks/item-submission-form/item-submission/item-submission-form.vue
+++ b/src/views/gutenberg-blocks/blocks/item-submission-form/item-submission/item-submission-form.vue
@@ -373,15 +373,42 @@
class="tainacan-icon tainacan-icon-1-25em"/>
-
-
-
+
+
@@ -539,9 +566,11 @@ export default {
return {
collecionAllowsItemSubmission: true,
isLoading: false,
+ isLoadingMetadataSections: false,
isSubmitting: false,
isUploading: false,
metadataCollapses: [],
+ metadataSectionCollapses: [],
collapseAll: true,
form: {
collection_id: Number,
@@ -587,6 +616,9 @@ export default {
} )
)) : [];
},
+ metadataSections() {
+ return this.getMetadataSections();
+ },
formErrors() {
return eventBusItemMetadata && eventBusItemMetadata.errors && eventBusItemMetadata.errors.length ? eventBusItemMetadata.errors : []
},
@@ -629,9 +661,13 @@ export default {
this.createNewItem();
eventBusItemMetadata.$on('hasErrorsOnForm', (hasErrors) => {
- if (hasErrors)
+ if (hasErrors) {
+ if (Array.isArray(this.formErrors)) {
+ for (let i = 0; i < this.metadataSectionCollapses.length; i++)
+ this.$set(this.metadataSectionCollapses, i, true);
+ }
this.formErrorMessage = this.formErrorMessage ? this.formErrorMessage : this.$i18n.get('info_errors_in_form');
- else
+ } else
this.formErrorMessage = '';
});
})
@@ -639,6 +675,20 @@ export default {
this.collecionAllowsItemSubmission = false;
this.isLoading = false;
});
+
+ // Loads Metadata Sections
+ this.isLoadingMetadataSections = true;
+ this.fetchMetadataSections({
+ collectionId: this.collectionId
+ })
+ .then((metadataSections) => {
+ this.metadataSectionCollapses = Array(metadataSections.length).fill(true)
+ this.isLoadingMetadataSections = false;
+ })
+ .catch((error) => {
+ this.isLoadingMetadataSections = false;
+ this.$console.error('Error loading metadata sections ', error);
+ });
},
mounted() {
@@ -666,10 +716,12 @@ export default {
'getItemSubmissionMetadata',
]),
...mapActions('metadata',[
- 'fetchMetadata'
+ 'fetchMetadata',
+ 'fetchMetadataSections'
]),
...mapGetters('metadata',[
- 'getMetadata'
+ 'getMetadata',
+ 'getMetadataSections'
]),
...mapActions('collection',[
'fetchCollectionForItemSubmission'
@@ -801,9 +853,14 @@ export default {
for (let i = 0; i < this.metadataCollapses.length; i++)
this.metadataCollapses[i] = this.collapseAll;
+ for (let i = 0; i < this.metadataSectionCollapses.length; i++)
+ this.$set(this.metadataSectionCollapses, i, this.collapseAll);
},
onChangeCollapse(event, index) {
this.metadataCollapses.splice(index, 1, event);
+ },
+ toggleMetadataSectionCollapse(sectionIndex) {
+ this.$set(this.metadataSectionCollapses, sectionIndex, (this.formErrorMessage ? true : !this.metadataSectionCollapses[sectionIndex]));
}
}
}
@@ -828,6 +885,7 @@ export default {
}
.field {
padding: 12px 0px 12px 34px;
+ margin-left: 24px;
}
.columns {
@@ -942,6 +1000,15 @@ export default {
}
}
+ .metadata-section-header {
+ padding-bottom: 7px;
+ border-bottom: 1px solid var(--tainacan-input-border-color);
+
+ .icon {
+ margin-left: -0.5rem;
+ }
+ }
+
.form-submission-footer {
padding: 18px 0;
width: 100%;
diff --git a/src/views/gutenberg-blocks/blocks/item-submission-form/theme.js b/src/views/gutenberg-blocks/blocks/item-submission-form/theme.js
index d5101f447..3a61c4fb1 100644
--- a/src/views/gutenberg-blocks/blocks/item-submission-form/theme.js
+++ b/src/views/gutenberg-blocks/blocks/item-submission-form/theme.js
@@ -17,7 +17,8 @@ import {
Loading,
Input,
Select,
- Taginput
+ Taginput,
+ Snackbar
} from 'buefy';
import VTooltip from 'floating-vue';
import cssVars from 'css-vars-ponyfill';
@@ -81,6 +82,7 @@ export default (element) => {
Vue.use(Taginput);
Vue.use(Autocomplete);
Vue.use(Collapse);
+ Vue.use(Snackbar);
Vue.use(Input);
Vue.use(VTooltip, {
popperTriggers: ['hover'],