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,15 +249,26 @@ 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();
},
methods: {
...mapActions('metadata', [
'fetchMetadata',
'cleanMetadata',
'fetchMappers',
'updateMapper',
]),
...mapGetters('metadata',[
'getMetadata'
]),
loadMetadata() {
this.isLoadingMetadata = true; this.isLoadingMetadata = true;
this.cleanMetadata(); this.cleanMetadata();
@ -271,7 +282,7 @@ export default {
}).then((resp) => { }).then((resp) => {
resp.request resp.request
.then(() => { .then(() => {
this.loadMapperMetadata(); this.buildMappingRows();
this.isLoadingMetadata = false; this.isLoadingMetadata = false;
}) })
.catch(() => { .catch(() => {
@ -279,22 +290,12 @@ export default {
}); });
}) })
.catch(() => this.isLoadingMetadata = false); .catch(() => this.isLoadingMetadata = false);
}, },
methods: { buildMappingRows() {
...mapActions('metadata', [
'fetchMetadata',
'cleanMetadata',
'fetchMappers',
'updateMapper',
]),
...mapGetters('metadata',[
'getMetadata'
]),
loadMapperMetadata() {
this.isMapperMetadataLoading = true; this.isMapperMetadataLoading = true;
this.mapperMetadata = []; this.mapperMetadata = [];
this.mappedMetadata = [];
if ( this.mapper && this.mapper.metadata ) { if ( this.mapper && this.mapper.metadata ) {