More and more tweaks for #794.

This commit is contained in:
mateuswetah 2024-01-02 09:54:40 -03:00
parent 141e6485ba
commit 5a8617552d
9 changed files with 392 additions and 257 deletions

184
package-lock.json generated
View File

@ -1968,6 +1968,7 @@
"version": "3.3.12",
"resolved": "https://registry.npmjs.org/@vue/compiler-core/-/compiler-core-3.3.12.tgz",
"integrity": "sha512-qAtjyG3GBLG0chzp5xGCyRLLe6wFCHmjI82aGzwuGKyznNP+GJJMxjc0wOYWDB2YKfho7niJFdoFpo0CZZQg9w==",
"dev": true,
"requires": {
"@babel/parser": "^7.23.5",
"@vue/shared": "3.3.12",
@ -1979,6 +1980,7 @@
"version": "3.3.12",
"resolved": "https://registry.npmjs.org/@vue/compiler-dom/-/compiler-dom-3.3.12.tgz",
"integrity": "sha512-RdJU9oEYaoPKUdGXCy0l+i4clesdDeLmbvRlszoc9iagsnBnMmQtYfCPVQ5BHB6o7K4SCucDdJM2Dh3oXB0D6g==",
"dev": true,
"requires": {
"@vue/compiler-core": "3.3.12",
"@vue/shared": "3.3.12"
@ -1988,6 +1990,7 @@
"version": "3.3.12",
"resolved": "https://registry.npmjs.org/@vue/compiler-sfc/-/compiler-sfc-3.3.12.tgz",
"integrity": "sha512-yy5b9e7b79dsGbMmglCe/YnhCQgBkHO7Uf6JfjWPSf2/5XH+MKn18LhzhHyxbHdJgnA4lZCqtXzLaJz8Pd8lMw==",
"dev": true,
"requires": {
"@babel/parser": "^7.23.5",
"@vue/compiler-core": "3.3.12",
@ -2005,6 +2008,7 @@
"version": "3.3.12",
"resolved": "https://registry.npmjs.org/@vue/compiler-ssr/-/compiler-ssr-3.3.12.tgz",
"integrity": "sha512-adCiMJPznfWcQyk/9HSuXGja859IaMV+b8UNSVzDatqv7h0PvT9BEeS22+gjkWofDiSg5d78/ZLls3sLA+cn3A==",
"dev": true,
"requires": {
"@vue/compiler-dom": "3.3.12",
"@vue/shared": "3.3.12"
@ -2016,17 +2020,25 @@
"integrity": "sha512-+KpckaAQyfbvshdDW5xQylLni1asvNSGme1JFs8I1+/H5pHEhqUKMEQD/qn3Nx5+/nycBq11qAEi8lk+LXI2dA=="
},
"@vue/reactivity": {
"version": "3.3.12",
"resolved": "https://registry.npmjs.org/@vue/reactivity/-/reactivity-3.3.12.tgz",
"integrity": "sha512-vOJORzO8DlIx88cgTnMLIf2GlLYpoXAKsuoQsK6SGdaqODjxO129pVPTd2s/N/Mb6KKZEFIHIEwWGmtN4YPs+g==",
"version": "3.3.13",
"resolved": "https://registry.npmjs.org/@vue/reactivity/-/reactivity-3.3.13.tgz",
"integrity": "sha512-fjzCxceMahHhi4AxUBzQqqVhuA21RJ0COaWTbIBl1PruGW1CeY97louZzLi4smpYx+CHfFPPU/CS8NybbGvPKQ==",
"requires": {
"@vue/shared": "3.3.12"
"@vue/shared": "3.3.13"
},
"dependencies": {
"@vue/shared": {
"version": "3.3.13",
"resolved": "https://registry.npmjs.org/@vue/shared/-/shared-3.3.13.tgz",
"integrity": "sha512-/zYUwiHD8j7gKx2argXEMCUXVST6q/21DFU0sTfNX0URJroCe3b1UF6vLJ3lQDfLNIiiRl2ONp7Nh5UVWS6QnA=="
}
}
},
"@vue/reactivity-transform": {
"version": "3.3.12",
"resolved": "https://registry.npmjs.org/@vue/reactivity-transform/-/reactivity-transform-3.3.12.tgz",
"integrity": "sha512-g5TijmML7FyKkLt6QnpqNmA4KD7K/T5SbXa88Bhq+hydNQEkzA8veVXWAQuNqg9rjaFYD0rPf0a9NofKA0ENgg==",
"dev": true,
"requires": {
"@babel/parser": "^7.23.5",
"@vue/compiler-core": "3.3.12",
@ -2036,37 +2048,88 @@
}
},
"@vue/runtime-core": {
"version": "3.3.12",
"resolved": "https://registry.npmjs.org/@vue/runtime-core/-/runtime-core-3.3.12.tgz",
"integrity": "sha512-5iL4w7MZrSGKEZU2wFAYhDZdZmgn+s//73EfgDXW1M+ZUOl36md7tlWp1QFK/ladiq4FvQ82shVjo0KiPDPr0A==",
"version": "3.3.13",
"resolved": "https://registry.npmjs.org/@vue/runtime-core/-/runtime-core-3.3.13.tgz",
"integrity": "sha512-1TzA5TvGuh2zUwMJgdfvrBABWZ7y8kBwBhm7BXk8rvdx2SsgcGfz2ruv2GzuGZNvL1aKnK8CQMV/jFOrxNQUMA==",
"requires": {
"@vue/reactivity": "3.3.12",
"@vue/shared": "3.3.12"
"@vue/reactivity": "3.3.13",
"@vue/shared": "3.3.13"
},
"dependencies": {
"@vue/shared": {
"version": "3.3.13",
"resolved": "https://registry.npmjs.org/@vue/shared/-/shared-3.3.13.tgz",
"integrity": "sha512-/zYUwiHD8j7gKx2argXEMCUXVST6q/21DFU0sTfNX0URJroCe3b1UF6vLJ3lQDfLNIiiRl2ONp7Nh5UVWS6QnA=="
}
}
},
"@vue/runtime-dom": {
"version": "3.3.12",
"resolved": "https://registry.npmjs.org/@vue/runtime-dom/-/runtime-dom-3.3.12.tgz",
"integrity": "sha512-8mMzqiIdl+IYa/OXwKwk6/4ebLq7cYV1pUcwCSwBK2KerUa6cwGosen5xrCL9f8o2DJ9TfPFwbPEvH7OXzUpoA==",
"version": "3.3.13",
"resolved": "https://registry.npmjs.org/@vue/runtime-dom/-/runtime-dom-3.3.13.tgz",
"integrity": "sha512-JJkpE8R/hJKXqVTgUoODwS5wqKtOsmJPEqmp90PDVGygtJ4C0PtOkcEYXwhiVEmef6xeXcIlrT3Yo5aQ4qkHhQ==",
"requires": {
"@vue/runtime-core": "3.3.12",
"@vue/shared": "3.3.12",
"@vue/runtime-core": "3.3.13",
"@vue/shared": "3.3.13",
"csstype": "^3.1.3"
},
"dependencies": {
"@vue/shared": {
"version": "3.3.13",
"resolved": "https://registry.npmjs.org/@vue/shared/-/shared-3.3.13.tgz",
"integrity": "sha512-/zYUwiHD8j7gKx2argXEMCUXVST6q/21DFU0sTfNX0URJroCe3b1UF6vLJ3lQDfLNIiiRl2ONp7Nh5UVWS6QnA=="
}
}
},
"@vue/server-renderer": {
"version": "3.3.12",
"resolved": "https://registry.npmjs.org/@vue/server-renderer/-/server-renderer-3.3.12.tgz",
"integrity": "sha512-OZ0IEK5TU5GXb5J8/wSplyxvGGdIcwEmS8EIO302Vz8K6fGSgSJTU54X0Sb6PaefzZdiN3vHsLXO8XIeF8crQQ==",
"version": "3.3.13",
"resolved": "https://registry.npmjs.org/@vue/server-renderer/-/server-renderer-3.3.13.tgz",
"integrity": "sha512-vSnN+nuf6iSqTL3Qgx/9A+BT+0Zf/VJOgF5uMZrKjYPs38GMYyAU1coDyBNHauehXDaP+zl73VhwWv0vBRBHcg==",
"requires": {
"@vue/compiler-ssr": "3.3.12",
"@vue/shared": "3.3.12"
"@vue/compiler-ssr": "3.3.13",
"@vue/shared": "3.3.13"
},
"dependencies": {
"@vue/compiler-core": {
"version": "3.3.13",
"resolved": "https://registry.npmjs.org/@vue/compiler-core/-/compiler-core-3.3.13.tgz",
"integrity": "sha512-bwi9HShGu7uaZLOErZgsH2+ojsEdsjerbf2cMXPwmvcgZfVPZ2BVZzCVnwZBxTAYd6Mzbmf6izcUNDkWnBBQ6A==",
"requires": {
"@babel/parser": "^7.23.5",
"@vue/shared": "3.3.13",
"estree-walker": "^2.0.2",
"source-map-js": "^1.0.2"
}
},
"@vue/compiler-dom": {
"version": "3.3.13",
"resolved": "https://registry.npmjs.org/@vue/compiler-dom/-/compiler-dom-3.3.13.tgz",
"integrity": "sha512-EYRDpbLadGtNL0Gph+HoKiYqXLqZ0xSSpR5Dvnu/Ep7ggaCbjRDIus1MMxTS2Qm0koXED4xSlvTZaTnI8cYAsw==",
"requires": {
"@vue/compiler-core": "3.3.13",
"@vue/shared": "3.3.13"
}
},
"@vue/compiler-ssr": {
"version": "3.3.13",
"resolved": "https://registry.npmjs.org/@vue/compiler-ssr/-/compiler-ssr-3.3.13.tgz",
"integrity": "sha512-d/P3bCeUGmkJNS1QUZSAvoCIW4fkOKK3l2deE7zrp0ypJEy+En2AcypIkqvcFQOcw3F0zt2VfMvNsA9JmExTaw==",
"requires": {
"@vue/compiler-dom": "3.3.13",
"@vue/shared": "3.3.13"
}
},
"@vue/shared": {
"version": "3.3.13",
"resolved": "https://registry.npmjs.org/@vue/shared/-/shared-3.3.13.tgz",
"integrity": "sha512-/zYUwiHD8j7gKx2argXEMCUXVST6q/21DFU0sTfNX0URJroCe3b1UF6vLJ3lQDfLNIiiRl2ONp7Nh5UVWS6QnA=="
}
}
},
"@vue/shared": {
"version": "3.3.12",
"resolved": "https://registry.npmjs.org/@vue/shared/-/shared-3.3.12.tgz",
"integrity": "sha512-6p0Yin0pclvnER7BLNOQuod9Z+cxSYh8pSh7CzHnWNjAIP6zrTlCdHRvSCb1aYEx6i3Q3kvfuWU7nG16CgG1ag=="
"integrity": "sha512-6p0Yin0pclvnER7BLNOQuod9Z+cxSYh8pSh7CzHnWNjAIP6zrTlCdHRvSCb1aYEx6i3Q3kvfuWU7nG16CgG1ag==",
"dev": true
},
"@webassemblyjs/ast": {
"version": "1.11.6",
@ -6869,15 +6932,80 @@
"dev": true
},
"vue": {
"version": "3.3.12",
"resolved": "https://registry.npmjs.org/vue/-/vue-3.3.12.tgz",
"integrity": "sha512-jYNv2QmET2OTHsFzfWHMnqgCfqL4zfo97QwofdET+GBRCHhSCHuMTTvNIgeSn0/xF3JRT5OGah6MDwUFN7MPlg==",
"version": "3.3.13",
"resolved": "https://registry.npmjs.org/vue/-/vue-3.3.13.tgz",
"integrity": "sha512-LDnUpQvDgsfc0u/YgtAgTMXJlJQqjkxW1PVcOnJA5cshPleULDjHi7U45pl2VJYazSSvLH8UKcid/kzH8I0a0Q==",
"requires": {
"@vue/compiler-dom": "3.3.12",
"@vue/compiler-sfc": "3.3.12",
"@vue/runtime-dom": "3.3.12",
"@vue/server-renderer": "3.3.12",
"@vue/shared": "3.3.12"
"@vue/compiler-dom": "3.3.13",
"@vue/compiler-sfc": "3.3.13",
"@vue/runtime-dom": "3.3.13",
"@vue/server-renderer": "3.3.13",
"@vue/shared": "3.3.13"
},
"dependencies": {
"@vue/compiler-core": {
"version": "3.3.13",
"resolved": "https://registry.npmjs.org/@vue/compiler-core/-/compiler-core-3.3.13.tgz",
"integrity": "sha512-bwi9HShGu7uaZLOErZgsH2+ojsEdsjerbf2cMXPwmvcgZfVPZ2BVZzCVnwZBxTAYd6Mzbmf6izcUNDkWnBBQ6A==",
"requires": {
"@babel/parser": "^7.23.5",
"@vue/shared": "3.3.13",
"estree-walker": "^2.0.2",
"source-map-js": "^1.0.2"
}
},
"@vue/compiler-dom": {
"version": "3.3.13",
"resolved": "https://registry.npmjs.org/@vue/compiler-dom/-/compiler-dom-3.3.13.tgz",
"integrity": "sha512-EYRDpbLadGtNL0Gph+HoKiYqXLqZ0xSSpR5Dvnu/Ep7ggaCbjRDIus1MMxTS2Qm0koXED4xSlvTZaTnI8cYAsw==",
"requires": {
"@vue/compiler-core": "3.3.13",
"@vue/shared": "3.3.13"
}
},
"@vue/compiler-sfc": {
"version": "3.3.13",
"resolved": "https://registry.npmjs.org/@vue/compiler-sfc/-/compiler-sfc-3.3.13.tgz",
"integrity": "sha512-DQVmHEy/EKIgggvnGRLx21hSqnr1smUS9Aq8tfxiiot8UR0/pXKHN9k78/qQ7etyQTFj5em5nruODON7dBeumw==",
"requires": {
"@babel/parser": "^7.23.5",
"@vue/compiler-core": "3.3.13",
"@vue/compiler-dom": "3.3.13",
"@vue/compiler-ssr": "3.3.13",
"@vue/reactivity-transform": "3.3.13",
"@vue/shared": "3.3.13",
"estree-walker": "^2.0.2",
"magic-string": "^0.30.5",
"postcss": "^8.4.32",
"source-map-js": "^1.0.2"
}
},
"@vue/compiler-ssr": {
"version": "3.3.13",
"resolved": "https://registry.npmjs.org/@vue/compiler-ssr/-/compiler-ssr-3.3.13.tgz",
"integrity": "sha512-d/P3bCeUGmkJNS1QUZSAvoCIW4fkOKK3l2deE7zrp0ypJEy+En2AcypIkqvcFQOcw3F0zt2VfMvNsA9JmExTaw==",
"requires": {
"@vue/compiler-dom": "3.3.13",
"@vue/shared": "3.3.13"
}
},
"@vue/reactivity-transform": {
"version": "3.3.13",
"resolved": "https://registry.npmjs.org/@vue/reactivity-transform/-/reactivity-transform-3.3.13.tgz",
"integrity": "sha512-oWnydGH0bBauhXvh5KXUy61xr9gKaMbtsMHk40IK9M4gMuKPJ342tKFarY0eQ6jef8906m35q37wwA8DMZOm5Q==",
"requires": {
"@babel/parser": "^7.23.5",
"@vue/compiler-core": "3.3.13",
"@vue/shared": "3.3.13",
"estree-walker": "^2.0.2",
"magic-string": "^0.30.5"
}
},
"@vue/shared": {
"version": "3.3.13",
"resolved": "https://registry.npmjs.org/@vue/shared/-/shared-3.3.13.tgz",
"integrity": "sha512-/zYUwiHD8j7gKx2argXEMCUXVST6q/21DFU0sTfNX0URJroCe3b1UF6vLJ3lQDfLNIiiRl2ONp7Nh5UVWS6QnA=="
}
}
},
"vue-countup-v3": {

View File

@ -32,7 +32,7 @@
"sortablejs": "^1.15.1",
"sortablejs-vue3": "^1.2.11",
"swiper": "^11.0.5",
"vue": "^3.3.10",
"vue": "^3.3.13",
"vue-countup-v3": "^1.4.0",
"vue-imask": "^7.1.3",
"vue-router": "^4.2.5",

View File

@ -1190,8 +1190,22 @@ class Item extends Entity {
foreach ( $rules as $meta_id => $meta_values_conditional ) {
$meta_values = get_post_meta( $item_id, $meta_id );
if (!array_intersect($meta_values, $meta_values_conditional))
$meta_values = [];
$metadatum = new \Tainacan\Entities\Metadatum($meta_id);
$metadatum_type = $metadatum->get_metadata_type_object();
if ( $metadatum_type->get_primitive_type() == 'term' ) {
$item_metadata = new \Tainacan\Entities\Item_Metadata_Entity($this, $metadatum);
$term_values = $metadatum->is_multiple() ? $item_metadata->get_value() : array( $item_metadata->get_value() );
$meta_values = array_map(function($term) {
return $term->get_id();
}, $term_values);
} else {
$meta_values = get_post_meta( $item_id, $meta_id );
}
if ( !array_intersect($meta_values, $meta_values_conditional) )
return $return;
}
}

View File

@ -162,14 +162,14 @@ export default (element) => {
autoHide: true,
html: true,
},
'tainacan-repository-tooltip': {
'$extend': 'tainacan-header-tooltip',
'tainacan-header-tooltip': {
'$extend': 'tainacan-tooltip',
triggers: ['hover', 'focus', 'touch'],
autoHide: true,
html: true,
},
'tainacan-repository-tooltip': {
'$extend': 'tainacan-repository-header-tooltip',
'tainacan-repository-header-tooltip': {
'$extend': 'tainacan-repository-tooltip',
triggers: ['hover', 'focus', 'touch'],
autoHide: true,
html: true,

View File

@ -2,16 +2,15 @@ import mitt from 'mitt';
export default {
install(app, options = {}) {
install(app) {
const router = app.config.globalProperties.$router;
const route = app.config.globalProperties.$route;
const store = app.config.globalProperties.$store;
const userPrefs = app.config.globalProperties.$userPrefs;
const emitter = mitt();
const bus = {
$userPrefs: app.config.globalProperties.$userPrefs,
$store: app.config.globalProperties.$store,
$router: app.config.globalProperties.$router,
$route: app.config.globalProperties.$route,
errors : [],
query: {},
collectionId: undefined,
defaultOrder: 'ASC',
defaultOrderBy: 'date',
@ -19,18 +18,18 @@ export default {
termId: undefined,
searchCancel: undefined,
performAdvancedSearch(data) {
this.$store.dispatch('search/set_advanced_query', data);
store.dispatch('search/setAdvancedQuery', data);
this.updateURLQueries();
},
addMetaquery( data ){
if ( data && data.collection_id ){
this.$store.dispatch('search/add_metaquery', data );
store.dispatch('search/addMetaquery', data );
}
this.updateURLQueries();
},
addTaxquery( data ){
if ( data && data.collection_id ){
this.$store.dispatch('search/add_taxquery', data );
store.dispatch('search/addTaxquery', data );
}
this.updateURLQueries();
},
@ -40,7 +39,7 @@ export default {
if (filterTag.argType !== 'postin') {
if (filterTag.taxonomy) {
this.$store.dispatch('search/remove_taxquery', {
store.dispatch('search/removeTaxQuery', {
filterId: filterTag.filterId,
label: filterTag.singleLabel ? filterTag.singleLabel : filterTag.label,
isMultiValue: filterTag.singleLabel ? false : true,
@ -48,7 +47,7 @@ export default {
value: filterTag.value
});
} else {
this.$store.dispatch('search/remove_metaquery', {
store.dispatch('search/removeMetaQuery', {
filterId: filterTag.filterId,
label: filterTag.singleLabel ? filterTag.singleLabel : filterTag.label,
isMultiValue: filterTag.singleLabel ? false : true,
@ -57,50 +56,50 @@ export default {
});
}
} else {
this.$store.dispatch('search/remove_postin');
store.dispatch('search/removePostIn');
}
this.$store.dispatch('search/removeFilterTag', filterTag);
store.dispatch('search/removeFilterTag', filterTag);
}
this.updateURLQueries();
},
addFetchOnly( metadatum, ignorePrefs, metadatumIDs ) {
this.$store.dispatch('search/add_fetch_only', metadatum );
this.$store.dispatch('search/add_fetch_only_meta', metadatumIDs);
store.dispatch('search/addFetchOnly', metadatum );
store.dispatch('search/addFetchOnlyMeta', metadatumIDs);
this.updateURLQueries();
if (!ignorePrefs) {
let prefsFetchOnly = this.collectionId ? `fetch_only_${this.collectionId}` : 'fetch_only';
let prefsFetchOnlyMeta = this.collectionId ? `fetch_only_meta_${this.collectionId}` : 'fetch_only_meta';
if (this.$userPrefs.get(prefsFetchOnly) != metadatum)
this.$userPrefs.set(prefsFetchOnly, metadatum);
if (userPrefs.get(prefsFetchOnly) != metadatum)
userPrefs.set(prefsFetchOnly, metadatum);
if (this.$userPrefs.get(prefsFetchOnlyMeta) != metadatumIDs)
this.$userPrefs.set(prefsFetchOnlyMeta, metadatumIDs);
if (userPrefs.get(prefsFetchOnlyMeta) != metadatumIDs)
userPrefs.set(prefsFetchOnlyMeta, metadatumIDs);
}
},
cleanFetchOnly() {
this.$store.dispatch('search/cleanFetchOnly');
store.dispatch('search/cleanFetchOnly');
},
removeFetchOnlyMeta( metadatum ){
this.$store.dispatch('search/remove_fetch_only_meta', metadatum );
store.dispatch('search/removeFetchOnlyMeta', metadatum );
this.updateURLQueries();
},
setPage(page) {
this.$store.dispatch('search/setPage', page);
store.dispatch('search/setPage', page);
this.updateURLQueries();
},
resetPageOnStore() {
this.$store.dispatch('search/setPage', 1);
store.dispatch('search/setPage', 1);
},
setItemsPerPage(itemsPerPage, shouldNotUpdatePrefs) {
this.$store.dispatch('search/setItemsPerPage', itemsPerPage);
store.dispatch('search/setItemsPerPage', itemsPerPage);
this.updateURLQueries();
if (shouldNotUpdatePrefs == undefined || shouldNotUpdatePrefs == false) {
let prefsPerPage = this.collectionId != undefined ? 'items_per_page_' + this.collectionId : 'items_per_page';
if (this.$userPrefs.get(prefsPerPage) != itemsPerPage) {
this.$userPrefs.set(prefsPerPage, itemsPerPage)
if (userPrefs.get(prefsPerPage) != itemsPerPage) {
userPrefs.set(prefsPerPage, itemsPerPage)
.catch(() => {});
}
}
@ -109,77 +108,76 @@ export default {
let prefsOrderBy = this.collectionId != undefined ? 'order_by_' + this.collectionId : 'order_by';
if (orderBy.metakey) {
if (!this.$userPrefs.get(prefsOrderBy) || orderBy.metakey != this.$userPrefs.get(prefsOrderBy).metakey)
this.$userPrefs.set(prefsOrderBy, orderBy).catch(() => {});
if (!userPrefs.get(prefsOrderBy) || orderBy.metakey != userPrefs.get(prefsOrderBy).metakey)
userPrefs.set(prefsOrderBy, orderBy).catch(() => {});
} else {
if (orderBy != this.$userPrefs.get(prefsOrderBy))
this.$userPrefs.set(prefsOrderBy, orderBy).catch(() => {});
if (orderBy != userPrefs.get(prefsOrderBy))
userPrefs.set(prefsOrderBy, orderBy).catch(() => {});
}
this.$store.dispatch('search/setOrderBy', orderBy);
store.dispatch('search/setOrderBy', orderBy);
this.updateURLQueries();
},
setOrder(order) {
let prefsOrder = this.collectionId != undefined ? 'order_' + this.collectionId : 'order';
if (this.$userPrefs.get(prefsOrder) != order) {
this.$userPrefs.set(prefsOrder, order)
if (userPrefs.get(prefsOrder) != order) {
userPrefs.set(prefsOrder, order)
.catch(() => {});
}
this.$store.dispatch('search/setOrder', order);
store.dispatch('search/setOrder', order);
this.updateURLQueries();
},
setStatus(status) {
this.$store.dispatch('search/setStatus', status);
store.dispatch('search/setStatus', status);
this.updateURLQueries();
},
setTotalItems(totalItems) {
this.$store.dispatch('search/setTotalItems', totalItems);
store.dispatch('search/setTotalItems', totalItems);
},
setSentenceMode(sentenceMode) {
this.$store.dispatch('search/setSentenceMode', sentenceMode);
store.dispatch('search/setSentenceMode', sentenceMode);
},
setSearchQuery(searchQuery) {
this.$store.dispatch('search/setSearchQuery', searchQuery);
store.dispatch('search/setSearchQuery', searchQuery);
this.updateURLQueries();
},
setViewMode(viewMode) {
this.$store.dispatch('search/setViewMode', viewMode);
store.dispatch('search/setViewMode', viewMode);
this.updateURLQueries();
let prefsViewMode = this.collectionId != undefined ? 'view_mode_' + this.collectionId : 'view_mode';
if(this.$userPrefs.get(prefsViewMode) != viewMode) {
this.$userPrefs.set(prefsViewMode, viewMode)
if(userPrefs.get(prefsViewMode) != viewMode) {
userPrefs.set(prefsViewMode, viewMode)
.catch(() => {});
}
},
setAdminViewMode(adminViewMode) {
console.log('setAdminViewMode', adminViewMode);
this.$store.dispatch('search/setAdminViewMode', adminViewMode);
store.dispatch('search/setAdminViewMode', adminViewMode);
this.updateURLQueries();
let prefsAdminViewMode = this.collectionId != undefined ? 'admin_view_mode_' + this.collectionId : 'admin_view_mode';
if (this.$userPrefs.get(prefsAdminViewMode) != adminViewMode) {
this.$userPrefs.set(prefsAdminViewMode, adminViewMode)
if (userPrefs.get(prefsAdminViewMode) != adminViewMode) {
userPrefs.set(prefsAdminViewMode, adminViewMode)
.catch(() => { });
}
},
setInitialViewMode(viewMode) {
this.$store.dispatch('search/setViewMode', viewMode);
store.dispatch('search/setViewMode', viewMode);
this.updateURLQueries();
},
setInitialAdminViewMode(adminViewMode) {
this.$store.dispatch('search/setAdminViewMode', adminViewMode);
store.dispatch('search/setAdminViewMode', adminViewMode);
this.updateURLQueries();
},
async setSelectedItemsForIframe(selectedItems, singleSelection) {
if (singleSelection)
this.$store.dispatch('search/cleanSelectedItems');
store.dispatch('search/cleanSelectedItems');
this.$store.dispatch('search/setSelectedItems', selectedItems);
store.dispatch('search/setSelectedItems', selectedItems);
let currentSelectedItems = this.$store.getters['search/getSelectedItems'];
let currentSelectedItems = store.getters['search/getSelectedItems'];
if (window.history.replaceState) {
let searchParams = new URLSearchParams(window.location.search);
@ -189,51 +187,51 @@ export default {
let newurl = window.location.protocol + "//" + window.location.host + window.location.pathname + '?' + searchParams.toString() + window.location.hash;
await this.$router.push(newurl)
await router.push(newurl)
window.history.replaceState({ ...window.history.state, ...{ path: newurl } }, '')
}
},
cleanSelectedItems() {
this.$store.dispatch('search/cleanSelectedItems');
store.dispatch('search/cleanSelectedItems');
},
filterBySelectedItems(selectedItems) {
if ( app.config.globalProperties.$route.name ) {
this.$router.replace({ name: app.config.globalProperties.$route.name, query: {} });
this.$router.replace({ name: app.config.globalProperties.$route.name, query: { postin: selectedItems } });
if ( route.name ) {
router.replace({ query: {} });
router.replace({ query: { postin: selectedItems } });
} else {
this.$router.replace({ path: '', query: {} });
this.$router.replace({ path: '', query: { postin: selectedItems } });
router.replace({ query: {} });
router.replace({ query: { postin: selectedItems } });
}
},
highlightsItem(itemId) {
this.$store.dispatch('search/highlightsItem', itemId);
store.dispatch('search/highlightsItem', itemId);
this.updateURLQueries();
},
updateURLQueries() {
if ( app.config.globalProperties.$route.name ) {
this.$router.replace({ name: app.config.globalProperties.$route.name, query: {} });
this.$router.replace({ name: app.config.globalProperties.$route.name, query: this.$store.getters['search/getPostQuery'], onabort: () => { console.log('abort'); }, onerror: () => { console.log('error'); }, onready: () => { console.log('ready'); }, onsuccess: () => { console.log('success'); } });
} else {
this.$router.replace({ path: this.$route.path, query: {} });
this.$router.replace({ path: this.$route.path, query: this.$store.getters['search/getPostQuery'] });
}
async updateURLQueries() {
const newQueries = store.getters['search/getPostQuery'];
await router.replace({ query: {} });
await router.replace({ query: newQueries });
},
updateStoreFromURL() {
this.$store.dispatch('search/set_postquery', this.$route.query);
store.dispatch('search/setPostQuery', route.query);
},
loadItems() {
console.log('loadItems')
console.log(JSON.parse(JSON.stringify(store.getters['search/getPostQuery'])))
// Forces fetch_only to be filled before any search happens
if (this.$store.getters['search/getPostQuery']['fetch_only'] != undefined) {
if (store.getters['search/getPostQuery']['fetch_only'] != undefined) {
app.config.globalProperties.$eventBusSearchEmitter.emit( 'isLoadingItems', true);
// Cancels previous Request
if (this.searchCancel != undefined)
this.searchCancel.cancel('Item search Canceled.');
this.$store.dispatch('collection/fetchItems', {
console.log('fetching')
store.dispatch('collection/fetchItems', {
'collectionId': this.collectionId,
'isOnTheme': app.config.globalProperties.$route.meta && app.config.globalProperties.$route.meta.isOnTheme,
'isOnTheme': route.meta && route.meta.isOnTheme,
'termId': this.termId,
'taxonomy': this.taxonomy
}).then((resp) => {
@ -267,9 +265,9 @@ export default {
this.taxonomy = taxonomy;
},
clearAllFilters() {
this.$store.dispatch('search/cleanFilterTags');
this.$store.dispatch('search/cleanMetaQueries', { keepCollections: true });
this.$store.dispatch('search/cleanTaxQueries');
store.dispatch('search/cleanFilterTags');
store.dispatch('search/cleanMetaQueries', { keepCollections: true });
store.dispatch('search/cleanTaxQueries');
this.updateURLQueries();
}
}

View File

@ -13,7 +13,7 @@ export const fetchItems = ({ rootGetters, dispatch, commit }, { collectionId, is
// Sets term query in case it's on a term items page
if (termId != undefined && taxonomy != undefined) {
dispatch('search/add_taxquery', {
dispatch('search/addTaxquery', {
taxonomy: taxonomy,
terms:[ termId ],
compare: 'IN'
@ -48,12 +48,12 @@ export const fetchItems = ({ rootGetters, dispatch, commit }, { collectionId, is
// Guarantees at least status is passed in case none is found
if (postQueries.fetch_only == '')
dispatch('search/add_fetch_only', 'status', { root: true });
dispatch('search/addFetchOnly', 'status', { root: true });
else
postQueries.fetch_only += ',status';
if (postQueries.fetch_only_meta == '')
dispatch('search/add_fetch_only_meta', '', { root: true });
dispatch('search/addFetchOnlyMeta', '', { root: true });
let query = qs.stringify(postQueries);
@ -97,7 +97,7 @@ export const fetchItems = ({ rootGetters, dispatch, commit }, { collectionId, is
hasFiltered: hasFiltered,
itemsPerPage: res.headers['x-wp-itemperpage'] });
}
console.log(res.headers['x-wp-total']);
dispatch('search/setTotalItems', Number(res.headers['x-wp-total']), { root: true } );
dispatch('search/setTotalPages', res.headers['x-wp-totalpages'], { root: true } );
dispatch('search/setItemsPerPage', res.headers['x-wp-itemsperpage'], { root: true } );

View File

@ -1,20 +1,20 @@
// General Post Queries
export const set_postquery_attribute = ({ commit }, filter, value ) => {
export const setPostQueryAttribute = ({ commit }, filter, value ) => {
commit('setPostQueryAttribute', { attr: filter, value: value } );
};
export const set_postquery = ({ commit }, postquery ) => {
export const setPostQuery = ({ commit }, postquery ) => {
commit('setPostQuery', postquery );
};
export const set_advanced_query = ({commit}, advancedSearchQuery) => {
export const setAdvancedQuery = ({commit}, advancedSearchQuery) => {
commit('removePostQueryAttribute', 'search');
commit('removePostQueryAttribute', 's');
commit('setAdvancedSearchQuery', advancedSearchQuery);
};
// Meta Queries from filters
export const add_metaquery = ( { commit }, filter ) => {
export const addMetaquery = ( { commit }, filter ) => {
if (filter && (filter.value === undefined || filter.value === null || filter.value.length === 0 || filter.value === '')) {
commit('removeMetaQuery', filter );
} else {
@ -23,23 +23,23 @@ export const add_metaquery = ( { commit }, filter ) => {
};
// Fetch Only for item attributes limiting on results
export const add_fetch_only = ( { commit }, metadatum ) => {
export const addFetchOnly = ( { commit }, metadatum ) => {
commit('addFetchOnly', metadatum );
};
export const remove_fetch_only = ( { commit }, metadatum ) => {
export const removeFetchOnly = ( { commit }, metadatum ) => {
commit('removeFetchOnly', metadatum );
};
// Fetch Only for metadata limiting on results
export const add_fetch_only_meta = ( { commit }, metadatum ) => {
export const addFetchOnlyMeta = ( { commit }, metadatum ) => {
commit('addFetchOnlyMeta', metadatum );
};
export const remove_fetch_only_meta = ( { commit }, metadatum ) => {
export const removeFetchOnlyMeta = ( { commit }, metadatum ) => {
commit('removeFetchOnlyMeta', metadatum );
};
// Tax Queries from filters
export const add_taxquery = ( { commit }, filter ) => {
export const addTaxquery = ( { commit }, filter ) => {
if (filter && (filter.terms === undefined || filter.terms === null || filter.terms === '' || filter.terms.length === 0 )) {
commit('removeTaxQuery', filter );
} else {
@ -47,15 +47,15 @@ export const add_taxquery = ( { commit }, filter ) => {
}
};
export const remove_metaquery = ( { commit }, filter ) => {
export const removeMetaQuery = ( { commit }, filter ) => {
commit('removeMetaQuery', filter );
};
export const remove_taxquery = ( { commit }, filter ) => {
export const removeTaxQuery = ( { commit }, filter ) => {
commit('removeTaxQuery', filter );
};
export const remove_postin = ( { commit } ) => {
export const removePostIn = ( { commit } ) => {
commit('removePostIn');
};

View File

@ -816,142 +816,137 @@
if (this.$route.name == 'CollectionItemsPage' || this.$route.name == 'ItemsPage')
this.$eventBusSearch.setCollectionId( !this.$route.params.collectionId ? this.$route.params.collectionId : parseInt(this.$route.params.collectionId) );
// Fills the URL with appropriate default values in case a query is not passed
if (this.$route.name == null || this.$route.name == undefined || this.$route.name == 'CollectionItemsPage' || this.$route.name == 'ItemsPage') {
// Items Per Page
if (this.$route.query.perpage == undefined || to.params.collectionId != from.params.collectionId) {
let perPageKey = (this.collectionId != undefined ? 'items_per_page_' + this.collectionId : 'items_per_page');
let perPageValue = this.$userPrefs.get(perPageKey);
// Items Per Page
if (this.$route.query.perpage == undefined || to.params.collectionId != from.params.collectionId) {
let perPageKey = (this.collectionId != undefined ? 'items_per_page_' + this.collectionId : 'items_per_page');
let perPageValue = this.$userPrefs.get(perPageKey);
if (perPageValue)
this.$route.query.perpage = perPageValue;
else {
this.$route.query.perpage = 12;
this.$userPrefs.set(perPageKey, 12);
}
if (perPageValue)
this.$route.query.perpage = perPageValue;
else {
this.$route.query.perpage = 12;
this.$userPrefs.set(perPageKey, 12);
}
}
// Page
if (this.$route.query.paged == undefined || to.params.collectionId != from.params.collectionId)
this.$route.query.paged = 1;
// Page
if (this.$route.query.paged == undefined || to.params.collectionId != from.params.collectionId)
this.$route.query.paged = 1;
// Order (ASC, DESC)
if (this.$route.query.order == undefined || to.params.collectionId != from.params.collectionId) {
let orderKey = (this.collectionId != undefined ? 'order_' + this.collectionId : 'order');
let orderValue = this.$userPrefs.get(orderKey) ? this.$userPrefs.get(orderKey) : this.defaultOrder;
// Order (ASC, DESC)
if (this.$route.query.order == undefined || to.params.collectionId != from.params.collectionId) {
let orderKey = (this.collectionId != undefined ? 'order_' + this.collectionId : 'order');
let orderValue = this.$userPrefs.get(orderKey) ? this.$userPrefs.get(orderKey) : this.defaultOrder;
if (orderValue)
this.$route.query.order = orderValue;
else {
this.$route.query.order = 'DESC';
this.$userPrefs.set(orderKey, 'DESC');
}
if (orderValue)
this.$route.query.order = orderValue;
else {
this.$route.query.order = 'DESC';
this.$userPrefs.set(orderKey, 'DESC');
}
}
// Order By (required extra work to deal with custom metadata ordering)
if (this.$route.query.orderby == undefined || (to.params.collectionId != from.params.collectionId)) {
let orderByKey = (this.collectionId != undefined ? 'order_by_' + this.collectionId : 'order_by');
let orderBy = this.$userPrefs.get(orderByKey) ? this.$userPrefs.get(orderByKey) : this.defaultOrderBy;
// Order By (required extra work to deal with custom metadata ordering)
if (this.$route.query.orderby == undefined || (to.params.collectionId != from.params.collectionId)) {
let orderByKey = (this.collectionId != undefined ? 'order_by_' + this.collectionId : 'order_by');
let orderBy = this.$userPrefs.get(orderByKey) ? this.$userPrefs.get(orderByKey) : this.defaultOrderBy;
if (orderBy && orderBy != 'name') {
if (orderBy && orderBy != 'name') {
// Previously was stored as a metadata object, now it is a orderby object
if (orderBy.slug || typeof orderBy == 'string')
orderBy = this.$orderByHelper.getOrderByForMetadatum(orderBy);
// Previously was stored as a metadata object, now it is a orderby object
if (orderBy.slug || typeof orderBy == 'string')
orderBy = this.$orderByHelper.getOrderByForMetadatum(orderBy);
if (orderBy.orderby)
Object.keys(orderBy).forEach((paramKey) => {
this.$route.query[paramKey] = orderBy[paramKey];
});
else
this.$route.query.orderby = 'date'
if (orderBy.orderby)
Object.keys(orderBy).forEach((paramKey) => {
this.$route.query[paramKey] = orderBy[paramKey];
});
else
this.$route.query.orderby = 'date'
} else {
this.$route.query.orderby = 'date';
this.$userPrefs.set(orderByKey, {
slug: 'creation_date',
name: this.$i18n.get('label_creation_date')
}).catch(() => { });
}
} else if ( this.$route.query.orderby == 'creation_date' ) { // Fixes old usage of creation_date
this.$route.query.orderby = 'date'
}
// Theme View Modes
if ((this.$route.name == null || this.$route.name == undefined ) &&
this.$route.name != 'CollectionItemsPage' && this.$route.name != 'ItemsPage' &&
(this.$route.query.view_mode == undefined || to.params.collectionId != from.params.collectionId)
) {
let viewModeKey = (this.collectionId != undefined ? 'view_mode_' + this.collectionId : 'view_mode');
let viewModeValue = this.$userPrefs.get(viewModeKey);
if (viewModeValue)
this.$route.query.view_mode = viewModeValue;
else {
this.$route.query.view_mode = 'table';
this.$userPrefs.set(viewModeKey, 'table');
}
}
// Emit slideshow-from to start this view mode from index
if (this.$route.query.view_mode != 'slideshow' && this.$route.query['slideshow-from'] !== null && this.$route.query['slideshow-from'] !== undefined && this.$route.query['slideshow-from'] !== false)
this.$eventBusSearchEmitter.emit('startSlideshowFromItem', this.$route.query['slideshow-from']);
// Admin View Modes
if (this.$route.name != null && this.$route.name != undefined &&
(this.$route.name == 'CollectionItemsPage' || this.$route.name == 'ItemsPage') &&
(this.$route.query.admin_view_mode == undefined || to.params.collectionId != from.params.collectionId)
) {
let adminViewModeKey = (this.collectionId != undefined ? 'admin_view_mode_' + this.collectionId : 'admin_view_mode');
let adminViewModeValue = this.$userPrefs.get(adminViewModeKey);
if (adminViewModeValue)
this.$route.query.admin_view_mode = adminViewModeValue;
else {
this.$route.query.admin_view_mode = 'table';
this.$userPrefs.set(adminViewModeKey, 'table');
}
}
// Advanced Search
if (this.$route.query && this.$route.query.advancedSearch){
this.$store.dispatch('search/set_advanced_query', this.$route.query);
} else {
this.$store.dispatch('search/set_postquery', this.$route.query);
this.$route.query.orderby = 'date';
this.$userPrefs.set(orderByKey, {
slug: 'creation_date',
name: this.$i18n.get('label_creation_date')
}).catch(() => { });
}
} else if ( this.$route.query.orderby == 'creation_date' ) { // Fixes old usage of creation_date
this.$route.query.orderby = 'date'
}
// Finally, loads items even berfore facets so they won't stuck them
if (to.fullPath != from.fullPath)
this.$eventBusSearch.loadItems();
// Theme View Modes
if ((this.$route.name == null || this.$route.name == undefined ) &&
this.$route.name != 'CollectionItemsPage' && this.$route.name != 'ItemsPage' &&
(this.$route.query.view_mode == undefined || to.params.collectionId != from.params.collectionId)
) {
// Checks current metaqueries and taxqueries to alert filters that should reload
// For some reason, this process is not working accessing to.query, so we need to check the path string.
const oldQueryString = from.fullPath.replace(from.path + '?', '');
const newQueryString = to.fullPath.replace(from.path + '?', '');
let viewModeKey = (this.collectionId != undefined ? 'view_mode_' + this.collectionId : 'view_mode');
let viewModeValue = this.$userPrefs.get(viewModeKey);
const oldQueryArray = oldQueryString.split('&');
const newQueryArray = newQueryString.split('&');
const oldMetaQueryArray = oldQueryArray.filter(queryItem => queryItem.startsWith('metaquery'));
const newMetaQueryArray = newQueryArray.filter(queryItem => queryItem.startsWith('metaquery'));
const oldTaxQueryArray = oldQueryArray.filter(queryItem => queryItem.startsWith('taxquery'));
const newTaxQueryArray = newQueryArray.filter(queryItem => queryItem.startsWith('taxquery'));
const oldStatusArray = oldQueryArray.filter(queryItem => queryItem.startsWith('status'));
const newStatusArray = newQueryArray.filter(queryItem => queryItem.startsWith('status'));
const oldSearchQuery = oldQueryArray.filter(queryItem => queryItem.startsWith('search'));
const newSearchQuery = newQueryArray.filter(queryItem => queryItem.startsWith('search'));
if (
JSON.stringify(oldMetaQueryArray) != JSON.stringify(newMetaQueryArray) ||
JSON.stringify(oldTaxQueryArray) != JSON.stringify(newTaxQueryArray) ||
JSON.stringify(oldStatusArray) != JSON.stringify(newStatusArray) ||
JSON.stringify(oldSearchQuery) != JSON.stringify(newSearchQuery)
) {
this.$eventBusSearchEmitter.emit('hasToReloadFacets', true);
if (viewModeValue)
this.$route.query.view_mode = viewModeValue;
else {
this.$route.query.view_mode = 'table';
this.$userPrefs.set(viewModeKey, 'table');
}
}
// Emit slideshow-from to start this view mode from index
if (this.$route.query.view_mode != 'slideshow' && this.$route.query['slideshow-from'] !== null && this.$route.query['slideshow-from'] !== undefined && this.$route.query['slideshow-from'] !== false)
this.$eventBusSearchEmitter.emit('startSlideshowFromItem', this.$route.query['slideshow-from']);
// Admin View Modes
if (this.$route.name != null && this.$route.name != undefined &&
(this.$route.name == 'CollectionItemsPage' || this.$route.name == 'ItemsPage') &&
(this.$route.query.admin_view_mode == undefined || to.params.collectionId != from.params.collectionId)
) {
let adminViewModeKey = (this.collectionId != undefined ? 'admin_view_mode_' + this.collectionId : 'admin_view_mode');
let adminViewModeValue = this.$userPrefs.get(adminViewModeKey);
if (adminViewModeValue)
this.$route.query.admin_view_mode = adminViewModeValue;
else {
this.$route.query.admin_view_mode = 'table';
this.$userPrefs.set(adminViewModeKey, 'table');
}
}
// Advanced Search
if (this.$route.query && this.$route.query.advancedSearch)
this.$store.dispatch('search/setAdvancedQuery', this.$route.query);
else
this.$store.dispatch('search/setPostQuery', this.$route.query);
// Finally, loads items even berfore facets so they won't stuck them
if (to.fullPath != from.fullPath)
this.$eventBusSearch.loadItems();
// Checks current metaqueries and taxqueries to alert filters that should reload
// For some reason, this process is not working accessing to.query, so we need to check the path string.
const oldQueryString = from.fullPath.replace(from.path + '?', '');
const newQueryString = to.fullPath.replace(from.path + '?', '');
const oldQueryArray = oldQueryString.split('&');
const newQueryArray = newQueryString.split('&');
const oldMetaQueryArray = oldQueryArray.filter(queryItem => queryItem.startsWith('metaquery'));
const newMetaQueryArray = newQueryArray.filter(queryItem => queryItem.startsWith('metaquery'));
const oldTaxQueryArray = oldQueryArray.filter(queryItem => queryItem.startsWith('taxquery'));
const newTaxQueryArray = newQueryArray.filter(queryItem => queryItem.startsWith('taxquery'));
const oldStatusArray = oldQueryArray.filter(queryItem => queryItem.startsWith('status'));
const newStatusArray = newQueryArray.filter(queryItem => queryItem.startsWith('status'));
const oldSearchQuery = oldQueryArray.filter(queryItem => queryItem.startsWith('search'));
const newSearchQuery = newQueryArray.filter(queryItem => queryItem.startsWith('search'));
if (
JSON.stringify(oldMetaQueryArray) != JSON.stringify(newMetaQueryArray) ||
JSON.stringify(oldTaxQueryArray) != JSON.stringify(newTaxQueryArray) ||
JSON.stringify(oldStatusArray) != JSON.stringify(newStatusArray) ||
JSON.stringify(oldSearchQuery) != JSON.stringify(newSearchQuery)
) {
this.$eventBusSearchEmitter.emit('hasToReloadFacets', true);
}
},
deep: true
},

View File

@ -936,9 +936,9 @@
// Advanced Search
if (this.$route.query && this.$route.query.advancedSearch){
this.$store.dispatch('search/set_advanced_query', this.$route.query);
this.$store.dispatch('search/setAdvancedQuery', this.$route.query);
} else {
this.$store.dispatch('search/set_postquery', this.$route.query);
this.$store.dispatch('search/setPostQuery', this.$route.query);
}
// Finally, loads items even berfore facets so they won't stuck them