Fixes sync between metadata and mapping. #783.

This commit is contained in:
mateuswetah 2023-10-13 18:09:39 -03:00
parent 4edffb7e78
commit d142b4af6a
1 changed files with 31 additions and 30 deletions

View File

@ -153,6 +153,7 @@
aria-modal aria-modal
aria-role="dialog" aria-role="dialog"
custom-class="tainacan-modal" custom-class="tainacan-modal"
width="800px"
:close-button-aria-label="$i18n.get('close')"> :close-button-aria-label="$i18n.get('close')">
<div <div
autofocus autofocus
@ -165,7 +166,6 @@
<hr> <hr>
</div> </div>
<b-field :addons="false"> <b-field :addons="false">
<label class="label is-inline"> <label class="label is-inline">
{{ $i18n.get('label') }} {{ $i18n.get('label') }}
@ -204,7 +204,7 @@
<button <button
:class="{ 'is-loading': isMapperMetadataLoading, 'is-success': !isMapperMetadataLoading }" :class="{ 'is-loading': isMapperMetadataLoading, 'is-success': !isMapperMetadataLoading }"
@click.prevent="onSaveNewMetadataMapperMetadata" @click.prevent="onSaveNewMetadataMapperMetadata"
:disabled="!mapper.add_meta_form && (isNewMetadataMapperMetadataDisabled || isMapperMetadataLoading)" :disabled="isNewMetadataMapperMetadataDisabled || isMapperMetadataLoading"
class="button">{{ $i18n.get('save') }} class="button">{{ $i18n.get('save') }}
</button> </button>
</div> </div>
@ -240,7 +240,7 @@ export default {
}, },
computed: { computed: {
isNewMetadataMapperMetadataDisabled() { isNewMetadataMapperMetadataDisabled() {
return !this.newMetadataLabel || !this.newMetadataUri; return !this.newMetadataLabel || (!this.mapper.add_meta_form && !this.newMetadataUri);
}, },
activeMetadatumList() { activeMetadatumList() {
return this.getMetadata(); return this.getMetadata();
@ -249,37 +249,14 @@ export default {
watch: { watch: {
mapper: { mapper: {
handler() { handler() {
this.loadMapperMetadata(); this.loadMetadata();
}, },
deep: true deep: true
} }
}, },
mounted() { mounted() {
this.collectionId = this.$route.params.collectionId; this.collectionId = this.$route.params.collectionId;
this.loadMetadata();
this.isLoadingMetadata = true;
this.cleanMetadata();
this.fetchMetadata({
collectionId: this.collectionId,
isRepositoryLevel: this.isRepositoryLevel,
isContextEdit: true,
includeDisabled: true,
includeOptionsAsHtml: false
}).then((resp) => {
resp.request
.then(() => {
this.loadMapperMetadata();
this.isLoadingMetadata = false;
})
.catch(() => {
this.isLoadingMetadata = false;
});
})
.catch(() => this.isLoadingMetadata = false);
}, },
methods: { methods: {
...mapActions('metadata', [ ...mapActions('metadata', [
@ -291,10 +268,34 @@ export default {
...mapGetters('metadata',[ ...mapGetters('metadata',[
'getMetadata' 'getMetadata'
]), ]),
loadMapperMetadata() { loadMetadata() {
this.isLoadingMetadata = true;
this.cleanMetadata();
this.fetchMetadata({
collectionId: this.collectionId,
isRepositoryLevel: this.isRepositoryLevel,
isContextEdit: true,
includeDisabled: true,
includeOptionsAsHtml: false
}).then((resp) => {
resp.request
.then(() => {
this.buildMappingRows();
this.isLoadingMetadata = false;
})
.catch(() => {
this.isLoadingMetadata = false;
});
})
.catch(() => this.isLoadingMetadata = false);
},
buildMappingRows() {
this.isMapperMetadataLoading = true; this.isMapperMetadataLoading = true;
this.mapperMetadata = []; this.mapperMetadata = [];
this.mappedMetadata = [];
if ( this.mapper && this.mapper.metadata ) { if ( this.mapper && this.mapper.metadata ) {