change select placeholder, right use of b-loading when using ajax to update metadata, clear selection when tab change

This commit is contained in:
Jacson Passold 2018-06-12 18:13:18 -03:00
parent cf7086f11a
commit e4a10e2085
2 changed files with 16 additions and 9 deletions

View File

@ -139,7 +139,9 @@
</div> </div>
</b-tab-item> </b-tab-item>
<!-- Exposer --> <!-- Exposer -->
<b-tab-item :label="$i18n.get('mapping')"> <b-tab-item
:label="$i18n.get('mapping')"
@click="onSelectMetadataMapper(this.mapper)">
<div class="active-metadata-area"> <div class="active-metadata-area">
<section <section
v-if="activeMetadatumList.length <= 0 && !isLoadingMetadata" v-if="activeMetadatumList.length <= 0 && !isLoadingMetadata"
@ -159,7 +161,7 @@
<b-select <b-select
id="mappers-options-dropdown" id="mappers-options-dropdown"
class="button is-secondary" class="button is-secondary"
:placeholder="$i18n.get('mappers')"> :placeholder="$i18n.get('instruction_select_a_mapper')">
<option <option
v-for="metadatum_mapper in metadatum_mappers" v-for="metadatum_mapper in metadatum_mappers"
:key="metadatum_mapper.slug" :key="metadatum_mapper.slug"
@ -427,9 +429,11 @@ export default {
this.openedMetadatumId = ''; this.openedMetadatumId = '';
}, },
onSelectMetadataMapper(metadatum_mapper) { onSelectMetadataMapper(metadatum_mapper) {
this.isMapperMetadataLoading = true;
this.mapper = metadatum_mapper; //TODO try to use v-model again
this.mapperMetadata = [];
this.mappedMetadata = [];
if(metadatum_mapper != '') { if(metadatum_mapper != '') {
this.isMapperMetadataLoading = true;
this.mapper = metadatum_mapper;
for (var k in metadatum_mapper.metadata) { for (var k in metadatum_mapper.metadata) {
var item = metadatum_mapper.metadata[k]; var item = metadatum_mapper.metadata[k];
item.slug = k; item.slug = k;
@ -445,9 +449,8 @@ export default {
}); });
this.mapperMetadata.push(item); this.mapperMetadata.push(item);
} }
this.isMapperMetadataLoading = false;
//console.log(JSON.stringify(this.mapperMetadata));
} }
this.isMapperMetadataLoading = false;
}, },
isMetadatumSelected(id) { isMetadatumSelected(id) {
return this.mappedMetadata.indexOf(id) > -1; return this.mappedMetadata.indexOf(id) > -1;
@ -483,8 +486,12 @@ export default {
metadataMapperMetadata.push(map); metadataMapperMetadata.push(map);
} }
}); });
this.updateMetadataMapperMetadata({metadataMapperMetadata: metadataMapperMetadata, mapper: this.mapper.slug}); this.updateMetadataMapperMetadata({metadataMapperMetadata: metadataMapperMetadata, mapper: this.mapper.slug}).then(() => {
this.isMapperMetadataLoading = false; this.isMapperMetadataLoading = false;
})
.catch(() => {
this.isMapperMetadataLoading = false;
});
}, },
onCancelUpdateMetadataMapperMetadata() { onCancelUpdateMetadataMapperMetadata() {
this.isMapperMetadataLoading = true; this.isMapperMetadataLoading = true;

View File

@ -25,7 +25,6 @@ return apply_filters('tainacan-admin-i18n',[
'term' => __( 'Term', 'tainacan' ), 'term' => __( 'Term', 'tainacan' ),
'terms' => __( 'Terms', 'tainacan' ), 'terms' => __( 'Terms', 'tainacan' ),
'mapping' => __( 'Mapping', 'tainacan' ), 'mapping' => __( 'Mapping', 'tainacan' ),
'mappers' => __( 'Mappers', 'tainacan' ),
'metadata' => __( 'metadata', 'tainacan' ), 'metadata' => __( 'metadata', 'tainacan' ),
// Actions // Actions
@ -239,6 +238,7 @@ return apply_filters('tainacan-admin-i18n',[
'instruction_write_text' => __( 'Write Text', 'tainacan' ), 'instruction_write_text' => __( 'Write Text', 'tainacan' ),
'instruction_search' => __( 'Search', 'tainacan' ), 'instruction_search' => __( 'Search', 'tainacan' ),
'instruction_select_a_metadatum' => __( 'Select a metadatum', 'tainacan' ), 'instruction_select_a_metadatum' => __( 'Select a metadatum', 'tainacan' ),
'instruction_select_a_mapper' => __( 'Select a mapper', 'tainacan' ),
'instruction_search_on_repository' => __( 'Search on repository', 'tainacan' ), 'instruction_search_on_repository' => __( 'Search on repository', 'tainacan' ),
// Info. Other feedback to user. // Info. Other feedback to user.