Displays title modal before running importer. #309.

This commit is contained in:
Mateus Machado Luna 2019-11-14 11:11:14 -03:00
parent 579591fb70
commit e86def51d8
2 changed files with 30 additions and 9 deletions

View File

@ -198,7 +198,7 @@
v-if="importerSourceInfo"
:active.sync="showTitlePromptModal"
:can-cancel="false"
:width="680"
:width="820"
scroll="keep"
trap-focus
autofocus
@ -248,7 +248,17 @@
<button
class="button is-outlined"
type="button"
@click="selectedTitle = ''; showTitlePromptModal = false">
@click="selectedTitle = ''; showTitlePromptModal = false;">
{{ $i18n.get('cancel') }}
</button>
</div>
<div
style="margin-left: auto"
class="control">
<button
class="button is-secondary"
type="button"
@click="selectedTitle = ''; showTitlePromptModal = false; onRunImporter(true)">
{{ $i18n.get('skip') }}
</button>
</div>
@ -388,10 +398,6 @@ export default {
this.collectionMetadata = JSON.parse(JSON.stringify(metadata));
this.isFetchingCollectionMetadata = false;
let coreTitleIndex = this.collectionMetadata.findIndex((metadatum) => metadatum.metadata_type == 'Tainacan\\Metadata_Types\\Core_Title');
if (coreTitleIndex >= 0)
this.showTitlePromptModal = true;
this.fetchMappingImporter({ collection: this.collectionId, sessionId: this.sessionId })
.then(res => {
if (res)
@ -431,7 +437,20 @@ export default {
}
return undefined;
},
onRunImporter() {
onRunImporter(skipTitleCheck) {
if (skipTitleCheck !== true) {
let coreTitleIndex = this.collectionMetadata.findIndex((metadatum) => metadatum.metadata_type == 'Tainacan\\Metadata_Types\\Core_Title');
if (coreTitleIndex >= 0 &&
this.mappedCollection &&
this.mappedCollection.mapping &&
!this.mappedCollection.mapping[this.collectionMetadata[coreTitleIndex].id]
) {
this.showTitlePromptModal = true;
return;
}
}
this.isLoadingRun = true;
this.updateImporterCollection({ sessionId: this.sessionId, collection: this.mappedCollection })
.then(updatedImporter => {
@ -540,6 +559,7 @@ export default {
this.onSelectCollectionMetadata(this.collectionMetadata[coreTitleIndex].id, this.importerSourceInfo.source_metadata[this.selectedTitle])
this.showTitlePromptModal = false;
this.onRunImporter();
}
},
created() {
@ -637,6 +657,7 @@ export default {
.source-metadatum {
padding: 2px 0;
min-height: 35px;
border-bottom: 1px solid $gray2;
width: 100%;
margin-bottom: 6px;

View File

@ -493,7 +493,7 @@ return apply_filters( 'tainacan-admin-i18n', [
'instruction_type_value_year' => __( 'Type year value', 'tainacan' ),
'instruction_select_the_amount_of_copies' => __( 'Select the amount of copies of the item that you want to create', 'tainacan'),
'instruction_select_a_interval' => __( 'Select an interval', 'tainacan'),
'instruction_select_title_mapping' => __( 'First, select the title source metadata', 'tainacan'),
'instruction_select_title_mapping' => __( 'Before runnning import, consider selecting the title source metadata', 'tainacan'),
// Info. Other feedback to user.
'info_items_tab_all' => __( 'Every published item, including those visible only to editors.', 'tainacan' ),
@ -673,7 +673,7 @@ return apply_filters( 'tainacan-admin-i18n', [
'info_initial_value' => __( 'Initial value', 'tainacan' ),
'info_final_value' => __( 'Final value', 'tainacan' ),
'info_show_interval_on_tag' => __( 'Show applied interval on tags', 'tainacan' ),
'info_title_mapping' => __( 'The title is the most relevant metadata, that shall identify your item on lists for different view modes. Select the title source metadata first, or skip to continue manual mapping.', 'taincan'),
'info_title_mapping' => __( 'The title is the most relevant metadata, that shall identify your item on lists for different view modes. Select the title source metadata first, or skip to run importer as it is.', 'taincan'),
// Datepicker months
'datepicker_month_january' => __( 'January', 'tainacan' ),