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", "version": "3.3.12",
"resolved": "https://registry.npmjs.org/@vue/compiler-core/-/compiler-core-3.3.12.tgz", "resolved": "https://registry.npmjs.org/@vue/compiler-core/-/compiler-core-3.3.12.tgz",
"integrity": "sha512-qAtjyG3GBLG0chzp5xGCyRLLe6wFCHmjI82aGzwuGKyznNP+GJJMxjc0wOYWDB2YKfho7niJFdoFpo0CZZQg9w==", "integrity": "sha512-qAtjyG3GBLG0chzp5xGCyRLLe6wFCHmjI82aGzwuGKyznNP+GJJMxjc0wOYWDB2YKfho7niJFdoFpo0CZZQg9w==",
"dev": true,
"requires": { "requires": {
"@babel/parser": "^7.23.5", "@babel/parser": "^7.23.5",
"@vue/shared": "3.3.12", "@vue/shared": "3.3.12",
@ -1979,6 +1980,7 @@
"version": "3.3.12", "version": "3.3.12",
"resolved": "https://registry.npmjs.org/@vue/compiler-dom/-/compiler-dom-3.3.12.tgz", "resolved": "https://registry.npmjs.org/@vue/compiler-dom/-/compiler-dom-3.3.12.tgz",
"integrity": "sha512-RdJU9oEYaoPKUdGXCy0l+i4clesdDeLmbvRlszoc9iagsnBnMmQtYfCPVQ5BHB6o7K4SCucDdJM2Dh3oXB0D6g==", "integrity": "sha512-RdJU9oEYaoPKUdGXCy0l+i4clesdDeLmbvRlszoc9iagsnBnMmQtYfCPVQ5BHB6o7K4SCucDdJM2Dh3oXB0D6g==",
"dev": true,
"requires": { "requires": {
"@vue/compiler-core": "3.3.12", "@vue/compiler-core": "3.3.12",
"@vue/shared": "3.3.12" "@vue/shared": "3.3.12"
@ -1988,6 +1990,7 @@
"version": "3.3.12", "version": "3.3.12",
"resolved": "https://registry.npmjs.org/@vue/compiler-sfc/-/compiler-sfc-3.3.12.tgz", "resolved": "https://registry.npmjs.org/@vue/compiler-sfc/-/compiler-sfc-3.3.12.tgz",
"integrity": "sha512-yy5b9e7b79dsGbMmglCe/YnhCQgBkHO7Uf6JfjWPSf2/5XH+MKn18LhzhHyxbHdJgnA4lZCqtXzLaJz8Pd8lMw==", "integrity": "sha512-yy5b9e7b79dsGbMmglCe/YnhCQgBkHO7Uf6JfjWPSf2/5XH+MKn18LhzhHyxbHdJgnA4lZCqtXzLaJz8Pd8lMw==",
"dev": true,
"requires": { "requires": {
"@babel/parser": "^7.23.5", "@babel/parser": "^7.23.5",
"@vue/compiler-core": "3.3.12", "@vue/compiler-core": "3.3.12",
@ -2005,6 +2008,7 @@
"version": "3.3.12", "version": "3.3.12",
"resolved": "https://registry.npmjs.org/@vue/compiler-ssr/-/compiler-ssr-3.3.12.tgz", "resolved": "https://registry.npmjs.org/@vue/compiler-ssr/-/compiler-ssr-3.3.12.tgz",
"integrity": "sha512-adCiMJPznfWcQyk/9HSuXGja859IaMV+b8UNSVzDatqv7h0PvT9BEeS22+gjkWofDiSg5d78/ZLls3sLA+cn3A==", "integrity": "sha512-adCiMJPznfWcQyk/9HSuXGja859IaMV+b8UNSVzDatqv7h0PvT9BEeS22+gjkWofDiSg5d78/ZLls3sLA+cn3A==",
"dev": true,
"requires": { "requires": {
"@vue/compiler-dom": "3.3.12", "@vue/compiler-dom": "3.3.12",
"@vue/shared": "3.3.12" "@vue/shared": "3.3.12"
@ -2016,17 +2020,25 @@
"integrity": "sha512-+KpckaAQyfbvshdDW5xQylLni1asvNSGme1JFs8I1+/H5pHEhqUKMEQD/qn3Nx5+/nycBq11qAEi8lk+LXI2dA==" "integrity": "sha512-+KpckaAQyfbvshdDW5xQylLni1asvNSGme1JFs8I1+/H5pHEhqUKMEQD/qn3Nx5+/nycBq11qAEi8lk+LXI2dA=="
}, },
"@vue/reactivity": { "@vue/reactivity": {
"version": "3.3.12", "version": "3.3.13",
"resolved": "https://registry.npmjs.org/@vue/reactivity/-/reactivity-3.3.12.tgz", "resolved": "https://registry.npmjs.org/@vue/reactivity/-/reactivity-3.3.13.tgz",
"integrity": "sha512-vOJORzO8DlIx88cgTnMLIf2GlLYpoXAKsuoQsK6SGdaqODjxO129pVPTd2s/N/Mb6KKZEFIHIEwWGmtN4YPs+g==", "integrity": "sha512-fjzCxceMahHhi4AxUBzQqqVhuA21RJ0COaWTbIBl1PruGW1CeY97louZzLi4smpYx+CHfFPPU/CS8NybbGvPKQ==",
"requires": { "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": { "@vue/reactivity-transform": {
"version": "3.3.12", "version": "3.3.12",
"resolved": "https://registry.npmjs.org/@vue/reactivity-transform/-/reactivity-transform-3.3.12.tgz", "resolved": "https://registry.npmjs.org/@vue/reactivity-transform/-/reactivity-transform-3.3.12.tgz",
"integrity": "sha512-g5TijmML7FyKkLt6QnpqNmA4KD7K/T5SbXa88Bhq+hydNQEkzA8veVXWAQuNqg9rjaFYD0rPf0a9NofKA0ENgg==", "integrity": "sha512-g5TijmML7FyKkLt6QnpqNmA4KD7K/T5SbXa88Bhq+hydNQEkzA8veVXWAQuNqg9rjaFYD0rPf0a9NofKA0ENgg==",
"dev": true,
"requires": { "requires": {
"@babel/parser": "^7.23.5", "@babel/parser": "^7.23.5",
"@vue/compiler-core": "3.3.12", "@vue/compiler-core": "3.3.12",
@ -2036,37 +2048,88 @@
} }
}, },
"@vue/runtime-core": { "@vue/runtime-core": {
"version": "3.3.12", "version": "3.3.13",
"resolved": "https://registry.npmjs.org/@vue/runtime-core/-/runtime-core-3.3.12.tgz", "resolved": "https://registry.npmjs.org/@vue/runtime-core/-/runtime-core-3.3.13.tgz",
"integrity": "sha512-5iL4w7MZrSGKEZU2wFAYhDZdZmgn+s//73EfgDXW1M+ZUOl36md7tlWp1QFK/ladiq4FvQ82shVjo0KiPDPr0A==", "integrity": "sha512-1TzA5TvGuh2zUwMJgdfvrBABWZ7y8kBwBhm7BXk8rvdx2SsgcGfz2ruv2GzuGZNvL1aKnK8CQMV/jFOrxNQUMA==",
"requires": { "requires": {
"@vue/reactivity": "3.3.12", "@vue/reactivity": "3.3.13",
"@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/runtime-dom": { "@vue/runtime-dom": {
"version": "3.3.12", "version": "3.3.13",
"resolved": "https://registry.npmjs.org/@vue/runtime-dom/-/runtime-dom-3.3.12.tgz", "resolved": "https://registry.npmjs.org/@vue/runtime-dom/-/runtime-dom-3.3.13.tgz",
"integrity": "sha512-8mMzqiIdl+IYa/OXwKwk6/4ebLq7cYV1pUcwCSwBK2KerUa6cwGosen5xrCL9f8o2DJ9TfPFwbPEvH7OXzUpoA==", "integrity": "sha512-JJkpE8R/hJKXqVTgUoODwS5wqKtOsmJPEqmp90PDVGygtJ4C0PtOkcEYXwhiVEmef6xeXcIlrT3Yo5aQ4qkHhQ==",
"requires": { "requires": {
"@vue/runtime-core": "3.3.12", "@vue/runtime-core": "3.3.13",
"@vue/shared": "3.3.12", "@vue/shared": "3.3.13",
"csstype": "^3.1.3" "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": { "@vue/server-renderer": {
"version": "3.3.12", "version": "3.3.13",
"resolved": "https://registry.npmjs.org/@vue/server-renderer/-/server-renderer-3.3.12.tgz", "resolved": "https://registry.npmjs.org/@vue/server-renderer/-/server-renderer-3.3.13.tgz",
"integrity": "sha512-OZ0IEK5TU5GXb5J8/wSplyxvGGdIcwEmS8EIO302Vz8K6fGSgSJTU54X0Sb6PaefzZdiN3vHsLXO8XIeF8crQQ==", "integrity": "sha512-vSnN+nuf6iSqTL3Qgx/9A+BT+0Zf/VJOgF5uMZrKjYPs38GMYyAU1coDyBNHauehXDaP+zl73VhwWv0vBRBHcg==",
"requires": { "requires": {
"@vue/compiler-ssr": "3.3.12", "@vue/compiler-ssr": "3.3.13",
"@vue/shared": "3.3.12" "@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": { "@vue/shared": {
"version": "3.3.12", "version": "3.3.12",
"resolved": "https://registry.npmjs.org/@vue/shared/-/shared-3.3.12.tgz", "resolved": "https://registry.npmjs.org/@vue/shared/-/shared-3.3.12.tgz",
"integrity": "sha512-6p0Yin0pclvnER7BLNOQuod9Z+cxSYh8pSh7CzHnWNjAIP6zrTlCdHRvSCb1aYEx6i3Q3kvfuWU7nG16CgG1ag==" "integrity": "sha512-6p0Yin0pclvnER7BLNOQuod9Z+cxSYh8pSh7CzHnWNjAIP6zrTlCdHRvSCb1aYEx6i3Q3kvfuWU7nG16CgG1ag==",
"dev": true
}, },
"@webassemblyjs/ast": { "@webassemblyjs/ast": {
"version": "1.11.6", "version": "1.11.6",
@ -6869,15 +6932,80 @@
"dev": true "dev": true
}, },
"vue": { "vue": {
"version": "3.3.12", "version": "3.3.13",
"resolved": "https://registry.npmjs.org/vue/-/vue-3.3.12.tgz", "resolved": "https://registry.npmjs.org/vue/-/vue-3.3.13.tgz",
"integrity": "sha512-jYNv2QmET2OTHsFzfWHMnqgCfqL4zfo97QwofdET+GBRCHhSCHuMTTvNIgeSn0/xF3JRT5OGah6MDwUFN7MPlg==", "integrity": "sha512-LDnUpQvDgsfc0u/YgtAgTMXJlJQqjkxW1PVcOnJA5cshPleULDjHi7U45pl2VJYazSSvLH8UKcid/kzH8I0a0Q==",
"requires": { "requires": {
"@vue/compiler-dom": "3.3.12", "@vue/compiler-dom": "3.3.13",
"@vue/compiler-sfc": "3.3.12", "@vue/compiler-sfc": "3.3.13",
"@vue/runtime-dom": "3.3.12", "@vue/runtime-dom": "3.3.13",
"@vue/server-renderer": "3.3.12", "@vue/server-renderer": "3.3.13",
"@vue/shared": "3.3.12" "@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": { "vue-countup-v3": {

View File

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

View File

@ -1190,8 +1190,22 @@ class Item extends Entity {
foreach ( $rules as $meta_id => $meta_values_conditional ) { foreach ( $rules as $meta_id => $meta_values_conditional ) {
$meta_values = get_post_meta( $item_id, $meta_id ); $meta_values = [];
if (!array_intersect($meta_values, $meta_values_conditional)) $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; return $return;
} }
} }

View File

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

View File

@ -2,16 +2,15 @@ import mitt from 'mitt';
export default { 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 emitter = mitt();
const bus = { 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, collectionId: undefined,
defaultOrder: 'ASC', defaultOrder: 'ASC',
defaultOrderBy: 'date', defaultOrderBy: 'date',
@ -19,18 +18,18 @@ export default {
termId: undefined, termId: undefined,
searchCancel: undefined, searchCancel: undefined,
performAdvancedSearch(data) { performAdvancedSearch(data) {
this.$store.dispatch('search/set_advanced_query', data); store.dispatch('search/setAdvancedQuery', data);
this.updateURLQueries(); this.updateURLQueries();
}, },
addMetaquery( data ){ addMetaquery( data ){
if ( data && data.collection_id ){ if ( data && data.collection_id ){
this.$store.dispatch('search/add_metaquery', data ); store.dispatch('search/addMetaquery', data );
} }
this.updateURLQueries(); this.updateURLQueries();
}, },
addTaxquery( data ){ addTaxquery( data ){
if ( data && data.collection_id ){ if ( data && data.collection_id ){
this.$store.dispatch('search/add_taxquery', data ); store.dispatch('search/addTaxquery', data );
} }
this.updateURLQueries(); this.updateURLQueries();
}, },
@ -40,7 +39,7 @@ export default {
if (filterTag.argType !== 'postin') { if (filterTag.argType !== 'postin') {
if (filterTag.taxonomy) { if (filterTag.taxonomy) {
this.$store.dispatch('search/remove_taxquery', { store.dispatch('search/removeTaxQuery', {
filterId: filterTag.filterId, filterId: filterTag.filterId,
label: filterTag.singleLabel ? filterTag.singleLabel : filterTag.label, label: filterTag.singleLabel ? filterTag.singleLabel : filterTag.label,
isMultiValue: filterTag.singleLabel ? false : true, isMultiValue: filterTag.singleLabel ? false : true,
@ -48,7 +47,7 @@ export default {
value: filterTag.value value: filterTag.value
}); });
} else { } else {
this.$store.dispatch('search/remove_metaquery', { store.dispatch('search/removeMetaQuery', {
filterId: filterTag.filterId, filterId: filterTag.filterId,
label: filterTag.singleLabel ? filterTag.singleLabel : filterTag.label, label: filterTag.singleLabel ? filterTag.singleLabel : filterTag.label,
isMultiValue: filterTag.singleLabel ? false : true, isMultiValue: filterTag.singleLabel ? false : true,
@ -57,50 +56,50 @@ export default {
}); });
} }
} else { } else {
this.$store.dispatch('search/remove_postin'); store.dispatch('search/removePostIn');
} }
this.$store.dispatch('search/removeFilterTag', filterTag); store.dispatch('search/removeFilterTag', filterTag);
} }
this.updateURLQueries(); this.updateURLQueries();
}, },
addFetchOnly( metadatum, ignorePrefs, metadatumIDs ) { addFetchOnly( metadatum, ignorePrefs, metadatumIDs ) {
this.$store.dispatch('search/add_fetch_only', metadatum ); store.dispatch('search/addFetchOnly', metadatum );
this.$store.dispatch('search/add_fetch_only_meta', metadatumIDs); store.dispatch('search/addFetchOnlyMeta', metadatumIDs);
this.updateURLQueries(); this.updateURLQueries();
if (!ignorePrefs) { if (!ignorePrefs) {
let prefsFetchOnly = this.collectionId ? `fetch_only_${this.collectionId}` : 'fetch_only'; let prefsFetchOnly = this.collectionId ? `fetch_only_${this.collectionId}` : 'fetch_only';
let prefsFetchOnlyMeta = this.collectionId ? `fetch_only_meta_${this.collectionId}` : 'fetch_only_meta'; let prefsFetchOnlyMeta = this.collectionId ? `fetch_only_meta_${this.collectionId}` : 'fetch_only_meta';
if (this.$userPrefs.get(prefsFetchOnly) != metadatum) if (userPrefs.get(prefsFetchOnly) != metadatum)
this.$userPrefs.set(prefsFetchOnly, metadatum); userPrefs.set(prefsFetchOnly, metadatum);
if (this.$userPrefs.get(prefsFetchOnlyMeta) != metadatumIDs) if (userPrefs.get(prefsFetchOnlyMeta) != metadatumIDs)
this.$userPrefs.set(prefsFetchOnlyMeta, metadatumIDs); userPrefs.set(prefsFetchOnlyMeta, metadatumIDs);
} }
}, },
cleanFetchOnly() { cleanFetchOnly() {
this.$store.dispatch('search/cleanFetchOnly'); store.dispatch('search/cleanFetchOnly');
}, },
removeFetchOnlyMeta( metadatum ){ removeFetchOnlyMeta( metadatum ){
this.$store.dispatch('search/remove_fetch_only_meta', metadatum ); store.dispatch('search/removeFetchOnlyMeta', metadatum );
this.updateURLQueries(); this.updateURLQueries();
}, },
setPage(page) { setPage(page) {
this.$store.dispatch('search/setPage', page); store.dispatch('search/setPage', page);
this.updateURLQueries(); this.updateURLQueries();
}, },
resetPageOnStore() { resetPageOnStore() {
this.$store.dispatch('search/setPage', 1); store.dispatch('search/setPage', 1);
}, },
setItemsPerPage(itemsPerPage, shouldNotUpdatePrefs) { setItemsPerPage(itemsPerPage, shouldNotUpdatePrefs) {
this.$store.dispatch('search/setItemsPerPage', itemsPerPage); store.dispatch('search/setItemsPerPage', itemsPerPage);
this.updateURLQueries(); this.updateURLQueries();
if (shouldNotUpdatePrefs == undefined || shouldNotUpdatePrefs == false) { if (shouldNotUpdatePrefs == undefined || shouldNotUpdatePrefs == false) {
let prefsPerPage = this.collectionId != undefined ? 'items_per_page_' + this.collectionId : 'items_per_page'; let prefsPerPage = this.collectionId != undefined ? 'items_per_page_' + this.collectionId : 'items_per_page';
if (this.$userPrefs.get(prefsPerPage) != itemsPerPage) { if (userPrefs.get(prefsPerPage) != itemsPerPage) {
this.$userPrefs.set(prefsPerPage, itemsPerPage) userPrefs.set(prefsPerPage, itemsPerPage)
.catch(() => {}); .catch(() => {});
} }
} }
@ -109,77 +108,76 @@ export default {
let prefsOrderBy = this.collectionId != undefined ? 'order_by_' + this.collectionId : 'order_by'; let prefsOrderBy = this.collectionId != undefined ? 'order_by_' + this.collectionId : 'order_by';
if (orderBy.metakey) { if (orderBy.metakey) {
if (!this.$userPrefs.get(prefsOrderBy) || orderBy.metakey != this.$userPrefs.get(prefsOrderBy).metakey) if (!userPrefs.get(prefsOrderBy) || orderBy.metakey != userPrefs.get(prefsOrderBy).metakey)
this.$userPrefs.set(prefsOrderBy, orderBy).catch(() => {}); userPrefs.set(prefsOrderBy, orderBy).catch(() => {});
} else { } else {
if (orderBy != this.$userPrefs.get(prefsOrderBy)) if (orderBy != userPrefs.get(prefsOrderBy))
this.$userPrefs.set(prefsOrderBy, orderBy).catch(() => {}); userPrefs.set(prefsOrderBy, orderBy).catch(() => {});
} }
this.$store.dispatch('search/setOrderBy', orderBy); store.dispatch('search/setOrderBy', orderBy);
this.updateURLQueries(); this.updateURLQueries();
}, },
setOrder(order) { setOrder(order) {
let prefsOrder = this.collectionId != undefined ? 'order_' + this.collectionId : 'order'; let prefsOrder = this.collectionId != undefined ? 'order_' + this.collectionId : 'order';
if (this.$userPrefs.get(prefsOrder) != order) { if (userPrefs.get(prefsOrder) != order) {
this.$userPrefs.set(prefsOrder, order) userPrefs.set(prefsOrder, order)
.catch(() => {}); .catch(() => {});
} }
this.$store.dispatch('search/setOrder', order); store.dispatch('search/setOrder', order);
this.updateURLQueries(); this.updateURLQueries();
}, },
setStatus(status) { setStatus(status) {
this.$store.dispatch('search/setStatus', status); store.dispatch('search/setStatus', status);
this.updateURLQueries(); this.updateURLQueries();
}, },
setTotalItems(totalItems) { setTotalItems(totalItems) {
this.$store.dispatch('search/setTotalItems', totalItems); store.dispatch('search/setTotalItems', totalItems);
}, },
setSentenceMode(sentenceMode) { setSentenceMode(sentenceMode) {
this.$store.dispatch('search/setSentenceMode', sentenceMode); store.dispatch('search/setSentenceMode', sentenceMode);
}, },
setSearchQuery(searchQuery) { setSearchQuery(searchQuery) {
this.$store.dispatch('search/setSearchQuery', searchQuery); store.dispatch('search/setSearchQuery', searchQuery);
this.updateURLQueries(); this.updateURLQueries();
}, },
setViewMode(viewMode) { setViewMode(viewMode) {
this.$store.dispatch('search/setViewMode', viewMode); store.dispatch('search/setViewMode', viewMode);
this.updateURLQueries(); this.updateURLQueries();
let prefsViewMode = this.collectionId != undefined ? 'view_mode_' + this.collectionId : 'view_mode'; let prefsViewMode = this.collectionId != undefined ? 'view_mode_' + this.collectionId : 'view_mode';
if(this.$userPrefs.get(prefsViewMode) != viewMode) { if(userPrefs.get(prefsViewMode) != viewMode) {
this.$userPrefs.set(prefsViewMode, viewMode) userPrefs.set(prefsViewMode, viewMode)
.catch(() => {}); .catch(() => {});
} }
}, },
setAdminViewMode(adminViewMode) { setAdminViewMode(adminViewMode) {
console.log('setAdminViewMode', adminViewMode); store.dispatch('search/setAdminViewMode', adminViewMode);
this.$store.dispatch('search/setAdminViewMode', adminViewMode);
this.updateURLQueries(); this.updateURLQueries();
let prefsAdminViewMode = this.collectionId != undefined ? 'admin_view_mode_' + this.collectionId : 'admin_view_mode'; let prefsAdminViewMode = this.collectionId != undefined ? 'admin_view_mode_' + this.collectionId : 'admin_view_mode';
if (this.$userPrefs.get(prefsAdminViewMode) != adminViewMode) { if (userPrefs.get(prefsAdminViewMode) != adminViewMode) {
this.$userPrefs.set(prefsAdminViewMode, adminViewMode) userPrefs.set(prefsAdminViewMode, adminViewMode)
.catch(() => { }); .catch(() => { });
} }
}, },
setInitialViewMode(viewMode) { setInitialViewMode(viewMode) {
this.$store.dispatch('search/setViewMode', viewMode); store.dispatch('search/setViewMode', viewMode);
this.updateURLQueries(); this.updateURLQueries();
}, },
setInitialAdminViewMode(adminViewMode) { setInitialAdminViewMode(adminViewMode) {
this.$store.dispatch('search/setAdminViewMode', adminViewMode); store.dispatch('search/setAdminViewMode', adminViewMode);
this.updateURLQueries(); this.updateURLQueries();
}, },
async setSelectedItemsForIframe(selectedItems, singleSelection) { async setSelectedItemsForIframe(selectedItems, singleSelection) {
if (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) { if (window.history.replaceState) {
let searchParams = new URLSearchParams(window.location.search); 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; 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 } }, '') window.history.replaceState({ ...window.history.state, ...{ path: newurl } }, '')
} }
}, },
cleanSelectedItems() { cleanSelectedItems() {
this.$store.dispatch('search/cleanSelectedItems'); store.dispatch('search/cleanSelectedItems');
}, },
filterBySelectedItems(selectedItems) { filterBySelectedItems(selectedItems) {
if ( app.config.globalProperties.$route.name ) { if ( route.name ) {
this.$router.replace({ name: app.config.globalProperties.$route.name, query: {} }); router.replace({ query: {} });
this.$router.replace({ name: app.config.globalProperties.$route.name, query: { postin: selectedItems } }); router.replace({ query: { postin: selectedItems } });
} else { } else {
this.$router.replace({ path: '', query: {} }); router.replace({ query: {} });
this.$router.replace({ path: '', query: { postin: selectedItems } }); router.replace({ query: { postin: selectedItems } });
} }
}, },
highlightsItem(itemId) { highlightsItem(itemId) {
this.$store.dispatch('search/highlightsItem', itemId); store.dispatch('search/highlightsItem', itemId);
this.updateURLQueries(); this.updateURLQueries();
}, },
updateURLQueries() { async updateURLQueries() {
if ( app.config.globalProperties.$route.name ) { const newQueries = store.getters['search/getPostQuery'];
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 { await router.replace({ query: {} });
this.$router.replace({ path: this.$route.path, query: {} }); await router.replace({ query: newQueries });
this.$router.replace({ path: this.$route.path, query: this.$store.getters['search/getPostQuery'] });
}
}, },
updateStoreFromURL() { updateStoreFromURL() {
this.$store.dispatch('search/set_postquery', this.$route.query); store.dispatch('search/setPostQuery', route.query);
}, },
loadItems() { loadItems() {
console.log('loadItems')
console.log(JSON.parse(JSON.stringify(store.getters['search/getPostQuery'])))
// Forces fetch_only to be filled before any search happens // 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); app.config.globalProperties.$eventBusSearchEmitter.emit( 'isLoadingItems', true);
// Cancels previous Request // Cancels previous Request
if (this.searchCancel != undefined) if (this.searchCancel != undefined)
this.searchCancel.cancel('Item search Canceled.'); this.searchCancel.cancel('Item search Canceled.');
console.log('fetching')
this.$store.dispatch('collection/fetchItems', { store.dispatch('collection/fetchItems', {
'collectionId': this.collectionId, 'collectionId': this.collectionId,
'isOnTheme': app.config.globalProperties.$route.meta && app.config.globalProperties.$route.meta.isOnTheme, 'isOnTheme': route.meta && route.meta.isOnTheme,
'termId': this.termId, 'termId': this.termId,
'taxonomy': this.taxonomy 'taxonomy': this.taxonomy
}).then((resp) => { }).then((resp) => {
@ -267,9 +265,9 @@ export default {
this.taxonomy = taxonomy; this.taxonomy = taxonomy;
}, },
clearAllFilters() { clearAllFilters() {
this.$store.dispatch('search/cleanFilterTags'); store.dispatch('search/cleanFilterTags');
this.$store.dispatch('search/cleanMetaQueries', { keepCollections: true }); store.dispatch('search/cleanMetaQueries', { keepCollections: true });
this.$store.dispatch('search/cleanTaxQueries'); store.dispatch('search/cleanTaxQueries');
this.updateURLQueries(); 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 // Sets term query in case it's on a term items page
if (termId != undefined && taxonomy != undefined) { if (termId != undefined && taxonomy != undefined) {
dispatch('search/add_taxquery', { dispatch('search/addTaxquery', {
taxonomy: taxonomy, taxonomy: taxonomy,
terms:[ termId ], terms:[ termId ],
compare: 'IN' compare: 'IN'
@ -45,15 +45,15 @@ export const fetchItems = ({ rootGetters, dispatch, commit }, { collectionId, is
postQueries.status = 'publish,private,draft'; postQueries.status = 'publish,private,draft';
dispatch('search/setStatus', 'publish,private,draft', { root: true }); dispatch('search/setStatus', 'publish,private,draft', { root: true });
} }
// Guarantees at least status is passed in case none is found // Guarantees at least status is passed in case none is found
if (postQueries.fetch_only == '') if (postQueries.fetch_only == '')
dispatch('search/add_fetch_only', 'status', { root: true }); dispatch('search/addFetchOnly', 'status', { root: true });
else else
postQueries.fetch_only += ',status'; postQueries.fetch_only += ',status';
if (postQueries.fetch_only_meta == '') if (postQueries.fetch_only_meta == '')
dispatch('search/add_fetch_only_meta', '', { root: true }); dispatch('search/addFetchOnlyMeta', '', { root: true });
let query = qs.stringify(postQueries); let query = qs.stringify(postQueries);
@ -97,7 +97,7 @@ export const fetchItems = ({ rootGetters, dispatch, commit }, { collectionId, is
hasFiltered: hasFiltered, hasFiltered: hasFiltered,
itemsPerPage: res.headers['x-wp-itemperpage'] }); 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/setTotalItems', Number(res.headers['x-wp-total']), { root: true } );
dispatch('search/setTotalPages', res.headers['x-wp-totalpages'], { root: true } ); dispatch('search/setTotalPages', res.headers['x-wp-totalpages'], { root: true } );
dispatch('search/setItemsPerPage', res.headers['x-wp-itemsperpage'], { root: true } ); dispatch('search/setItemsPerPage', res.headers['x-wp-itemsperpage'], { root: true } );

View File

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

View File

@ -816,142 +816,137 @@
if (this.$route.name == 'CollectionItemsPage' || this.$route.name == 'ItemsPage') 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) ); 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 // Items Per Page
if (this.$route.name == null || this.$route.name == undefined || this.$route.name == 'CollectionItemsPage' || this.$route.name == 'ItemsPage') { 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');
// Items Per Page let perPageValue = this.$userPrefs.get(perPageKey);
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) if (perPageValue)
this.$route.query.perpage = perPageValue; this.$route.query.perpage = perPageValue;
else { else {
this.$route.query.perpage = 12; this.$route.query.perpage = 12;
this.$userPrefs.set(perPageKey, 12); this.$userPrefs.set(perPageKey, 12);
} }
} }
// Page
if (this.$route.query.paged == undefined || to.params.collectionId != from.params.collectionId)
this.$route.query.paged = 1;
// Order (ASC, DESC) // Page
if (this.$route.query.order == undefined || to.params.collectionId != from.params.collectionId) { if (this.$route.query.paged == undefined || to.params.collectionId != from.params.collectionId)
let orderKey = (this.collectionId != undefined ? 'order_' + this.collectionId : 'order'); this.$route.query.paged = 1;
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');
}
}
// 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') {
// 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 (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;
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);
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 { } 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'
}
// 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)
) {
// Finally, loads items even berfore facets so they won't stuck them let viewModeKey = (this.collectionId != undefined ? 'view_mode_' + this.collectionId : 'view_mode');
if (to.fullPath != from.fullPath) let viewModeValue = this.$userPrefs.get(viewModeKey);
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')); if (viewModeValue)
const newMetaQueryArray = newQueryArray.filter(queryItem => queryItem.startsWith('metaquery')); this.$route.query.view_mode = viewModeValue;
const oldTaxQueryArray = oldQueryArray.filter(queryItem => queryItem.startsWith('taxquery')); else {
const newTaxQueryArray = newQueryArray.filter(queryItem => queryItem.startsWith('taxquery')); this.$route.query.view_mode = 'table';
const oldStatusArray = oldQueryArray.filter(queryItem => queryItem.startsWith('status')); this.$userPrefs.set(viewModeKey, 'table');
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);
} }
} }
// 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 deep: true
}, },

View File

@ -936,9 +936,9 @@
// Advanced Search // Advanced Search
if (this.$route.query && this.$route.query.advancedSearch){ 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 { } 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 // Finally, loads items even berfore facets so they won't stuck them