diff --git a/src/classes/entities/class-tainacan-item.php b/src/classes/entities/class-tainacan-item.php index 79c14d659..a79253022 100644 --- a/src/classes/entities/class-tainacan-item.php +++ b/src/classes/entities/class-tainacan-item.php @@ -132,7 +132,8 @@ class Item extends Entity { if( in_array('tainacan-small', $sizes ) ) { $tmp_src = wp_get_attachment_image_src( $this->get__thumbnail_id(), 'tainacan-small' ); - $blurhash = $this->get_image_blurhash($tmp_src[0], $tmp_src[1], $tmp_src[2]); + $file_name = get_attached_file( $this->get__thumbnail_id() ); + $blurhash = $this->get_image_blurhash($file_name, $tmp_src[1], $tmp_src[2]); } foreach ( $sizes as $size ) { diff --git a/src/classes/repositories/class-tainacan-logs.php b/src/classes/repositories/class-tainacan-logs.php index 075e0f973..3b0101790 100644 --- a/src/classes/repositories/class-tainacan-logs.php +++ b/src/classes/repositories/class-tainacan-logs.php @@ -740,7 +740,9 @@ class Logs extends Repository { } private function insert_item_metadata( Entities\Item_Metadata_Entity $entity ) { - + if($this->current_diff == false) { + return; + } $log = new Entities\Log(); $item_id = $entity->get_item()->get_id(); diff --git a/src/readme.txt b/src/readme.txt index 0ec08b332..e51c9e10a 100644 --- a/src/readme.txt +++ b/src/readme.txt @@ -4,7 +4,7 @@ Tags: museums, libraries, archives, GLAM, collections, repository Requires at least: 5.0 Tested up to: 5.6 Requires PHP: 5.6 -Stable tag: 0.18.1 +Stable tag: 0.18.2 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-3.0.html diff --git a/src/tainacan.php b/src/tainacan.php index 33407213c..e5aaada70 100644 --- a/src/tainacan.php +++ b/src/tainacan.php @@ -4,13 +4,13 @@ Plugin Name: Tainacan Plugin URI: https://tainacan.org/ Description: Open source, powerful and flexible repository platform for WordPress. Manage and publish you digital collections as easily as publishing a post to your blog, while having all the tools of a professional repository platform. Author: Tainacan.org -Version: 0.18.1 +Version: 0.18.2 Text Domain: tainacan License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-3.0.html */ -const TAINACAN_VERSION = '0.18.1'; +const TAINACAN_VERSION = '0.18.2'; defined( 'ABSPATH' ) or die( 'No script kiddies please!' ); $TAINACAN_BASE_URL = plugins_url('', __FILE__); diff --git a/src/views/admin/components/filter-types/checkbox/Checkbox.vue b/src/views/admin/components/filter-types/checkbox/Checkbox.vue index 85b2fc69d..31920063a 100644 --- a/src/views/admin/components/filter-types/checkbox/Checkbox.vue +++ b/src/views/admin/components/filter-types/checkbox/Checkbox.vue @@ -78,21 +78,22 @@ if (!isEqual) this.onSelect(); }, - 'query'() { - if (!this.isUsingElasticSearch) - this.loadOptions(); - }, facetsFromItemSearch: { handler() { if (this.isUsingElasticSearch) this.loadOptions(); }, immediate: true - } + }, }, mounted() { if (!this.isUsingElasticSearch && !this.filtersAsModal) this.loadOptions(); + + this.$eventBusSearch.$on('has-to-reload-facets', (shouldReload) => { + if ( !this.isUsingElasticSearch && shouldReload ) + this.loadOptions(); + }); }, methods: { loadOptions() { diff --git a/src/views/admin/components/filter-types/numeric-interval/class-tainacan-numeric-interval.php b/src/views/admin/components/filter-types/numeric-interval/class-tainacan-numeric-interval.php index eb34d813f..969cee614 100644 --- a/src/views/admin/components/filter-types/numeric-interval/class-tainacan-numeric-interval.php +++ b/src/views/admin/components/filter-types/numeric-interval/class-tainacan-numeric-interval.php @@ -67,7 +67,7 @@ class Numeric_Interval extends Filter_Type { return [ 'step' => [ 'title' => __( 'Step', 'tainacan' ), - 'description' => __( 'The amount to be increased or decreased when clicking on filter control buttons. This alo defines whether the input accepts decimal numbers.', 'tainacan' ), + 'description' => __( 'The amount to be increased or decreased when clicking on the filter control buttons. This also defines whether the input accepts decimal numbers.', 'tainacan' ), ], 'custom' => ['title' => __('Custom interval','tainacan')], ]; diff --git a/src/views/admin/components/filter-types/numeric/class-tainacan-numeric.php b/src/views/admin/components/filter-types/numeric/class-tainacan-numeric.php index 3c94a5ed2..0eaa9e36d 100644 --- a/src/views/admin/components/filter-types/numeric/class-tainacan-numeric.php +++ b/src/views/admin/components/filter-types/numeric/class-tainacan-numeric.php @@ -76,7 +76,7 @@ class Numeric extends Filter_Type { return [ 'step' => [ 'title' => __( 'Step', 'tainacan' ), - 'description' => __( 'The amount to be increased or decreased when clicking on filter control buttons.', 'tainacan' ), + 'description' => __( 'The amount to be increased or decreased when clicking on the filter control buttons. This also defines whether the input accepts decimal numbers.', 'tainacan' ), ] ]; } diff --git a/src/views/admin/components/filter-types/selectbox/Selectbox.vue b/src/views/admin/components/filter-types/selectbox/Selectbox.vue index 0824b5bb6..5c1d62867 100644 --- a/src/views/admin/components/filter-types/selectbox/Selectbox.vue +++ b/src/views/admin/components/filter-types/selectbox/Selectbox.vue @@ -37,10 +37,6 @@ } }, watch: { - 'query'() { - if (!this.isUsingElasticSearch) - this.loadOptions(); - }, facetsFromItemSearch: { handler() { if (this.isUsingElasticSearch) @@ -49,9 +45,14 @@ immediate: true } }, - mounted(){ + mounted() { if (!this.isUsingElasticSearch) this.loadOptions(); + + this.$eventBusSearch.$on('has-to-reload-facets', (shouldReload) => { + if ( !this.isUsingElasticSearch && shouldReload ) + this.loadOptions(); + }); }, methods: { loadOptions(){ diff --git a/src/views/admin/components/filter-types/taxonomy/Checkbox.vue b/src/views/admin/components/filter-types/taxonomy/Checkbox.vue index 2464af055..dba2b15eb 100644 --- a/src/views/admin/components/filter-types/taxonomy/Checkbox.vue +++ b/src/views/admin/components/filter-types/taxonomy/Checkbox.vue @@ -107,13 +107,10 @@ }, isLoadingItems: { handler() { - if (!this.filtersAsModal) - this.isLoadingOptions = this.isLoadingItems; + if (!this.filtersAsModal && this.isUsingElasticSearch) + this.isLoadingOptions = this.isLoadingItems; }, immediate: true - }, - 'query'() { - this.loadOptions(); } }, created() { @@ -129,6 +126,11 @@ mounted(){ if (!this.filtersAsModal) this.loadOptions(); + + this.$eventBusSearch.$on('has-to-reload-facets', (shouldReload) => { + if ( !this.isUsingElasticSearch && shouldReload ) + this.loadOptions(); + }); }, beforeDestroy() { diff --git a/src/views/admin/components/metadata-types/numeric/class-tainacan-numeric.php b/src/views/admin/components/metadata-types/numeric/class-tainacan-numeric.php index 4ad0584e7..5998dca1d 100644 --- a/src/views/admin/components/metadata-types/numeric/class-tainacan-numeric.php +++ b/src/views/admin/components/metadata-types/numeric/class-tainacan-numeric.php @@ -33,7 +33,7 @@ class Numeric extends Metadata_Type { return [ 'step' => [ 'title' => __( 'Step', 'tainacan' ), - 'description' => __( 'The amount to be increased or decreased when clicking on filter control buttons.', 'tainacan' ), + 'description' => __( 'The amount to be increased or decreased when clicking on the metadatum control buttons. This also defines whether the input accepts decimal numbers.', 'tainacan' ), ] ]; } diff --git a/src/views/admin/components/metadata-types/tainacan-form-item.vue b/src/views/admin/components/metadata-types/tainacan-form-item.vue index ee73690cf..edacb083d 100644 --- a/src/views/admin/components/metadata-types/tainacan-form-item.vue +++ b/src/views/admin/components/metadata-types/tainacan-form-item.vue @@ -176,7 +176,7 @@ if (this.metadatumComponent == 'tainacan-compound') return; - if (this.itemMetadatum.value !== null) { + if (this.itemMetadatum.value !== null && this.itemMetadatum.value !== false) { // This routine avoids calling the API if the value did not changed switch(this.itemMetadatum.value.constructor.name) { diff --git a/src/views/admin/components/metadata-types/taxonomy/Taxonomy.vue b/src/views/admin/components/metadata-types/taxonomy/Taxonomy.vue index d78487247..5f9343bbf 100644 --- a/src/views/admin/components/metadata-types/taxonomy/Taxonomy.vue +++ b/src/views/admin/components/metadata-types/taxonomy/Taxonomy.vue @@ -143,7 +143,7 @@ let val = this.valueComponent; - if (!Array.isArray(val) && this.itemMetadatum.metadatum.multiple === 'no') { + if ((!Array.isArray(val) || val.length == 0) && this.itemMetadatum.metadatum.multiple === 'no') { axios.patch(`/item/${this.itemMetadatum.item.id}/metadata/${this.itemMetadatum.metadatum.id}`, { values: term.id, }).then(() => { diff --git a/src/views/admin/js/event-bus-search.js b/src/views/admin/js/event-bus-search.js index 362c016f7..ae21f3e83 100644 --- a/src/views/admin/js/event-bus-search.js +++ b/src/views/admin/js/event-bus-search.js @@ -160,7 +160,28 @@ export default { } else { this.$store.dispatch('search/set_postquery', this.$route.query); } + + // 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')); + + if ( + JSON.stringify(oldMetaQueryArray) != JSON.stringify(newMetaQueryArray) || + JSON.stringify(oldTaxQueryArray) != JSON.stringify(newTaxQueryArray) + ) { + this.$emit('has-to-reload-facets', true); + } + + // Finally, loads items if (to.fullPath != from.fullPath) { this.loadItems(to); } diff --git a/src/views/admin/js/filter-types-mixin.js b/src/views/admin/js/filter-types-mixin.js index 6746066f4..ba2dc2574 100644 --- a/src/views/admin/js/filter-types-mixin.js +++ b/src/views/admin/js/filter-types-mixin.js @@ -49,7 +49,8 @@ export const dynamicFilterTypeMixin = { watch: { isLoadingItems: { handler() { - this.isLoadingOptions = this.isLoadingItems; + if (this.isUsingElasticSearch ) + this.isLoadingOptions = this.isLoadingItems; }, immediate: true } diff --git a/src/views/admin/scss/_view-mode-cards.scss b/src/views/admin/scss/_view-mode-cards.scss index 35857e172..7865fd6cb 100644 --- a/src/views/admin/scss/_view-mode-cards.scss +++ b/src/views/admin/scss/_view-mode-cards.scss @@ -87,7 +87,7 @@ &:hover .actions-area { visibility: visible; opacity: 1.0; - top: -7px; + top: calc(-1 * 0.5em - var(--tainacan-container-padding)); a { opacity: 1; diff --git a/src/views/admin/scss/_view-mode-list.scss b/src/views/admin/scss/_view-mode-list.scss index ea0a04cd5..b34cf2144 100644 --- a/src/views/admin/scss/_view-mode-list.scss +++ b/src/views/admin/scss/_view-mode-list.scss @@ -55,7 +55,7 @@ &:hover .actions-area { visibility: visible; opacity: 1.0; - top: -7px; + top: calc(-1 * 0.5em - var(--tainacan-container-padding)); a { opacity: 1; diff --git a/src/views/admin/scss/_view-mode-records.scss b/src/views/admin/scss/_view-mode-records.scss index 2f57e3f33..85328cd8f 100644 --- a/src/views/admin/scss/_view-mode-records.scss +++ b/src/views/admin/scss/_view-mode-records.scss @@ -61,7 +61,7 @@ &:hover .actions-area { visibility: visible; opacity: 1.0; - top: -7px; + top: calc(-1 * 0.5em - var(--tainacan-container-padding)); a { opacity: 1;