Accepts taxonomy type metadata in conditional metadata form settings. #819.
This commit is contained in:
parent
20eaf4e8f4
commit
5d8376fafd
|
@ -179,7 +179,7 @@
|
|||
:extra-classes="isRepositoryLevel ? 'tainacan-repository-tooltip' : ''" />
|
||||
</label>
|
||||
<b-select
|
||||
v-model="selectedConditionalMetadatum"
|
||||
v-model="selectedConditionalMetadatumId"
|
||||
:placeholder="$i18n.get('label_select_metadatum')">
|
||||
<option
|
||||
v-for="conditionalMetadatum of availableConditionalMetadata"
|
||||
|
@ -192,22 +192,23 @@
|
|||
</transition>
|
||||
<transition name="filter-item">
|
||||
<b-field
|
||||
v-if="isConditionalSection && selectedConditionalMetadatum"
|
||||
v-if="isConditionalSection && selectedConditionalMetadatumId && selectedConditionalMetadatum && selectedConditionalMetadatum.name"
|
||||
:addons="false"
|
||||
:type="formErrors['conditional_section_rules'] != undefined ? 'is-danger' : ''"
|
||||
:message="formErrors['conditional_section_rules'] != undefined ? formErrors['conditional_section_rules'] : ''">
|
||||
<label class="label is-inline">
|
||||
{{ availableConditionalMetadata.find((availableMetadatum) => availableMetadatum.id == selectedConditionalMetadatum).name }}
|
||||
{{ selectedConditionalMetadatum.name }}
|
||||
</label>
|
||||
<div style="overflow-y: auto; overflow-x: hidden; max-height: 100px;">
|
||||
<b-checkbox
|
||||
v-model="selectedConditionalValue"
|
||||
v-for="(conditionalValue, conditionalValueIndex) of availableConditionalMetadata.find((availableMetadatum) => availableMetadatum.id == selectedConditionalMetadatum).metadata_type_object.options.options.split('\n')"
|
||||
:key="conditionalValueIndex"
|
||||
:native-value="conditionalValue">
|
||||
{{ conditionalValue }}
|
||||
</b-checkbox>
|
||||
</div>
|
||||
<component
|
||||
:is="selectedConditionalMetadatum.metadata_type_object.component"
|
||||
:forced-component-type="selectedConditionalMetadatum.metadata_type_object.component.includes('taxonomy') ? 'tainacan-taxonomy-tag-input' : ''"
|
||||
:item-metadatum="{ metadatum: selectedConditionalMetadatum }"
|
||||
:value="selectedConditionalValue"
|
||||
:allow-new="false"
|
||||
:allow-select-to-create="false"
|
||||
:maxtags="1"
|
||||
@input="$event => selectedConditionalValue = $event"
|
||||
/>
|
||||
</b-field>
|
||||
</transition>
|
||||
</div>
|
||||
|
@ -266,7 +267,7 @@
|
|||
closedByForm: false,
|
||||
entityName: 'metadataSection',
|
||||
isUpdating: false,
|
||||
selectedConditionalMetadatum: undefined,
|
||||
selectedConditionalMetadatumId: undefined,
|
||||
selectedConditionalValue: [],
|
||||
hideConditionalSectionSettings: false
|
||||
}
|
||||
|
@ -281,12 +282,15 @@
|
|||
const availableMetadata = [];
|
||||
for (let aMetadataSection of otherMetadataSections)
|
||||
availableMetadata.push.apply(availableMetadata, aMetadataSection.metadata_object_list);
|
||||
return availableMetadata.filter(aMetadatum => aMetadatum.metadata_type === 'Tainacan\\Metadata_Types\\Selectbox');
|
||||
return availableMetadata.filter(aMetadatum => aMetadatum.metadata_type === 'Tainacan\\Metadata_Types\\Selectbox' || aMetadatum.metadata_type === 'Tainacan\\Metadata_Types\\Taxonomy');
|
||||
}
|
||||
return {};
|
||||
return [];
|
||||
},
|
||||
isConditionalSection() {
|
||||
return this.form.is_conditional_section == 'yes';
|
||||
},
|
||||
selectedConditionalMetadatum() {
|
||||
return this.availableConditionalMetadata.find(aMetadatum => aMetadatum.id == this.selectedConditionalMetadatumId)
|
||||
}
|
||||
},
|
||||
created() {
|
||||
|
@ -297,7 +301,7 @@
|
|||
|
||||
if ( this.form.is_conditional_section == 'yes' && Object.keys(this.form.conditional_section_rules).length ) {
|
||||
const conditionalMetadatum = Object.keys(this.form.conditional_section_rules)[0];
|
||||
this.selectedConditionalMetadatum = conditionalMetadatum;
|
||||
this.selectedConditionalMetadatumId = conditionalMetadatum;
|
||||
this.selectedConditionalValue = this.form.conditional_section_rules[conditionalMetadatum];
|
||||
}
|
||||
|
||||
|
@ -316,10 +320,9 @@
|
|||
'updateMetadataSection'
|
||||
]),
|
||||
saveEdition(metadataSection) {
|
||||
|
||||
if ( this.form.is_conditional_section == 'yes' && this.selectedConditionalMetadatum && this.selectedConditionalValue ) {
|
||||
if ( this.form.is_conditional_section == 'yes' && this.selectedConditionalMetadatumId && this.selectedConditionalValue ) {
|
||||
this.form.conditional_section_rules = {}
|
||||
this.form.conditional_section_rules[this.selectedConditionalMetadatum] = this.selectedConditionalValue;
|
||||
this.form.conditional_section_rules[this.selectedConditionalMetadatumId] = this.selectedConditionalValue;
|
||||
} else
|
||||
this.form.conditional_section_rules = null;
|
||||
|
||||
|
@ -459,6 +462,23 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/deep/ .is-special-hidden-for-mobile,
|
||||
/deep/ .is-special-hidden-for-mobile:focus,
|
||||
/deep/ .is-special-hidden-for-mobile:focus-visible {
|
||||
opacity: 0;
|
||||
width: 0;
|
||||
height: 0 !important;
|
||||
min-height: 0;
|
||||
min-width: 0;
|
||||
padding: 0 !important;
|
||||
line-height: 0px !important;
|
||||
border: none !important;
|
||||
border-color: transparent !important;
|
||||
border-width: 0px !important;
|
||||
font-size: 0px !important;
|
||||
display: block !important;
|
||||
}
|
||||
.form-submit {
|
||||
background-color: var(--tainacan-gray1);
|
||||
position: sticky;
|
||||
|
|
|
@ -555,7 +555,7 @@
|
|||
.status-radios {
|
||||
display: flex;
|
||||
}
|
||||
.status-radios .control-lable {
|
||||
.status-radios .control-label {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
disabled: false,
|
||||
},
|
||||
computed: {
|
||||
getOptions(){
|
||||
getOptions() {
|
||||
if (this.itemMetadatum && this.itemMetadatum.metadatum.metadata_type_options && this.itemMetadatum.metadatum.metadata_type_options.options ) {
|
||||
const metadata = this.itemMetadatum.metadatum.metadata_type_options.options;
|
||||
return ( metadata ) ? metadata.split("\n") : [];
|
||||
|
|
|
@ -48,41 +48,43 @@
|
|||
</a>
|
||||
</div>
|
||||
|
||||
<!-- Term creation modal, used on admin for a complete term creation -->
|
||||
<b-modal
|
||||
v-model="isTermCreationModalOpen"
|
||||
:width="768"
|
||||
trap-focus
|
||||
aria-role="dialog"
|
||||
aria-modal
|
||||
:can-cancel="['outside', 'escape']"
|
||||
custom-class="tainacan-modal"
|
||||
:close-button-aria-label="$i18n.get('close')">
|
||||
<term-edition-form
|
||||
:metadatum-id="itemMetadatum.metadatum.id"
|
||||
:item-id="itemMetadatum.item.id"
|
||||
:is-hierarchical="isHierarchical"
|
||||
:taxonomy-id="taxonomyId"
|
||||
:original-form="{ id: 'new', name: newTermName ? newTermName : '' }"
|
||||
:is-term-insertion-flow="true"
|
||||
@onEditionFinished="($event) => addRecentlyCreatedTerm($event.term)"
|
||||
@onEditionCanceled="() => $console.log('Editing canceled')"
|
||||
@onErrorFound="($event) => $console.log('Form with errors: ' + $event)" />
|
||||
</b-modal>
|
||||
<template v-if="allowNew && itemMetadatum.item">
|
||||
<!-- Term creation modal, used on admin for a complete term creation -->
|
||||
<b-modal
|
||||
v-model="isTermCreationModalOpen"
|
||||
:width="768"
|
||||
trap-focus
|
||||
aria-role="dialog"
|
||||
aria-modal
|
||||
:can-cancel="['outside', 'escape']"
|
||||
custom-class="tainacan-modal"
|
||||
:close-button-aria-label="$i18n.get('close')">
|
||||
<term-edition-form
|
||||
:metadatum-id="itemMetadatum.metadatum.id"
|
||||
:item-id="itemMetadatum.item.id"
|
||||
:is-hierarchical="isHierarchical"
|
||||
:taxonomy-id="taxonomyId"
|
||||
:original-form="{ id: 'new', name: newTermName ? newTermName : '' }"
|
||||
:is-term-insertion-flow="true"
|
||||
@onEditionFinished="($event) => addRecentlyCreatedTerm($event.term)"
|
||||
@onEditionCanceled="() => $console.log('Editing canceled')"
|
||||
@onErrorFound="($event) => $console.log('Form with errors: ' + $event)" />
|
||||
</b-modal>
|
||||
|
||||
<!-- Term creation panel, used on item submission block for a simpler term creation -->
|
||||
<transition name="filter-item">
|
||||
<term-creation-panel
|
||||
:metadatum-id="itemMetadatum.metadatum.id"
|
||||
:item-id="itemMetadatum.item.id"
|
||||
:is-hierarchical="isHierarchical"
|
||||
v-if="isTermCreationPanelOpen"
|
||||
:taxonomy-id="taxonomyId"
|
||||
:original-form="{ id: 'new', name: newTermName ? newTermName : '' }"
|
||||
@onEditionFinished="($event) => addTermToBeCreated($event)"
|
||||
@onEditionCanceled="() => isTermCreationPanelOpen = false"
|
||||
@onErrorFound="($event) => $console.log('Form with errors: ' + $event)" />
|
||||
</transition>
|
||||
<!-- Term creation panel, used on item submission block for a simpler term creation -->
|
||||
<transition name="filter-item">
|
||||
<term-creation-panel
|
||||
:metadatum-id="itemMetadatum.metadatum.id"
|
||||
:item-id="itemMetadatum.item.id"
|
||||
:is-hierarchical="isHierarchical"
|
||||
v-if="isTermCreationPanelOpen"
|
||||
:taxonomy-id="taxonomyId"
|
||||
:original-form="{ id: 'new', name: newTermName ? newTermName : '' }"
|
||||
@onEditionFinished="($event) => addTermToBeCreated($event)"
|
||||
@onEditionCanceled="() => isTermCreationPanelOpen = false"
|
||||
@onErrorFound="($event) => $console.log('Form with errors: ' + $event)" />
|
||||
</transition>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
@ -173,7 +175,7 @@
|
|||
methods: {
|
||||
getTermsId() {
|
||||
let values = [];
|
||||
|
||||
|
||||
if (this.value && this.itemMetadatum.metadatum && this.getComponent != 'tainacan-taxonomy-tag-input') {
|
||||
values = this.value.map(term => term.id).filter(term => term !== undefined);
|
||||
this.valueComponent = (values.length > 0 && this.itemMetadatum.metadatum && this.itemMetadatum.metadatum.multiple === 'no') ? values[0] : values;
|
||||
|
|
|
@ -82,6 +82,8 @@
|
|||
created() {
|
||||
if (this.value && this.value.length > 0)
|
||||
this.selected = this.value;
|
||||
|
||||
this.labels = this.selected.map(term => { return { label: term.name, value: term.id } });
|
||||
},
|
||||
methods: {
|
||||
...mapActions('taxonomy', [
|
||||
|
|
|
@ -213,7 +213,7 @@
|
|||
:style="{
|
||||
marginRight: !bulkEditionProcedures[criterion].isDone && !bulkEditionProcedures[criterion].isExecuting ? '-7.4px': 0
|
||||
}"
|
||||
class="field buttons-r-bulk">
|
||||
class="field bulk-last-field">
|
||||
|
||||
<button
|
||||
v-if="!bulkEditionProcedures[criterion].isDone && !bulkEditionProcedures[criterion].isExecuting"
|
||||
|
@ -643,7 +643,7 @@
|
|||
padding-left: 0 !important;
|
||||
}
|
||||
|
||||
.buttons-r-bulk {
|
||||
.bulk-last-field {
|
||||
margin-left: 0 !important;
|
||||
justify-content: center !important;
|
||||
}
|
||||
|
@ -786,9 +786,26 @@
|
|||
&:not(:first-child) {
|
||||
padding-left: 13px;
|
||||
}
|
||||
|
||||
/deep/ .is-special-hidden-for-mobile,
|
||||
/deep/ .is-special-hidden-for-mobile:focus,
|
||||
/deep/ .is-special-hidden-for-mobile:focus-visible {
|
||||
opacity: 0;
|
||||
width: 0;
|
||||
height: 0 !important;
|
||||
min-height: 0;
|
||||
min-width: 0;
|
||||
padding: 0 !important;
|
||||
line-height: 0px !important;
|
||||
border: none !important;
|
||||
border-color: transparent !important;
|
||||
border-width: 0px !important;
|
||||
font-size: 0px !important;
|
||||
display: block !important;
|
||||
}
|
||||
}
|
||||
|
||||
.buttons-r-bulk {
|
||||
.bulk-last-field {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
height: 32px;
|
||||
|
|
Loading…
Reference in New Issue