From dfcf887554dc5e9b8e4878940898469a005abb6c Mon Sep 17 00:00:00 2001 From: Mateus Machado Luna Date: Mon, 20 May 2019 11:02:02 -0300 Subject: [PATCH] Sorts all gutenberg modal queries alphabetically. Proper feedback when facet item search is canceled inside some filters. --- src/classes/filter-types/autocomplete/Autocomplete.vue | 5 ++++- src/classes/filter-types/checkbox/Checkbox.vue | 5 ++++- src/classes/filter-types/selectbox/Selectbox.vue | 5 ++++- src/classes/filter-types/taginput/Taginput.vue | 5 ++++- .../collections-list/collections-modal.js | 4 ++-- .../dynamic-items-list/dynamic-items-modal.js | 4 ++-- .../tainacan-items/items-list/items-modal.js | 8 ++++---- .../tainacan-terms/terms-list/terms-modal.js | 8 ++++---- 8 files changed, 28 insertions(+), 16 deletions(-) diff --git a/src/classes/filter-types/autocomplete/Autocomplete.vue b/src/classes/filter-types/autocomplete/Autocomplete.vue index 8f3de3139..ae85ed8c4 100644 --- a/src/classes/filter-types/autocomplete/Autocomplete.vue +++ b/src/classes/filter-types/autocomplete/Autocomplete.vue @@ -120,7 +120,10 @@ promise = this.getValuesPlainText( this.metadatum, query, this.isRepositoryLevel ); promise.request.catch( error => { - this.$console.log('error select', error ); + if (axios.isCancel(error)) + this.$console.log('Request canceled: ', error.message); + else + this.$console.error( error ); }); // Search Request Token for cancelling diff --git a/src/classes/filter-types/checkbox/Checkbox.vue b/src/classes/filter-types/checkbox/Checkbox.vue index 5a447972e..5214b448f 100644 --- a/src/classes/filter-types/checkbox/Checkbox.vue +++ b/src/classes/filter-types/checkbox/Checkbox.vue @@ -138,7 +138,10 @@ this.selectedValues(); }) .catch( error => { - this.$console.log('error select', error ); + if (axios.isCancel(error)) + this.$console.log('Request canceled: ', error.message); + else + this.$console.error( error ); }); } diff --git a/src/classes/filter-types/selectbox/Selectbox.vue b/src/classes/filter-types/selectbox/Selectbox.vue index 0555fcc1c..cac4e132b 100644 --- a/src/classes/filter-types/selectbox/Selectbox.vue +++ b/src/classes/filter-types/selectbox/Selectbox.vue @@ -111,7 +111,10 @@ .then(() => { }) .catch( error => { - this.$console.error('error select', error ); + if (axios.isCancel(error)) + this.$console.log('Request canceled: ', error.message); + else + this.$console.error( error ); }); // Search Request Token for cancelling diff --git a/src/classes/filter-types/taginput/Taginput.vue b/src/classes/filter-types/taginput/Taginput.vue index 236a046b1..7e4d6f7f7 100644 --- a/src/classes/filter-types/taginput/Taginput.vue +++ b/src/classes/filter-types/taginput/Taginput.vue @@ -135,7 +135,10 @@ promise.request .catch( error => { - this.$console.log('error select', error ); + if (axios.isCancel(error)) + this.$console.log('Request canceled: ', error.message); + else + this.$console.error( error ); }); // Search Request Token for cancelling diff --git a/src/gutenberg-blocks/tainacan-collections/collections-list/collections-modal.js b/src/gutenberg-blocks/tainacan-collections/collections-list/collections-modal.js index ea364ce2f..9a423acbc 100644 --- a/src/gutenberg-blocks/tainacan-collections/collections-list/collections-modal.js +++ b/src/gutenberg-blocks/tainacan-collections/collections-list/collections-modal.js @@ -113,7 +113,7 @@ export default class CollectionsModal extends React.Component { if (this.state.collectionsPage <= 1) currentModalCollections = []; - let endpoint = '/collections/?perpage=' + this.state.collectionsPerPage + '&paged=' + this.state.collectionsPage; + let endpoint = '/collections/?orderby=title&order=asc&perpage=' + this.state.collectionsPerPage + '&paged=' + this.state.collectionsPage; this.setState({ isLoadingCollections: true, @@ -159,7 +159,7 @@ export default class CollectionsModal extends React.Component { isLoadingCollections: true }); - let endpoint = '/collections/?perpage=' + this.state.collectionsPerPage; + let endpoint = '/collections/?orderby=title&order=asc&perpage=' + this.state.collectionsPerPage; if (name != undefined && name != '') endpoint += '&search=' + name; diff --git a/src/gutenberg-blocks/tainacan-items/dynamic-items-list/dynamic-items-modal.js b/src/gutenberg-blocks/tainacan-items/dynamic-items-list/dynamic-items-modal.js index d20d5a6d9..7668793a8 100644 --- a/src/gutenberg-blocks/tainacan-items/dynamic-items-list/dynamic-items-modal.js +++ b/src/gutenberg-blocks/tainacan-items/dynamic-items-list/dynamic-items-modal.js @@ -56,7 +56,7 @@ export default class DynamicItemsModal extends React.Component { if (this.state.collectionPage <= 1) someModalCollections = []; - let endpoint = '/collections/?perpage=' + this.state.collectionsPerPage + '&paged=' + this.state.collectionPage; + let endpoint = '/collections/?orderby=title&order=asc&perpage=' + this.state.collectionsPerPage + '&paged=' + this.state.collectionPage; this.setState({ isLoadingCollections: true, @@ -121,7 +121,7 @@ export default class DynamicItemsModal extends React.Component { items: [] }); - let endpoint = '/collections/?perpage=' + this.state.collectionsPerPage; + let endpoint = '/collections/?orderby=title&order=asc&perpage=' + this.state.collectionsPerPage; if (name != undefined && name != '') endpoint += '&search=' + name; diff --git a/src/gutenberg-blocks/tainacan-items/items-list/items-modal.js b/src/gutenberg-blocks/tainacan-items/items-list/items-modal.js index f11374191..c9809b2c9 100644 --- a/src/gutenberg-blocks/tainacan-items/items-list/items-modal.js +++ b/src/gutenberg-blocks/tainacan-items/items-list/items-modal.js @@ -128,7 +128,7 @@ export default class ItemsModal extends React.Component { let anItemsRequestSource = axios.CancelToken.source(); - let endpoint = '/collection/'+ this.state.collectionId + '/items/?fetch_only=title,thumbnail&perpage=' + this.state.itemsPerPage; + let endpoint = '/collection/'+ this.state.collectionId + '/items/?orderby=title&order=asc&fetch_only=title,thumbnail&perpage=' + this.state.itemsPerPage; if (name != undefined && name != '') endpoint += '&search=' + name; @@ -164,7 +164,7 @@ export default class ItemsModal extends React.Component { if (this.state.itemsPage <= 1) someModalItems = []; - let endpoint = '/collection/'+ collectionId + '/items/?fetch_only=title,thumbnail&perpage=' + this.state.itemsPerPage + '&paged=' + this.state.itemsPage; + let endpoint = '/collection/'+ collectionId + '/items/?orderby=title&order=asc&fetch_only=title,thumbnail&perpage=' + this.state.itemsPerPage + '&paged=' + this.state.itemsPage; this.setState({ isLoadingItems: true, @@ -208,7 +208,7 @@ export default class ItemsModal extends React.Component { if (this.state.collectionPage <= 1) someModalCollections = []; - let endpoint = '/collections/?perpage=' + this.state.itemsPerPage + '&paged=' + this.state.collectionPage; + let endpoint = '/collections/?orderby=title&order=asc&perpage=' + this.state.itemsPerPage + '&paged=' + this.state.collectionPage; this.setState({ isLoadingCollections: true, @@ -272,7 +272,7 @@ export default class ItemsModal extends React.Component { items: [] }); - let endpoint = '/collections/?perpage=' + this.state.itemsPerPage; + let endpoint = '/collections/?orderby=title&order=asc&perpage=' + this.state.itemsPerPage; if (name != undefined && name != '') endpoint += '&search=' + name; diff --git a/src/gutenberg-blocks/tainacan-terms/terms-list/terms-modal.js b/src/gutenberg-blocks/tainacan-terms/terms-list/terms-modal.js index 0f93a6523..2629d03e5 100644 --- a/src/gutenberg-blocks/tainacan-terms/terms-list/terms-modal.js +++ b/src/gutenberg-blocks/tainacan-terms/terms-list/terms-modal.js @@ -120,7 +120,7 @@ export default class TermsModal extends React.Component { fetchTerms(name) { - let endpoint = '/taxonomy/'+ this.state.taxonomyId + '/terms/?hideempty=0&number=' + this.state.termsPerPage; + let endpoint = '/taxonomy/'+ this.state.taxonomyId + '/terms/?order=asc&hideempty=0&number=' + this.state.termsPerPage; if (name != undefined && name != '') endpoint += '&searchterm=' + name; @@ -157,7 +157,7 @@ export default class TermsModal extends React.Component { if (offset <= 0) someModalTerms = []; - let endpoint = '/taxonomy/'+ taxonomyId + '/terms/?hideempty=0&number=' + this.state.termsPerPage + '&offset=' + offset; + let endpoint = '/taxonomy/'+ taxonomyId + '/terms/?order=asc&hideempty=0&number=' + this.state.termsPerPage + '&offset=' + offset; this.setState({ isLoadingTerms: true, @@ -200,7 +200,7 @@ export default class TermsModal extends React.Component { if (this.state.taxonomyPage <= 1) someModalTaxonomies = []; - let endpoint = '/taxonomies/?perpage=' + this.state.termsPerPage + '&paged=' + this.state.taxonomyPage; + let endpoint = '/taxonomies/?orderby=title&order=asc&perpage=' + this.state.termsPerPage + '&paged=' + this.state.taxonomyPage; this.setState({ isLoadingTaxonomies: true, @@ -259,7 +259,7 @@ export default class TermsModal extends React.Component { terms: [] }); - let endpoint = '/taxonomies/?perpage=' + this.state.termsPerPage; + let endpoint = '/taxonomies/?orderby=title&order=asc&perpage=' + this.state.termsPerPage; if (name != undefined && name != '') endpoint += '&search=' + name;