@@ -281,6 +259,7 @@
{{ $i18n.get('info_there_is_no_filter' ) }}
+
{{ $i18n.get('info_collection_filter_on_repository_level') }}
this.isLoadingFilters = false);
// Custom filter loading, get's from collections that have items with that taxonomy
- } else {
+ } else if ( this.taxonomy ) {
let collectionsIds = [];
@@ -466,20 +445,24 @@
this.fetchTaxonomyFilters({ taxonomyId: taxonomyId[taxonomyId.length - 1], collectionsIds: collectionsIds })
.catch(() => this.isLoadingFilters = false);
+ } else if ( this.isRepositoryLevel && !this.taxonomy ) {
+
+ // Cancels previous Request
+ if (this.repositoryFiltersSearchCancel != undefined)
+ this.repositoryFiltersSearchCancel.cancel('Repository Collection Filters search Canceled.');
+
+ this.fetchRepositoryCollectionFilters()
+ .then((anotherResp) => {
+ anotherResp.request
+ .then(() => this.isLoadingFilters = false)
+ .catch(() => this.isLoadingFilters = false);
+
+ this.repositoryFiltersSearchCancel = anotherResp.source;
+ })
+ .catch(() => this.isLoadingFilters = false);
+
}
- // On repository level we also fetch collection filters
- 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;
- });
- }
},
updateIsLoadingItems(isLoadingItems) {
this.$emit('updateIsLoadingItemsState', isLoadingItems);
diff --git a/src/views/admin/js/store/modules/filter/actions.js b/src/views/admin/js/store/modules/filter/actions.js
index 195b86d25..cec956883 100644
--- a/src/views/admin/js/store/modules/filter/actions.js
+++ b/src/views/admin/js/store/modules/filter/actions.js
@@ -144,15 +144,15 @@ export const updateCollectionFiltersOrder = ({ commit }, { collectionId, filters
export const fetchFilterTypes = ({ commit} ) => {
return new Promise((resolve, reject) => {
axios.tainacan.get('/filter-types')
- .then((res) => {
- let filterTypes = res.data;
- commit('setFilterTypes', filterTypes);
- resolve (filterTypes);
- })
- .catch((error) => {
- console.log(error);
- reject(error);
- });
+ .then((res) => {
+ let filterTypes = res.data;
+ commit('setFilterTypes', filterTypes);
+ resolve (filterTypes);
+ })
+ .catch((error) => {
+ console.log(error);
+ reject(error);
+ });
});
};
@@ -165,62 +165,65 @@ export const fetchRepositoryCollectionFilters = ({ dispatch, commit } ) => {
commit('clearRepositoryCollectionFilters');
- return new Promise((resolve, reject) => {
+ const source = axios.CancelToken.source();
- dispatch('collection/fetchAllCollectionNames', { } ,{ root: true })
- .then((resp) => {
- resp.request
- .then((res) => {
- let collections = res;
- if (collections != undefined && collections.length != undefined) {
+ return Object({
+ request: new Promise((resolve, reject) => {
- let promises = [];
+ dispatch('collection/fetchAllCollectionNames', { } ,{ root: true })
+ .then((resp) => {
+ resp.request
+ .then((res) => {
+ let collections = res;
+ if (collections != undefined && collections.length != undefined) {
- // 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' } })
- .catch((error) => {
- reject(error);
- })
- );
+ let promises = [];
- // Then we add collection level filters
- collections.forEach(collection => {
+ // First, we add repository level filters
promises.push(
- axios.tainacan.get('/collection/' + collection.id + '/filters/?include_control_metadata_types=true&nopaging=1&include_disabled=false&metaquery[0][key]=collection_id&metaquery[0][value]=default&metaquery[0][compare]=!=')
- .then((resp) => { return { filters: resp.data, collectionId: collection.id } })
+ axios.tainacan.get('/filters/?include_control_metadata_types=true&nopaging=1&include_disabled=false')
+ .then((resp) => { return { filters: resp.data, collectionId: 'default' } })
.catch((error) => {
reject(error);
})
);
- });
-
- // Process it all
- axios.all(promises)
- .then((results) => {
- let futureRepositoryCollectionFilters = {};
-
- for (let resp of results)
- futureRepositoryCollectionFilters[resp.collectionId != 'default' ? resp.collectionId : 'repository-filters'] = resp.filters;
- commit('setRepositoryCollectionFilters', futureRepositoryCollectionFilters);
+ // Then we add collection level filters
+ collections.forEach(collection => {
+ promises.push(
+ axios.tainacan.get('/collection/' + collection.id + '/filters/?include_control_metadata_types=true&nopaging=1&include_disabled=false&metaquery[0][key]=collection_id&metaquery[0][value]=default&metaquery[0][compare]=!=&metaquery[1][key]=display_in_repository_level_lists&metaquery[1][value]=no&metaquery[1][compare]=!=')
+ .then((resp) => { return { filters: resp.data, collectionId: collection.id } })
+ .catch((error) => {
+ reject(error);
+ })
+ );
+ });
+
+ // Process it all
+ axios.all(promises)
+ .then((results) => {
+ let futureRepositoryCollectionFilters = {};
+
+ for (let resp of results) {
+ if (resp.filters.length > 0)
+ futureRepositoryCollectionFilters[resp.collectionId != 'default' ? resp.collectionId : 'repository-filters'] = resp.filters;
+ }
+ commit('setRepositoryCollectionFilters', futureRepositoryCollectionFilters);
- resolve();
- })
- .catch((error) => {
- console.log(error);
- reject(error);
- })
- }
- })
- .catch(() => {
- reject();
- });
-
- // Search Request Token for cancelling
- resolve(resp.source);
- });
+ resolve();
+ })
+ .catch((error) => {
+ console.log(error);
+ reject(error);
+ })
+ }
+ })
+ .catch(() => {
+ reject();
+ });
+ });
+ }),
+ source: source
});
};
@@ -251,7 +254,7 @@ export const fetchTaxonomyFilters = ({ dispatch, commit }, { taxonomyId, collect
const collectionsToSearch = collectionsIds.length ? collectionsIds : taxonomy.collections_ids
collectionsToSearch.forEach(collectionId => {
promises.push(
- axios.tainacan.get('/collection/' + collectionId + '/filters/?include_control_metadata_types=true&nopaging=1&include_disabled=false&metaquery[0][key]=collection_id&metaquery[0][value]=default&metaquery[0][compare]=!=')
+ axios.tainacan.get('/collection/' + collectionId + '/filters/?include_control_metadata_types=true&nopaging=1&include_disabled=false&metaquery[0][key]=collection_id&metaquery[0][value]=default&metaquery[0][compare]=!=&metaquery[1][key]=display_in_repository_level_lists&metaquery[1][value]=no&metaquery[1][compare]=!=')
.then((resp) => { return { filters: resp.data, collectionId: collectionId } })
.catch((error) => {
reject(error);
@@ -268,7 +271,8 @@ export const fetchTaxonomyFilters = ({ dispatch, commit }, { taxonomyId, collect
let taxonomyFilters = resp.filters.filter((filter) => {
return filter.metadatum.metadata_type_object.options.taxonomy_id != taxonomyId
});
- futureTaxonomyFilters[resp.collectionId != 'default' ? resp.collectionId : 'repository-filters'] = taxonomyFilters;
+ if (taxonomyFilters.length > 0)
+ futureTaxonomyFilters[resp.collectionId != 'default' ? resp.collectionId : 'repository-filters'] = taxonomyFilters;
}
commit('setTaxonomyFilters', futureTaxonomyFilters);
diff --git a/src/views/class-tainacan-admin.php b/src/views/class-tainacan-admin.php
index ca942efbf..ea1c5478a 100644
--- a/src/views/class-tainacan-admin.php
+++ b/src/views/class-tainacan-admin.php
@@ -127,7 +127,7 @@ class Admin {
global $TAINACAN_BASE_URL;
wp_enqueue_style( 'tainacan-fonts', $TAINACAN_BASE_URL . '/assets/css/tainacanicons.css', [], TAINACAN_VERSION );
- wp_enqueue_style( 'roboto-fonts', 'https://fonts.googleapis.com/css?family=Roboto:400,400i,500,500i,700,700i', [], TAINACAN_VERSION );
+ wp_enqueue_style( 'roboto-fonts', 'https://fonts.googleapis.com/css?family=Roboto:400,400i,500,500i,700,700i', [] );
wp_enqueue_script('underscore');
}
diff --git a/src/views/tainacan-i18n.php b/src/views/tainacan-i18n.php
index 3a0dab5fd..f66b5d0ff 100644
--- a/src/views/tainacan-i18n.php
+++ b/src/views/tainacan-i18n.php
@@ -906,6 +906,7 @@ return apply_filters( 'tainacan-i18n', [
'info_there_is_no_metadatum' => __( 'There is no metadata here yet.', 'tainacan' ),
'info_there_is_no_metadata_section' => __( 'There is no metadata section here yet.', 'tainacan' ),
'info_there_is_no_filter' => __( 'There is no filter here yet.', 'tainacan' ),
+ 'info_collection_filter_on_repository_level' => __( 'If there are filters set in the collections, you can also set them to be displayed at repository level.', 'tainacan' ),
'info_changes' => __( 'Changes', 'tainacan' ),
'info_possible_external_sources' => __( 'Possible external sources: CSV, Instagram, YouTube, etc.', 'tainacan' ),
'info_help_term_name' => __( 'The term name', 'tainacan' ),