Removes redundant calls to collection names in the filters panel.
This commit is contained in:
parent
557ed4342e
commit
4e70fab914
|
@ -47,7 +47,7 @@
|
|||
((filters.length >= 0 && isRepositoryLevel) || filters.length > 0)"
|
||||
class="filters-components-list">
|
||||
|
||||
<!-- TERM ITEMS PAGE FILTERS -->
|
||||
<!-- TAXONOMY TERM ITEMS FILTERS -->
|
||||
<template v-if="taxonomy && taxonomyFilters">
|
||||
<div
|
||||
v-if="key == 'repository-filters'"
|
||||
|
@ -149,7 +149,7 @@
|
|||
</div>
|
||||
</template>
|
||||
|
||||
<!-- REPOSITORY ITEMS PAGE FILTERS -->
|
||||
<!-- REPOSITORY ITEMS FILTERS -->
|
||||
<template v-else-if="isRepositoryLevel && !taxonomy">
|
||||
<div
|
||||
v-if="key == 'repository-filters'"
|
||||
|
@ -251,7 +251,7 @@
|
|||
</div>
|
||||
</template>
|
||||
|
||||
<!-- COLLECTION ITEMS PAGE FILTERS -->
|
||||
<!-- COLLECTION ITEMS FILTERS -->
|
||||
<template v-else>
|
||||
<tainacan-filter-item
|
||||
:is-loading-items="isLoadingItems"
|
||||
|
@ -342,17 +342,16 @@
|
|||
},
|
||||
watch: {
|
||||
taxonomyFilters() {
|
||||
if (this.taxonomyFilters != undefined) {
|
||||
if ( this.taxonomyFilters != undefined && Object.keys(this.taxonomyFilters).length ) {
|
||||
|
||||
this.$set(this.taxonomyFiltersCollectionNames, 'repository-filters', this.$i18n.get('repository'));
|
||||
|
||||
// Cancels previous collection name Request
|
||||
if (this.collectionNameSearchCancel != undefined)
|
||||
this.collectionNameSearchCancel.cancel('Collection name search Canceled.');
|
||||
const collectionIds = JSON.parse(JSON.stringify(Object.keys(this.taxonomyFilters)));
|
||||
delete collectionIds['repository-filters'];
|
||||
|
||||
this.fetchAllCollectionNames(collectionIds)
|
||||
let collectionIds = JSON.parse(JSON.stringify(Object.keys(this.taxonomyFilters)));
|
||||
|
||||
this.fetchAllCollectionNames( collectionIds.filter(aCollectionId => aCollectionId !== 'repository-filters') )
|
||||
.then((resp) => {
|
||||
resp.request
|
||||
.then((collections) => {
|
||||
|
@ -365,24 +364,12 @@
|
|||
}
|
||||
},
|
||||
repositoryCollectionFilters() {
|
||||
if (this.repositoryCollectionFilters != undefined) {
|
||||
if ( this.repositoryCollectionFilters != undefined && Object.keys(this.repositoryCollectionFilters).length ) {
|
||||
|
||||
this.$set(this.repositoryCollectionNames, 'repository-filters', this.$i18n.get('repository'));
|
||||
|
||||
// Cancels previous collection name Request
|
||||
if (this.collectionNameSearchCancel != undefined)
|
||||
this.collectionNameSearchCancel.cancel('Collection name search Canceled.');
|
||||
|
||||
this.fetchAllCollectionNames()
|
||||
.then((resp) => {
|
||||
resp.request
|
||||
.then((collections) => {
|
||||
for (let collection of collections)
|
||||
this.$set(this.repositoryCollectionNames, '' + collection.id, collection.name);
|
||||
});
|
||||
// Search Request Token for cancelling
|
||||
this.collectionNameSearchCancel = resp.source;
|
||||
});
|
||||
for ( let collection of this.getCollections() )
|
||||
this.$set(this.repositoryCollectionNames, '' + collection.id, collection.name);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -414,7 +401,8 @@
|
|||
'getPostQuery'
|
||||
]),
|
||||
...mapGetters('collection',[
|
||||
'getCollection'
|
||||
'getCollection',
|
||||
'getCollections'
|
||||
]),
|
||||
...mapActions('collection',[
|
||||
'fetchAllCollectionNames'
|
||||
|
@ -475,12 +463,12 @@
|
|||
}
|
||||
|
||||
// On repository level we also fetch collection filters
|
||||
if (!this.taxonomy && this.isRepositoryLevel) {
|
||||
if ( !this.taxonomy && this.isRepositoryLevel ) {
|
||||
|
||||
// Cancels previous Request
|
||||
if (this.repositoryFiltersSearchCancel != undefined)
|
||||
this.repositoryFiltersSearchCancel.cancel('Repository Collection Filters search Canceled.');
|
||||
|
||||
|
||||
this.fetchRepositoryCollectionFilters()
|
||||
.then((source) => {
|
||||
this.repositoryFiltersSearchCancel = source;
|
||||
|
|
|
@ -176,7 +176,7 @@ export const fetchRepositoryCollectionFilters = ({ dispatch, commit } ) => {
|
|||
|
||||
let promises = [];
|
||||
|
||||
// First, we add reporitory level filters
|
||||
// First, we add repository level filters
|
||||
promises.push(
|
||||
axios.tainacan.get('/filters/?include_control_metadata_types=true&nopaging=1&include_disabled=false')
|
||||
.then((resp) => { return { filters: resp.data, collectionId: 'default' } })
|
||||
|
@ -199,8 +199,12 @@ export const fetchRepositoryCollectionFilters = ({ dispatch, commit } ) => {
|
|||
// Process it all
|
||||
axios.all(promises)
|
||||
.then((results) => {
|
||||
let futureRepositoryCollectionFilters = {};
|
||||
|
||||
for (let resp of results)
|
||||
commit('setRepositoryCollectionFilters', { collectionName: (resp.collectionId != 'default' ? resp.collectionId : undefined), repositoryCollectionFilters: resp.filters });
|
||||
futureRepositoryCollectionFilters[resp.collectionId != 'default' ? resp.collectionId : 'repository-filters'] = resp.filters;
|
||||
|
||||
commit('setRepositoryCollectionFilters', futureRepositoryCollectionFilters);
|
||||
|
||||
resolve();
|
||||
})
|
||||
|
@ -258,13 +262,16 @@ export const fetchTaxonomyFilters = ({ dispatch, commit }, { taxonomyId, collect
|
|||
// Process it all
|
||||
axios.all(promises)
|
||||
.then((results) => {
|
||||
let futureTaxonomyFilters = {};
|
||||
|
||||
for (let resp of results) {
|
||||
let taxonomyFilters = resp.filters.filter((filter) => {
|
||||
return filter.metadatum.metadata_type_object.options.taxonomy_id != taxonomyId
|
||||
});
|
||||
commit('setTaxonomyFiltersForCollection', { collectionName: (resp.collectionId != 'default' ? resp.collectionId : undefined), taxonomyFilters: taxonomyFilters });
|
||||
futureTaxonomyFilters[resp.collectionId != 'default' ? resp.collectionId : 'repository-filters'] = taxonomyFilters;
|
||||
}
|
||||
|
||||
commit('setTaxonomyFilters', futureTaxonomyFilters);
|
||||
resolve();
|
||||
})
|
||||
.catch((error) => {
|
||||
|
|
|
@ -36,22 +36,16 @@ export const setFilterTypes = (state, filterTypes) => {
|
|||
state.filterTypes = filterTypes;
|
||||
}
|
||||
|
||||
export const setRepositoryCollectionFilters = (state, { collectionName, repositoryCollectionFilters }) => {
|
||||
if (collectionName != undefined)
|
||||
Vue.set(state.repositoryCollectionFilters, collectionName, repositoryCollectionFilters);
|
||||
else
|
||||
Vue.set(state.repositoryCollectionFilters, 'repository-filters', repositoryCollectionFilters);
|
||||
export const setRepositoryCollectionFilters = (state, repositoryCollectionFilters) => {
|
||||
state.repositoryCollectionFilters = repositoryCollectionFilters;
|
||||
}
|
||||
|
||||
export const clearRepositoryCollectionFilters = (state) => {
|
||||
state.repositoryCollectionFilters = {};
|
||||
}
|
||||
|
||||
export const setTaxonomyFiltersForCollection = (state, { collectionName, taxonomyFilters }) => {
|
||||
if (collectionName != undefined)
|
||||
Vue.set(state.taxonomyFilters, collectionName, taxonomyFilters);
|
||||
else
|
||||
Vue.set(state.taxonomyFilters, 'repository-filters', taxonomyFilters);
|
||||
export const setTaxonomyFilters = (state, taxonomyFilters) => {
|
||||
state.taxonomyFilters = taxonomyFilters;
|
||||
}
|
||||
|
||||
export const clearTaxonomyFilters = (state) => {
|
||||
|
|
Loading…
Reference in New Issue