Shows special fields on the smae way that metadata list. #299.

This commit is contained in:
Mateus Machado Luna 2019-09-19 15:57:12 -03:00
parent 1696c4c025
commit c1465846c9
2 changed files with 47 additions and 51 deletions

View File

@ -41,59 +41,55 @@
<div
v-if="importerSourceInfo != undefined &&
importerSourceInfo != null">
<template v-if="importerSourceInfo.source_metadata.length > 0">
importerSourceInfo != null &&
!isLoading">
<template v-if="importerSourceInfo.source_metadata.length > 0 || (importerSourceInfo.source_special_fields && importerSourceInfo.source_special_fields.length > 0)">
<p class="mapping-header-label is-inline">{{ $i18n.get('label_from_source_collection') }}</p>
<p class="mapping-header-label is-pulled-right">{{ $i18n.get('label_to_target_collection') }}</p>
<div
class="source-metadatum"
v-for="(source_metadatum, index) of importerSourceInfo.source_metadata"
:key="index">
<p>{{ source_metadatum }}</p>
<b-select
v-if="collectionMetadata != undefined &&
collectionMetadata.length > 0 &&
!isFetchingCollectionMetadata"
:value="checkCurrentSelectedCollectionMetadatum(source_metadatum)"
@input="onSelectCollectionMetadata($event, source_metadatum)"
:placeholder="$i18n.get('label_select_metadatum')">
<option :value="undefined">
{{ $i18n.get('label_select_metadatum') }}
</option>
<option :value="'create_metadata' + index">
{{ $i18n.get('label_create_metadatum') }}
</option>
<option
v-for="(metadatum, index) of collectionMetadata"
:key="index"
:value="metadatum.id"
:disabled="checkIfMetadatumIsAvailable(metadatum.id)">
<span class="metadatum-name">
{{ metadatum.name }}
</span>
<span class="label-details">
({{ $i18n.get(metadatum.metadata_type_object.component) }}) <em>{{ (metadatum.collection_id != collectionId) ? $i18n.get('label_inherited') : '' }}</em>
</span>
</option>
</b-select>
<p v-if="collectionMetadata == undefined || collectionMetadata.length <= 0">{{ $i18n.get('info_select_collection_to_list_metadata') }}</p>
</div>
</template>
<template v-if="importerSourceInfo.source_metadata.length <= 0 && !isLoading">
<br>
<p>{{ $i18n.get('info_no_metadata_source_file') }}</p>
<p v-if="importerSourceInfo.source_special_fields && importerSourceInfo.source_special_fields.length > 0">
{{ $i18n.get('info_special_fields_available') }}
<ul style="list-style: disc; margin-left: 1rem; font-style: italic;">
<li
:key="specialFieldIndex"
v-for="(specialField, specialFieldIndex) of importerSourceInfo.source_special_fields">
{{ specialField }}
</li>
</ul>
</p>
<p v-else>{{ $i18n.get('info_no_special_fields_available') }}</p>
</template>
<div
class="source-metadatum"
v-for="(source_metadatum, index) of importerSourceInfo.source_metadata"
:key="index">
<p>{{ source_metadatum }}</p>
<b-select
v-if="collectionMetadata != undefined &&
collectionMetadata.length > 0 &&
!isFetchingCollectionMetadata"
:value="checkCurrentSelectedCollectionMetadatum(source_metadatum)"
@input="onSelectCollectionMetadata($event, source_metadatum)"
:placeholder="$i18n.get('label_select_metadatum')">
<option :value="undefined">
{{ $i18n.get('label_select_metadatum') }}
</option>
<option :value="'create_metadata' + index">
{{ $i18n.get('label_create_metadatum') }}
</option>
<option
v-for="(metadatum, index) of collectionMetadata"
:key="index"
:value="metadatum.id"
:disabled="checkIfMetadatumIsAvailable(metadatum.id)">
<span class="metadatum-name">
{{ metadatum.name }}
</span>
<span class="label-details">
({{ $i18n.get(metadatum.metadata_type_object.component) }}) <em>{{ (metadatum.collection_id != collectionId) ? $i18n.get('label_inherited') : '' }}</em>
</span>
</option>
</b-select>
<p v-if="collectionMetadata == undefined || collectionMetadata.length <= 0">{{ $i18n.get('info_select_collection_to_list_metadata') }}</p>
</div>
<div
v-if="importerSourceInfo.source_special_fields && importerSourceInfo.source_special_fields.length > 0"
class="source-metadatum"
:key="specialFieldIndex"
v-for="(specialField, specialFieldIndex) of importerSourceInfo.source_special_fields">
<p style="font-style: italic">{{ specialField }}</p>
<p>{{ $i18n.get('info_special_fields_mapped_default') }}</p>
</div>
<p v-if="importerSourceInfo.source_metadata.length <= 0">{{ $i18n.get('info_no_metadata_source_file') }}<br></p>
<p v-if="(!importerSourceInfo.source_special_fields || importerSourceInfo.source_special_fields.length <= 0)">{{ $i18n.get('info_no_special_fields_available') }}<br></p>
<b-modal
@close="onMetadatumEditionCanceled()"
:active.sync="isNewMetadatumModalActive">

View File

@ -597,7 +597,7 @@ return apply_filters( 'tainacan-admin-i18n', [
'info_source_file_upload' => __( 'The file containing the data to be imported.', 'tainacan' ),
'info_no_metadata_source_file' => __( 'No metadata was found from the source file.', 'tainacan' ),
'info_no_special_fields_available' => __( 'No special field was found.', 'tainacan' ),
'info_special_fields_available' => __( 'The following special fields were found:', 'tainacan' ),
'info_special_fields_mapped_default' => __( 'Mapped to default field on collection.', 'tainacan' ),
'info_metadata_mapping_helper' => __( 'Map each file metadata with the corresponding one in selected collection.', 'tainacan' ),
'info_upload_a_source_to_see_metadata' => __( 'Upload a source file to load metadata.', 'tainacan' ),
'info_select_collection_to_list_metadata' => __( 'Select a target collection to list metadata.', 'tainacan' ),