Adds support for all actions (#18)
This commit is contained in:
parent
847ab14a13
commit
0d8dfcdf31
|
@ -77,6 +77,10 @@
|
|||
getMetadataByID(bulkEditionProcedures[criterion].metadatumID).multiple == 'yes'))">
|
||||
|
||||
<component
|
||||
:forced-component-type="getMetadataByID(bulkEditionProcedures[criterion].metadatumID)
|
||||
.metadata_type_object.component.includes('taxonomy') ? 'tainacan-taxonomy-tag-input' : ''"
|
||||
:allow-new="false"
|
||||
:allow-select-to-create="true"
|
||||
:class="{'is-field-history': bulkEditionProcedures[criterion].isDone}"
|
||||
:disabled="bulkEditionProcedures[criterion].isDone"
|
||||
:id="getMetadataByID(bulkEditionProcedures[criterion].metadatumID).metadata_type_object.component +
|
||||
|
@ -126,6 +130,10 @@
|
|||
bulkEditionProcedures[criterion].metadatumID &&
|
||||
bulkEditionProcedures[criterion].action">
|
||||
<component
|
||||
:forced-component-type="getMetadataByID(bulkEditionProcedures[criterion].metadatumID)
|
||||
.metadata_type_object.component.includes('taxonomy') ? 'tainacan-taxonomy-tag-input' : ''"
|
||||
:allow-new="false"
|
||||
:allow-select-to-create="true"
|
||||
:class="{'is-field-history': bulkEditionProcedures[criterion].isDone}"
|
||||
:disabled="bulkEditionProcedures[criterion].isDone"
|
||||
:id="getMetadataByID(bulkEditionProcedures[criterion].metadatumID).metadata_type_object.component +
|
||||
|
@ -155,13 +163,20 @@
|
|||
type="is-gray4"
|
||||
icon="close-circle-outline"/>
|
||||
</button>
|
||||
<a
|
||||
<div
|
||||
v-if="bulkEditionProcedures[criterion].isDone"
|
||||
class="is-pulled-right">
|
||||
<b-icon
|
||||
type="is-success"
|
||||
icon="check-circle"/>
|
||||
</a>
|
||||
</div>
|
||||
<div
|
||||
v-if="bulkEditionProcedures[criterion].isDoneWithError && !bulkEditionProcedures[criterion].isExecuting"
|
||||
class="is-pulled-right">
|
||||
<b-icon
|
||||
type="is-danger"
|
||||
icon="alert-circle"/>
|
||||
</div>
|
||||
<button
|
||||
v-if="!bulkEditionProcedures[criterion].isDone &&
|
||||
!bulkEditionProcedures[criterion].isExecuting &&
|
||||
|
@ -182,8 +197,8 @@
|
|||
</div>
|
||||
</div>
|
||||
<button
|
||||
style="padding-left: 2px !important;"
|
||||
class="button is-white is-text"
|
||||
style="padding-left: 3px !important;"
|
||||
class="button is-white"
|
||||
:disabled="dones.every((item) => item === true) === false"
|
||||
@click="addEditionCriterion()">
|
||||
<a
|
||||
|
@ -205,6 +220,7 @@
|
|||
<footer class="field form-submit">
|
||||
<div class="control is-pulled-right">
|
||||
<button
|
||||
:disabled="dones.every((item) => item === true) === false"
|
||||
class="button is-success"
|
||||
type="button"
|
||||
@click="$parent.close()">{{ $i18n.get('conclude') }}
|
||||
|
@ -245,10 +261,10 @@
|
|||
},
|
||||
editionCriteria: [1],
|
||||
editionActionsForMultiple: {
|
||||
remove: this.$i18n.get('remove'),
|
||||
add: this.$i18n.get('add'),
|
||||
redefine: this.$i18n.get('redefine'),
|
||||
remove: this.$i18n.get('remove'),
|
||||
replace: this.$i18n.get('replace'),
|
||||
add: this.$i18n.get('add')
|
||||
},
|
||||
editionActionsForNotMultiple: {
|
||||
redefine: this.$i18n.get('redefine'),
|
||||
|
@ -256,11 +272,13 @@
|
|||
bulkEditionProcedures: {
|
||||
1: {
|
||||
isDone: false,
|
||||
isDoneWithError: false,
|
||||
isExecuting: false
|
||||
}
|
||||
},
|
||||
groupID: null,
|
||||
dones: [false],
|
||||
totalItemsEditedWithSuccess: 0
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
@ -275,30 +293,39 @@
|
|||
'replaceValueInBulk',
|
||||
'redefineValueInBulk',
|
||||
'setStatusInBulk',
|
||||
'removeValueInBulk'
|
||||
]),
|
||||
finalizeProcedure(criterion){
|
||||
this.$set(this.bulkEditionProcedures[criterion], 'isDone', true);
|
||||
finalizeProcedure(criterion, withError){
|
||||
this.$set(this.bulkEditionProcedures[criterion], 'isDone', !withError);
|
||||
this.$set(this.bulkEditionProcedures[criterion], 'isDoneWithError', withError);
|
||||
|
||||
let index = this.editionCriteria.indexOf(criterion);
|
||||
|
||||
this.dones[index] = true;
|
||||
this.dones[index] = !withError;
|
||||
|
||||
this.$set(this.bulkEditionProcedures[criterion], 'isExecuting', false);
|
||||
},
|
||||
executeBulkEditionProcedure(criterion){
|
||||
let procedure = this.bulkEditionProcedures[criterion];
|
||||
|
||||
if(procedure.action === 'Redefine'){
|
||||
if(procedure.action === this.editionActionsForMultiple.redefine){
|
||||
this.$set(this.bulkEditionProcedures[criterion], 'isExecuting', true);
|
||||
|
||||
if(procedure.metadatumID == 'status'){
|
||||
if(procedure.metadatumID === 'status'){
|
||||
this.setStatusInBulk({
|
||||
collectionID: this.collectionID,
|
||||
groupID: this.groupID,
|
||||
bodyParams: { value: procedure.newValue }
|
||||
}).then(() => {
|
||||
this.finalizeProcedure(criterion)
|
||||
})
|
||||
let actionResult = this.getActionResult();
|
||||
|
||||
if(actionResult.constructor.name === 'Object' && actionResult.data.status.toString().split('')[0] != 2 ) {
|
||||
this.finalizeProcedure(criterion, true);
|
||||
} else {
|
||||
this.finalizeProcedure(criterion);
|
||||
this.totalItemsEditedWithSuccess = actionResult;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.setValueInBulk({
|
||||
collectionID: this.collectionID,
|
||||
|
@ -308,9 +335,77 @@
|
|||
value: procedure.newValue
|
||||
}
|
||||
}).then(() => {
|
||||
this.finalizeProcedure(criterion)
|
||||
let actionResult = this.getActionResult();
|
||||
|
||||
if(actionResult.constructor.name === 'Object' && actionResult.data.status.toString().split('')[0] != 2 ) {
|
||||
this.finalizeProcedure(criterion, true);
|
||||
} else {
|
||||
this.finalizeProcedure(criterion);
|
||||
this.totalItemsEditedWithSuccess = actionResult;
|
||||
}
|
||||
});
|
||||
}
|
||||
} else if(procedure.action === this.editionActionsForMultiple.add){
|
||||
this.$set(this.bulkEditionProcedures[criterion], 'isExecuting', true);
|
||||
|
||||
this.addValueInBulk({
|
||||
collectionID: this.collectionID,
|
||||
groupID: this.groupID,
|
||||
bodyParams: {
|
||||
metadatum_id: procedure.metadatumID,
|
||||
value: procedure.newValue,
|
||||
}
|
||||
}).then(() => {
|
||||
let actionResult = this.getActionResult();
|
||||
|
||||
if(actionResult.constructor.name === 'Object' && actionResult.data.status.toString().split('')[0] != 2 ) {
|
||||
this.finalizeProcedure(criterion, true);
|
||||
} else {
|
||||
this.finalizeProcedure(criterion);
|
||||
this.totalItemsEditedWithSuccess = actionResult;
|
||||
}
|
||||
});
|
||||
} else if(procedure.action === this.editionActionsForMultiple.replace){
|
||||
this.$set(this.bulkEditionProcedures[criterion], 'isExecuting', true);
|
||||
|
||||
this.replaceValueInBulk({
|
||||
collectionID: this.collectionID,
|
||||
groupID: this.groupID,
|
||||
bodyParams: {
|
||||
metadatum_id: procedure.metadatumID,
|
||||
old_value: procedure.oldValue,
|
||||
new_value: procedure.newValue,
|
||||
}
|
||||
}).then(() => {
|
||||
let actionResult = this.getActionResult();
|
||||
|
||||
if(actionResult.constructor.name === 'Object' && actionResult.data.status.toString().split('')[0] != 2 ) {
|
||||
this.finalizeProcedure(criterion, true);
|
||||
} else {
|
||||
this.finalizeProcedure(criterion);
|
||||
this.totalItemsEditedWithSuccess = actionResult;
|
||||
}
|
||||
});
|
||||
} else if(procedure.action === this.editionActionsForMultiple.remove){
|
||||
this.$set(this.bulkEditionProcedures[criterion], 'isExecuting', true);
|
||||
|
||||
this.removeValueInBulk({
|
||||
collectionID: this.collectionID,
|
||||
groupID: this.groupID,
|
||||
bodyParams: {
|
||||
metadatum_id: procedure.metadatumID,
|
||||
value: procedure.newValue,
|
||||
}
|
||||
}).then(() => {
|
||||
let actionResult = this.getActionResult();
|
||||
|
||||
if(actionResult.constructor.name === 'Object' && actionResult.data.status.toString().split('')[0] != 2 ) {
|
||||
this.finalizeProcedure(criterion, true);
|
||||
} else {
|
||||
this.finalizeProcedure(criterion);
|
||||
this.totalItemsEditedWithSuccess = actionResult;
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
addEditionCriterion() {
|
||||
|
@ -326,6 +421,7 @@
|
|||
this.bulkEditionProcedures = Object.assign({}, this.bulkEditionProcedures, {
|
||||
[`${aleatoryKey}`]: {
|
||||
isDone: false,
|
||||
isDoneWithError: false,
|
||||
isExecuting: false
|
||||
}
|
||||
});
|
||||
|
@ -354,6 +450,10 @@
|
|||
return found ? found : {};
|
||||
},
|
||||
addToBulkEditionProcedures(value, key, criterion){
|
||||
if(Array.isArray(value)){
|
||||
value = value[0];
|
||||
}
|
||||
|
||||
this.$set(this.bulkEditionProcedures[criterion], `${key}`, value);
|
||||
}
|
||||
},
|
||||
|
@ -366,6 +466,7 @@
|
|||
|
||||
.modal-card-body {
|
||||
padding: 0 !important;
|
||||
overflow: unset !important;
|
||||
}
|
||||
|
||||
.tainacan-total-objects-info {
|
||||
|
@ -393,8 +494,52 @@
|
|||
}
|
||||
}
|
||||
|
||||
.taginput-container {
|
||||
height: 32px !important;
|
||||
|
||||
.tags {
|
||||
margin-bottom: calc(0.275em - 1px) !important;
|
||||
|
||||
.tag {
|
||||
height: 2em !important;
|
||||
padding-left: 0.75em !important;
|
||||
padding-right: 0.75em !important;
|
||||
margin-right: 0 !important;
|
||||
}
|
||||
}
|
||||
|
||||
.icon {
|
||||
height: 28px !important;
|
||||
}
|
||||
}
|
||||
|
||||
.is-field-history {
|
||||
|
||||
.input[disabled], .taginput [disabled].taginput-container.is-focusable, .textarea[disabled] {
|
||||
color: black !important;
|
||||
border: none !important;
|
||||
background-color: white !important;
|
||||
}
|
||||
|
||||
.taginput-container {
|
||||
.tags {
|
||||
color: black !important;
|
||||
background-color: white !important;
|
||||
|
||||
.tag.is-delete {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.tag {
|
||||
max-width: 100% !important;
|
||||
}
|
||||
}
|
||||
|
||||
.icon {
|
||||
display: none !important;
|
||||
}
|
||||
}
|
||||
|
||||
input {
|
||||
color: black !important;
|
||||
border: none !important;
|
||||
|
@ -425,8 +570,7 @@
|
|||
flex-shrink: 1;
|
||||
text-align: center;
|
||||
padding-bottom: 9px;
|
||||
max-height: 150px;
|
||||
overflow-y: auto;
|
||||
flex-basis: 10%;
|
||||
|
||||
&:not(:first-child) {
|
||||
padding-left: 13px;
|
||||
|
@ -439,13 +583,16 @@
|
|||
height: 32px;
|
||||
margin-left: 10px;
|
||||
flex-direction: row-reverse;
|
||||
|
||||
.icon.has-text-gray4:hover {
|
||||
color: $gray5 !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.tainacan-add-edition-criterion-button {
|
||||
font-size: 12px;
|
||||
color: $turquoise5;
|
||||
text-decoration: none !important;
|
||||
}
|
||||
|
||||
.tainacan-add-edition-criterion-button-disabled {
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
:value="allItemsOnPageSelected">{{ $i18n.get('label_select_all_items_page') }}</b-checkbox>
|
||||
</span>
|
||||
|
||||
<!-- TODO: Only appear if had more than 1 page -->
|
||||
<span>
|
||||
<b-checkbox
|
||||
@click.native="selectAllItems()"
|
||||
|
@ -22,7 +21,7 @@
|
|||
:mobile-modal="true"
|
||||
position="is-bottom-left"
|
||||
v-if="items.length > 0 && items[0].current_user_can_edit"
|
||||
:disabled="!isSelectingItems"
|
||||
:disabled="selectedItemsIDs.every(id => id === false) || this.selectedItemsIDs.filter(item => item !== false).length <= 1"
|
||||
id="bulk-actions-dropdown">
|
||||
<button
|
||||
class="button is-white"
|
||||
|
@ -579,25 +578,30 @@ export default {
|
|||
},
|
||||
mounted() {
|
||||
this.selectedItems = [];
|
||||
for (let i = 0; i < this.items.length; i++)
|
||||
this.selectedItemsIDs = [];
|
||||
|
||||
for (let i = 0; i < this.items.length; i++) {
|
||||
this.selectedItemsIDs.push(false);
|
||||
this.selectedItems.push(false);
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
selectedItems() {
|
||||
let allSelected = true;
|
||||
let isSelecting = false;
|
||||
|
||||
for (let i = 0; i < this.selectedItems.length; i++) {
|
||||
if (this.selectedItems[i] == false) {
|
||||
allSelected = false;
|
||||
allSelected = !this.selectedItems.some(item => item === false);
|
||||
|
||||
this.selectedItemsIDs.splice(i, 1);
|
||||
this.selectedItems.map((item, index) => {
|
||||
if(item === false){
|
||||
this.selectedItemsIDs.splice(index, 1, false);
|
||||
this.queryAllItemsSelected = {};
|
||||
} else {
|
||||
} else if(item === true) {
|
||||
isSelecting = true;
|
||||
this.selectedItemsIDs.splice(i, 1, this.items[i].id);
|
||||
|
||||
this.selectedItemsIDs.splice(index, 1, this.items[index].id);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if(!allSelected) {
|
||||
this.isAllItemsSelected = allSelected;
|
||||
|
@ -617,8 +621,8 @@ export default {
|
|||
component: BulkEditionModal,
|
||||
props: {
|
||||
modalTitle: this.$i18n.get('info_editing_items_in_bulk'),
|
||||
totalItems: Object.keys(this.queryAllItemsSelected).length ? this.totalItems : this.selectedItemsIDs.length,
|
||||
selectedForBulk: Object.keys(this.queryAllItemsSelected).length ? this.queryAllItemsSelected : this.selectedItemsIDs,
|
||||
totalItems: Object.keys(this.queryAllItemsSelected).length ? this.totalItems : this.selectedItemsIDs.filter(item => item !== false).length,
|
||||
selectedForBulk: Object.keys(this.queryAllItemsSelected).length ? this.queryAllItemsSelected : this.selectedItemsIDs.filter(item => item !== false),
|
||||
objectType: this.$i18n.get('items'),
|
||||
metadata: this.tableMetadata,
|
||||
collectionID: this.$route.params.collectionId,
|
||||
|
|
|
@ -69,6 +69,7 @@ return apply_filters( 'tainacan-admin-i18n', [
|
|||
'redefine' => __( 'Redefine', 'tainacan' ),
|
||||
'replace' => __( 'Replace', 'tainacan' ),
|
||||
'conclude' => __( 'Conclude', 'tainacan' ),
|
||||
'select_to_create' => __( 'select to create', 'tainacan' ),
|
||||
|
||||
// Wordpress Status
|
||||
'publish' => __( 'Publish', 'tainacan' ),
|
||||
|
|
|
@ -49,7 +49,7 @@ class REST_Bulkedit_Controller extends REST_Controller {
|
|||
'description' => __( 'The metadatum ID', 'tainacan' ),
|
||||
],
|
||||
'value' => [
|
||||
'type' => 'string',
|
||||
'type' => 'string/integer',
|
||||
'description' => __( 'The value to be added', 'tainacan' ),
|
||||
],
|
||||
],
|
||||
|
@ -110,7 +110,7 @@ class REST_Bulkedit_Controller extends REST_Controller {
|
|||
'description' => __( 'The metadatum ID', 'tainacan' ),
|
||||
],
|
||||
'value' => [
|
||||
'type' => 'string',
|
||||
'type' => 'string/integer',
|
||||
'description' => __( 'The value to be added', 'tainacan' ),
|
||||
],
|
||||
],
|
||||
|
@ -129,7 +129,7 @@ class REST_Bulkedit_Controller extends REST_Controller {
|
|||
'description' => __( 'The metadatum ID', 'tainacan' ),
|
||||
],
|
||||
'value' => [
|
||||
'type' => 'string',
|
||||
'type' => 'string/integer',
|
||||
'description' => __( 'The value to be added', 'tainacan' ),
|
||||
],
|
||||
],
|
||||
|
@ -140,7 +140,7 @@ class REST_Bulkedit_Controller extends REST_Controller {
|
|||
array(
|
||||
array(
|
||||
'methods' => \WP_REST_Server::CREATABLE,
|
||||
'callback' => array($this, 'add_value'),
|
||||
'callback' => array($this, 'replace_value'),
|
||||
'permission_callback' => array($this, 'bulk_edit_permissions_check'),
|
||||
'args' => [
|
||||
'metadatum_id' => [
|
||||
|
@ -148,11 +148,11 @@ class REST_Bulkedit_Controller extends REST_Controller {
|
|||
'description' => __( 'The metadatum ID', 'tainacan' ),
|
||||
],
|
||||
'old_value' => [
|
||||
'type' => 'string',
|
||||
'type' => 'string/integer',
|
||||
'description' => __( 'The value to search for', 'tainacan' ),
|
||||
],
|
||||
'new_value' => [
|
||||
'type' => 'string',
|
||||
'type' => 'string/integer',
|
||||
'description' => __( 'The value to be set', 'tainacan' ),
|
||||
],
|
||||
],
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
:class="{'has-content': dateValue !== undefined && dateValue !== ''}"
|
||||
class="control is-inline">
|
||||
<input
|
||||
:disabled="disabled"
|
||||
class="input"
|
||||
type="text"
|
||||
v-mask="dateMask"
|
||||
|
@ -65,6 +66,7 @@
|
|||
type: Object
|
||||
},
|
||||
value: [String, Number, Array],
|
||||
disabled: false,
|
||||
},
|
||||
methods: {
|
||||
onBlur() {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<template>
|
||||
<b-input
|
||||
:disabled="disabled"
|
||||
:class="{'has-content': inputValue !== undefined && inputValue !== ''}"
|
||||
:id="id"
|
||||
type="number"
|
||||
|
@ -28,6 +29,7 @@
|
|||
type: Object
|
||||
},
|
||||
value: [String, Number, Array],
|
||||
disabled: false,
|
||||
},
|
||||
methods: {
|
||||
onBlur() {
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
<template>
|
||||
<div :class="{ 'is-flex': metadatum.metadatum.multiple != 'yes' }">
|
||||
<b-taginput
|
||||
:disabled="disabled"
|
||||
:id="id"
|
||||
v-model="selected"
|
||||
:data="options"
|
||||
:maxtags="metadatum.metadatum.multiple === 'yes' ? 100 : 1"
|
||||
:maxtags="metadatum.metadatum.multiple === 'yes' && allowNew === true ? 100 : 1"
|
||||
autocomplete
|
||||
attached
|
||||
:loading="loading"
|
||||
|
@ -69,7 +70,9 @@
|
|||
collection_id: {
|
||||
type: Number
|
||||
},
|
||||
id: ''
|
||||
id: '',
|
||||
disabled: false,
|
||||
allowNew: true,
|
||||
},
|
||||
watch: {
|
||||
selected( value ){
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
<template>
|
||||
<div>
|
||||
<b-select
|
||||
:id = "id"
|
||||
:placeholder="$i18n.get('label_selectbox_init')"
|
||||
:value="value"
|
||||
:class="{'is-empty': value == undefined || value == ''}"
|
||||
@blur="$emit('blur')"
|
||||
@input="onChecked($event)">
|
||||
<b-select
|
||||
:disabled="disabled"
|
||||
:id = "id"
|
||||
:placeholder="$i18n.get('label_selectbox_init')"
|
||||
:value="value"
|
||||
:class="{'is-empty': value == undefined || value == ''}"
|
||||
@blur="$emit('blur')"
|
||||
@input="onChecked($event)">
|
||||
<option
|
||||
v-for="(option, index) in getOptions"
|
||||
:key="index"
|
||||
|
@ -28,7 +29,8 @@
|
|||
type: String
|
||||
},
|
||||
value: [String, Number, Array],
|
||||
id: ''
|
||||
id: '',
|
||||
disabled: false,
|
||||
},
|
||||
computed: {
|
||||
getOptions(){
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
<template>
|
||||
<div>
|
||||
<component
|
||||
:disabled="disabled"
|
||||
:is="getComponent()"
|
||||
:maxtags="maxtags"
|
||||
v-model="valueComponent"
|
||||
:allow-select-to-create="allowSelectToCreate"
|
||||
:allow-new="allowNew"
|
||||
:terms="terms"
|
||||
:taxonomy-id="taxonomy"
|
||||
|
@ -40,7 +43,7 @@
|
|||
}
|
||||
|
||||
// This condition is temporary
|
||||
if(this.component != 'tainacan-taxonomy-tag-input'){
|
||||
if(this.component != 'tainacan-taxonomy-tag-input' || this.forcedComponentType != 'tainacan-taxonomy-tag-input'){
|
||||
this.getTermsFromTaxonomy();
|
||||
}
|
||||
|
||||
|
@ -60,7 +63,6 @@
|
|||
collectionId: '',
|
||||
taxonomy: '',
|
||||
terms:[], // object with names
|
||||
allowNew: false
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
|
@ -78,11 +80,18 @@
|
|||
type: String
|
||||
},
|
||||
value: [ Number, String, Array,Object ],
|
||||
id: ''
|
||||
id: '',
|
||||
disabled: false,
|
||||
forcedComponentType: '',
|
||||
allowNew: false,
|
||||
maxtags: '',
|
||||
allowSelectToCreate: false,
|
||||
},
|
||||
methods: {
|
||||
getComponent(){
|
||||
if( this.metadatum.metadatum
|
||||
if(this.forcedComponentType){
|
||||
return this.forcedComponentType;
|
||||
} else if( this.metadatum.metadatum
|
||||
&& this.metadatum.metadatum.metadata_type_options && this.metadatum.metadatum.metadata_type_options.input_type ){
|
||||
return this.metadatum.metadatum.metadata_type_options.input_type;
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
v-for="(option, index) in options"
|
||||
:key="index">
|
||||
<b-checkbox
|
||||
:disabled="disabled"
|
||||
:id="id"
|
||||
:style="{ paddingLeft: (option.level * 30) + 'px' }"
|
||||
:key="index"
|
||||
|
@ -39,7 +40,8 @@
|
|||
options: {
|
||||
type: Array
|
||||
},
|
||||
value: [ Number, String, Array ]
|
||||
value: [ Number, String, Array ],
|
||||
disabled: false,
|
||||
},
|
||||
methods: {
|
||||
onChecked() {
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
v-for="(option, index) in options"
|
||||
:key="index">
|
||||
<b-radio
|
||||
:disabled="disabled"
|
||||
:id="id"
|
||||
:style="{ paddingLeft: (option.level * 30) + 'px' }"
|
||||
:key="index"
|
||||
|
@ -35,7 +36,8 @@
|
|||
options: {
|
||||
type: Array
|
||||
},
|
||||
value: [ Number, String, Array ]
|
||||
value: [ Number, String, Array ],
|
||||
disabled: false,
|
||||
},
|
||||
methods: {
|
||||
onChecked() {
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
<div>
|
||||
<div class="block">
|
||||
<b-select
|
||||
:disabled="disabled"
|
||||
:id="id"
|
||||
v-model="selected"
|
||||
@input="emitChange()"
|
||||
|
@ -39,7 +40,8 @@
|
|||
options: {
|
||||
type: Array
|
||||
},
|
||||
value: [ Number, String, Array ]
|
||||
value: [ Number, String, Array ],
|
||||
disabled: false,
|
||||
},
|
||||
methods: {
|
||||
emitChange() {
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
<template>
|
||||
<div class="block">
|
||||
<b-taginput
|
||||
:disabled="disabled"
|
||||
size="is-small"
|
||||
icon="magnify"
|
||||
:allow-new="allowNew"
|
||||
:maxtags="!allowNew ? 1 : ''"
|
||||
@add="emitAdd"
|
||||
@remove="emitRemove"
|
||||
v-model="selected"
|
||||
|
@ -35,8 +37,10 @@
|
|||
type: Array
|
||||
},
|
||||
value: [ Number, String, Array ],
|
||||
allowNew: [ Boolean ],
|
||||
allowNew: true,
|
||||
taxonomyId: Number,
|
||||
disabled: false,
|
||||
allowSelectToCreate: false,
|
||||
},
|
||||
created(){
|
||||
if(this.value && this.value.length > 0){
|
||||
|
@ -73,6 +77,11 @@
|
|||
for(let term of this.termList){
|
||||
this.labels.push({label: term.name, value: term.id});
|
||||
}
|
||||
|
||||
if(this.termList.length <= 0 && this.allowSelectToCreate){
|
||||
this.labels.push({label: `${value} (${this.$i18n.get('select_to_create')})`, value: value})
|
||||
}
|
||||
|
||||
this.isFetching = false;
|
||||
}).catch((error) => {
|
||||
this.isFetching = false;
|
||||
|
|
|
@ -22,7 +22,7 @@ export const createEditGroup = ({commit}, parameters) => {
|
|||
})
|
||||
.catch(error => {
|
||||
console.error(error);
|
||||
})
|
||||
});
|
||||
};
|
||||
|
||||
export const setValueInBulk = ({commit}, parameters) => {
|
||||
|
@ -37,9 +37,11 @@ export const setValueInBulk = ({commit}, parameters) => {
|
|||
return axios.tainacan.post(`/collection/${collectionID}/bulk-edit/${groupID}/set`, bodyParams)
|
||||
.then(response => {
|
||||
commit('setActionResult', response.data);
|
||||
return response;
|
||||
})
|
||||
.catch(error => {
|
||||
console.error(error);
|
||||
commit('setActionResult', error.response.data);
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -55,9 +57,11 @@ export const addValueInBulk = ({commit}, parameters) => {
|
|||
return axios.tainacan.post(`/collection/${collectionID}/bulk-edit/${groupID}/add`, bodyParams)
|
||||
.then(response => {
|
||||
commit('setActionResult', response.data);
|
||||
return response;
|
||||
})
|
||||
.catch(error => {
|
||||
console.error(error);
|
||||
commit('setActionResult', error.response.data);
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -76,6 +80,7 @@ export const removeValueInBulk = ({commit}, parameters) => {
|
|||
})
|
||||
.catch(error => {
|
||||
console.error(error);
|
||||
commit('setActionResult', error.response.data);
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -91,9 +96,11 @@ export const replaceValueInBulk = ({commit}, parameters) => {
|
|||
return axios.tainacan.post(`/collection/${collectionID}/bulk-edit/${groupID}/replace`, bodyParams)
|
||||
.then(response => {
|
||||
commit('setActionResult', response.data);
|
||||
return response;
|
||||
})
|
||||
.catch(error => {
|
||||
console.error(error);
|
||||
commit('setActionResult', error.response.data);
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -110,8 +117,10 @@ export const setStatusInBulk = ({commit}, parameters) => {
|
|||
return axios.tainacan.post(`/collection/${collectionID}/bulk-edit/${groupID}/set_status`, bodyParams)
|
||||
.then(response => {
|
||||
commit('setActionResult', response.data);
|
||||
return response;
|
||||
})
|
||||
.catch(error => {
|
||||
console.error(error);
|
||||
commit('setActionResult', error.response.data);
|
||||
});
|
||||
};
|
Loading…
Reference in New Issue