Adds compound children to bulk edition modal. #17.

This commit is contained in:
mateuswetah 2020-03-26 10:38:04 -03:00
parent 3bb45a0443
commit 91d76e6b29
2 changed files with 52 additions and 40 deletions

View File

@ -33,10 +33,22 @@
v-for="(metadatum, index) in metadata">
<option
:key="index"
v-if="metadatum.id"
v-if="metadatum.id && metadatum.metadata_type_object.component !== 'tainacan-compound' && metadatum.parent <= 0"
:value="metadatum.id">
{{ metadatum.name }}
</option>
<optgroup
v-if="metadatum.id && metadatum.metadata_type_object.component === 'tainacan-compound'"
:key="index"
:label="metadatum.name">
<option
v-for="(childMetadatum, childIndex) of metadatum.metadata_type_options.children_objects"
:key="childIndex"
v-if="childMetadatum.id"
:value="childMetadatum.id">
{{ childMetadatum.name }}
</option>
</optgroup>
<option
:key="index"
v-if="index === Object.keys(metadata).length-1"
@ -83,15 +95,15 @@
bulkEditionProcedures[criterion].action == editionActionsForMultiple.replace">
<component
:is="getMetadataByID(bulkEditionProcedures[criterion].metadatumID).metadata_type_object.component"
:forced-component-type="getMetadataByID(bulkEditionProcedures[criterion].metadatumID)
.metadata_type_object.component.includes('taxonomy') ? 'tainacan-taxonomy-tag-input' : ''"
:item-metadatum="{ metadatum: getMetadataByID(bulkEditionProcedures[criterion].metadatumID) }"
:allow-new="false"
:allow-select-to-create="false"
:maxtags="1"
:class="{'is-field-history': bulkEditionProcedures[criterion].isDone}"
:disabled="bulkEditionProcedures[criterion].isDone"
:is="getMetadataByID(bulkEditionProcedures[criterion].metadatumID).metadata_type_object.component"
:item-metadatum="{metadatum: getMetadataByID(bulkEditionProcedures[criterion].metadatumID)}"
class="tainacan-bulk-edition-field"
@input="addToBulkEditionProcedures($event, 'oldValue', criterion)"
/>
@ -103,17 +115,17 @@
</div>
<component
:is="getMetadataByID(bulkEditionProcedures[criterion].metadatumID).metadata_type_object.component"
:forced-component-type="getMetadataByID(bulkEditionProcedures[criterion].metadatumID)
.metadata_type_object.component.includes('taxonomy') ? 'tainacan-taxonomy-tag-input' : ''"
:item-metadatum="{ metadatum: getMetadataByID(bulkEditionProcedures[criterion].metadatumID) }"
:allow-new="false"
:allow-select-to-create="getMetadataByID(bulkEditionProcedures[criterion].metadatumID)
.metadata_type_options.allow_new_terms === 'yes'"
:maxtags="1"
:class="{'is-field-history': bulkEditionProcedures[criterion].isDone}"
:disabled="bulkEditionProcedures[criterion].isDone"
:is="getMetadataByID(bulkEditionProcedures[criterion].metadatumID).metadata_type_object.component"
:item-metadatum="{metadatum: getMetadataByID(bulkEditionProcedures[criterion].metadatumID)}"
class="tainacan-bulk-edition-field tainacan-bulk-edition-field-not-last"
:disabled="bulkEditionProcedures[criterion].isDone"
@input="addToBulkEditionProcedures($event, 'newValue', criterion)"
/>
</template>
@ -121,7 +133,7 @@
<!-- Not replace -->
<template
v-else-if="bulkEditionProcedures[criterion] &&
bulkEditionProcedures[criterion].metadatumID == 'status'">
bulkEditionProcedures[criterion].metadatumID == 'status'">
<b-select
:class="{'is-field-history': bulkEditionProcedures[criterion].isDone, 'hidden-select-arrow': bulkEditionProcedures[criterion].isDone}"
:disabled="bulkEditionProcedures[criterion].isDone"
@ -139,7 +151,7 @@
<template
v-else-if="bulkEditionProcedures[criterion] &&
bulkEditionProcedures[criterion].metadatumID == 'comments'">
bulkEditionProcedures[criterion].metadatumID == 'comments'">
<b-select
:class="{'is-field-history': bulkEditionProcedures[criterion].isDone, 'hidden-select-arrow': bulkEditionProcedures[criterion].isDone}"
:disabled="bulkEditionProcedures[criterion].isDone"
@ -157,28 +169,28 @@
<template
v-else-if="bulkEditionProcedures[criterion] &&
bulkEditionProcedures[criterion].metadatumID &&
bulkEditionProcedures[criterion].action &&
bulkEditionProcedures[criterion].action != editionActionsForMultiple.clear">
bulkEditionProcedures[criterion].metadatumID &&
bulkEditionProcedures[criterion].action &&
bulkEditionProcedures[criterion].action != editionActionsForMultiple.clear">
<component
:is="getMetadataByID(bulkEditionProcedures[criterion].metadatumID).metadata_type_object.component"
:forced-component-type="getMetadataByID(bulkEditionProcedures[criterion].metadatumID)
.metadata_type_object.component.includes('taxonomy') ? 'tainacan-taxonomy-tag-input' : ''"
.metadata_type_object.component.includes('taxonomy') ? 'tainacan-taxonomy-tag-input' : ''"
:item-metadatum="{ metadatum: getMetadataByID(bulkEditionProcedures[criterion].metadatumID) }"
:allow-new="false"
:allow-select-to-create="getMetadataByID(bulkEditionProcedures[criterion].metadatumID)
.metadata_type_options.allow_new_terms === 'yes'"
.metadata_type_options.allow_new_terms === 'yes'"
:maxtags="1"
:class="{'is-field-history': bulkEditionProcedures[criterion].isDone}"
:disabled="bulkEditionProcedures[criterion].isDone || bulkEditionProcedures[criterion].isExecuting"
:is="getMetadataByID(bulkEditionProcedures[criterion].metadatumID).metadata_type_object.component"
:item-metadatum="{metadatum: getMetadataByID(bulkEditionProcedures[criterion].metadatumID)}"
:class="{ 'is-field-history': bulkEditionProcedures[criterion].isDone }"
class="tainacan-bulk-edition-field tainacan-bulk-edition-field-last"
:disabled="bulkEditionProcedures[criterion].isDone || bulkEditionProcedures[criterion].isExecuting"
@input="addToBulkEditionProcedures($event, 'newValue', criterion)"
/>
</template>
<div
:style="{
marginRight: !bulkEditionProcedures[criterion].isDone && !bulkEditionProcedures[criterion].isExecuting ? '-7.4px': 0
marginRight: !bulkEditionProcedures[criterion].isDone && !bulkEditionProcedures[criterion].isExecuting ? '-7.4px': 0
}"
class="field buttons-r-bulk">
@ -235,10 +247,7 @@
</button>
<div v-if="bulkEditionProcedures[criterion].isExecuting">
<b-icon
class="mdi-loader"
type="is-success"
icon="loading"/>
<button class="button is-white is-loading" />
</div>
</div>
</div>
@ -258,7 +267,7 @@
<button
@click="$eventBusSearch.loadItems(); $parent.close()"
:disabled="(Object.keys(bulkEditionProcedures).length &&
bulkEditionProcedures[editionCriteria[editionCriteria.length-1]].isExecuting) || false"
bulkEditionProcedures[editionCriteria[editionCriteria.length-1]].isExecuting) || false"
type="button"
class="button is-outlined">
{{ $i18n.get('close') }}
@ -329,7 +338,7 @@
}
},
created(){
if (this.collectionID){
if (this.collectionID) {
this.metadataIsLoading = true;
// Cancels previous Request
@ -340,7 +349,8 @@
collectionId: this.collectionID,
isRepositoryLevel: false,
isContextEdit: true,
includeDisabled: false
includeDisabled: false,
parent: 'any'
}).then((resp) => {
resp.request
.then(() => {
@ -522,7 +532,7 @@
return element == criterion;
});
if(this.editionCriteria[criterionIndex]){
if (this.editionCriteria[criterionIndex]) {
this.editionCriteria.splice(criterionIndex, 1);
delete this.bulkEditionProcedures[criterion];
this.dones.splice(criterionIndex, 1)
@ -539,14 +549,14 @@
return validEditionActions;
},
getMetadataByID(id){
getMetadataByID(id) {
let found = this.metadata.find((element) => {
return element.id == id;
});
return found ? found : {};
},
addToBulkEditionProcedures(value, key, criterion){
addToBulkEditionProcedures(value, key, criterion) {
if (Array.isArray(value))
value = value[0];
@ -722,20 +732,15 @@
cursor: not-allowed !important;
}
.mdi-loader {
-webkit-animation: spin 2s linear infinite; /* Safari */
animation: spin 2s linear infinite;
.button.is-white.is-loading {
cursor: inherit;
color: var(--tainacan-gray4) !important;
}
/* Safari */
@-webkit-keyframes spin {
0% { -webkit-transform: rotate(0deg); }
100% { -webkit-transform: rotate(360deg); }
.is-pulled-right .is-success {
background-color: transparent !important;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
.add-link {
font-size: 0.875em;
}
</style>

View File

@ -54,5 +54,12 @@
}
&.is-loading.is-small::after {
font-size: 0.875em;
}
optgroup,
optgroup[label],
optgroup::before {
color: var(--tainacan-gray2);
font-weight: normal;
font-style: italic;
}
}