Adds possibility to create new metadatum directly from Importer's page.
This commit is contained in:
parent
cfa402dbc5
commit
e7e7dc4644
|
@ -118,27 +118,58 @@
|
|||
</b-select>
|
||||
<p v-if="collectionMetadata == undefined || collectionMetadata.length <= 0">{{ $i18n.get('info_select_collection_to_list_metadata') }}</p>
|
||||
</div>
|
||||
<!-- <b-modal
|
||||
:active.sync="isNewMetadatumModalActive"
|
||||
has-modal-card>
|
||||
<metadatum-edition-form
|
||||
:collection-id="collectionId"
|
||||
:is-repository-level="false"
|
||||
@onEditionFinished="onEditionFinished()"
|
||||
@onEditionCanceled="onEditionCanceled()"
|
||||
:index="0"
|
||||
:original-metadatum="{}"
|
||||
:edited-metadatum="{}"/>
|
||||
<b-modal
|
||||
@close="onMetadatumEditionCanceled()"
|
||||
:active.sync="isNewMetadatumModalActive">
|
||||
<b-loading
|
||||
:is-full-page="isFullPage"
|
||||
:active.sync="isLoadingMetadatumTypes"/>
|
||||
<div
|
||||
v-if="selectedMetadatumType == undefined && !isEditingMetadatum"
|
||||
class="tainacan-modal-content">
|
||||
<div class="tainacan-modal-title">
|
||||
<h2>{{ $i18n.get('instruction_select_metadatum_type') }}</h2>
|
||||
<hr>
|
||||
</div>
|
||||
<b-select
|
||||
:value="selectedMetadatumType"
|
||||
@input="onSelectMetadatumType($event)"
|
||||
:placeholder="$i18n.get('label_select_metadatum_type')">
|
||||
<option
|
||||
v-for="(metadatumType, index) of metadatumTypes"
|
||||
:key="index"
|
||||
:value="metadatumType">
|
||||
{{ metadatumType.name }}
|
||||
</option>
|
||||
</b-select>
|
||||
</div>
|
||||
<div
|
||||
v-if="isEditingMetadatum"
|
||||
class="tainacan-modal-content">
|
||||
<div class="tainacan-modal-title">
|
||||
<h2>{{ $i18n.get('instruction_configure_new_metadatum') }}</h2>
|
||||
<hr>
|
||||
</div>
|
||||
<metadatum-edition-form
|
||||
:collection-id="collectionId"
|
||||
:is-repository-level="false"
|
||||
@onEditionFinished="onMetadatumEditionFinished()"
|
||||
@onEditionCanceled="onMetadatumEditionCanceled()"
|
||||
:index="0"
|
||||
:original-metadatum="metadatum"
|
||||
:edited-metadatum="editedMetadatum"
|
||||
:is-on-modal="true"/>
|
||||
</div>
|
||||
</b-modal>
|
||||
<a
|
||||
v-if="collectionId != null && collectionId != undefined"
|
||||
class="is-inline is-pulled-right add-link"
|
||||
@click="isNewMetadatumModalActive = true">
|
||||
@click="createNewMetadatum()">
|
||||
<b-icon
|
||||
icon="plus-circle"
|
||||
size="is-small"
|
||||
type="is-secondary"/>
|
||||
{{ $i18n.get('label_add_more_metadata') }}</a> -->
|
||||
{{ $i18n.get('label_add_more_metadata') }}</a>
|
||||
</div>
|
||||
<div
|
||||
v-if="importerSourceInfo == undefined ||
|
||||
|
@ -175,7 +206,7 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import { mapActions } from 'vuex';
|
||||
import { mapActions, mapGetters } from 'vuex';
|
||||
import MetadatumEditionForm from './../edition/metadatum-edition-form.vue';
|
||||
|
||||
export default {
|
||||
|
@ -202,12 +233,22 @@ export default {
|
|||
collectionMetadata: [],
|
||||
collectionId: undefined,
|
||||
url: '',
|
||||
isNewMetadatumModalActive: false
|
||||
isNewMetadatumModalActive: false,
|
||||
isLoadingMetadatumTypes: false,
|
||||
selectedMetadatumType: undefined,
|
||||
isEditingMetadatum: false,
|
||||
metadatum: {},
|
||||
editedMetadatum: {}
|
||||
}
|
||||
},
|
||||
components: {
|
||||
MetadatumEditionForm
|
||||
},
|
||||
computed: {
|
||||
metadatumTypes() {
|
||||
return this.getMetadatumTypes();
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
...mapActions('importer', [
|
||||
'fetchImporterTypes',
|
||||
|
@ -224,7 +265,12 @@ export default {
|
|||
'fetchCollectionsForParent'
|
||||
]),
|
||||
...mapActions('metadata', [
|
||||
'fetchMetadata'
|
||||
'fetchMetadata',
|
||||
'fetchMetadatumTypes',
|
||||
'sendMetadatum'
|
||||
]),
|
||||
...mapGetters('metadata', [
|
||||
'getMetadatumTypes'
|
||||
]),
|
||||
createImporter() {
|
||||
// Puts loading on Draft Importer creation
|
||||
|
@ -345,17 +391,63 @@ export default {
|
|||
this.collectionMetadata.push("");
|
||||
this.collectionMetadata.pop();
|
||||
},
|
||||
onMetadatumEditionFinished() {
|
||||
// this.formWithErrors = '';
|
||||
// delete this.editForms[this.openedMetadatumId];
|
||||
// this.openedMetadatumId = '';
|
||||
console.log("Metadatum Edition Finished!");
|
||||
onSelectMetadatumType(newMetadatum) {
|
||||
this.sendMetadatum({
|
||||
collectionId: this.collectionId,
|
||||
name: newMetadatum.name, metadatumType:
|
||||
newMetadatum.className,
|
||||
status: 'auto-draft',
|
||||
isRepositoryLevel: false,
|
||||
newIndex: 0
|
||||
})
|
||||
.then((metadatum) => {
|
||||
this.metadatum = metadatum;
|
||||
this.editedMetadatum = JSON.parse(JSON.stringify(metadatum));
|
||||
this.editedMetadatum.saved = false;
|
||||
this.editedMetadatum.status = 'publish';
|
||||
this.isEditingMetadatum = true;
|
||||
})
|
||||
.catch((error) => {
|
||||
this.$console.error(error);
|
||||
});
|
||||
},
|
||||
onEditionCanceled() {
|
||||
// this.formWithErrors = '';
|
||||
// delete this.editForms[this.openedMetadatumId];
|
||||
// this.openedMetadatumId = '';
|
||||
console.log("Metadatum Edition Canceled");
|
||||
createNewMetadatum() {
|
||||
this.fetchMetadatumTypes()
|
||||
.then(() => {
|
||||
this.isLoadingMetadatumTypes = false;
|
||||
this.isNewMetadatumModalActive = true;
|
||||
})
|
||||
.catch(() => {
|
||||
this.isLoadingMetadatumTypes = false;
|
||||
});
|
||||
},
|
||||
onMetadatumEditionFinished() {
|
||||
// Reset variables for metadatum creation
|
||||
delete this.metadatum;
|
||||
delete this.editedMetadatum;
|
||||
this.isEditingMetadatum = false;
|
||||
this.isNewMetadatumModalActive = false;
|
||||
this.selectedMetadatumType = undefined;
|
||||
|
||||
// Generates options for metadata listing
|
||||
this.isFetchingCollectionMetadata = true;
|
||||
this.fetchMetadata({collectionId: this.collectionId, isRepositoryLevel: false, isContextEdit: false })
|
||||
.then((metadata) => {
|
||||
this.collectionMetadata = JSON.parse(JSON.stringify(metadata));
|
||||
this.isFetchingCollectionMetadata = false;
|
||||
})
|
||||
.catch((error) => {
|
||||
this.$console.error(error);
|
||||
this.isFetchingCollectionMetadata = false;
|
||||
});
|
||||
},
|
||||
onMetadatumEditionCanceled() {
|
||||
// Reset variables for metadatum creation
|
||||
delete this.metadatum;
|
||||
delete this.editedMetadatum;
|
||||
this.isEditingMetadatum = false;
|
||||
this.isNewMetadatumModalActive = false;
|
||||
this.selectedMetadatumType = undefined;
|
||||
}
|
||||
},
|
||||
created() {
|
||||
|
@ -404,6 +496,16 @@ export default {
|
|||
margin: 12px 0 6px 0;
|
||||
}
|
||||
|
||||
.modal .animation-content {
|
||||
width: 100%;
|
||||
z-index: 99999;
|
||||
|
||||
#metadatumEditForm {
|
||||
background-color: white;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
</style>
|
||||
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
<form
|
||||
id="metadatumEditForm"
|
||||
class="tainacan-form"
|
||||
:class="{ 'inCollapse': !isOnModal }"
|
||||
@submit.prevent="saveEdition(editForm)">
|
||||
|
||||
<b-field
|
||||
|
@ -229,7 +230,8 @@
|
|||
editedMetadatum: Object,
|
||||
originalMetadatum: Object,
|
||||
isRepositoryLevel: false,
|
||||
collectionId: ''
|
||||
collectionId: '',
|
||||
isOnModal: false
|
||||
},
|
||||
created() {
|
||||
|
||||
|
@ -334,7 +336,7 @@
|
|||
|
||||
@import "../../scss/_variables.scss";
|
||||
|
||||
form {
|
||||
form.inCollapse {
|
||||
padding: 1.0em 2.0em;
|
||||
border-top: 1px solid $draggable-border-color;
|
||||
border-bottom: 1px solid $draggable-border-color;
|
||||
|
|
|
@ -292,6 +292,7 @@ export default {
|
|||
} else {
|
||||
|
||||
this.openedMetadatumId = metadatum.id;
|
||||
|
||||
// First time opening
|
||||
if (this.editForms[this.openedMetadatumId] == undefined) {
|
||||
this.editForms[this.openedMetadatumId] = JSON.parse(JSON.stringify(metadatum));
|
||||
|
|
|
@ -230,6 +230,7 @@ return apply_filters('tainacan-admin-i18n',[
|
|||
'label_url_source_link' => __( 'URL Source link', 'tainacan' ),
|
||||
'label_metadata_mapping' => __( 'Metadata mapping', 'tainacan' ),
|
||||
'label_select_metadatum' => __( 'Select metadatum', 'tainacan' ),
|
||||
'label_select_metadatum_type' => __( 'Select a metadatum type', 'tainacan' ),
|
||||
'label_add_more_metadata' => __( 'Add more metadata', 'tainacan' ),
|
||||
'label_from_source_collection' => __( 'From source collection', 'tainacan' ),
|
||||
'label_to_target_collection' => __( 'To target collection', 'tainacan' ),
|
||||
|
@ -258,6 +259,8 @@ return apply_filters('tainacan-admin-i18n',[
|
|||
'instruction_select_a_target_collection' => __( 'Select a target collection', 'tainacan' ),
|
||||
'instruction_select_an_importer_type' => __( 'Select an importer type from the options above:', 'tainacan' ),
|
||||
'instruction_drop_file_or_click_to_upload' => __( 'Drop your source file or click here to upload.', 'tainacan' ),
|
||||
'instruction_select_metadatum_type' => __( 'Select a metadatum type.', 'tainacan' ),
|
||||
'instruction_configure_new_metadatum' => __( 'Configure new metadatum.', 'tainacan' ),
|
||||
|
||||
// Info. Other feedback to user.
|
||||
'info_search_results' => __( 'Search Results', 'tainacan' ),
|
||||
|
|
Loading…
Reference in New Issue