From d95871e254fe14dd134ecc9f02c1d2987e2a882e Mon Sep 17 00:00:00 2001 From: mateuswetah Date: Wed, 16 Feb 2022 16:21:50 -0300 Subject: [PATCH 1/7] Major Advanced Search refactor #321. --- .../class-tainacan-rest-items-controller.php | 11 +- .../edition/metadatum-edition-form.vue | 2 - .../components/navigation/tainacan-header.vue | 67 +- .../components/search/advanced-search.vue | 856 +++++++----------- src/views/admin/js/event-bus-search.js | 13 +- .../js/store/modules/collection/actions.js | 8 +- src/views/admin/pages/lists/items-page.vue | 143 ++- src/views/admin/pages/lists/metadata-page.vue | 2 - .../theme-search/theme-items-page.vue | 87 +- 9 files changed, 442 insertions(+), 747 deletions(-) diff --git a/src/classes/api/endpoints/class-tainacan-rest-items-controller.php b/src/classes/api/endpoints/class-tainacan-rest-items-controller.php index 2220cb62d..d725b11ee 100644 --- a/src/classes/api/endpoints/class-tainacan-rest-items-controller.php +++ b/src/classes/api/endpoints/class-tainacan-rest-items-controller.php @@ -750,13 +750,12 @@ class REST_Items_Controller extends REST_Controller { private function get_items_permissions_check_for_taxonomy($taxonomies) { foreach ($taxonomies as $tax) { - if( !isset($tax['taxonomy']) ) - return false; - $taxonomy = \tainacan_taxonomies()->fetch_by_db_identifier( $tax['taxonomy'] ); + if ( isset($tax['taxonomy']) ) { + $taxonomy = \tainacan_taxonomies()->fetch_by_db_identifier( $tax['taxonomy'] ); - if( $taxonomy instanceof Entities\Taxonomy ) { - if(!$taxonomy->can_read()) { - return false; + if ( $taxonomy instanceof Entities\Taxonomy ) { + if (!$taxonomy->can_read()) + return false; } } } diff --git a/src/views/admin/components/edition/metadatum-edition-form.vue b/src/views/admin/components/edition/metadatum-edition-form.vue index 34fa74f94..96994206a 100644 --- a/src/views/admin/components/edition/metadatum-edition-form.vue +++ b/src/views/admin/components/edition/metadatum-edition-form.vue @@ -429,7 +429,6 @@ this.isUpdating = false; this.closedByForm = true; - this.$root.$emit('metadatumUpdated', this.isRepositoryLevel); this.$emit('onEditionFinished'); }) .catch((errors) => { @@ -468,7 +467,6 @@ this.isUpdating = false; this.closedByForm = true; - this.$root.$emit('metadatumUpdated', this.isRepositoryLevel); this.$emit('onEditionFinished'); }) .catch((errors) => { diff --git a/src/views/admin/components/navigation/tainacan-header.vue b/src/views/admin/components/navigation/tainacan-header.vue index 78c376a9f..5acd04511 100644 --- a/src/views/admin/components/navigation/tainacan-header.vue +++ b/src/views/admin/components/navigation/tainacan-header.vue @@ -59,38 +59,12 @@ icon-right="magnify" icon-right-clickable @icon-right-click="updateSearch()" /> - - - {{ $i18n.get('advanced_search') }} - - -
-

{{ $i18n.get('advanced_search') }}

- - - -
-
-
- - - -
+ class="advanced-search-text" + :to="$routerHelper.getItemsPath({ advancedSearch: true })"> + {{ $i18n.get('advanced_search') }} + -
+
@@ -478,41 +460,22 @@ @mousemove="handleMouseMoveOverList"> -
@@ -679,9 +642,7 @@ localDisplayedMetadata: [], registeredViewModes: tainacan_plugin.registered_view_modes, openAdvancedSearch: false, - openFormAdvancedSearch: false, - advancedSearchResults: false, - isDoingSearch: false, + hasAdvancedSearchResults: false, sortingMetadata: [], isFiltersModalActive: false, hasAnOpenModal: false, @@ -746,7 +707,7 @@ openAdvancedSearch(newValue) { if (newValue == false){ this.$eventBusSearch.$emit('closeAdvancedSearch'); - this.advancedSearchResults = false; + this.hasAdvancedSearchResults = false; this.isFiltersModalActive = true; } else { this.isFiltersModalActive = false; @@ -790,8 +751,8 @@ this.hasFiltered = hasFiltered; }); - this.$eventBusSearch.$on('advancedSearchResults', advancedSearchResults => { - this.advancedSearchResults = advancedSearchResults; + this.$eventBusSearch.$on('hasAdvancedSearchResults', hasAdvancedSearchResults => { + this.hasAdvancedSearchResults = hasAdvancedSearchResults; }); this.$eventBusSearch.$on('hasToPrepareMetadataAndFilters', () => { @@ -1327,7 +1288,7 @@ // $eventBusSearch this.$eventBusSearch.$off('isLoadingItems'); this.$eventBusSearch.$off('hasFiltered'); - this.$eventBusSearch.$off('advancedSearchResults'); + this.$eventBusSearch.$off('hasAdvancedSearchResults'); this.$eventBusSearch.$off('hasToPrepareMetadataAndFilters'); } } @@ -1373,7 +1334,7 @@ } } - .advanced-search-results-title { + .has-advanced-search-results-title { margin-bottom: 40px; margin: 0 var(--tainacan-one-column) 42px var(--tainacan-one-column); @@ -1516,7 +1477,7 @@ opacity: 1; } - .search-area .is-pulled-right { + .search-area .advanced-search-toggle { display: none; } } @@ -1538,7 +1499,7 @@ padding-right: 0; max-width: 100% !important; } - .is-pulled-right { + .advanced-search-toggle.is-closed { position: relative; right: 0px !important; } @@ -1627,15 +1588,43 @@ width: 100%; margin-bottom: 5px; } - .is-pulled-right { - position: absolute; - right: 15px; - top: 100%; - } - a { + a.advanced-search-toggle { margin-left: 12px; white-space: nowrap; + position: absolute; + transition: font-size 0.2s ease, right 0.3s ease, left 0.3s ease, top 0.4s ease; + + .icon { + transition: opacity 0.2s ease, max-width 0.2s ease; + } + + &.is-closed { + font-size: 0.75em; + right: 15px; + left: unset; + top: 100%; + + .icon { + display: 0; + opacity: 0.0; + max-width: 0; + } + } + &.is-open { + font-size: 1em; + right: unset; + left: 15px; + top: 6.125em; + z-index: 9; + + .icon { + display: inline; + opacity: 1.0; + max-width: 1.5em; + } + } } + } } diff --git a/src/views/admin/pages/lists/metadata-page.vue b/src/views/admin/pages/lists/metadata-page.vue index 9cf65cea0..8893eaeed 100644 --- a/src/views/admin/pages/lists/metadata-page.vue +++ b/src/views/admin/pages/lists/metadata-page.vue @@ -560,8 +560,6 @@ export default { .then(() => { if (!this.isRepositoryLevel) this.updateMetadataOrder(); - else - this.$root.$emit('metadatumUpdated', this.isRepositoryLevel); }) .catch(() => { this.$console.log("Error deleting metadatum.") diff --git a/src/views/gutenberg-blocks/blocks/faceted-search/theme-search/theme-items-page.vue b/src/views/gutenberg-blocks/blocks/faceted-search/theme-search/theme-items-page.vue index dede25134..00f14baa3 100644 --- a/src/views/gutenberg-blocks/blocks/faceted-search/theme-search/theme-items-page.vue +++ b/src/views/gutenberg-blocks/blocks/faceted-search/theme-search/theme-items-page.vue @@ -8,57 +8,6 @@ 'is-fullscreen': registeredViewModes[viewMode] != undefined && registeredViewModes[viewMode].full_screen }" aria-live="polite"> - - -

+ +

{{ @@ -509,7 +470,7 @@

@@ -613,9 +574,7 @@ localDisplayedMetadata: [], registeredViewModes: tainacan_plugin.registered_view_modes, openAdvancedSearch: false, - openFormAdvancedSearch: false, - advancedSearchResults: false, - isDoingSearch: false, + hasAdvancedSearchResults: false, sortingMetadata: [], isFiltersModalActive: false, hasAnOpenModal: false, @@ -681,7 +640,7 @@ openAdvancedSearch(newValue){ if (newValue == false){ this.$eventBusSearch.$emit('closeAdvancedSearch'); - this.advancedSearchResults = false; + this.hasAdvancedSearchResults = false; this.isFiltersModalActive = !this.startWithFiltersHidden; } else { this.isFiltersModalActive = false; @@ -739,8 +698,8 @@ }); if (!this.hideAdvancedSearch) { - this.$eventBusSearch.$on('advancedSearchResults', advancedSearchResults => { - this.advancedSearchResults = advancedSearchResults; + this.$eventBusSearch.$on('hasAdvancedSearchResults', hasAdvancedSearchResults => { + this.hasAdvancedSearchResults = hasAdvancedSearchResults; }); if (this.$route.query && this.$route.query.advancedSearch) { @@ -1209,7 +1168,7 @@ this.$eventBusSearch.$off('isLoadingItems'); this.$eventBusSearch.$off('hasFiltered'); if (!this.hideAdvancedSearch) - this.$eventBusSearch.$off('advancedSearchResults'); + this.$eventBusSearch.$off('hasAdvancedSearchResults'); this.$eventBusSearch.$off('hasToPrepareMetadataAndFilters'); }, @@ -1279,7 +1238,7 @@ } } - .advanced-search-results-title { + .has-advanced-search-results-title { margin-bottom: 40px; margin: 0 var(--tainacan-one-column) 42px var(--tainacan-one-column); From 2acbe38d51f12322649b03401c030591374d0928 Mon Sep 17 00:00:00 2001 From: mateuswetah Date: Fri, 18 Feb 2022 13:39:44 -0300 Subject: [PATCH 2/7] Moreee tests with advanced search --- .../components/search/advanced-search.vue | 185 +++++++++++------- 1 file changed, 113 insertions(+), 72 deletions(-) diff --git a/src/views/admin/components/search/advanced-search.vue b/src/views/admin/components/search/advanced-search.vue index 7eabba15b..0f84d28b7 100644 --- a/src/views/admin/components/search/advanced-search.vue +++ b/src/views/admin/components/search/advanced-search.vue @@ -1,9 +1,9 @@