From a4133f819e22c34fbf64c6ad253b3d26417e1f8e Mon Sep 17 00:00:00 2001 From: weryques Date: Tue, 19 Jun 2018 13:04:26 -0300 Subject: [PATCH] Advanced search for metaquery and taxquery (#22) --- .../advanced-search/advanced-search.vue | 271 +++++++++++++----- src/admin/components/lists/terms-list.vue | 2 +- src/admin/pages/lists/items-page.vue | 32 ++- src/admin/tainacan-admin-i18n.php | 6 +- src/api/class-tainacan-rest-controller.php | 3 +- .../class-tainacan-rest-items-controller.php | 2 +- ...lass-tainacan-rest-metadata-controller.php | 8 +- .../relationship/FormRelationship.vue | 2 +- .../class-tainacan-relationship.php | 2 +- .../taxonomy/class-tainacan-taxonomy.php | 2 +- ...ss-tainacan-entity-collection-relation.php | 5 +- ...s-tainacan-entity-collections-relation.php | 6 +- src/js/event-bus-search.js | 46 +-- src/js/store/modules/collection/actions.js | 36 +-- src/js/store/modules/search/mutations.js | 5 +- src/js/store/modules/taxonomy/actions.js | 14 +- src/languages/tainacan-pt_BR.po | 2 +- 17 files changed, 303 insertions(+), 141 deletions(-) diff --git a/src/admin/components/advanced-search/advanced-search.vue b/src/admin/components/advanced-search/advanced-search.vue index 47d6ac1cb..ae263c7df 100644 --- a/src/admin/components/advanced-search/advanced-search.vue +++ b/src/admin/components/advanced-search/advanced-search.vue @@ -10,33 +10,65 @@ + + + :disabled="advancedSearchQuery.taxquery[searchCriteria] || + advancedSearchQuery.metaquery[searchCriteria] ? true : false" + @input="addToAdvancedSearchQuery($event, 'metadatum', searchCriteria)"> + v-for="metadatum in metadata" + v-if="metadatum.enabled" + :value="`${metadatum.id}-${metadatum.metadata_type_options.taxonomy}`" + :key="metadatum.id" + >{{ metadatum.name }} - + + + v-if="advancedSearchQuery.metaquery[searchCriteria]" + @input="addValueToAdvancedSearchQuery($event, 'value', searchCriteria)" + /> + - + + - + :value="key" + >{{ comparator }} + +
+ +
@@ -52,12 +84,12 @@ - {{ $i18n.get('add_more_one_search_criteria') }} + {{ $i18n.get('add_another_search_criteria') }}
- {{ Array.isArray(advancedSearchQuery[searchCriteria].value) ? - advancedSearchQuery[searchCriteria].value.toString() : - advancedSearchQuery[searchCriteria].value }} - + {{ Array.isArray(advancedSearchQuery.taxquery[searchCriteria].terms) ? + advancedSearchQuery.taxquery[searchCriteria].btags.toString() : + advancedSearchQuery.taxquery[searchCriteria].btags }} + + + {{ Array.isArray(advancedSearchQuery.metaquery[searchCriteria].value) ? + advancedSearchQuery.metaquery[searchCriteria].value: + advancedSearchQuery.metaquery[searchCriteria].value }} +
@@ -95,42 +138,108 @@ -
{{ advancedSearchQuery }}
+