Fixes bug where sequential disabling/enabling metadada or filters would affect only the most recent clicks, due to assynchronous manipulation of collection filters_order and metadata_order.
This commit is contained in:
parent
ce4148855b
commit
d6122f2911
|
@ -35,7 +35,7 @@
|
|||
<div
|
||||
class="active-filter-item"
|
||||
:class="{
|
||||
'not-sortable-item': filter.id == undefined || openedFilterId != '' || choosenMetadatum.name == filter.name,
|
||||
'not-sortable-item': filter.id == undefined || openedFilterId != '' || choosenMetadatum.name == filter.name || isUpdatingFiltersOrder,
|
||||
'not-focusable-item': openedFilterId == filter.id,
|
||||
'disabled-filter': filter.enabled == false,
|
||||
'inherited-filter': filter.collection_id != collectionId || isRepositoryLevel
|
||||
|
@ -70,7 +70,8 @@
|
|||
<span
|
||||
class="controls"
|
||||
v-if="filter.filter_type != undefined">
|
||||
<b-switch
|
||||
<b-switch
|
||||
:disabled="isUpdatingFiltersOrder"
|
||||
size="is-small"
|
||||
:value="filter.enabled"
|
||||
@input="onChangeEnable($event, index)"/>
|
||||
|
@ -203,6 +204,7 @@ export default {
|
|||
isLoadingFilters: false,
|
||||
isLoadingFilterTypes: false,
|
||||
isLoadingFilter: false,
|
||||
iisUpdatingFiltersOrder: false,
|
||||
openedFilterId: '',
|
||||
formWithErrors: '',
|
||||
editForms: {},
|
||||
|
@ -288,7 +290,10 @@ export default {
|
|||
for (let filter of this.activeFilterList) {
|
||||
filtersOrder.push({'id': filter.id, 'enabled': filter.enabled});
|
||||
}
|
||||
this.updateCollectionFiltersOrder({ collectionId: this.collectionId, filtersOrder: filtersOrder });
|
||||
this.isUpdatingFiltersOrder = true;
|
||||
this.updateCollectionFiltersOrder({ collectionId: this.collectionId, filtersOrder: filtersOrder })
|
||||
.then(() => this.isUpdatingFiltersOrder = false)
|
||||
.catch(() => this.isUpdatingFiltersOrder = false);
|
||||
},
|
||||
updateListOfMetadata() {
|
||||
|
||||
|
@ -311,7 +316,10 @@ export default {
|
|||
filtersOrder.push({'id': filter.id, 'enabled': filter.enabled});
|
||||
}
|
||||
filtersOrder[index].enabled = $event;
|
||||
this.updateCollectionFiltersOrder({ collectionId: this.collectionId, filtersOrder: filtersOrder });
|
||||
this.isUpdatingFiltersOrder = true;
|
||||
this.updateCollectionFiltersOrder({ collectionId: this.collectionId, filtersOrder: filtersOrder })
|
||||
.then(() => this.isUpdatingFiltersOrder = false)
|
||||
.catch(() => this.isUpdatingFiltersOrder = false);
|
||||
},
|
||||
addMetadatumViaButton(metadatumType, metadatumIndex) {
|
||||
this.availableMetadatumList.splice(metadatumIndex, 1);
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
<div
|
||||
class="active-metadatum-item"
|
||||
:class="{
|
||||
'not-sortable-item': metadatum.id == undefined || openedMetadatumId != '' ,
|
||||
'not-sortable-item': metadatum.id == undefined || openedMetadatumId != '' || isUpdatingMetadataOrder,
|
||||
'not-focusable-item': openedMetadatumId == metadatum.id,
|
||||
'disabled-metadatum': metadatum.enabled == false,
|
||||
'inherited-metadatum': metadatum.collection_id != collectionId || isRepositoryLevel
|
||||
|
@ -75,6 +75,7 @@
|
|||
class="controls"
|
||||
v-if="metadatum.id !== undefined">
|
||||
<b-switch
|
||||
:disabled="isUpdatingMetadataOrder"
|
||||
size="is-small"
|
||||
:value="metadatum.enabled"
|
||||
@input="onChangeEnable($event, index)"/>
|
||||
|
@ -351,6 +352,7 @@ export default {
|
|||
isLoadingMetadatumTypes: true,
|
||||
isLoadingMetadata: false,
|
||||
isLoadingMetadatum: false,
|
||||
isUpdatingMetadataOrder: false,
|
||||
openedMetadatumId: '',
|
||||
formWithErrors: '',
|
||||
hightlightedMetadatum: '',
|
||||
|
@ -449,7 +451,10 @@ export default {
|
|||
for (let metadatum of this.activeMetadatumList) {
|
||||
metadataOrder.push({'id': metadatum.id, 'enabled': metadatum.enabled});
|
||||
}
|
||||
this.updateCollectionMetadataOrder({ collectionId: this.collectionId, metadataOrder: metadataOrder });
|
||||
this.isUpdatingMetadataOrder = true;
|
||||
this.updateCollectionMetadataOrder({ collectionId: this.collectionId, metadataOrder: metadataOrder })
|
||||
.then(() => this.isUpdatingMetadataOrder = false)
|
||||
.catch(() => this.isUpdatingMetadataOrder = false);
|
||||
},
|
||||
onChangeEnable($event, index) {
|
||||
let metadataOrder = [];
|
||||
|
@ -457,7 +462,10 @@ export default {
|
|||
metadataOrder.push({'id': metadatum.id, 'enabled': metadatum.enabled});
|
||||
}
|
||||
metadataOrder[index].enabled = $event;
|
||||
this.updateCollectionMetadataOrder({ collectionId: this.collectionId, metadataOrder: metadataOrder });
|
||||
this.isUpdatingMetadataOrder = true;
|
||||
this.updateCollectionMetadataOrder({ collectionId: this.collectionId, metadataOrder: metadataOrder })
|
||||
.then(() => this.isUpdatingMetadataOrder = false)
|
||||
.catch(() => this.isUpdatingMetadataOrder = false);
|
||||
},
|
||||
addMetadatumViaButton(metadatumType) {
|
||||
let lastIndex = this.activeMetadatumList.length;
|
||||
|
|
|
@ -89,8 +89,7 @@ export const deleteFilter = ({ commit }, filterId ) => {
|
|||
.then( res => {
|
||||
commit('deleteFilter', res.data );
|
||||
resolve( res.data );
|
||||
}).catch((error) => {
|
||||
console.log(error);
|
||||
}).catch((error) => {
|
||||
reject( error );
|
||||
});
|
||||
|
||||
|
@ -111,6 +110,7 @@ export const updateCollectionFiltersOrder = ({ commit }, { collectionId, filters
|
|||
filters_order: filtersOrder
|
||||
}).then( res => {
|
||||
commit('collection/setCollection', res.data, { root: true });
|
||||
commit('updateFiltersOrderFromCollection', res.data.filters_order);
|
||||
resolve( res.data );
|
||||
}).catch( error => {
|
||||
reject( error.response );
|
||||
|
|
|
@ -24,6 +24,14 @@ export const setFilters = (state, filters) => {
|
|||
state.filters = filters;
|
||||
}
|
||||
|
||||
export const updateFiltersOrderFromCollection = (state, filtersOrder) => {
|
||||
for (let i = 0; i < state.filters.length; i++) {
|
||||
let updatedFilterIndex = filtersOrder.findIndex(aFilter => aFilter.id == state.filters[i].id);
|
||||
if (updatedFilterIndex >= 0)
|
||||
state.filters[i].enabled = filtersOrder[updatedFilterIndex].enabled;
|
||||
}
|
||||
}
|
||||
|
||||
export const setFilterTypes = (state, filterTypes) => {
|
||||
state.filterTypes = filterTypes;
|
||||
}
|
|
@ -122,12 +122,13 @@ export const deleteMetadatum = ({commit}, {collectionId, metadatumId, isReposito
|
|||
});
|
||||
};
|
||||
|
||||
export const updateCollectionMetadataOrder = ({ dispatch }, {collectionId, metadataOrder}) => {
|
||||
export const updateCollectionMetadataOrder = ({ commit }, {collectionId, metadataOrder}) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
axios.tainacan.patch('/collections/' + collectionId, {
|
||||
metadata_order: metadataOrder
|
||||
}).then(res => {
|
||||
//dispatch('collection/setCollection', res.data, {root: true});
|
||||
commit('collection/setCollection', res.data, { root: true });
|
||||
commit('updateMetadataOrderFromCollection', res.data.metadata_order);
|
||||
resolve(res.data);
|
||||
}).catch(error => {
|
||||
reject(error.response);
|
||||
|
|
|
@ -15,6 +15,14 @@ export const setMetadata = (state, metadata) => {
|
|||
state.metadata = metadata;
|
||||
}
|
||||
|
||||
export const updateMetadataOrderFromCollection = (state, metadataOrder) => {
|
||||
for (let i = 0; i < state.metadata.length; i++) {
|
||||
let updatedMetadatumIndex = metadataOrder.findIndex(aMetadatum => aMetadatum.id == state.metadata[i].id);
|
||||
if (updatedMetadatumIndex >= 0)
|
||||
state.metadata[i].enabled = metadataOrder[updatedMetadatumIndex].enabled;
|
||||
}
|
||||
}
|
||||
|
||||
export const setMetadatumTypes = (state, metadatumTypes) => {
|
||||
state.metadatumTypes = metadatumTypes;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue