Refactors metadatum edition form to be inside a modal.
This commit is contained in:
parent
d3de562ed7
commit
1039a86d4f
|
@ -130,12 +130,11 @@ class Metadata extends Repository {
|
|||
],
|
||||
'cardinality' => [
|
||||
'map' => 'meta',
|
||||
'title' => __( 'Cardinality', 'tainacan' ),
|
||||
'title' => __( 'Maximum number of values', 'tainacan' ),
|
||||
'type' => ['string', 'number'],
|
||||
'description' => __( 'Number of multiples possible metadata', 'tainacan' ),
|
||||
'on_error' => __( 'This number of multiples metadata is not allowed', 'tainacan' ),
|
||||
'description' => __( 'Limit the amount of possible metadata values', 'tainacan' ),
|
||||
'on_error' => __( 'This number of multiple metadata is not allowed', 'tainacan' ),
|
||||
//'validation' => v::numeric()->positive(),
|
||||
'default' => 1
|
||||
],
|
||||
'mask' => [
|
||||
'map' => 'meta',
|
||||
|
|
|
@ -208,12 +208,13 @@
|
|||
autofocus="true"
|
||||
tabindex="-1"
|
||||
role="dialog"
|
||||
aria-modal>
|
||||
aria-modal
|
||||
v-if="selectedMetadatumType == undefined && !isEditingMetadatum">
|
||||
<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>
|
||||
|
@ -226,7 +227,7 @@
|
|||
v-for="(metadatumType, index) of metadatumTypes"
|
||||
:key="index"
|
||||
@click="onSelectMetadatumType(metadatumType)">
|
||||
<h4>{{ metadatumType.name }}</h4>
|
||||
<h4>{{ metadatumType.name }}</h4>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field is-grouped form-submit">
|
||||
|
@ -241,29 +242,17 @@
|
|||
</div>
|
||||
</section>
|
||||
</div>
|
||||
<div
|
||||
v-if="isEditingMetadatum"
|
||||
class="tainacan-modal-content">
|
||||
<div class="tainacan-modal-title">
|
||||
<h2>{{ $i18n.get('instruction_configure_new_metadatum') }}</h2>
|
||||
<a
|
||||
class="back-link"
|
||||
@click="isEditingMetadatum = false">
|
||||
{{ $i18n.get('back') }}
|
||||
</a>
|
||||
<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>
|
||||
</div>
|
||||
|
||||
<metadatum-edition-form
|
||||
v-if="selectedMetadatumType && isEditingMetadatum"
|
||||
:collection-id="collectionId"
|
||||
:is-repository-level="false"
|
||||
@onEditionFinished="onMetadatumEditionFinished()"
|
||||
@onEditionCanceled="onMetadatumEditionCanceled()"
|
||||
:index="0"
|
||||
:original-metadatum="metadatum"
|
||||
:is-inside-importer-flow="true" />
|
||||
</b-modal>
|
||||
</div>
|
||||
<div
|
||||
|
@ -411,7 +400,6 @@ export default {
|
|||
selectedMetadatumType: undefined,
|
||||
isEditingMetadatum: false,
|
||||
metadatum: {},
|
||||
editedMetadatum: {},
|
||||
backgroundProcess: undefined,
|
||||
metadataSearchCancel: undefined,
|
||||
showTitlePromptModal: false,
|
||||
|
@ -717,17 +705,15 @@ export default {
|
|||
|
||||
this.sendMetadatum({
|
||||
collectionId: this.collectionId,
|
||||
name: newMetadatum.name, metadatumType:
|
||||
newMetadatum.className,
|
||||
name: newMetadatum.name,
|
||||
metadatumType: newMetadatum.className,
|
||||
status: 'auto-draft',
|
||||
isRepositoryLevel: false,
|
||||
newIndex: 0
|
||||
})
|
||||
.then((metadatum) => {
|
||||
this.selectedMetadatumType = newMetadatum.className;
|
||||
this.metadatum = metadatum;
|
||||
this.editedMetadatum = JSON.parse(JSON.stringify(metadatum));
|
||||
this.editedMetadatum.saved = false;
|
||||
this.editedMetadatum.status = 'publish';
|
||||
this.isEditingMetadatum = true;
|
||||
})
|
||||
.catch((error) => {
|
||||
|
@ -747,7 +733,6 @@ export default {
|
|||
onMetadatumEditionFinished() {
|
||||
// Reset variables for metadatum creation
|
||||
delete this.metadatum;
|
||||
delete this.editedMetadatum;
|
||||
this.isEditingMetadatum = false;
|
||||
this.isNewMetadatumModalActive = false;
|
||||
this.selectedMetadatumType = undefined;
|
||||
|
@ -783,8 +768,6 @@ export default {
|
|||
// Reset variables for metadatum creation
|
||||
if (this.metadatum)
|
||||
delete this.metadatum;
|
||||
if (this.editedMetadatum)
|
||||
delete this.editedMetadatum;
|
||||
this.isEditingMetadatum = false;
|
||||
this.isNewMetadatumModalActive = false;
|
||||
this.selectedMetadatumType = undefined;
|
||||
|
|
|
@ -1,275 +1,324 @@
|
|||
<template>
|
||||
<form
|
||||
id="metadatumEditForm"
|
||||
class="tainacan-form"
|
||||
:class="{ 'inCollapse': !isOnModal }"
|
||||
@submit.prevent="saveEdition(editForm)">
|
||||
<div class="options-columns">
|
||||
<b-field
|
||||
:addons="false"
|
||||
:type="formErrors['name'] != undefined ? 'is-danger' : ''"
|
||||
:message="formErrors['name'] != undefined ? formErrors['name'] : ''">
|
||||
<label class="label is-inline-block">
|
||||
{{ $i18n.get('label_name') }}
|
||||
<span
|
||||
class="required-metadatum-asterisk"
|
||||
:class="formErrors['name'] != undefined ? 'is-danger' : ''">*</span>
|
||||
<help-button
|
||||
:title="$i18n.getHelperTitle('metadata', 'name')"
|
||||
:message="$i18n.getHelperMessage('metadata', 'name')"/>
|
||||
</label>
|
||||
<b-input
|
||||
v-model="editForm.name"
|
||||
name="name"
|
||||
@focus="clearErrors('name')"/>
|
||||
</b-field>
|
||||
|
||||
<!-- Hook for extra Form options -->
|
||||
<template
|
||||
v-if="formHooks != undefined &&
|
||||
formHooks['metadatum'] != undefined &&
|
||||
formHooks['metadatum']['begin-left'] != undefined">
|
||||
<form
|
||||
id="form-metadatum-begin-left"
|
||||
class="form-hook-region"
|
||||
v-html="formHooks['metadatum']['begin-left'].join('')"/>
|
||||
</template>
|
||||
|
||||
<b-field
|
||||
:addons="false"
|
||||
:type="formErrors['description'] != undefined ? 'is-danger' : ''"
|
||||
:message="formErrors['description'] != undefined ? formErrors['description'] : ''">
|
||||
<label class="label is-inline-block">
|
||||
{{ $i18n.get('label_description') }}
|
||||
<help-button
|
||||
:title="$i18n.getHelperTitle('metadata', 'description')"
|
||||
:message="$i18n.getHelperMessage('metadata', 'description')"/>
|
||||
</label>
|
||||
<b-input
|
||||
type="textarea"
|
||||
name="description"
|
||||
rows="3"
|
||||
v-model="editForm.description"
|
||||
@focus="clearErrors('description')"/>
|
||||
</b-field>
|
||||
|
||||
<b-field
|
||||
:addons="false">
|
||||
<label class="label is-inline-block">
|
||||
{{ $i18n.get('label_semantic_uri') }}
|
||||
<help-button
|
||||
:title="$i18n.getHelperTitle('metadata', 'semantic_uri')"
|
||||
:message="$i18n.getHelperMessage('metadata', 'semantic_uri')"/>
|
||||
</label>
|
||||
<b-input
|
||||
v-model="editForm.semantic_uri"
|
||||
name="semantic_uri"
|
||||
type="url"
|
||||
@focus="clearErrors('semantic_uri')"/>
|
||||
</b-field>
|
||||
|
||||
<b-field
|
||||
v-if="editedMetadatum.parent == 0"
|
||||
:addons="false"
|
||||
:type="formErrors['status'] != undefined ? 'is-danger' : ''"
|
||||
:message="formErrors['status'] != undefined ? formErrors['status'] : ''">
|
||||
<label class="label is-inline-block">
|
||||
{{ $i18n.get('label_status') }}
|
||||
<help-button
|
||||
:title="$i18n.getHelperTitle('metadata', 'status')"
|
||||
:message="$i18n.getHelperMessage('metadata', 'status')"/>
|
||||
</label>
|
||||
<b-field>
|
||||
<b-radio
|
||||
@focus="clearErrors('label_status')"
|
||||
id="tainacan-select-status-publish"
|
||||
name="status"
|
||||
v-model="editForm.status"
|
||||
native-value="publish">
|
||||
<span class="icon has-text-gray3">
|
||||
<i class="tainacan-icon tainacan-icon-public"/>
|
||||
</span>
|
||||
{{ $i18n.get('status_public') }}
|
||||
</b-radio>
|
||||
</b-field>
|
||||
<b-field>
|
||||
<b-radio
|
||||
@focus="clearErrors('label_status')"
|
||||
id="tainacan-select-status-private"
|
||||
name="status"
|
||||
v-model="editForm.status"
|
||||
native-value="private">
|
||||
<span class="icon has-text-gray3">
|
||||
<i class="tainacan-icon tainacan-icon-private"/>
|
||||
</span>
|
||||
{{ $i18n.get('status_private') }}
|
||||
</b-radio>
|
||||
</b-field>
|
||||
</b-field>
|
||||
|
||||
<!-- Display on listing -->
|
||||
<b-field
|
||||
v-if="editedMetadatum.parent == 0"
|
||||
:type="formErrors['display'] != undefined ? 'is-danger' : ''"
|
||||
:message="formErrors['display'] != undefined ? formErrors['display'] : ''"
|
||||
:addons="false">
|
||||
<label class="label is-inline-block">
|
||||
{{ $i18n.get('label_display') }}
|
||||
<help-button
|
||||
:title="$i18n.getHelperTitle('metadata', 'display')"
|
||||
:message="$i18n.getHelperMessage('metadata', 'display')"/>
|
||||
</label>
|
||||
|
||||
<b-field>
|
||||
<b-radio
|
||||
@input="clearErrors('display')"
|
||||
v-model="editForm.display"
|
||||
native-value="yes"
|
||||
name="display">
|
||||
{{ $i18n.get('label_display_default') }}
|
||||
</b-radio>
|
||||
</b-field>
|
||||
|
||||
<b-field>
|
||||
<b-radio
|
||||
@input="clearErrors('display')"
|
||||
v-model="editForm.display"
|
||||
native-value="no"
|
||||
name="display">
|
||||
{{ $i18n.get('label_not_display') }}
|
||||
</b-radio>
|
||||
</b-field>
|
||||
|
||||
<b-field>
|
||||
<b-radio
|
||||
v-model="editForm.display"
|
||||
@input="clearErrors('display')"
|
||||
native-value="never"
|
||||
name="display">
|
||||
{{ $i18n.get('label_display_never') }}
|
||||
</b-radio>
|
||||
</b-field>
|
||||
|
||||
</b-field>
|
||||
|
||||
<b-field
|
||||
:addons="false">
|
||||
<label class="label is-inline-block">{{ $i18n.get('label_insert_options') }}</label>
|
||||
|
||||
<b-field
|
||||
v-if="editedMetadatum.metadata_type_object.component != 'tainacan-compound' && (editedMetadatum.parent == 0 || (editedMetadatum.parent != 0 && !isParentMultiple))"
|
||||
:type="formErrors['required'] != undefined ? 'is-danger' : ''"
|
||||
:message="formErrors['required'] != undefined ? formErrors['required'] : ''">
|
||||
<b-checkbox
|
||||
@input="clearErrors('required')"
|
||||
v-model="editForm.required"
|
||||
true-value="yes"
|
||||
false-value="no"
|
||||
class="is-inline-block"
|
||||
name="required">
|
||||
{{ $i18n.get('label_required') }}
|
||||
<help-button
|
||||
:title="$i18n.getHelperTitle('metadata', 'required')"
|
||||
:message="$i18n.getHelperMessage('metadata', 'required')"/>
|
||||
</b-checkbox>
|
||||
</b-field>
|
||||
|
||||
<b-field
|
||||
v-if="!originalMetadatum.metadata_type_object.core && editedMetadatum.parent == 0"
|
||||
:type="formErrors['multiple'] != undefined ? 'is-danger' : ''"
|
||||
:message="formErrors['multiple'] != undefined ? formErrors['multiple'] : ''">
|
||||
<b-checkbox
|
||||
@input="clearErrors('multiple')"
|
||||
v-model="editForm.multiple"
|
||||
true-value="yes"
|
||||
false-value="no"
|
||||
class="is-inline-block"
|
||||
name="multiple">
|
||||
{{ $i18n.get('label_allow_multiple') }}
|
||||
<help-button
|
||||
:title="$i18n.getHelperTitle('metadata', 'multiple')"
|
||||
:message="$i18n.getHelperMessage('metadata', 'multiple')"/>
|
||||
</b-checkbox>
|
||||
</b-field>
|
||||
|
||||
<b-field
|
||||
v-if="editedMetadatum.metadata_type_object.component != 'tainacan-compound'"
|
||||
:type="formErrors['collection_key'] != undefined ? 'is-danger' : ''"
|
||||
:message="formErrors['collection_key'] != undefined ? formErrors['collection_key'] : ''">
|
||||
<b-checkbox
|
||||
@input="clearErrors('collection_key')"
|
||||
v-model="editForm.collection_key"
|
||||
true-value="yes"
|
||||
false-value="no"
|
||||
class="is-inline-block"
|
||||
name="collecion_key">
|
||||
{{ $i18n.get('label_unique_value') }}
|
||||
<help-button
|
||||
:title="$i18n.getHelperTitle('metadata', 'collection_key')"
|
||||
:message="$i18n.getHelperMessage('metadata', 'collection_key')"/>
|
||||
</b-checkbox>
|
||||
</b-field>
|
||||
|
||||
<b-field
|
||||
v-if="!isRepositoryLevel && isOnModal"
|
||||
>
|
||||
<b-checkbox
|
||||
class="is-inline-block"
|
||||
v-model="editForm.repository_level"
|
||||
@input="clearErrors('repository_level')"
|
||||
name="repository_level"
|
||||
true-value="yes"
|
||||
false-value="no"
|
||||
>
|
||||
{{ $i18n.get('label_repository_metadata') }}
|
||||
<help-button
|
||||
:title="$i18n.getHelperTitle('metadata', 'repository_level')"
|
||||
:message="$i18n.getHelperMessage('metadata', 'repository_level')"/>
|
||||
</b-checkbox>
|
||||
</b-field>
|
||||
</b-field>
|
||||
|
||||
<component
|
||||
:errors="formErrors['metadata_type_options']"
|
||||
v-if="(editForm.metadata_type_object && editForm.metadata_type_object.form_component) || editForm.edit_form == ''"
|
||||
:is="editForm.metadata_type_object.form_component"
|
||||
:metadatum="editForm"
|
||||
v-model="editForm.metadata_type_options"/>
|
||||
<div
|
||||
v-html="editForm.edit_form"
|
||||
v-else/>
|
||||
|
||||
<!-- Hook for extra Form options -->
|
||||
<template
|
||||
v-if="formHooks != undefined &&
|
||||
formHooks['metadatum'] != undefined &&
|
||||
formHooks['metadatum']['end-left'] != undefined">
|
||||
<form
|
||||
id="form-metadatum-end-left"
|
||||
class="form-hook-region"
|
||||
v-html="formHooks['metadatum']['end-left'].join('')"/>
|
||||
</template>
|
||||
<form
|
||||
id="metadatumEditForm"
|
||||
@submit.prevent="saveEdition(editForm)"
|
||||
autofocus="true"
|
||||
tabindex="-1"
|
||||
role="dialog"
|
||||
aria-modal>
|
||||
<div
|
||||
v-if="editForm && Object.keys(editForm).length"
|
||||
class="tainacan-modal-content">
|
||||
<div class="tainacan-modal-title">
|
||||
<h2 v-html="editForm.name ? ($i18n.get('instruction_configure_the_metadatum') + ' <em>' + editForm.name + '</em>') : $i18n.get('instruction_configure_new_metadatum')" />
|
||||
<!-- <a
|
||||
class="back-link"
|
||||
@click="onEditionCanceled()">
|
||||
{{ $i18n.get('back') }}
|
||||
</a> -->
|
||||
<hr>
|
||||
</div>
|
||||
<div class="field is-grouped form-submit">
|
||||
<div class="control">
|
||||
<button
|
||||
type="button"
|
||||
class="button is-outlined"
|
||||
@click.prevent="cancelEdition()"
|
||||
slot="trigger">{{ $i18n.get('cancel') }}
|
||||
</button>
|
||||
<div class="tainacan-form">
|
||||
<div class="options-columns">
|
||||
<b-field
|
||||
:addons="false"
|
||||
:type="formErrors['name'] != undefined ? 'is-danger' : ''"
|
||||
:message="formErrors['name'] != undefined ? formErrors['name'] : ''">
|
||||
<label class="label is-inline-block">
|
||||
{{ $i18n.get('label_name') }}
|
||||
<span
|
||||
class="required-metadatum-asterisk"
|
||||
:class="formErrors['name'] != undefined ? 'is-danger' : ''">*</span>
|
||||
<help-button
|
||||
:title="$i18n.getHelperTitle('metadata', 'name')"
|
||||
:message="$i18n.getHelperMessage('metadata', 'name')"/>
|
||||
</label>
|
||||
<b-input
|
||||
v-model="editForm.name"
|
||||
name="name"
|
||||
@focus="clearErrors('name')"/>
|
||||
</b-field>
|
||||
|
||||
<!-- Hook for extra Form options -->
|
||||
<template
|
||||
v-if="formHooks != undefined &&
|
||||
formHooks['metadatum'] != undefined &&
|
||||
formHooks['metadatum']['begin-left'] != undefined">
|
||||
<form
|
||||
id="form-metadatum-begin-left"
|
||||
class="form-hook-region"
|
||||
v-html="formHooks['metadatum']['begin-left'].join('')"/>
|
||||
</template>
|
||||
|
||||
<b-field
|
||||
:addons="false"
|
||||
:type="formErrors['description'] != undefined ? 'is-danger' : ''"
|
||||
:message="formErrors['description'] != undefined ? formErrors['description'] : ''">
|
||||
<label class="label is-inline-block">
|
||||
{{ $i18n.get('label_description') }}
|
||||
<help-button
|
||||
:title="$i18n.getHelperTitle('metadata', 'description')"
|
||||
:message="$i18n.getHelperMessage('metadata', 'description')"/>
|
||||
</label>
|
||||
<b-input
|
||||
type="textarea"
|
||||
name="description"
|
||||
rows="3"
|
||||
v-model="editForm.description"
|
||||
@focus="clearErrors('description')"/>
|
||||
</b-field>
|
||||
|
||||
<!-- Display on listing -->
|
||||
<b-field
|
||||
v-if="editForm.parent == 0"
|
||||
:type="formErrors['display'] != undefined ? 'is-danger' : ''"
|
||||
:message="formErrors['display'] != undefined ? formErrors['display'] : ''"
|
||||
:addons="false">
|
||||
<label class="label is-inline-block">
|
||||
{{ $i18n.get('label_display') }}
|
||||
<help-button
|
||||
:title="$i18n.getHelperTitle('metadata', 'display')"
|
||||
:message="$i18n.getHelperMessage('metadata', 'display')"/>
|
||||
</label>
|
||||
<b-select
|
||||
expanded
|
||||
v-model="editForm.display"
|
||||
@input="clearErrors('display')">
|
||||
<option value="yes">
|
||||
{{ $i18n.get('label_display_default') }}
|
||||
</option>
|
||||
<option value="no">
|
||||
{{ $i18n.get('label_not_display') }}
|
||||
</option>
|
||||
<option value="never">
|
||||
{{ $i18n.get('label_display_never') }}
|
||||
</option>
|
||||
</b-select>
|
||||
</b-field>
|
||||
|
||||
<b-field
|
||||
v-if="editForm.parent == 0"
|
||||
:addons="false"
|
||||
:type="formErrors['status'] != undefined ? 'is-danger' : ''"
|
||||
:message="formErrors['status'] != undefined ? formErrors['status'] : ''">
|
||||
<label class="label is-inline-block">
|
||||
{{ $i18n.get('label_status') }}
|
||||
<help-button
|
||||
:title="$i18n.getHelperTitle('metadata', 'status')"
|
||||
:message="$i18n.getHelperMessage('metadata', 'status')"/>
|
||||
</label>
|
||||
<div class="is-flex is-justify-content-space-between">
|
||||
<b-radio
|
||||
@focus="clearErrors('label_status')"
|
||||
id="tainacan-select-status-publish"
|
||||
name="status"
|
||||
v-model="editForm.status"
|
||||
native-value="publish">
|
||||
<span class="icon has-text-gray3">
|
||||
<i class="tainacan-icon tainacan-icon-public"/>
|
||||
</span>
|
||||
{{ $i18n.get('status_public') }}
|
||||
</b-radio>
|
||||
<b-radio
|
||||
@focus="clearErrors('label_status')"
|
||||
id="tainacan-select-status-private"
|
||||
name="status"
|
||||
v-model="editForm.status"
|
||||
native-value="private">
|
||||
<span class="icon has-text-gray3">
|
||||
<i class="tainacan-icon tainacan-icon-private"/>
|
||||
</span>
|
||||
{{ $i18n.get('status_private') }}
|
||||
</b-radio>
|
||||
</div>
|
||||
</b-field>
|
||||
|
||||
<b-field
|
||||
:addons="false">
|
||||
<label class="label is-inline-block">{{ $i18n.get('label_insert_options') }}</label>
|
||||
|
||||
<b-field
|
||||
v-if="editForm.metadata_type_object.component != 'tainacan-compound' && (editForm.parent == 0 || (editForm.parent != 0 && !isParentMultiple))"
|
||||
:type="formErrors['required'] != undefined ? 'is-danger' : ''"
|
||||
:message="formErrors['required'] != undefined ? formErrors['required'] : ''">
|
||||
<b-checkbox
|
||||
@input="clearErrors('required')"
|
||||
v-model="editForm.required"
|
||||
true-value="yes"
|
||||
false-value="no"
|
||||
class="is-inline-block"
|
||||
name="required">
|
||||
{{ $i18n.get('label_required') }}
|
||||
<help-button
|
||||
:title="$i18n.getHelperTitle('metadata', 'required')"
|
||||
:message="$i18n.getHelperMessage('metadata', 'required')"/>
|
||||
</b-checkbox>
|
||||
</b-field>
|
||||
|
||||
<b-field
|
||||
v-if="editForm.metadata_type_object.component != 'tainacan-compound'"
|
||||
:type="formErrors['collection_key'] != undefined ? 'is-danger' : ''"
|
||||
:message="formErrors['collection_key'] != undefined ? formErrors['collection_key'] : ''">
|
||||
<b-checkbox
|
||||
@input="clearErrors('collection_key')"
|
||||
v-model="editForm.collection_key"
|
||||
true-value="yes"
|
||||
false-value="no"
|
||||
class="is-inline-block"
|
||||
name="collecion_key">
|
||||
{{ $i18n.get('label_unique_value') }}
|
||||
<help-button
|
||||
:title="$i18n.getHelperTitle('metadata', 'collection_key')"
|
||||
:message="$i18n.getHelperMessage('metadata', 'collection_key')"/>
|
||||
</b-checkbox>
|
||||
</b-field>
|
||||
|
||||
<b-field
|
||||
v-if="!originalMetadatum.metadata_type_object.core && editForm.parent == 0"
|
||||
:type="formErrors['multiple'] != undefined ? 'is-danger' : ''"
|
||||
:message="formErrors['multiple'] != undefined ? formErrors['multiple'] : ''">
|
||||
<b-checkbox
|
||||
@input="clearErrors('multiple')"
|
||||
v-model="editForm.multiple"
|
||||
true-value="yes"
|
||||
false-value="no"
|
||||
class="is-inline-block"
|
||||
name="multiple">
|
||||
{{ $i18n.get('label_allow_multiple') }}
|
||||
<help-button
|
||||
:title="$i18n.getHelperTitle('metadata', 'multiple')"
|
||||
:message="$i18n.getHelperMessage('metadata', 'multiple')"/>
|
||||
</b-checkbox>
|
||||
|
||||
</b-field>
|
||||
</b-field>
|
||||
|
||||
<b-field
|
||||
v-if="editForm.multiple == 'yes' && !originalMetadatum.metadata_type_object.core && editForm.parent == 0"
|
||||
:type="formErrors['cardinality'] != undefined ? 'is-danger' : ''"
|
||||
:message="formErrors['cardinality'] != undefined ? formErrors['cardinality'] : ''"
|
||||
:addons="false">
|
||||
<label class="label is-inline-block">
|
||||
{{ $i18n.getHelperTitle('metadata', 'cardinality') }}
|
||||
<help-button
|
||||
:title="$i18n.getHelperTitle('metadata', 'cardinality')"
|
||||
:message="$i18n.getHelperMessage('metadata', 'cardinality')"/>
|
||||
</label>
|
||||
<b-input
|
||||
name="cardinality"
|
||||
type="number"
|
||||
step="1" />
|
||||
</b-field>
|
||||
|
||||
<b-field v-if="!isRepositoryLevel && isInsideImporterFlow">
|
||||
<b-checkbox
|
||||
class="is-inline-block"
|
||||
v-model="editForm.repository_level"
|
||||
@input="clearErrors('repository_level')"
|
||||
name="repository_level"
|
||||
true-value="yes"
|
||||
false-value="no">
|
||||
{{ $i18n.get('label_repository_metadata') }}
|
||||
<help-button
|
||||
:title="$i18n.getHelperTitle('metadata', 'repository_level')"
|
||||
:message="$i18n.getHelperMessage('metadata', 'repository_level')"/>
|
||||
</b-checkbox>
|
||||
</b-field>
|
||||
</div>
|
||||
<div class="control">
|
||||
<b-button
|
||||
:loading="isLoading"
|
||||
class="button is-success"
|
||||
native-type="submit">
|
||||
{{ $i18n.get('save') }}
|
||||
</b-button>
|
||||
|
||||
<div
|
||||
v-if="(editForm.metadata_type_object && editForm.metadata_type_object.form_component) || editForm.edit_form != ''"
|
||||
class="metadata-form-section"
|
||||
@click="hideMetadataTypeOptions = !hideMetadataTypeOptions;">
|
||||
<span class="icon">
|
||||
<i
|
||||
class="tainacan-icon"
|
||||
:class="!hideMetadataTypeOptions ? 'tainacan-icon-arrowdown' : 'tainacan-icon-arrowright'" />
|
||||
</span>
|
||||
<strong>{{ $i18n.getWithVariables('label_options_of_the_%s_metadata_type', [ editForm.metadata_type_object.name ]) }}</strong>
|
||||
<hr>
|
||||
</div>
|
||||
|
||||
<transition name="filter-item">
|
||||
<div
|
||||
v-show="!hideMetadataTypeOptions"
|
||||
class="options-columns">
|
||||
<component
|
||||
:errors="formErrors['metadata_type_options']"
|
||||
v-if="(editForm.metadata_type_object && editForm.metadata_type_object.form_component) || editForm.edit_form != ''"
|
||||
:is="editForm.metadata_type_object.form_component"
|
||||
:metadatum="editForm"
|
||||
v-model="editForm.metadata_type_options"/>
|
||||
<div
|
||||
v-html="editForm.edit_form"
|
||||
v-else/>
|
||||
|
||||
<!-- Hook for extra Form options -->
|
||||
<template
|
||||
v-if="formHooks != undefined &&
|
||||
formHooks['metadatum'] != undefined &&
|
||||
formHooks['metadatum']['end-left'] != undefined">
|
||||
<form
|
||||
id="form-metadatum-end-left"
|
||||
class="form-hook-region"
|
||||
v-html="formHooks['metadatum']['end-left'].join('')"/>
|
||||
</template>
|
||||
</div>
|
||||
</transition>
|
||||
|
||||
<div
|
||||
@click="showAdvancedOptions = !showAdvancedOptions;"
|
||||
class="metadata-form-section">
|
||||
<span class="icon">
|
||||
<i
|
||||
class="tainacan-icon"
|
||||
:class="showAdvancedOptions ? 'tainacan-icon-arrowdown' : 'tainacan-icon-arrowright'" />
|
||||
</span>
|
||||
<strong>{{ $i18n.get('label_advanced_metadata_options') }}</strong>
|
||||
<hr>
|
||||
</div>
|
||||
|
||||
<transition name="filter-item">
|
||||
<div
|
||||
v-if="showAdvancedOptions"
|
||||
class="options-columns">
|
||||
<b-field :addons="false">
|
||||
<label class="label is-inline-block">
|
||||
{{ $i18n.get('label_semantic_uri') }}
|
||||
<help-button
|
||||
:title="$i18n.getHelperTitle('metadata', 'semantic_uri')"
|
||||
:message="$i18n.getHelperMessage('metadata', 'semantic_uri')"/>
|
||||
</label>
|
||||
<b-input
|
||||
v-model="editForm.semantic_uri"
|
||||
name="semantic_uri"
|
||||
type="url"
|
||||
@focus="clearErrors('semantic_uri')"/>
|
||||
</b-field>
|
||||
</div>
|
||||
</transition>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field is-grouped form-submit">
|
||||
<div class="control">
|
||||
<button
|
||||
type="button"
|
||||
class="button is-outlined"
|
||||
@click.prevent="cancelEdition()"
|
||||
slot="trigger">{{ $i18n.get('cancel') }}
|
||||
</button>
|
||||
</div>
|
||||
<p class="help is-danger">{{ formErrorMessage }}</p>
|
||||
</form>
|
||||
<div class="control">
|
||||
<b-button
|
||||
:loading="isLoading"
|
||||
class="button is-success"
|
||||
native-type="submit">
|
||||
{{ $i18n.get('save') }}
|
||||
</b-button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
@ -281,29 +330,32 @@
|
|||
mixins: [ formHooks ],
|
||||
props: {
|
||||
index: '',
|
||||
editedMetadatum: Object,
|
||||
originalMetadatum: Object,
|
||||
isRepositoryLevel: false,
|
||||
collectionId: '',
|
||||
isOnModal: false,
|
||||
isParentMultiple: false
|
||||
isParentMultiple: false,
|
||||
isInsideImporterFlow: false
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
editForm: {},
|
||||
oldForm: {},
|
||||
formErrors: {},
|
||||
formErrorMessage: '',
|
||||
closedByForm: false,
|
||||
entityName: 'metadatum',
|
||||
isUpdating: false
|
||||
isUpdating: false,
|
||||
hideMetadataTypeOptions: false,
|
||||
showAdvancedOptions: false
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.editForm = this.editedMetadatum;
|
||||
this.editForm = JSON.parse(JSON.stringify(this.originalMetadatum));
|
||||
|
||||
if (this.editForm.status == 'auto-draft')
|
||||
this.editForm.status = 'publish';
|
||||
|
||||
this.formErrors = this.editForm.formErrors != undefined ? this.editForm.formErrors : {};
|
||||
this.formErrorMessage = this.editForm.formErrors != undefined ? this.editForm.formErrorMessage : '';
|
||||
this.oldForm = JSON.parse(JSON.stringify(this.originalMetadatum));
|
||||
},
|
||||
mounted() {
|
||||
// Fills hook forms with it's real values
|
||||
|
@ -312,27 +364,15 @@
|
|||
this.updateExtraFormData(this.editForm);
|
||||
});
|
||||
},
|
||||
beforeDestroy() {
|
||||
if (this.closedByForm) {
|
||||
this.editedMetadatum.saved = true;
|
||||
} else {
|
||||
this.$set(this.oldForm, 'saved', this.editForm.saved);
|
||||
if (!_.isEqual(this.editForm, this.oldForm))
|
||||
this.editedMetadatum.saved = false;
|
||||
else
|
||||
this.editedMetadatum.saved = true;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
...mapActions('metadata', [
|
||||
'updateMetadatum'
|
||||
]),
|
||||
saveEdition(metadatum) {
|
||||
if ((metadatum.metadata_type_object && metadatum.metadata_type_object.form_component) || metadatum.edit_form == '') {
|
||||
saveEdition(metadatum) {
|
||||
if ( (metadatum.metadata_type_object && metadatum.metadata_type_object.form_component) || metadatum.edit_form == '') {
|
||||
let repository = this.editForm.repository_level;
|
||||
if (repository && repository === 'yes') {
|
||||
if (repository && repository === 'yes')
|
||||
this.isRepositoryLevel = true;
|
||||
}
|
||||
|
||||
this.fillExtraFormData(this.editForm);
|
||||
this.isUpdating = true;
|
||||
|
@ -361,7 +401,6 @@
|
|||
this.formErrors[attribute] = error[attribute];
|
||||
}
|
||||
this.formErrorMessage = errors.error_message;
|
||||
this.$emit('onErrorFound');
|
||||
|
||||
this.editForm.formErrors = this.formErrors;
|
||||
this.editForm.formErrorMessage = this.formErrorMessage;
|
||||
|
@ -424,24 +463,19 @@
|
|||
|
||||
form#metadatumEditForm {
|
||||
|
||||
&.inCollapse {
|
||||
padding: 1.5em var(--tainacan-one-column) 0.5em var(--tainacan-one-column);
|
||||
border-top: 1px solid var(--tainacan-gray2);
|
||||
border-bottom: 1px solid var(--tainacan-gray2);
|
||||
margin-top: 1.0em;
|
||||
font-size: 1.1em;
|
||||
}
|
||||
.options-columns {
|
||||
-moz-column-count: 2;
|
||||
-moz-column-gap: 0;
|
||||
-moz-column-rule: none;
|
||||
-moz-column-rule: 1px solid var(--tainacan-gray1);
|
||||
-webkit-column-count: 2;
|
||||
-webkit-column-gap: 0;
|
||||
-webkit-column-rule: none;
|
||||
-webkit-column-rule: 1px solid var(--tainacan-gray1);
|
||||
column-count: 2;
|
||||
column-gap: 4em;
|
||||
column-rule: none;
|
||||
padding-bottom: 0.25em;
|
||||
column-rule: 1px solid var(--tainacan-gray1);
|
||||
padding-left: 0.25em;
|
||||
padding-right: 0.25em;
|
||||
padding-bottom: 0.5em;
|
||||
|
||||
&>.field, &>section {
|
||||
-webkit-column-break-inside: avoid;
|
||||
|
@ -451,6 +485,14 @@
|
|||
.field > .field:not(:last-child) {
|
||||
margin-bottom: 0em;
|
||||
}
|
||||
/deep/ .field {
|
||||
-webkit-column-break-inside: avoid;
|
||||
page-break-inside: avoid;
|
||||
break-inside: avoid;
|
||||
}
|
||||
section {
|
||||
display: grid;
|
||||
}
|
||||
.field:first-child {
|
||||
-webkit-column-span: all;
|
||||
column-span: all;
|
||||
|
@ -459,10 +501,49 @@
|
|||
font-size: 1.25em;
|
||||
}
|
||||
}
|
||||
|
||||
.form-submit {
|
||||
margin-bottom: 0.75em;
|
||||
.tainacan-form .field:not(:last-child) {
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
.metadata-form-section {
|
||||
margin: 0.5em 0;
|
||||
position: relative;
|
||||
cursor: pointer;
|
||||
|
||||
.icon {
|
||||
background: var(--tainacan-background-color);
|
||||
z-index: 1;
|
||||
position: relative;
|
||||
}
|
||||
strong {
|
||||
background: var(--tainacan-background-color);
|
||||
color: var(--tainacan-gray4);
|
||||
font-size: 0.875em;
|
||||
z-index: 1;
|
||||
position: relative;
|
||||
padding-right: 12px;
|
||||
}
|
||||
hr {
|
||||
position: absolute;
|
||||
top: -0.75em;
|
||||
width: calc(100% - 42px);
|
||||
height: 1px;
|
||||
background-color: var(--tainacan-gray2);
|
||||
margin-left: 42px;
|
||||
}
|
||||
}
|
||||
.metadata-form-section+.options-columns {
|
||||
padding-left: 1.75em;
|
||||
}
|
||||
}
|
||||
.form-submit {
|
||||
background-color: var(--tainacan-gray1);
|
||||
position: sticky;
|
||||
bottom: 0;
|
||||
padding: 16px 4.166666667vw;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
z-index: 2;
|
||||
font-size: 1.125em;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
|
|
@ -66,9 +66,7 @@
|
|||
<i class="tainacan-icon tainacan-icon-18px tainacan-icon-drag"/>
|
||||
</span>
|
||||
|
||||
<span
|
||||
class="metadatum-name"
|
||||
:class="{'is-danger': formWithErrors == metadatum.id }">
|
||||
<span class="metadatum-name">
|
||||
{{ metadatum.name }}
|
||||
</span>
|
||||
<span
|
||||
|
@ -86,11 +84,6 @@
|
|||
metadatum.metadata_type_object.related_mapped_prop == 'description'">
|
||||
{{ $i18n.get('label_core_description') }}
|
||||
</em>
|
||||
<span
|
||||
class="not-saved"
|
||||
v-if="(editForms[metadatum.id] != undefined && editForms[metadatum.id].saved != true) || metadatum.status == 'auto-draft'">
|
||||
{{ $i18n.get('info_not_saved') }}
|
||||
</span>
|
||||
<span
|
||||
v-if="metadatum.status == 'private'"
|
||||
class="icon"
|
||||
|
@ -182,20 +175,22 @@
|
|||
v-if="isCollapseOpen(metadatum.id) && openedMetadatumId !== metadatum.id"
|
||||
:metadatum="metadatum" />
|
||||
</transition>
|
||||
<transition name="form-collapse">
|
||||
<div v-if="openedMetadatumId == metadatum.id">
|
||||
<metadatum-edition-form
|
||||
:collection-id="collectionId"
|
||||
:is-repository-level="isRepositoryLevel"
|
||||
@onEditionFinished="onEditionFinished()"
|
||||
@onEditionCanceled="onEditionCanceled()"
|
||||
@onErrorFound="formWithErrors = metadatum.id"
|
||||
:index="index"
|
||||
:original-metadatum="metadatum"
|
||||
:edited-metadatum="editForms[metadatum.id]"
|
||||
:is-parent-multiple="isParentMultiple"/>
|
||||
</div>
|
||||
</transition>
|
||||
<b-modal
|
||||
@close="onEditionCanceled()"
|
||||
:active="openedMetadatumId == metadatum.id"
|
||||
trap-focus
|
||||
aria-modal
|
||||
aria-role="dialog"
|
||||
custom-class="tainacan-modal">
|
||||
<metadatum-edition-form
|
||||
:collection-id="collectionId"
|
||||
:original-metadatum="metadatum"
|
||||
:is-parent-multiple="isParentMultiple"
|
||||
:is-repository-level="isRepositoryLevel"
|
||||
@onEditionFinished="onEditionFinished()"
|
||||
@onEditionCanceled="onEditionCanceled()"
|
||||
:index="index" />
|
||||
</b-modal>
|
||||
</div>
|
||||
</draggable>
|
||||
</div>
|
||||
|
@ -236,9 +231,7 @@
|
|||
isLoadingMetadata: false,
|
||||
isUpdatingMetadataOrder: false,
|
||||
openedMetadatumId: '',
|
||||
formWithErrors: '',
|
||||
hightlightedMetadatum: '',
|
||||
editForms: {},
|
||||
metadataSearchCancel: undefined,
|
||||
childrenMetadata: [],
|
||||
collapses: {}
|
||||
|
@ -269,33 +262,6 @@
|
|||
this.childrenMetadata.forEach((metadatum) => this.$set(this.collapses, metadatum.id, isCollapsed));
|
||||
}
|
||||
},
|
||||
beforeRouteLeave ( to, from, next ) {
|
||||
|
||||
let hasUnsavedForms = false;
|
||||
for (let editForm in this.editForms) {
|
||||
if (!this.editForms[editForm].saved)
|
||||
hasUnsavedForms = true;
|
||||
}
|
||||
if ((this.openedMetadatumId != '' && this.openedMetadatumId != undefined) || hasUnsavedForms ) {
|
||||
this.$buefy.modal.open({
|
||||
parent: this,
|
||||
component: CustomDialog,
|
||||
props: {
|
||||
icon: 'alert',
|
||||
title: this.$i18n.get('label_warning'),
|
||||
message: this.$i18n.get('info_warning_metadata_not_saved'),
|
||||
onConfirm: () => {
|
||||
this.onEditionCanceled();
|
||||
next();
|
||||
},
|
||||
},
|
||||
trapFocus: true,
|
||||
customClass: 'tainacan-modal'
|
||||
});
|
||||
} else {
|
||||
next();
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
if (this.isRepositoryLevel)
|
||||
this.collectionId = 'default';
|
||||
|
@ -400,34 +366,12 @@
|
|||
},
|
||||
editMetadatum(metadatum) {
|
||||
this.openedMetadatumId = metadatum.id;
|
||||
|
||||
// Scroll to opened metadata form
|
||||
this.$nextTick(() => {
|
||||
if (this.$refs['metadatum-handler-' + metadatum.id] && this.$refs['metadatum-handler-' + metadatum.id][0])
|
||||
this.$refs['metadatum-handler-' + metadatum.id][0].scrollIntoView({ behavior: 'smooth', block: 'start' });
|
||||
});
|
||||
|
||||
// First time opening
|
||||
if (this.editForms[this.openedMetadatumId] == undefined) {
|
||||
this.editForms[this.openedMetadatumId] = JSON.parse(JSON.stringify(metadatum));
|
||||
this.editForms[this.openedMetadatumId].saved = true;
|
||||
|
||||
// Metadatum inserted now
|
||||
if (this.editForms[this.openedMetadatumId].status == 'auto-draft') {
|
||||
this.editForms[this.openedMetadatumId].status = 'publish';
|
||||
this.editForms[this.openedMetadatumId].saved = false;
|
||||
}
|
||||
}
|
||||
},
|
||||
onEditionFinished() {
|
||||
this.formWithErrors = '';
|
||||
delete this.editForms[this.openedMetadatumId];
|
||||
this.openedMetadatumId = '';
|
||||
this.$router.push({ query: {}});
|
||||
},
|
||||
onEditionCanceled() {
|
||||
this.formWithErrors = '';
|
||||
delete this.editForms[this.openedMetadatumId];
|
||||
this.openedMetadatumId = '';
|
||||
this.$router.push({ query: {}});
|
||||
},
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
<template>
|
||||
<div :class="{ 'repository-level-page page-container': isRepositoryLevel }">
|
||||
<div
|
||||
:class="{ 'repository-level-page page-container': isRepositoryLevel }"
|
||||
style="padding-bottom: 0;">
|
||||
<tainacan-title
|
||||
:bread-crumb-items="[{ path: '', label: this.$i18n.get('metadata') }]"/>
|
||||
|
||||
|
@ -152,9 +154,7 @@
|
|||
class="icon grip-icon">
|
||||
<i class="tainacan-icon tainacan-icon-1-25em tainacan-icon-drag"/>
|
||||
</span>
|
||||
<span
|
||||
class="metadatum-name"
|
||||
:class="{'is-danger': formWithErrors == metadatum.id }">
|
||||
<span class="metadatum-name">
|
||||
{{ metadatum.name }}
|
||||
</span>
|
||||
<span
|
||||
|
@ -163,11 +163,6 @@
|
|||
:class="{ 'has-text-weight-bold': metadatum.metadata_type_object.core }">
|
||||
({{ metadatum.metadata_type_object.name }})
|
||||
<em v-if="metadatum.inherited">{{ $i18n.get('label_inherited') }}</em>
|
||||
<span
|
||||
class="not-saved"
|
||||
v-if="(editForms[metadatum.id] != undefined && editForms[metadatum.id].saved != true) || metadatum.status == 'auto-draft'">
|
||||
{{ $i18n.get('info_not_saved') }}
|
||||
</span>
|
||||
<span
|
||||
v-if="metadatum.status === 'private'"
|
||||
class="icon"
|
||||
|
@ -226,7 +221,7 @@
|
|||
metadatum.collection_id != collectionId
|
||||
? 'hidden' : 'visible'
|
||||
}"
|
||||
@click.prevent="toggleMetadatumEdition(metadatum.id)">
|
||||
@click.prevent="toggleMetadatumEdition(metadatum)">
|
||||
<span
|
||||
v-tooltip="{
|
||||
content: $i18n.get('edit'),
|
||||
|
@ -260,33 +255,36 @@
|
|||
v-if="isCollapseOpen(metadatum.id) && openedMetadatumId !== metadatum.id"
|
||||
:metadatum="metadatum" />
|
||||
</transition>
|
||||
<transition name="form-collapse">
|
||||
<div v-if="openedMetadatumId == metadatum.id">
|
||||
<metadatum-edition-form
|
||||
:collection-id="collectionId"
|
||||
:is-repository-level="isRepositoryLevel"
|
||||
@onEditionFinished="onEditionFinished()"
|
||||
@onEditionCanceled="onEditionCanceled()"
|
||||
@onErrorFound="formWithErrors = metadatum.id"
|
||||
:index="index"
|
||||
:original-metadatum="metadatum"
|
||||
:edited-metadatum="editForms[metadatum.id]"/>
|
||||
</div>
|
||||
</transition>
|
||||
</div>
|
||||
|
||||
<child-metadata-list
|
||||
v-if="metadatum.metadata_type_object && metadatum.metadata_type_object.component == 'tainacan-compound'"
|
||||
:parent.sync="metadatum"
|
||||
:metadata-name-filter-string="metadataNameFilterString"
|
||||
:metadata-type-filter-options="metadataTypeFilterOptions"
|
||||
:has-some-metadata-type-filter-applied="hasSomeMetadataTypeFilterApplied"
|
||||
:is-parent-multiple="metadatum.multiple == 'yes' || (editForms[metadatum.id] && editForms[metadatum.id].multiple == 'yes')"
|
||||
:is-parent-multiple="metadatum.multiple == 'yes'"
|
||||
:is-repository-level="isRepositoryLevel"
|
||||
:collapse-all="collapseAll" />
|
||||
|
||||
<b-modal
|
||||
@close="onEditionCanceled()"
|
||||
:active="openedMetadatumId == metadatum.id"
|
||||
trap-focus
|
||||
aria-modal
|
||||
aria-role="dialog"
|
||||
custom-class="tainacan-modal">
|
||||
<metadatum-edition-form
|
||||
:collection-id="collectionId"
|
||||
:original-metadatum="metadatum"
|
||||
:is-repository-level="isRepositoryLevel"
|
||||
@onEditionFinished="onEditionFinished()"
|
||||
@onEditionCanceled="onEditionCanceled()"
|
||||
:index="index" />
|
||||
</b-modal>
|
||||
</div>
|
||||
</draggable>
|
||||
</draggable>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="(isRepositoryLevel && $userCaps.hasCapability('tnc_rep_edit_metadata')) || !isRepositoryLevel"
|
||||
class="column available-metadata-area" >
|
||||
|
@ -382,9 +380,7 @@ export default {
|
|||
isLoadingMetadata: false,
|
||||
isUpdatingMetadataOrder: false,
|
||||
openedMetadatumId: '',
|
||||
formWithErrors: '',
|
||||
hightlightedMetadatum: '',
|
||||
editForms: {},
|
||||
collapses: {},
|
||||
columnsTopY: 0,
|
||||
collapseAll: false,
|
||||
|
@ -431,33 +427,6 @@ export default {
|
|||
this.activeMetadatumList.forEach((metadatum) => this.$set(this.collapses, metadatum.id, isCollapsed));
|
||||
}
|
||||
},
|
||||
beforeRouteLeave ( to, from, next ) {
|
||||
|
||||
let hasUnsavedForms = false;
|
||||
for (let editForm in this.editForms) {
|
||||
if (!this.editForms[editForm].saved)
|
||||
hasUnsavedForms = true;
|
||||
}
|
||||
if ((this.openedMetadatumId != '' && this.openedMetadatumId != undefined) || hasUnsavedForms ) {
|
||||
this.$buefy.modal.open({
|
||||
parent: this,
|
||||
component: CustomDialog,
|
||||
props: {
|
||||
icon: 'alert',
|
||||
title: this.$i18n.get('label_warning'),
|
||||
message: this.$i18n.get('info_warning_metadata_not_saved'),
|
||||
onConfirm: () => {
|
||||
this.onEditionCanceled();
|
||||
next();
|
||||
},
|
||||
},
|
||||
trapFocus: true,
|
||||
customClass: 'tainacan-modal'
|
||||
});
|
||||
} else {
|
||||
next();
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.isRepositoryLevel = (this.$route.params.collectionId === undefined);
|
||||
},
|
||||
|
@ -570,7 +539,7 @@ export default {
|
|||
if (!this.isRepositoryLevel)
|
||||
this.updateMetadataOrder();
|
||||
|
||||
this.toggleMetadatumEdition(metadatum.id)
|
||||
this.toggleMetadatumEdition(metadatum)
|
||||
this.hightlightedMetadatum = '';
|
||||
})
|
||||
.catch((error) => {
|
||||
|
@ -602,48 +571,17 @@ export default {
|
|||
customClass: 'tainacan-modal'
|
||||
});
|
||||
},
|
||||
toggleMetadatumEdition(metadatumId) {
|
||||
// Closing collapse
|
||||
if (this.openedMetadatumId == metadatumId) {
|
||||
this.openedMetadatumId = '';
|
||||
this.$router.push({ query: {}});
|
||||
|
||||
// Opening collapse
|
||||
} else {
|
||||
this.$router.push({ query: { edit: metadatumId}})
|
||||
}
|
||||
toggleMetadatumEdition(metadatum) {
|
||||
this.$router.push({ query: { edit: metadatum.id } });
|
||||
},
|
||||
editMetadatum(metadatum) {
|
||||
|
||||
this.openedMetadatumId = metadatum.id;
|
||||
|
||||
// Scroll to opened metadata form
|
||||
this.$nextTick(() => {
|
||||
if (this.$refs['metadatum-handler-' + metadatum.id] && this.$refs['metadatum-handler-' + metadatum.id][0])
|
||||
this.$refs['metadatum-handler-' + metadatum.id][0].scrollIntoView({ behavior: 'smooth', block: 'start' });
|
||||
});
|
||||
|
||||
// First time opening
|
||||
if (this.editForms[this.openedMetadatumId] == undefined) {
|
||||
this.editForms[this.openedMetadatumId] = JSON.parse(JSON.stringify(metadatum));
|
||||
this.editForms[this.openedMetadatumId].saved = true;
|
||||
|
||||
// Metadatum inserted now
|
||||
if (this.editForms[this.openedMetadatumId].status == 'auto-draft') {
|
||||
this.editForms[this.openedMetadatumId].status = 'publish';
|
||||
this.editForms[this.openedMetadatumId].saved = false;
|
||||
}
|
||||
}
|
||||
},
|
||||
onEditionFinished() {
|
||||
this.formWithErrors = '';
|
||||
delete this.editForms[this.openedMetadatumId];
|
||||
this.openedMetadatumId = '';
|
||||
this.$router.push({ query: {}});
|
||||
},
|
||||
onEditionCanceled() {
|
||||
this.formWithErrors = '';
|
||||
delete this.editForms[this.openedMetadatumId];
|
||||
this.openedMetadatumId = '';
|
||||
this.$router.push({ query: {}});
|
||||
},
|
||||
|
|
|
@ -588,6 +588,8 @@ return apply_filters( 'tainacan-admin-i18n', [
|
|||
'label_related_items' => __( 'Items related to this', 'tainacan'),
|
||||
'label_view_all_%s_related_items' => __( 'View all %s related items', 'tainacan'),
|
||||
'label_back_to_related_item' => __( 'Back to related item', 'tainacan'),
|
||||
'label_options_of_the_%s_metadata_type' => __( 'Options of the %s metadata type', 'tainacan'),
|
||||
'label_advanced_metadata_options' => __( 'Advanced metadata options', 'tainacan'),
|
||||
|
||||
// Instructions. More complex sentences to guide user and placeholders
|
||||
'instruction_delete_selected_collections' => __( 'Delete selected collections', 'tainacan' ),
|
||||
|
@ -623,6 +625,7 @@ return apply_filters( 'tainacan-admin-i18n', [
|
|||
'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' ),
|
||||
'instruction_configure_the_metadatum' => __( 'Configure the metadatum', 'tainacan' ),
|
||||
'instruction_insert_mapper_metadatum_info' => __( 'Insert the new mapper\'s metadatum info', 'tainacan' ),
|
||||
'instruction_select_max_options_to_show' => __( 'Select max options to show', 'tainacan' ),
|
||||
'instruction_select_collection_fetch_items' => __( 'Select a collection to fetch items', 'tainacan' ),
|
||||
|
|
Loading…
Reference in New Issue