From 161fc5cc9f1267dbea4078602a902f6d25eb26e0 Mon Sep 17 00:00:00 2001
From: mateuswetah
Date: Fri, 31 May 2024 09:40:38 -0300
Subject: [PATCH 01/39] Begins implementation of enabled comparators for date
filter. #886.
---
.../edition/filter-edition-form.vue | 2 +
.../components/filter-types/date/FormDate.vue | 80 +++++++++++++
.../filter-types/date/TainacanFilterDate.vue | 113 ++++++++----------
.../filter-types/date/class-tainacan-date.php | 33 +++++
4 files changed, 163 insertions(+), 65 deletions(-)
create mode 100644 src/views/admin/components/filter-types/date/FormDate.vue
diff --git a/src/views/admin/components/edition/filter-edition-form.vue b/src/views/admin/components/edition/filter-edition-form.vue
index e3c609502..b13491c9f 100644
--- a/src/views/admin/components/edition/filter-edition-form.vue
+++ b/src/views/admin/components/edition/filter-edition-form.vue
@@ -249,6 +249,7 @@ import { nextTick } from 'vue';
import { mapActions } from 'vuex';
import { formHooks } from "../../js/mixins";
+import FormFilterDate from '../filter-types/date/FormDate.vue';
import FormFilterNumeric from '../filter-types/numeric/FormNumeric.vue';
import FormFilterNumericInterval from '../filter-types/numeric-interval/FormNumericInterval.vue';
import FormFilterNumericListInterval from '../filter-types/numeric-list-interval/FormNumericListInterval.vue';
@@ -256,6 +257,7 @@ import FormFilterNumericListInterval from '../filter-types/numeric-list-interval
export default {
name: 'FilterEditionForm',
components: {
+ 'tainacan-filter-form-date': FormFilterDate,
'tainacan-filter-form-numeric': FormFilterNumeric,
'tainacan-filter-form-numeric-interval': FormFilterNumericInterval,
'tainacan-filter-form-numeric-list-interval': FormFilterNumericListInterval
diff --git a/src/views/admin/components/filter-types/date/FormDate.vue b/src/views/admin/components/filter-types/date/FormDate.vue
new file mode 100644
index 000000000..feab75549
--- /dev/null
+++ b/src/views/admin/components/filter-types/date/FormDate.vue
@@ -0,0 +1,80 @@
+
+
+
+
+ {{ $i18n.getHelperTitle('tainacan-filter-date', 'comparators') }} *
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/views/admin/components/filter-types/date/TainacanFilterDate.vue b/src/views/admin/components/filter-types/date/TainacanFilterDate.vue
index 5c6e30649..749dc0fe9 100644
--- a/src/views/admin/components/filter-types/date/TainacanFilterDate.vue
+++ b/src/views/admin/components/filter-types/date/TainacanFilterDate.vue
@@ -10,66 +10,25 @@
:aria-label="$i18n.get('label_comparator')"
class="button is-white">
-
+
-
- = {{ $i18n.get('is_equal_to') }}
-
-
- ≠ {{ $i18n.get('is_not_equal_to') }}
-
-
- > {{ $i18n.get('after') }}
-
-
- ≥ {{ $i18n.get('after_or_on_day') }}
-
-
- < {{ $i18n.get('before') }}
-
-
- ≤ {{ $i18n.get('before_or_on_day') }}
-
+
+
+
-
, >=, <, <=
}
},
computed: {
yearsOnlyValue() {
return this.value && typeof this.value.getUTCFullYear === 'function' ? this.value.getUTCFullYear() : null
- },
- comparatorSymbol() {
- switch(this.comparator) {
- case '=': return '=';
- case '!=': return '≠';
- case '>': return '>';
- case '>=': return '≥';
- case '<': return '<';
- case '<=': return '≤';
- default: return '';
- }
}
},
watch: {
@@ -156,6 +105,40 @@
deep: true,
},
},
+ created() {
+ this.comparatorsObject = {
+ '=': {
+ symbol: '=',
+ label: this.$i18n.get('is_equal_to'),
+ enabled: this.filterTypeOptions.comparators.indexOf('=') < 0 ? 'no' : 'yes'
+ },
+ '!=': {
+ symbol: '≠',
+ label: this.$i18n.get('is_not_equal_to'),
+ enabled: this.filterTypeOptions.comparators.indexOf('!=') < 0 ? 'no' : 'yes'
+ },
+ '>': {
+ symbol: '>',
+ label: this.$i18n.get('after'),
+ enabled: this.filterTypeOptions.comparators.indexOf('>') < 0 ? 'no' : 'yes'
+ },
+ '>=': {
+ symbol: '≥',
+ label: this.$i18n.get('after_or_on_day'),
+ enabled: this.filterTypeOptions.comparators.indexOf('>=') < 0 ? 'no' : 'yes'
+ },
+ '<': {
+ symbol: '<',
+ label: this.$i18n.get('before'),
+ enabled: this.filterTypeOptions.comparators.indexOf('<') < 0 ? 'no' : 'yes'
+ },
+ '<=': {
+ symbol: '≤',
+ label: this.$i18n.get('before_or_on_day'),
+ enabled: this.filterTypeOptions.comparators.indexOf('<=') < 0 ? 'no' : 'yes'
+ },
+ };
+ },
mounted() {
this.updateSelectedValues();
},
diff --git a/src/views/admin/components/filter-types/date/class-tainacan-date.php b/src/views/admin/components/filter-types/date/class-tainacan-date.php
index 7c76022d6..255fc6988 100644
--- a/src/views/admin/components/filter-types/date/class-tainacan-date.php
+++ b/src/views/admin/components/filter-types/date/class-tainacan-date.php
@@ -13,7 +13,11 @@ class Date extends Filter_Type {
$this->set_name( __('Date', 'tainacan') );
$this->set_supported_types(['date']);
$this->set_component('tainacan-filter-date');
+ $this->set_form_component('tainacan-filter-form-date');
$this->set_use_max_options(false);
+ $this->set_default_options([
+ 'comparators' => [ '=', '!=', '>', '>=', '<', '<=' ]
+ ]);
$this->set_preview_template('
@@ -57,6 +61,35 @@ class Date extends Filter_Type {
');
}
+
+ /**
+ * @inheritdoc
+ */
+ public function get_form_labels(){
+ return [
+ 'comparators' => [
+ 'title' => __( 'Enabled comparators', 'tainacan' ),
+ 'description' => __( 'A list of comparators to be available in the filter, such as equal, greater than, smaller than, etc.', 'tainacan' ),
+ ]
+ ];
+ }
+
+ /**
+ * @param \Tainacan\Entities\Filter $filter
+ * @return array|bool true if is validate or array if has error
+ */
+ public function validate_options(\Tainacan\Entities\Filter $filter) {
+ if ( !in_array($filter->get_status(), apply_filters('tainacan-status-require-validation', ['publish','future','private'])) )
+ return true;
+
+ if ( empty( $this->get_option('comparators') ) )
+ return [
+ 'comparators' => __('"Comparators" array is required', 'tainacan')
+ ];
+
+ return true;
+ }
+
}
class Date_Helper {
From 685b61b0b110f7601b73757782c6683d22054aa1 Mon Sep 17 00:00:00 2001
From: mateuswetah
Date: Mon, 3 Jun 2024 11:50:50 -0300
Subject: [PATCH 02/39] Creates first version of dates intersection filter.
#887.
---
.../edition/filter-edition-form.vue | 4 +-
.../FormDatesIntersection.vue | 98 +++++++++
.../TainacanFilterDatesIntersection.vue | 187 ++++++++++++++++++
.../class-tainacan-dates-intersection.php | 119 +++++++++++
.../class-tainacan-filter-type-helper.php | 1 +
.../filter-types/tainacan-filter-item.vue | 1 +
src/views/tainacan-i18n.php | 1 +
7 files changed, 410 insertions(+), 1 deletion(-)
create mode 100644 src/views/admin/components/filter-types/dates-intersection/FormDatesIntersection.vue
create mode 100644 src/views/admin/components/filter-types/dates-intersection/TainacanFilterDatesIntersection.vue
create mode 100644 src/views/admin/components/filter-types/dates-intersection/class-tainacan-dates-intersection.php
diff --git a/src/views/admin/components/edition/filter-edition-form.vue b/src/views/admin/components/edition/filter-edition-form.vue
index e3c609502..3f0e845ab 100644
--- a/src/views/admin/components/edition/filter-edition-form.vue
+++ b/src/views/admin/components/edition/filter-edition-form.vue
@@ -252,13 +252,15 @@ import { formHooks } from "../../js/mixins";
import FormFilterNumeric from '../filter-types/numeric/FormNumeric.vue';
import FormFilterNumericInterval from '../filter-types/numeric-interval/FormNumericInterval.vue';
import FormFilterNumericListInterval from '../filter-types/numeric-list-interval/FormNumericListInterval.vue';
+import FormFilterDatesIntersection from '../filter-types/dates-intersection/FormDatesIntersection.vue';
export default {
name: 'FilterEditionForm',
components: {
'tainacan-filter-form-numeric': FormFilterNumeric,
'tainacan-filter-form-numeric-interval': FormFilterNumericInterval,
- 'tainacan-filter-form-numeric-list-interval': FormFilterNumericListInterval
+ 'tainacan-filter-form-numeric-list-interval': FormFilterNumericListInterval,
+ 'tainacan-filter-form-dates-intersection': FormFilterDatesIntersection
},
mixins: [ formHooks ],
props: {
diff --git a/src/views/admin/components/filter-types/dates-intersection/FormDatesIntersection.vue b/src/views/admin/components/filter-types/dates-intersection/FormDatesIntersection.vue
new file mode 100644
index 000000000..83ddf0de3
--- /dev/null
+++ b/src/views/admin/components/filter-types/dates-intersection/FormDatesIntersection.vue
@@ -0,0 +1,98 @@
+
+
+
+
+ {{ $i18n.getHelperTitle('tainacan-filter-dates-intersection', 'secondary_filter_metadatum_id') }} *
+
+
+
+
+ {{ $i18n.get('instruction_select_second_date_to_compare' ) }}
+
+
+ {{ option.name }}
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/views/admin/components/filter-types/dates-intersection/TainacanFilterDatesIntersection.vue b/src/views/admin/components/filter-types/dates-intersection/TainacanFilterDatesIntersection.vue
new file mode 100644
index 000000000..c2f16c362
--- /dev/null
+++ b/src/views/admin/components/filter-types/dates-intersection/TainacanFilterDatesIntersection.vue
@@ -0,0 +1,187 @@
+
+
+
{ resetPage(); validadeValues($event) }" />
+
+ {{ $i18n.get('label_until') }}
+
+
+
+
+
+
+
+
diff --git a/src/views/admin/components/filter-types/dates-intersection/class-tainacan-dates-intersection.php b/src/views/admin/components/filter-types/dates-intersection/class-tainacan-dates-intersection.php
new file mode 100644
index 000000000..cf3162042
--- /dev/null
+++ b/src/views/admin/components/filter-types/dates-intersection/class-tainacan-dates-intersection.php
@@ -0,0 +1,119 @@
+set_name( __('Dates Intersection', 'tainacan') );
+ $this->set_supported_types(['date']);
+ $this->set_component('tainacan-filter-dates-intersection');
+ $this->set_form_component('tainacan-filter-form-dates-intersection');
+ $this->set_default_options([
+ 'secondary_filter_metadatum_id' => '',
+ 'secondary_filter_metadatum_name' => '',
+ ]);
+ $this->set_use_max_options(false);
+ $this->set_preview_template('
+
+ ');
+
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function get_form_labels(){
+ return [
+ 'secondary_filter_metadatum_id' => [
+ 'title' => __( 'Second date metadatum', 'tainacan' ),
+ 'description' => __( 'The other metadatum to which this filter will compare values to find if there is an intersection of dates.', 'tainacan' ),
+ ],
+ 'secondary_filter_metadatum_name' => [
+ 'title' => __( 'Second date metadatum', 'tainacan' ),
+ 'description' => __( 'Label of the other metadatum to which this filter will compare values to find if there is an intersection of dates.', 'tainacan' ),
+ ]
+ ];
+ }
+
+ /**
+ * @param \Tainacan\Entities\Filter $filter
+ * @return array|bool true if is validate or array if has error
+ */
+ public function validate_options(\Tainacan\Entities\Filter $filter) {
+ if ( !in_array($filter->get_status(), apply_filters('tainacan-status-require-validation', ['publish','future','private'])) )
+ return true;
+
+ if ( empty($this->get_option('secondary_filter_metadatum_id')) ) {
+ return [
+ 'secondary_filter_metadatum_id' => __('The secondary date metadatum is required.','tainacan')
+ ];
+ }
+
+ // Validate if the second date metadatum is a date metadatum
+
+ return true;
+ }
+
+}
+
+class Dates_Intersection_Interval_Helper {
+ use \Tainacan\Traits\Singleton_Instance;
+
+ protected function init() {
+ add_filter( 'tainacan-api-items-tainacan-filter-dates-intersection-filter-arguments', [$this, 'format_filter_arguments']);
+ }
+
+ function format_filter_arguments( $filter_arguments ) {
+ if (
+ !isset($filter_arguments['compare']) ||
+ !isset($filter_arguments['label'])
+ ) {
+ return $filter_arguments;
+ }
+
+ if (
+ is_array($filter_arguments['label']) &&
+ count($filter_arguments['label']) === 2
+ ) {
+ $filter_arguments['label'] = $filter_arguments['label'][0] . ' - ' . $filter_arguments['label'][1];
+ }
+ if (
+ isset( $filter_arguments['filter'] ) &&
+ isset( $filter_arguments['filter']['filter_type_options'] ) &&
+ isset( $filter_arguments['filter']['filter_type_options']['secondary_filter_metadatum_name'] ) &&
+ !empty( $filter_arguments['filter']['filter_type_options']['secondary_filter_metadatum_name'] )
+ ) {
+ $filter_arguments['filter']['name'] = $filter_arguments['filter']['name'] . ' - ' . $filter_arguments['filter']['filter_type_options']['secondary_filter_metadatum_name'];
+ }
+ return $filter_arguments;
+ }
+}
+Dates_Intersection_Interval_Helper::get_instance();
\ No newline at end of file
diff --git a/src/views/admin/components/filter-types/filter-type-helper/class-tainacan-filter-type-helper.php b/src/views/admin/components/filter-types/filter-type-helper/class-tainacan-filter-type-helper.php
index 594589ec6..cb4ffa3b5 100644
--- a/src/views/admin/components/filter-types/filter-type-helper/class-tainacan-filter-type-helper.php
+++ b/src/views/admin/components/filter-types/filter-type-helper/class-tainacan-filter-type-helper.php
@@ -38,6 +38,7 @@ class Filter_Type_Helper {
$this->Tainacan_Filters->register_filter_type('Tainacan\Filter_Types\Selectbox');
$this->Tainacan_Filters->register_filter_type('Tainacan\Filter_Types\Autocomplete');
$this->Tainacan_Filters->register_filter_type('Tainacan\Filter_Types\Date_Interval');
+ $this->Tainacan_Filters->register_filter_type('Tainacan\Filter_Types\Dates_Intersection');
$this->Tainacan_Filters->register_filter_type('Tainacan\Filter_Types\Numeric_Interval');
$this->Tainacan_Filters->register_filter_type('Tainacan\Filter_Types\TaxonomyTaginput');
$this->Tainacan_Filters->register_filter_type('Tainacan\Filter_Types\TaxonomyCheckbox');
diff --git a/src/views/admin/components/filter-types/tainacan-filter-item.vue b/src/views/admin/components/filter-types/tainacan-filter-item.vue
index 73479b805..bd3f4609f 100644
--- a/src/views/admin/components/filter-types/tainacan-filter-item.vue
+++ b/src/views/admin/components/filter-types/tainacan-filter-item.vue
@@ -100,6 +100,7 @@
TainacanFilterTaxonomyCheckbox: defineAsyncComponent(() => import('./taxonomy/TainacanFilterCheckbox.vue')),
TainacanFilterTaxonomyTaginput: defineAsyncComponent(() => import('./taxonomy/TainacanFilterTaginput.vue')),
TainacanFilterDateInterval: defineAsyncComponent(() => import('./date-interval/TainacanFilterDateInterval.vue')),
+ TainacanFilterDatesIntersection: defineAsyncComponent(() => import('./dates-intersection/TainacanFilterDatesIntersection.vue')),
TainacanFilterNumericInterval: defineAsyncComponent(() => import('./numeric-interval/TainacanFilterNumericInterval.vue')),
TainacanFilterNumericListInterval: defineAsyncComponent(() => import('./numeric-list-interval/TainacanFilterNumericListInterval.vue'))
},
diff --git a/src/views/tainacan-i18n.php b/src/views/tainacan-i18n.php
index c63e44a7b..4bb2101c4 100644
--- a/src/views/tainacan-i18n.php
+++ b/src/views/tainacan-i18n.php
@@ -788,6 +788,7 @@ return apply_filters( 'tainacan-i18n', [
'instruction_click_to_add_a_point' => __( 'Drag to reposition or click to insert a marker', 'tainacan' ),
'instruction_select_geocoordinate_metadatum' => __( 'Select a geocoordinate metadatum', 'tainacan' ),
'instruction_multiple_terms_insertion' => __( 'Type or paste here a list of names using a separator to create multiple terms at once.', 'tainacan' ),
+ 'instruction_select_second_date_to_compare' => __( 'Select the second date metadatum', 'tainacan' ),
// Info. Other feedback to user.
'info_items_tab_all' => __( 'Every item, except by those sent to trash.', 'tainacan' ),
From a9df08c15f746c7822a794b321117277d501772b Mon Sep 17 00:00:00 2001
From: mateuswetah
Date: Mon, 3 Jun 2024 15:11:07 -0300
Subject: [PATCH 03/39] Adds first and second comparator options to
intersection metadata. #887.
---
.../edition/filter-edition-form.vue | 2 +-
.../FormDatesIntersection.vue | 96 ++++++++++++++++++-
.../TainacanFilterDatesIntersection.vue | 4 +-
.../class-tainacan-dates-intersection.php | 30 +++++-
4 files changed, 119 insertions(+), 13 deletions(-)
diff --git a/src/views/admin/components/edition/filter-edition-form.vue b/src/views/admin/components/edition/filter-edition-form.vue
index 3f0e845ab..1dd6b4183 100644
--- a/src/views/admin/components/edition/filter-edition-form.vue
+++ b/src/views/admin/components/edition/filter-edition-form.vue
@@ -420,7 +420,7 @@ export default {
-webkit-column-gap: 0;
-webkit-column-rule: none;
column-count: 2;
- column-gap: 4em;
+ column-gap: 3em;
column-rule: none;
padding-bottom: 0.5em;
diff --git a/src/views/admin/components/filter-types/dates-intersection/FormDatesIntersection.vue b/src/views/admin/components/filter-types/dates-intersection/FormDatesIntersection.vue
index 83ddf0de3..346b90b3a 100644
--- a/src/views/admin/components/filter-types/dates-intersection/FormDatesIntersection.vue
+++ b/src/views/admin/components/filter-types/dates-intersection/FormDatesIntersection.vue
@@ -29,6 +29,46 @@
+
+
+
+ {{ $i18n.getHelperTitle('tainacan-filter-dates-intersection', 'first_comparator') }} *
+
+
+
+
+
+
+
+
+ {{ $i18n.getHelperTitle('tainacan-filter-dates-intersection', 'second_comparator') }} *
+
+
+
+
+
+
+
@@ -50,7 +90,11 @@
loading: true,
metadataType: '',
metadataMessage: '',
- secondDateMetadatumId: [Number, String]
+ secondDateMetadatumId: [Number, String],
+ secondDateMetadatumName: String,
+ firstComparator: String,
+ secondComparator: String,
+ comparatorsObject: {}
}
},
watch: {
@@ -63,13 +107,46 @@
},
created() {
this.secondDateMetadatumId = this.modelValue && this.modelValue.secondary_filter_metadatum_id ? this.modelValue.secondary_filter_metadatum_id : '';
+ this.secondDateMetadatumName = this.modelValue && this.modelValue.secondary_filter_metadatum_name ? this.modelValue.secondary_filter_metadatum_name : '';
+ this.firstComparator = this.modelValue && this.modelValue.first_comparator ? this.modelValue.first_comparator : '>=';
+ this.secondComparator = this.modelValue && this.modelValue.second_comparator ? this.modelValue.second_comparator : '<=';
+
this.loading = true;
this.fetchMetadata();
- console.log(this.filter)
+
+ this.comparatorsObject = {
+ '=': {
+ symbol: '=',
+ label: this.$i18n.get('is_equal_to')
+ },
+ '!=': {
+ symbol: '≠',
+ label: this.$i18n.get('is_not_equal_to')
+ },
+ '>': {
+ symbol: '>',
+ label: this.$i18n.get('after')
+ },
+ '>=': {
+ symbol: '≥',
+ label: this.$i18n.get('after_or_on_day')
+ },
+ '<': {
+ symbol: '<',
+ label: this.$i18n.get('before')
+ },
+ '<=': {
+ symbol: '≤',
+ label: this.$i18n.get('before_or_on_day')
+ }
+ };
},
methods: {
async fetchMetadata() {
- let endpoint = this.filter.collectionId && this.filter.collectionId !== 'default' ? ( '/collections/' + this.filter.collectionId + '/metadata' ) : '/metadata';
+
+ let endpoint = this.filter.collection_id && this.filter.collection_id !== 'default' ? ( '/collection/' + this.filter.collection_id + '/metadata' ) : '/metadata';
+ endpoint += '?metaquery[0][key]=metadata_type&metaquery[0][value]=Tainacan\\Metadata_Types\\Date&nopaging=1&exclude=' + this.filter.metadatum_id;
+
return await tainacanApi.get(endpoint)
.then(res => {
this.loading = false;
@@ -82,8 +159,17 @@
},
onUpdateSecondDateMetadatumId() {
const selectedMetadatum = this.metadata.find( aMetadatum => aMetadatum.id == this.secondDateMetadatumId );
- const selectedMetadatumName = selectedMetadatum ? selectedMetadatum.name : '';
- this.$emit('update:model-value', { secondary_filter_metadatum_id: this.secondDateMetadatumId, secondary_filter_metadatum_name: selectedMetadatumName});
+ this.selectedMetadatumName = selectedMetadatum ? selectedMetadatum.name : '';
+ this.selectedMetadatumId = selectedMetadatum ? selectedMetadatum.id : '';
+ this.emitValues();
+ },
+ emitValues() {
+ this.$emit('update:model-value', {
+ first_comparator: this.firstComparator,
+ second_comparator: this.secondComparator,
+ secondary_filter_metadatum_id: this.secondDateMetadatumId,
+ secondary_filter_metadatum_name: this.secondDateMetadatumName
+ });
},
setErrorsAttributes( type, message ) {
this.metadataType = type;
diff --git a/src/views/admin/components/filter-types/dates-intersection/TainacanFilterDatesIntersection.vue b/src/views/admin/components/filter-types/dates-intersection/TainacanFilterDatesIntersection.vue
index c2f16c362..cd9a67aa6 100644
--- a/src/views/admin/components/filter-types/dates-intersection/TainacanFilterDatesIntersection.vue
+++ b/src/views/admin/components/filter-types/dates-intersection/TainacanFilterDatesIntersection.vue
@@ -159,7 +159,7 @@
this.$emit('input', {
filter: 'intersection',
type: 'DATE',
- compare: '>=',
+ compare: this.filterTypeOptions.first_comparator,
metadatum_id: this.metadatumId,
collection_id: this.collectionId,
value: values
@@ -167,7 +167,7 @@
this.$emit('input', {
filter: 'intersection',
type: 'DATE',
- compare: '<=',
+ compare: this.filterTypeOptions.second_comparator,
metadatum_id: this.filterTypeOptions.secondary_filter_metadatum_id,
collection_id: this.collectionId,
value: values
diff --git a/src/views/admin/components/filter-types/dates-intersection/class-tainacan-dates-intersection.php b/src/views/admin/components/filter-types/dates-intersection/class-tainacan-dates-intersection.php
index cf3162042..eb43af28e 100644
--- a/src/views/admin/components/filter-types/dates-intersection/class-tainacan-dates-intersection.php
+++ b/src/views/admin/components/filter-types/dates-intersection/class-tainacan-dates-intersection.php
@@ -17,6 +17,8 @@ class Dates_Intersection extends Filter_Type {
$this->set_default_options([
'secondary_filter_metadatum_id' => '',
'secondary_filter_metadatum_name' => '',
+ 'first_comparator' => '>=',
+ 'second_comparator' => '<='
]);
$this->set_use_max_options(false);
$this->set_preview_template('
@@ -59,6 +61,14 @@ class Dates_Intersection extends Filter_Type {
'secondary_filter_metadatum_name' => [
'title' => __( 'Second date metadatum', 'tainacan' ),
'description' => __( 'Label of the other metadatum to which this filter will compare values to find if there is an intersection of dates.', 'tainacan' ),
+ ],
+ 'first_comparator' => [
+ 'title' => __( 'First comparator', 'tainacan' ),
+ 'description' => __( 'Comparator to be used for checking the first metadata value.', 'tainacan' ),
+ ],
+ 'second_comparator' => [
+ 'title' => __( 'Second comparator', 'tainacan' ),
+ 'description' => __( 'Comparator to be used for checking the second metadata value.', 'tainacan' ),
]
];
}
@@ -68,18 +78,28 @@ class Dates_Intersection extends Filter_Type {
* @return array|bool true if is validate or array if has error
*/
public function validate_options(\Tainacan\Entities\Filter $filter) {
+
if ( !in_array($filter->get_status(), apply_filters('tainacan-status-require-validation', ['publish','future','private'])) )
return true;
- if ( empty($this->get_option('secondary_filter_metadatum_id')) ) {
- return [
+ $errors = [];
+
+ if ( empty($this->get_option('secondary_filter_metadatum_id')) )
+ $errors[] = [
'secondary_filter_metadatum_id' => __('The secondary date metadatum is required.','tainacan')
];
- }
- // Validate if the second date metadatum is a date metadatum
+ if ( empty($this->get_option('first_comparator')) )
+ $errors[] = [
+ 'first_comparator' => __('The first comparator is required.','tainacan')
+ ];
+
+ if ( empty($this->get_option('second_comparator')) )
+ $errors[] = [
+ 'second_comparator' => __('The second comparator is required.','tainacan')
+ ];
- return true;
+ return count($errors) > 0 ? $errors : true;
}
}
From ebf478d5ff7ade98fb5b7dd78fb9512e1288c638 Mon Sep 17 00:00:00 2001
From: mateuswetah
Date: Mon, 3 Jun 2024 15:53:13 -0300
Subject: [PATCH 04/39] Adds option to display the filter as a range instead of
one date. #887.
---
.../TainacanFilterDateInterval.vue | 30 ++++++++++++-
.../FormDatesIntersection.vue | 25 ++++++++++-
.../TainacanFilterDatesIntersection.vue | 44 ++++++++++++++++---
.../class-tainacan-dates-intersection.php | 12 ++++-
4 files changed, 100 insertions(+), 11 deletions(-)
diff --git a/src/views/admin/components/filter-types/date-interval/TainacanFilterDateInterval.vue b/src/views/admin/components/filter-types/date-interval/TainacanFilterDateInterval.vue
index 1a4e4b1b5..79c9ddb0a 100644
--- a/src/views/admin/components/filter-types/date-interval/TainacanFilterDateInterval.vue
+++ b/src/views/admin/components/filter-types/date-interval/TainacanFilterDateInterval.vue
@@ -3,7 +3,7 @@
{ resetPage(); validadeValues($event) }" />
diff --git a/src/views/admin/components/filter-types/dates-intersection/FormDatesIntersection.vue b/src/views/admin/components/filter-types/dates-intersection/FormDatesIntersection.vue
index 346b90b3a..19a9b7e0c 100644
--- a/src/views/admin/components/filter-types/dates-intersection/FormDatesIntersection.vue
+++ b/src/views/admin/components/filter-types/dates-intersection/FormDatesIntersection.vue
@@ -69,6 +69,24 @@
+
+
+
+
+
+
@@ -94,7 +112,8 @@
secondDateMetadatumName: String,
firstComparator: String,
secondComparator: String,
- comparatorsObject: {}
+ comparatorsObject: {},
+ acceptDateInterval: String
}
},
watch: {
@@ -110,6 +129,7 @@
this.secondDateMetadatumName = this.modelValue && this.modelValue.secondary_filter_metadatum_name ? this.modelValue.secondary_filter_metadatum_name : '';
this.firstComparator = this.modelValue && this.modelValue.first_comparator ? this.modelValue.first_comparator : '>=';
this.secondComparator = this.modelValue && this.modelValue.second_comparator ? this.modelValue.second_comparator : '<=';
+ this.acceptDateInterval = this.modelValue && this.modelValue.accept_date_interval ? this.modelValue.accept_date_interval : 'no';
this.loading = true;
this.fetchMetadata();
@@ -168,7 +188,8 @@
first_comparator: this.firstComparator,
second_comparator: this.secondComparator,
secondary_filter_metadatum_id: this.secondDateMetadatumId,
- secondary_filter_metadatum_name: this.secondDateMetadatumName
+ secondary_filter_metadatum_name: this.secondDateMetadatumName,
+ accept_date_interval: this.acceptDateInterval
});
},
setErrorsAttributes( type, message ) {
diff --git a/src/views/admin/components/filter-types/dates-intersection/TainacanFilterDatesIntersection.vue b/src/views/admin/components/filter-types/dates-intersection/TainacanFilterDatesIntersection.vue
index cd9a67aa6..b43d7a002 100644
--- a/src/views/admin/components/filter-types/dates-intersection/TainacanFilterDatesIntersection.vue
+++ b/src/views/admin/components/filter-types/dates-intersection/TainacanFilterDatesIntersection.vue
@@ -3,7 +3,7 @@
{ resetPage(); validadeValues($event) }" />
{{ $i18n.get('label_until') }}
@@ -92,13 +122,13 @@
// only validate if the first value is higher than first
validadeValues: _.debounce( function (){
- if (this.dateInit === undefined)
+ if ( this.dateInit === undefined )
this.dateInit = new Date();
- if (this.dateEnd === undefined)
+ if ( this.dateEnd === undefined )
this.dateEnd = new Date();
- if (this.dateInit > this.dateEnd) {
+ if ( this.filterTypeOptions.accept_date_interval === 'yes' && this.dateInit > this.dateEnd ) {
this.showErrorMessage();
return
}
@@ -162,7 +192,7 @@
compare: this.filterTypeOptions.first_comparator,
metadatum_id: this.metadatumId,
collection_id: this.collectionId,
- value: values
+ value: this.filterTypeOptions.accept_date_interval === 'yes' ? values : values[0]
});
this.$emit('input', {
filter: 'intersection',
@@ -170,7 +200,7 @@
compare: this.filterTypeOptions.second_comparator,
metadatum_id: this.filterTypeOptions.secondary_filter_metadatum_id,
collection_id: this.collectionId,
- value: values
+ value: this.filterTypeOptions.accept_date_interval === 'yes' ? values : values[0]
});
}
}
diff --git a/src/views/admin/components/filter-types/dates-intersection/class-tainacan-dates-intersection.php b/src/views/admin/components/filter-types/dates-intersection/class-tainacan-dates-intersection.php
index eb43af28e..59860e686 100644
--- a/src/views/admin/components/filter-types/dates-intersection/class-tainacan-dates-intersection.php
+++ b/src/views/admin/components/filter-types/dates-intersection/class-tainacan-dates-intersection.php
@@ -18,7 +18,8 @@ class Dates_Intersection extends Filter_Type {
'secondary_filter_metadatum_id' => '',
'secondary_filter_metadatum_name' => '',
'first_comparator' => '>=',
- 'second_comparator' => '<='
+ 'second_comparator' => '<=',
+ 'accept_date_interval' => 'no'
]);
$this->set_use_max_options(false);
$this->set_preview_template('
@@ -69,6 +70,10 @@ class Dates_Intersection extends Filter_Type {
'second_comparator' => [
'title' => __( 'Second comparator', 'tainacan' ),
'description' => __( 'Comparator to be used for checking the second metadata value.', 'tainacan' ),
+ ],
+ 'accept_date_interval' => [
+ 'title' => __( 'Accept date interval', 'tainacan' ),
+ 'description' => __( 'If checked, the filter will accept date intervals as values.', 'tainacan' ),
]
];
}
@@ -99,6 +104,11 @@ class Dates_Intersection extends Filter_Type {
'second_comparator' => __('The second comparator is required.','tainacan')
];
+ if ( empty($this->get_option('accept_date_interval')) )
+ $errors[] = [
+ 'accept_date_interval' => __('The filter should define if it accepts date interval.','tainacan')
+ ];
+
return count($errors) > 0 ? $errors : true;
}
From 658789e2bb5867d857d074d81e372b5befca01ce Mon Sep 17 00:00:00 2001
From: mateuswetah
Date: Mon, 3 Jun 2024 16:32:48 -0300
Subject: [PATCH 05/39] Disables comparator dropdown if only one option is
available. #886.
---
.../admin/components/filter-types/date/FormDate.vue | 11 +++++++----
.../filter-types/date/TainacanFilterDate.vue | 2 ++
2 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/src/views/admin/components/filter-types/date/FormDate.vue b/src/views/admin/components/filter-types/date/FormDate.vue
index feab75549..d23c3a073 100644
--- a/src/views/admin/components/filter-types/date/FormDate.vue
+++ b/src/views/admin/components/filter-types/date/FormDate.vue
@@ -12,7 +12,8 @@
v-for="(comparatorObject, comparatorKey) in comparatorsObject"
:key="comparatorKey"
v-model="comparators"
- :native-value="comparatorObject.key"
+ :native-value="comparatorKey"
+ :disabled="comparators.indexOf(comparatorKey) >= 0 && comparators.length <= 1"
name="metadata_type_relationship[display_related_item_metadata]"
@update:model-value="emitValues()">
@@ -33,7 +34,8 @@
],
data() {
return {
- comparatorsObject: Object
+ comparatorsObject: Object,
+ comparators: Array
}
},
created() {
@@ -72,8 +74,9 @@
};
},
methods: {
- onUpdateComparators(value) {
- this.$emit('update:model-value', { comparators: value });
+ emitValues() {
+ console.log(this.comparators)
+ this.$emit('update:model-value', { comparators: this.comparators });
}
}
}
diff --git a/src/views/admin/components/filter-types/date/TainacanFilterDate.vue b/src/views/admin/components/filter-types/date/TainacanFilterDate.vue
index 749dc0fe9..22e552e80 100644
--- a/src/views/admin/components/filter-types/date/TainacanFilterDate.vue
+++ b/src/views/admin/components/filter-types/date/TainacanFilterDate.vue
@@ -1,6 +1,7 @@
Date: Mon, 3 Jun 2024 17:01:53 -0300
Subject: [PATCH 06/39] Added comparators options to numeric filter as well.
#886.
---
.../components/filter-types/date/FormDate.vue | 65 ++++++-----
.../filter-types/date/class-tainacan-date.php | 5 +
.../filter-types/numeric/FormNumeric.vue | 65 ++++++++++-
.../numeric/TainacanFilterNumeric.vue | 105 ++++++++----------
.../numeric/class-tainacan-numeric.php | 28 ++++-
5 files changed, 168 insertions(+), 100 deletions(-)
diff --git a/src/views/admin/components/filter-types/date/FormDate.vue b/src/views/admin/components/filter-types/date/FormDate.vue
index d23c3a073..eaf9498cf 100644
--- a/src/views/admin/components/filter-types/date/FormDate.vue
+++ b/src/views/admin/components/filter-types/date/FormDate.vue
@@ -14,7 +14,7 @@
v-model="comparators"
:native-value="comparatorKey"
:disabled="comparators.indexOf(comparatorKey) >= 0 && comparators.length <= 1"
- name="metadata_type_relationship[display_related_item_metadata]"
+ name="date_filter_options[comparators]"
@update:model-value="emitValues()">
@@ -41,41 +41,40 @@
created() {
this.comparators = ( this.modelValue && this.modelValue.comparators ) ? this.modelValue.comparators : [ '=', '!=', '>', '>=', '<', '<=' ];
this.comparatorsObject = {
- '=': {
- symbol: '=',
- label: this.$i18n.get('is_equal_to'),
- enabled: this.comparators.indexOf('=') < 0 ? 'no' : 'yes'
- },
- '!=': {
- symbol: '≠',
- label: this.$i18n.get('is_not_equal_to'),
- enabled: this.comparators.indexOf('!=') < 0 ? 'no' : 'yes'
- },
- '>': {
- symbol: '>',
- label: this.$i18n.get('after'),
- enabled: this.comparators.indexOf('>') < 0 ? 'no' : 'yes'
- },
- '>=': {
- symbol: '≥',
- label: this.$i18n.get('after_or_on_day'),
- enabled: this.comparators.indexOf('>=') < 0 ? 'no' : 'yes'
- },
- '<': {
- symbol: '<',
- label: this.$i18n.get('before'),
- enabled: this.comparators.indexOf('<') < 0 ? 'no' : 'yes'
- },
- '<=': {
- symbol: '≤',
- label: this.$i18n.get('before_or_on_day'),
- enabled: this.comparators.indexOf('<=') < 0 ? 'no' : 'yes'
- }
- };
+ '=': {
+ symbol: '=',
+ label: this.$i18n.get('is_equal_to'),
+ enabled: this.comparators.indexOf('=') < 0 ? 'no' : 'yes'
+ },
+ '!=': {
+ symbol: '≠',
+ label: this.$i18n.get('is_not_equal_to'),
+ enabled: this.comparators.indexOf('!=') < 0 ? 'no' : 'yes'
+ },
+ '>': {
+ symbol: '>',
+ label: this.$i18n.get('greater_than'),
+ enabled: this.comparators.indexOf('>') < 0 ? 'no' : 'yes'
+ },
+ '>=': {
+ symbol: '≥',
+ label: this.$i18n.get('greater_than_or_equal_to'),
+ enabled: this.comparators.indexOf('>=') < 0 ? 'no' : 'yes'
+ },
+ '<': {
+ symbol: '<',
+ label: this.$i18n.get('less_than'),
+ enabled: this.comparators.indexOf('<') < 0 ? 'no' : 'yes'
+ },
+ '<=': {
+ symbol: '≤',
+ label: this.$i18n.get('less_than_or_equal_to'),
+ enabled: this.comparators.indexOf('<=') < 0 ? 'no' : 'yes'
+ }
+ };
},
methods: {
emitValues() {
- console.log(this.comparators)
this.$emit('update:model-value', { comparators: this.comparators });
}
}
diff --git a/src/views/admin/components/filter-types/date/class-tainacan-date.php b/src/views/admin/components/filter-types/date/class-tainacan-date.php
index 255fc6988..34f5b3eed 100644
--- a/src/views/admin/components/filter-types/date/class-tainacan-date.php
+++ b/src/views/admin/components/filter-types/date/class-tainacan-date.php
@@ -87,6 +87,11 @@ class Date extends Filter_Type {
'comparators' => __('"Comparators" array is required', 'tainacan')
];
+ if ( count( $this->get_option('comparators') ) < 1 )
+ return [
+ 'comparators' => __('At least one comparator should be provided', 'tainacan')
+ ];
+
return true;
}
diff --git a/src/views/admin/components/filter-types/numeric/FormNumeric.vue b/src/views/admin/components/filter-types/numeric/FormNumeric.vue
index 6a41fcb94..dcbd67780 100644
--- a/src/views/admin/components/filter-types/numeric/FormNumeric.vue
+++ b/src/views/admin/components/filter-types/numeric/FormNumeric.vue
@@ -13,7 +13,7 @@
+ @update:model-value="emitValues()">
0.001
@@ -70,7 +70,7 @@
name="max_options"
type="number"
step="1"
- @update:model-value="onUpdateStep" />
+ @update:model-value="emitValues()" />
@@ -87,6 +87,26 @@
+
+
+ {{ $i18n.getHelperTitle('tainacan-filter-numeric', 'comparators') }} *
+
+
+
+
+
+
+
+
@@ -102,15 +122,50 @@
data() {
return {
step: [Number, String],
- showEditStepOptions: false
+ showEditStepOptions: false,
+ comparatorsObject: Object,
+ comparators: Array
}
},
created() {
this.step = this.modelValue && this.modelValue.step ? this.modelValue.step : 1;
+ this.comparators = ( this.modelValue && this.modelValue.comparators ) ? this.modelValue.comparators : [ '=', '!=', '>', '>=', '<', '<=' ];
+ this.comparatorsObject = {
+ '=': {
+ symbol: '=',
+ label: this.$i18n.get('is_equal_to'),
+ enabled: this.comparators.indexOf('=') < 0 ? 'no' : 'yes'
+ },
+ '!=': {
+ symbol: '≠',
+ label: this.$i18n.get('is_not_equal_to'),
+ enabled: this.comparators.indexOf('!=') < 0 ? 'no' : 'yes'
+ },
+ '>': {
+ symbol: '>',
+ label: this.$i18n.get('after'),
+ enabled: this.comparators.indexOf('>') < 0 ? 'no' : 'yes'
+ },
+ '>=': {
+ symbol: '≥',
+ label: this.$i18n.get('after_or_on_day'),
+ enabled: this.comparators.indexOf('>=') < 0 ? 'no' : 'yes'
+ },
+ '<': {
+ symbol: '<',
+ label: this.$i18n.get('before'),
+ enabled: this.comparators.indexOf('<') < 0 ? 'no' : 'yes'
+ },
+ '<=': {
+ symbol: '≤',
+ label: this.$i18n.get('before_or_on_day'),
+ enabled: this.comparators.indexOf('<=') < 0 ? 'no' : 'yes'
+ }
+ };
},
methods: {
- onUpdateStep(modelValue) {
- this.$emit('update:model-value', { step: modelValue });
+ emitValues() {
+ this.$emit('update:model-value', { step: this.step, comparators: this.comparators });
}
}
}
diff --git a/src/views/admin/components/filter-types/numeric/TainacanFilterNumeric.vue b/src/views/admin/components/filter-types/numeric/TainacanFilterNumeric.vue
index 4d6a77ea2..25ca61d2a 100644
--- a/src/views/admin/components/filter-types/numeric/TainacanFilterNumeric.vue
+++ b/src/views/admin/components/filter-types/numeric/TainacanFilterNumeric.vue
@@ -1,6 +1,7 @@
-
+
-
- = {{ $i18n.get('is_equal_to') }}
-
-
- ≠ {{ $i18n.get('is_not_equal_to') }}
-
-
- > {{ $i18n.get('greater_than') }}
-
-
- ≥ {{ $i18n.get('greater_than_or_equal_to') }}
-
-
- < {{ $i18n.get('less_than') }}
-
-
- ≤ {{ $i18n.get('less_than_or_equal_to') }}
-
+
+
+
-
, >=, <, <=
}
},
- computed: {
- comparatorSymbol() {
- switch(this.comparator) {
- case '=': return '=';
- case '!=': return '≠';
- case '>': return '>';
- case '>=': return '≥';
- case '<': return '<';
- case '<=': return '≤';
- default: return '';
- }
- }
- },
watch: {
'query': {
handler() {
@@ -110,6 +66,41 @@
deep: true
}
},
+ created() {
+ this.comparatorsObject = {
+ '=': {
+ symbol: '=',
+ label: this.$i18n.get('is_equal_to'),
+ enabled: this.filterTypeOptions.comparators.indexOf('=') < 0 ? 'no' : 'yes'
+ },
+ '!=': {
+ symbol: '≠',
+ label: this.$i18n.get('is_not_equal_to'),
+ enabled: this.filterTypeOptions.comparators.indexOf('!=') < 0 ? 'no' : 'yes'
+ },
+ '>': {
+ symbol: '>',
+ label: this.$i18n.get('greater_than'),
+ enabled: this.filterTypeOptions.comparators.indexOf('>') < 0 ? 'no' : 'yes'
+ },
+ '>=': {
+ symbol: '≥',
+ label: this.$i18n.get('greater_than_or_equal_to'),
+ enabled: this.filterTypeOptions.comparators.indexOf('>=') < 0 ? 'no' : 'yes'
+ },
+ '<': {
+ symbol: '<',
+ label: this.$i18n.get('less_than'),
+ enabled: this.filterTypeOptions.comparators.indexOf('<') < 0 ? 'no' : 'yes'
+ },
+ '<=': {
+ symbol: '≤',
+ label: this.$i18n.get('less_than_or_equal_to'),
+ enabled: this.filterTypeOptions.comparators.indexOf('<=') < 0 ? 'no' : 'yes'
+ },
+ };
+ this.comparator = this.filterTypeOptions.comparators[0];
+ },
mounted() {
this.updateSelectedValues();
},
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 b973d8460..e5bb818c7 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
@@ -16,7 +16,8 @@ class Numeric extends Filter_Type {
$this->set_form_component('tainacan-filter-form-numeric');
$this->set_use_max_options(false);
$this->set_default_options([
- 'step' => 1
+ 'step' => 1,
+ 'comparators' => [ '=', '!=', '>', '>=', '<', '<=' ]
]);
$this->set_preview_template('
@@ -77,6 +78,10 @@ class Numeric extends Filter_Type {
'step' => [
'title' => __( 'Step', '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' ),
+ ],
+ 'comparators' => [
+ 'title' => __( 'Enabled comparators', 'tainacan' ),
+ 'description' => __( 'A list of comparators to be available in the filter, such as equal, greater than, smaller than, etc.', 'tainacan' ),
]
];
}
@@ -89,13 +94,24 @@ class Numeric extends Filter_Type {
if ( !in_array($filter->get_status(), apply_filters('tainacan-status-require-validation', ['publish','future','private'])) )
return true;
- if ( empty($this->get_option('step')) ) {
- return [
+ $errors = [];
+
+ if ( empty($this->get_option('step')) )
+ $errors[] = [
'step' => __('"Step" value is required','tainacan')
];
- }
- return true;
+ if ( empty($this->get_option('comparators')) )
+ $errors[] = [
+ 'comparators' => __('"Comparators" array is required', 'tainacan')
+ ];
+
+ if ( count( $this->get_option('comparators') ) < 1 )
+ $errors[] = [
+ 'comparators' => __('At least one comparator should be provided', 'tainacan')
+ ];
+
+ return count($errors) ? $errors : true;
}
}
@@ -134,6 +150,8 @@ class Numeric_Helper {
case '<=':
$filter_arguments['label'] = '≤ ' . $filter_arguments['label'][0];
break;
+ default:
+ $filter_arguments['label'] = $filter_arguments['label'][0];
}
}
From d215c9a9cee092468677faa2d8a0a40bdacafee4 Mon Sep 17 00:00:00 2001
From: mateuswetah
Date: Mon, 3 Jun 2024 18:21:53 -0300
Subject: [PATCH 07/39] Creates intersection filter for numeric as well. #887.
---
.../edition/filter-edition-form.vue | 2 +
.../FormDatesIntersection.vue | 8 +-
.../class-tainacan-dates-intersection.php | 16 +-
.../class-tainacan-filter-type-helper.php | 1 +
.../FormNumericsIntersection.vue | 298 ++++++++++++++++++
.../TainacanFilterNumericsIntersection.vue | 139 ++++++++
.../class-tainacan-numerics-intersection.php | 161 ++++++++++
.../filter-types/tainacan-filter-item.vue | 3 +-
src/views/tainacan-i18n.php | 1 +
9 files changed, 613 insertions(+), 16 deletions(-)
create mode 100644 src/views/admin/components/filter-types/numerics-intersection/FormNumericsIntersection.vue
create mode 100644 src/views/admin/components/filter-types/numerics-intersection/TainacanFilterNumericsIntersection.vue
create mode 100644 src/views/admin/components/filter-types/numerics-intersection/class-tainacan-numerics-intersection.php
diff --git a/src/views/admin/components/edition/filter-edition-form.vue b/src/views/admin/components/edition/filter-edition-form.vue
index 1dd6b4183..a243bc665 100644
--- a/src/views/admin/components/edition/filter-edition-form.vue
+++ b/src/views/admin/components/edition/filter-edition-form.vue
@@ -252,6 +252,7 @@ import { formHooks } from "../../js/mixins";
import FormFilterNumeric from '../filter-types/numeric/FormNumeric.vue';
import FormFilterNumericInterval from '../filter-types/numeric-interval/FormNumericInterval.vue';
import FormFilterNumericListInterval from '../filter-types/numeric-list-interval/FormNumericListInterval.vue';
+import FormFilterNumericsIntersection from '../filter-types/numerics-intersection/FormNumericsIntersection.vue';
import FormFilterDatesIntersection from '../filter-types/dates-intersection/FormDatesIntersection.vue';
export default {
@@ -260,6 +261,7 @@ export default {
'tainacan-filter-form-numeric': FormFilterNumeric,
'tainacan-filter-form-numeric-interval': FormFilterNumericInterval,
'tainacan-filter-form-numeric-list-interval': FormFilterNumericListInterval,
+ 'tainacan-filter-form-numerics-intersection': FormFilterNumericsIntersection,
'tainacan-filter-form-dates-intersection': FormFilterDatesIntersection
},
mixins: [ formHooks ],
diff --git a/src/views/admin/components/filter-types/dates-intersection/FormDatesIntersection.vue b/src/views/admin/components/filter-types/dates-intersection/FormDatesIntersection.vue
index 19a9b7e0c..a44aaa777 100644
--- a/src/views/admin/components/filter-types/dates-intersection/FormDatesIntersection.vue
+++ b/src/views/admin/components/filter-types/dates-intersection/FormDatesIntersection.vue
@@ -72,7 +72,9 @@
+ style="margin-top: 1.125rem;"
+ :type="errors && errors['accept_date_interval'] != undefined ? 'is-danger' : ''"
+ :message="errors && errors['accept_date_interval'] != undefined ? errors['accept_date_interval'] : ''">
aMetadatum.id == this.secondDateMetadatumId );
- this.selectedMetadatumName = selectedMetadatum ? selectedMetadatum.name : '';
- this.selectedMetadatumId = selectedMetadatum ? selectedMetadatum.id : '';
+ this.secondDateMetadatumName = selectedMetadatum ? selectedMetadatum.name : '';
+ this.secondDateMetadatumId = selectedMetadatum ? selectedMetadatum.id : '';
this.emitValues();
},
emitValues() {
diff --git a/src/views/admin/components/filter-types/dates-intersection/class-tainacan-dates-intersection.php b/src/views/admin/components/filter-types/dates-intersection/class-tainacan-dates-intersection.php
index 59860e686..13ae80953 100644
--- a/src/views/admin/components/filter-types/dates-intersection/class-tainacan-dates-intersection.php
+++ b/src/views/admin/components/filter-types/dates-intersection/class-tainacan-dates-intersection.php
@@ -90,24 +90,16 @@ class Dates_Intersection extends Filter_Type {
$errors = [];
if ( empty($this->get_option('secondary_filter_metadatum_id')) )
- $errors[] = [
- 'secondary_filter_metadatum_id' => __('The secondary date metadatum is required.','tainacan')
- ];
+ $errors['secondary_filter_metadatum_id'] = __('The secondary date metadatum is required.','tainacan');
if ( empty($this->get_option('first_comparator')) )
- $errors[] = [
- 'first_comparator' => __('The first comparator is required.','tainacan')
- ];
+ $errors['first_comparator'] = __('The first comparator is required.','tainacan');
if ( empty($this->get_option('second_comparator')) )
- $errors[] = [
- 'second_comparator' => __('The second comparator is required.','tainacan')
- ];
+ $errors['second_comparator'] = __('The second comparator is required.','tainacan');
if ( empty($this->get_option('accept_date_interval')) )
- $errors[] = [
- 'accept_date_interval' => __('The filter should define if it accepts date interval.','tainacan')
- ];
+ $errors['accept_date_interval'] = __('The filter should define if it accepts date interval.','tainacan');
return count($errors) > 0 ? $errors : true;
}
diff --git a/src/views/admin/components/filter-types/filter-type-helper/class-tainacan-filter-type-helper.php b/src/views/admin/components/filter-types/filter-type-helper/class-tainacan-filter-type-helper.php
index cb4ffa3b5..fd91b2a50 100644
--- a/src/views/admin/components/filter-types/filter-type-helper/class-tainacan-filter-type-helper.php
+++ b/src/views/admin/components/filter-types/filter-type-helper/class-tainacan-filter-type-helper.php
@@ -43,6 +43,7 @@ class Filter_Type_Helper {
$this->Tainacan_Filters->register_filter_type('Tainacan\Filter_Types\TaxonomyTaginput');
$this->Tainacan_Filters->register_filter_type('Tainacan\Filter_Types\TaxonomyCheckbox');
$this->Tainacan_Filters->register_filter_type('Tainacan\Filter_Types\Numeric_List_Interval');
+ $this->Tainacan_Filters->register_filter_type('Tainacan\Filter_Types\Numerics_Intersection');
// the priority should see less than on function
// `load_admin_page()` of class `Admin` in file /src/views/class-tainacan-admin.php
diff --git a/src/views/admin/components/filter-types/numerics-intersection/FormNumericsIntersection.vue b/src/views/admin/components/filter-types/numerics-intersection/FormNumericsIntersection.vue
new file mode 100644
index 000000000..bb2384fbd
--- /dev/null
+++ b/src/views/admin/components/filter-types/numerics-intersection/FormNumericsIntersection.vue
@@ -0,0 +1,298 @@
+
+
+
+
+ {{ $i18n.getHelperTitle('tainacan-filter-numeric-interval', 'step') }} *
+
+
+
+
+
+ 0.001
+
+
+ 0.01
+
+
+ 0.1
+
+
+ 1
+
+
+ 2
+
+
+ 5
+
+
+ 10
+
+
+ 100
+
+
+ 1000
+
+
+ {{ step }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ $i18n.getHelperTitle('tainacan-filter-numerics-intersection', 'secondary_filter_metadatum_id') }} *
+
+
+
+
+ {{ $i18n.get('instruction_select_second_numeric_to_compare' ) }}
+
+
+ {{ option.name }}
+
+
+
+
+
+
+ {{ $i18n.getHelperTitle('tainacan-filter-numerics-intersection', 'first_comparator') }} *
+
+
+
+
+
+
+
+
+ {{ $i18n.getHelperTitle('tainacan-filter-numerics-intersection', 'second_comparator') }} *
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/views/admin/components/filter-types/numerics-intersection/TainacanFilterNumericsIntersection.vue b/src/views/admin/components/filter-types/numerics-intersection/TainacanFilterNumericsIntersection.vue
new file mode 100644
index 000000000..6805d6acc
--- /dev/null
+++ b/src/views/admin/components/filter-types/numerics-intersection/TainacanFilterNumericsIntersection.vue
@@ -0,0 +1,139 @@
+
+
+
{ resetPage(); validadeValues($event) }"
+ />
+
+ {{ $i18n.get('label_until') }}
+
+ { resetPage(); validadeValues($event) }" />
+
+
+
+
+
+
+
diff --git a/src/views/admin/components/filter-types/numerics-intersection/class-tainacan-numerics-intersection.php b/src/views/admin/components/filter-types/numerics-intersection/class-tainacan-numerics-intersection.php
new file mode 100644
index 000000000..b53da5ab8
--- /dev/null
+++ b/src/views/admin/components/filter-types/numerics-intersection/class-tainacan-numerics-intersection.php
@@ -0,0 +1,161 @@
+set_name( __('Numerics Intersection', 'tainacan') );
+ $this->set_supported_types(['float']);
+ $this->set_component('tainacan-filter-numerics-intersection');
+ $this->set_form_component('tainacan-filter-form-numerics-intersection');
+ $this->set_default_options([
+ 'step' => 1,
+ 'secondary_filter_metadatum_id' => '',
+ 'secondary_filter_metadatum_name' => '',
+ 'first_comparator' => '>=',
+ 'second_comparator' => '<=',
+ 'accept_numeric_interval' => 'no'
+ ]);
+ $this->set_use_max_options(false);
+ $this->set_preview_template('
+
+ ');
+ }
+
+ public function get_form_labels(){
+ return [
+ 'step' => [
+ 'title' => __( 'Step', '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' ),
+ ],
+ 'secondary_filter_metadatum_id' => [
+ 'title' => __( 'Second numeric metadatum', 'tainacan' ),
+ 'description' => __( 'The other metadatum to which this filter will compare values to find if there is an intersection of numeric values.', 'tainacan' ),
+ ],
+ 'secondary_filter_metadatum_name' => [
+ 'title' => __( 'Second numeric metadatum', 'tainacan' ),
+ 'description' => __( 'Label of the other metadatum to which this filter will compare values to find if there is an intersection of numeric values.', 'tainacan' ),
+ ],
+ 'first_comparator' => [
+ 'title' => __( 'First comparator', 'tainacan' ),
+ 'description' => __( 'Comparator to be used for checking the first metadata value.', 'tainacan' ),
+ ],
+ 'second_comparator' => [
+ 'title' => __( 'Second comparator', 'tainacan' ),
+ 'description' => __( 'Comparator to be used for checking the second metadata value.', 'tainacan' ),
+ ],
+ 'accept_numeric_interval' => [
+ 'title' => __( 'Accept numeric interval', 'tainacan' ),
+ 'description' => __( 'If checked, the filter will accept numeric intervals as values.', 'tainacan' ),
+ ]
+ ];
+ }
+
+
+ /**
+ * @param \Tainacan\Entities\Filter $filter
+ * @return array|bool true if is validate or array if has error
+ */
+ public function validate_options(\Tainacan\Entities\Filter $filter) {
+
+ if ( !in_array($filter->get_status(), apply_filters('tainacan-status-require-validation', ['publish','future','private'])) )
+ return true;
+
+ $errors = [];
+
+ if ( empty($this->get_option('secondary_filter_metadatum_id')) )
+ $errors['secondary_filter_metadatum_id'] = __('The secondary numeric metadatum is required.','tainacan');
+
+ if ( empty($this->get_option('first_comparator')) )
+ $errors['first_comparator'] = __('The first comparator is required.','tainacan');
+
+ if ( empty($this->get_option('second_comparator')) )
+ $errors['second_comparator'] = __('The second comparator is required.','tainacan');
+
+ if ( empty($this->get_option('accept_numeric_interval')) )
+ $errors['accept_numeric_interval'] = __('The filter should define if it accepts a numeric interval.','tainacan');
+
+ return count($errors) > 0 ? $errors : true;
+ }
+
+}
+
+class Numerics_Intersection_Interval_Helper {
+ use \Tainacan\Traits\Singleton_Instance;
+
+ protected function init() {
+ add_filter( 'tainacan-api-items-tainacan-filter-numerics-intersection-filter-arguments', [$this, 'format_filter_arguments']);
+ }
+
+ function format_filter_arguments( $filter_arguments ) {
+ if (
+ !isset($filter_arguments['compare']) ||
+ !isset($filter_arguments['label'])
+ ) {
+ return $filter_arguments;
+ }
+
+ if (
+ is_array($filter_arguments['label']) &&
+ count($filter_arguments['label']) === 2
+ ) {
+ $filter_arguments['label'] = $filter_arguments['label'][0] . ' - ' . $filter_arguments['label'][1];
+ }
+ if (
+ isset( $filter_arguments['filter'] ) &&
+ isset( $filter_arguments['filter']['filter_type_options'] ) &&
+ isset( $filter_arguments['filter']['filter_type_options']['secondary_filter_metadatum_name'] ) &&
+ !empty( $filter_arguments['filter']['filter_type_options']['secondary_filter_metadatum_name'] )
+ ) {
+ $filter_arguments['filter']['name'] = $filter_arguments['filter']['name'] . ' - ' . $filter_arguments['filter']['filter_type_options']['secondary_filter_metadatum_name'];
+ }
+ return $filter_arguments;
+ }
+}
+Numerics_Intersection_Interval_Helper::get_instance();
\ No newline at end of file
diff --git a/src/views/admin/components/filter-types/tainacan-filter-item.vue b/src/views/admin/components/filter-types/tainacan-filter-item.vue
index bd3f4609f..04b0e33ef 100644
--- a/src/views/admin/components/filter-types/tainacan-filter-item.vue
+++ b/src/views/admin/components/filter-types/tainacan-filter-item.vue
@@ -102,7 +102,8 @@
TainacanFilterDateInterval: defineAsyncComponent(() => import('./date-interval/TainacanFilterDateInterval.vue')),
TainacanFilterDatesIntersection: defineAsyncComponent(() => import('./dates-intersection/TainacanFilterDatesIntersection.vue')),
TainacanFilterNumericInterval: defineAsyncComponent(() => import('./numeric-interval/TainacanFilterNumericInterval.vue')),
- TainacanFilterNumericListInterval: defineAsyncComponent(() => import('./numeric-list-interval/TainacanFilterNumericListInterval.vue'))
+ TainacanFilterNumericListInterval: defineAsyncComponent(() => import('./numeric-list-interval/TainacanFilterNumericListInterval.vue')),
+ TainacanFilterNumericsIntersection: defineAsyncComponent(() => import('./numerics-intersection/TainacanFilterNumericsIntersection.vue'))
},
props: {
filter: Object,
diff --git a/src/views/tainacan-i18n.php b/src/views/tainacan-i18n.php
index 4bb2101c4..ab0ebc810 100644
--- a/src/views/tainacan-i18n.php
+++ b/src/views/tainacan-i18n.php
@@ -789,6 +789,7 @@ return apply_filters( 'tainacan-i18n', [
'instruction_select_geocoordinate_metadatum' => __( 'Select a geocoordinate metadatum', 'tainacan' ),
'instruction_multiple_terms_insertion' => __( 'Type or paste here a list of names using a separator to create multiple terms at once.', 'tainacan' ),
'instruction_select_second_date_to_compare' => __( 'Select the second date metadatum', 'tainacan' ),
+ 'instruction_select_second_numeric_to_compare' => __( 'Select the second numeric metadatum', 'tainacan' ),
// Info. Other feedback to user.
'info_items_tab_all' => __( 'Every item, except by those sent to trash.', 'tainacan' ),
From 4729bd31180515848bfcfada599388d9fb0bbb22 Mon Sep 17 00:00:00 2001
From: vnmedeiros
Date: Thu, 6 Jun 2024 12:25:58 -0300
Subject: [PATCH 08/39] feat: add secondary in metaquery #887
---
.../class-tainacan-rest-items-controller.php | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/src/classes/api/endpoints/class-tainacan-rest-items-controller.php b/src/classes/api/endpoints/class-tainacan-rest-items-controller.php
index d25d70d11..5d1d3982c 100644
--- a/src/classes/api/endpoints/class-tainacan-rest-items-controller.php
+++ b/src/classes/api/endpoints/class-tainacan-rest-items-controller.php
@@ -454,7 +454,7 @@ class REST_Items_Controller extends REST_Controller {
* @return array
* @throws \Exception
*/
- private function prepare_filters_arguments ( $args, $collection_id = false ) {
+ private function prepare_filters_arguments ( $args, $collection_id = false, $ignore_filter_arguments = [] ) {
$filters_arguments = array();
$meta_query = isset($args['meta_query']) ? $args['meta_query'] : [];
if(isset($meta_query['value'])) $meta_query = [$meta_query];
@@ -498,8 +498,7 @@ class REST_Items_Controller extends REST_Controller {
}
foreach($meta_query as $meta) {
-
- if ( !isset($meta['key']) || !isset($meta['value']) )
+ if ( !isset($meta['key']) || !isset($meta['value']) || ( in_array($meta['key'], $ignore_filter_arguments) ))
continue;
$meta_id = $meta['key'];
@@ -554,6 +553,7 @@ class REST_Items_Controller extends REST_Controller {
$date_format = get_option( 'date_format' ) != false ? get_option( 'date_format' ) : 'Y-m-d';
return empty($date) == false ? mysql2date($date_format, $date) : "";
}, $meta_label);
+ $meta_type = 'DATE';
break;
case 'item':
$meta_label = array_map(function($item_id) {
@@ -643,7 +643,15 @@ class REST_Items_Controller extends REST_Controller {
if($request['collection_id']) {
$collection_id = $request['collection_id'];
}
- $filters_args = $this->prepare_filters_arguments($args, $collection_id);
+ $metaqueries = isset($request['metaquery']) ? $request['metaquery'] : [];
+ $ignore_filter_arguments = array_map(
+ function($metaquery) { return $metaquery['key']; },
+ array_filter(
+ $metaqueries,
+ function($metaquery) { return isset($metaquery['key']) && isset($metaquery['secondary']) && $metaquery['secondary'] == 'true'; }
+ )
+ );
+ $filters_args = $this->prepare_filters_arguments($args, $collection_id, $ignore_filter_arguments);
if(isset($args['meta_query']) && !empty($args['meta_query']) && is_array($filters_args) && !empty($filters_args)) {
foreach($filters_args as $filters_arg) {
if($filters_arg['filter'] !== false) {
From a8aa9bb7cba1daab8bc355f0bc8698c1008121e1 Mon Sep 17 00:00:00 2001
From: mateuswetah
Date: Thu, 6 Jun 2024 14:06:52 -0300
Subject: [PATCH 09/39] Passes 'secondary' indicator to metaquery. #887.
---
.../TainacanFilterDatesIntersection.vue | 3 +-
.../js/store/modules/search/mutations.js | 65 ++++++++-----------
2 files changed, 28 insertions(+), 40 deletions(-)
diff --git a/src/views/admin/components/filter-types/dates-intersection/TainacanFilterDatesIntersection.vue b/src/views/admin/components/filter-types/dates-intersection/TainacanFilterDatesIntersection.vue
index b43d7a002..a51506939 100644
--- a/src/views/admin/components/filter-types/dates-intersection/TainacanFilterDatesIntersection.vue
+++ b/src/views/admin/components/filter-types/dates-intersection/TainacanFilterDatesIntersection.vue
@@ -200,7 +200,8 @@
compare: this.filterTypeOptions.second_comparator,
metadatum_id: this.filterTypeOptions.secondary_filter_metadatum_id,
collection_id: this.collectionId,
- value: this.filterTypeOptions.accept_date_interval === 'yes' ? values : values[0]
+ value: this.filterTypeOptions.accept_date_interval === 'yes' ? values : values[0],
+ secondary: true
});
}
}
diff --git a/src/views/admin/js/store/modules/search/mutations.js b/src/views/admin/js/store/modules/search/mutations.js
index 7e0c73a2a..fe1d2baec 100644
--- a/src/views/admin/js/store/modules/search/mutations.js
+++ b/src/views/admin/js/store/modules/search/mutations.js
@@ -21,52 +21,39 @@ export const setAdvancedSearchQuery = (state, advancedSearchQuery) => {
export const addMetaQuery = ( state, filter ) => {
state.postquery.metaquery = ( ! state.postquery.metaquery || state.postquery.metaquery.length == undefined ) ? [] : state.postquery.metaquery;
- let index = state.postquery.metaquery.findIndex( item => item.key === filter.metadatum_id);
- if ( index >= 0 ) {
- Object.assign(
- state.postquery.metaquery,
- {
- [index]: {
- key: filter.metadatum_id,
- value: filter.value,
- compare: filter.compare,
- type: filter.type
- }
- }
- );
- } else {
- state.postquery.metaquery.push({
- key: filter.metadatum_id,
- value: filter.value,
- compare: filter.compare,
- type: filter.type
- });
+ let metaquery = {
+ key: filter.metadatum_id,
+ value: filter.value
}
+ if ( filter.compare )
+ metaquery.compare = filter.compare;
+ if ( filter.type )
+ metaquery.type = filter.type;
+ if ( filter.secondary )
+ metaquery.secondary = filter.secondary;
+
+ let index = state.postquery.metaquery.findIndex( item => item.key === filter.metadatum_id);
+ if ( index >= 0 )
+ Object.assign( state.postquery.metaquery, { [index]: metaquery } );
+ else
+ state.postquery.metaquery.push(metaquery);
};
export const addTaxQuery = ( state, filter ) => {
state.postquery.taxquery = ( ! state.postquery.taxquery || state.postquery.taxquery.length == undefined ) ? [] : state.postquery.taxquery;
- let index = state.postquery.taxquery.findIndex( item => item.taxonomy === filter.taxonomy);
-
- if ( index >= 0 ) {
- Object.assign(
- state.postquery.taxquery,
- {
- [index]: {
- taxonomy: filter.taxonomy,
- terms: filter.terms,
- compare: filter.compare
- }
- }
- );
- } else {
- state.postquery.taxquery.push({
- taxonomy: filter.taxonomy,
- terms: filter.terms,
- compare: filter.compare
- });
+ let taxquery = {
+ taxonomy: filter.taxonomy,
+ terms: filter.terms
}
+ if ( filter.compare )
+ taxquery.compare = filter.compare;
+
+ let index = state.postquery.taxquery.findIndex( item => item.taxonomy === filter.taxonomy);
+ if ( index >= 0 )
+ Object.assign( state.postquery.taxquery, { [index]: taxquery } );
+ else
+ state.postquery.taxquery.push(taxquery);
};
export const addFetchOnly = ( state, metadatum ) => {
From 9fae42446052fc80beb10a136ce21c7d309f5c0f Mon Sep 17 00:00:00 2001
From: vnmedeiros
Date: Fri, 7 Jun 2024 08:28:00 -0300
Subject: [PATCH 10/39] fix: test quantity os filters types
---
tests/test-filters.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tests/test-filters.php b/tests/test-filters.php
index 27517e746..65eb4a046 100644
--- a/tests/test-filters.php
+++ b/tests/test-filters.php
@@ -97,7 +97,7 @@ class Filters extends TAINACAN_UnitTestCase {
$Tainacan_Filters = \Tainacan\Repositories\Filters::get_instance();
$all_filter_types = $Tainacan_Filters->fetch_filter_types();
- $this->assertEquals( 11, count( $all_filter_types ) );
+ $this->assertEquals( 13, count( $all_filter_types ) );
$float_filters = $Tainacan_Filters->fetch_supported_filter_types('float');
$this->assertTrue( count( $float_filters ) > 0 );
From 0ff12f3b67836a70a3139d0f94d5a37755dfd363 Mon Sep 17 00:00:00 2001
From: mateuswetah
Date: Fri, 7 Jun 2024 15:57:20 -0300
Subject: [PATCH 11/39] Basic logic for intersection filters without range by
now. #887.
---
.../FormDatesIntersection.vue | 163 +++++++++++++++---
.../TainacanFilterDatesIntersection.vue | 53 +++---
.../class-tainacan-dates-intersection.php | 11 --
.../FormNumericsIntersection.vue | 162 ++++++++++++++---
.../TainacanFilterNumericsIntersection.vue | 46 +++--
.../class-tainacan-numerics-intersection.php | 20 ---
src/views/admin/pages/lists/filters-page.vue | 2 +-
src/views/tainacan-i18n.php | 3 +
8 files changed, 336 insertions(+), 124 deletions(-)
diff --git a/src/views/admin/components/filter-types/dates-intersection/FormDatesIntersection.vue b/src/views/admin/components/filter-types/dates-intersection/FormDatesIntersection.vue
index a44aaa777..d9bea5a41 100644
--- a/src/views/admin/components/filter-types/dates-intersection/FormDatesIntersection.vue
+++ b/src/views/admin/components/filter-types/dates-intersection/FormDatesIntersection.vue
@@ -6,9 +6,11 @@
:message="metadataMessage">
{{ $i18n.getHelperTitle('tainacan-filter-dates-intersection', 'secondary_filter_metadatum_id') }} *
-
+
+
+
-
+
+
+
+ {{ $i18n.get('info_intersection_explainer') }}
+
+
+
+
+
-
- {{ $i18n.getHelperTitle('tainacan-filter-dates-intersection', 'first_comparator') }} *
-
-
+
+
+
+ {{ filter.metadatum.metadatum_name }}
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ $i18n.get('label_and') }}
+
-
- {{ $i18n.getHelperTitle('tainacan-filter-dates-intersection', 'second_comparator') }} *
-
-
+
+ {{ secondDateMetadatumName }}
+
+
+
+
+
+
+
+
+
+
-
-
+
+
@@ -115,7 +190,9 @@
firstComparator: String,
secondComparator: String,
comparatorsObject: {},
- acceptDateInterval: String
+ acceptDateInterval: String,
+ showEditFirstComparatorOptions: false,
+ showEditSecondComparatorOptions: false
}
},
watch: {
@@ -132,7 +209,7 @@
this.firstComparator = this.modelValue && this.modelValue.first_comparator ? this.modelValue.first_comparator : '>=';
this.secondComparator = this.modelValue && this.modelValue.second_comparator ? this.modelValue.second_comparator : '<=';
this.acceptDateInterval = this.modelValue && this.modelValue.accept_date_interval ? this.modelValue.accept_date_interval : 'no';
-
+
this.loading = true;
this.fetchMetadata();
@@ -204,4 +281,38 @@
},
}
}
-
\ No newline at end of file
+
+
+
\ No newline at end of file
diff --git a/src/views/admin/components/filter-types/dates-intersection/TainacanFilterDatesIntersection.vue b/src/views/admin/components/filter-types/dates-intersection/TainacanFilterDatesIntersection.vue
index a51506939..b46b1efeb 100644
--- a/src/views/admin/components/filter-types/dates-intersection/TainacanFilterDatesIntersection.vue
+++ b/src/views/admin/components/filter-types/dates-intersection/TainacanFilterDatesIntersection.vue
@@ -159,11 +159,16 @@
if (index >= 0) {
let metadata = this.query.metaquery[ index ];
- if (metadata.value && metadata.value.length > 0) {
- const dateValueInit = new Date(metadata.value[0].replace(/-/g, '/'));
- this.dateInit = moment(dateValueInit, moment.ISO_8601).toDate();
- const dateValueEnd = new Date(metadata.value[1].replace(/-/g, '/'));
- this.dateEnd = moment(dateValueEnd, moment.ISO_8601).toDate();
+ if (metadata.value ) {
+ if ( Array.isArray(metadata.value) && metadata.value.length > 0 ) {
+ const dateValueInit = new Date(metadata.value[0].replace(/-/g, '/'));
+ this.dateInit = moment(dateValueInit, moment.ISO_8601).toDate();
+ const dateValueEnd = new Date(metadata.value[1].replace(/-/g, '/'));
+ this.dateEnd = moment(dateValueEnd, moment.ISO_8601).toDate();
+ } else {
+ const dateValueInit = new Date(metadata.value.replace(/-/g, '/'));
+ this.dateInit = moment(dateValueInit, moment.ISO_8601).toDate();
+ }
}
} else {
this.dateInit = null;
@@ -186,23 +191,27 @@
values = [ dateInit, dateEnd ];
}
- this.$emit('input', {
- filter: 'intersection',
- type: 'DATE',
- compare: this.filterTypeOptions.first_comparator,
- metadatum_id: this.metadatumId,
- collection_id: this.collectionId,
- value: this.filterTypeOptions.accept_date_interval === 'yes' ? values : values[0]
- });
- this.$emit('input', {
- filter: 'intersection',
- type: 'DATE',
- compare: this.filterTypeOptions.second_comparator,
- metadatum_id: this.filterTypeOptions.secondary_filter_metadatum_id,
- collection_id: this.collectionId,
- value: this.filterTypeOptions.accept_date_interval === 'yes' ? values : values[0],
- secondary: true
- });
+ if ( this.filterTypeOptions.accept_date_interval !== 'yes' ) {
+ this.$emit('input', {
+ filter: 'intersection',
+ type: 'DATE',
+ compare: this.filterTypeOptions.first_comparator,
+ metadatum_id: this.metadatumId,
+ collection_id: this.collectionId,
+ value: values[0]
+ });
+ this.$emit('input', {
+ filter: 'intersection',
+ type: 'DATE',
+ compare: this.filterTypeOptions.second_comparator,
+ metadatum_id: this.filterTypeOptions.secondary_filter_metadatum_id,
+ collection_id: this.collectionId,
+ value: values[0],
+ secondary: true
+ });
+ } else {
+ // Much more complicated logic to be implemented in the future. See #889
+ }
}
}
}
diff --git a/src/views/admin/components/filter-types/dates-intersection/class-tainacan-dates-intersection.php b/src/views/admin/components/filter-types/dates-intersection/class-tainacan-dates-intersection.php
index 13ae80953..4e87802d4 100644
--- a/src/views/admin/components/filter-types/dates-intersection/class-tainacan-dates-intersection.php
+++ b/src/views/admin/components/filter-types/dates-intersection/class-tainacan-dates-intersection.php
@@ -34,17 +34,6 @@ class Dates_Intersection extends Filter_Type {
- until
-
');
diff --git a/src/views/admin/components/filter-types/numerics-intersection/FormNumericsIntersection.vue b/src/views/admin/components/filter-types/numerics-intersection/FormNumericsIntersection.vue
index bb2384fbd..45180670f 100644
--- a/src/views/admin/components/filter-types/numerics-intersection/FormNumericsIntersection.vue
+++ b/src/views/admin/components/filter-types/numerics-intersection/FormNumericsIntersection.vue
@@ -3,9 +3,11 @@
{{ $i18n.getHelperTitle('tainacan-filter-numeric-interval', 'step') }} *
-
+
+
+
-
+
+
+
+ {{ $i18n.get('info_intersection_explainer') }}
+
+
+
+
+
-
- {{ $i18n.getHelperTitle('tainacan-filter-numerics-intersection', 'first_comparator') }} *
-
-
+
+
+
+ {{ filter.metadatum.metadatum_name }}
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ $i18n.get('label_and') }}
+
-
- {{ $i18n.getHelperTitle('tainacan-filter-numerics-intersection', 'second_comparator') }} *
-
-
+
+ {{ secondNumericMetadatumName }}
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
@@ -204,7 +280,9 @@
firstComparator: String,
secondComparator: String,
comparatorsObject: {},
- acceptNumericInterval: String
+ acceptNumericInterval: String,
+ showEditFirstComparatorOptions: false,
+ showEditSecondComparatorOptions: false
}
},
watch: {
@@ -295,4 +373,38 @@
},
}
}
-
\ No newline at end of file
+
+
+
\ No newline at end of file
diff --git a/src/views/admin/components/filter-types/numerics-intersection/TainacanFilterNumericsIntersection.vue b/src/views/admin/components/filter-types/numerics-intersection/TainacanFilterNumericsIntersection.vue
index 6805d6acc..5981bd661 100644
--- a/src/views/admin/components/filter-types/numerics-intersection/TainacanFilterNumericsIntersection.vue
+++ b/src/views/admin/components/filter-types/numerics-intersection/TainacanFilterNumericsIntersection.vue
@@ -94,22 +94,26 @@
let values = [ this.valueInit, this.valueEnd ];
let type = ! Number.isInteger( this.valueInit ) || ! Number.isInteger( this.valueEnd ) ? 'DECIMAL(20,3)' : 'NUMERIC';
- this.$emit('input', {
- filter: 'intersection',
- type: type,
- compare: this.filterTypeOptions.first_comparator,
- metadatum_id: this.metadatumId,
- collection_id: this.collectionId,
- value: this.filterTypeOptions.accept_numeric_interval === 'yes' ? values : values[0]
- });
- this.$emit('input', {
- filter: 'intersection',
- type: type,
- compare: this.filterTypeOptions.second_comparator,
- metadatum_id: this.filterTypeOptions.secondary_filter_metadatum_id,
- collection_id: this.collectionId,
- value: this.filterTypeOptions.accept_numeric_interval === 'yes' ? values : values[0]
- });
+ if ( this.filterTypeOptions.accept_numeric_interval !== 'yes' ) {
+ this.$emit('input', {
+ filter: 'intersection',
+ type: type,
+ compare: this.filterTypeOptions.first_comparator,
+ metadatum_id: this.metadatumId,
+ collection_id: this.collectionId,
+ value: this.filterTypeOptions.accept_numeric_interval === 'yes' ? values : values[0]
+ });
+ this.$emit('input', {
+ filter: 'intersection',
+ type: type,
+ compare: this.filterTypeOptions.second_comparator,
+ metadatum_id: this.filterTypeOptions.secondary_filter_metadatum_id,
+ collection_id: this.collectionId,
+ value: this.filterTypeOptions.accept_numeric_interval === 'yes' ? values : values[0]
+ });
+ } else {
+ // Much more complicated logic to be implemented in the future. See #889
+ }
},
updateSelectedValues(){
if ( !this.query || !this.query.metaquery || !Array.isArray( this.query.metaquery ) )
@@ -119,9 +123,13 @@
if ( index >= 0 ) {
let metaquery = this.query.metaquery[ index ];
- if ( metaquery.value && metaquery.value.length > 1 ) {
- this.valueInit = new Number(metaquery.value[0]);
- this.valueEnd = new Number(metaquery.value[1]);
+ if ( metaquery.value ) {
+ if ( Array.isArray(metaquery.value) && metaquery.value.length > 1 ) {
+ this.valueInit = new Number(metaquery.value[0]);
+ this.valueEnd = new Number(metaquery.value[1]);
+ } else {
+ this.valueInit = new Number(metaquery.value);
+ }
}
} else {
this.valueInit = null;
diff --git a/src/views/admin/components/filter-types/numerics-intersection/class-tainacan-numerics-intersection.php b/src/views/admin/components/filter-types/numerics-intersection/class-tainacan-numerics-intersection.php
index b53da5ab8..6ab929e7e 100644
--- a/src/views/admin/components/filter-types/numerics-intersection/class-tainacan-numerics-intersection.php
+++ b/src/views/admin/components/filter-types/numerics-intersection/class-tainacan-numerics-intersection.php
@@ -44,26 +44,6 @@ class Numerics_Intersection extends Filter_Type {
- until
-
');
}
diff --git a/src/views/admin/pages/lists/filters-page.vue b/src/views/admin/pages/lists/filters-page.vue
index 921dd650d..c19d6b871 100644
--- a/src/views/admin/pages/lists/filters-page.vue
+++ b/src/views/admin/pages/lists/filters-page.vue
@@ -976,7 +976,7 @@ export default {
}
&:not(.available-metadata-area){
- margin-right: var(--tainacan-one-column);
+ margin-right: 30px;
flex-grow: 2;
@media screen and (max-width: 769px) {
diff --git a/src/views/tainacan-i18n.php b/src/views/tainacan-i18n.php
index ab0ebc810..ca131e628 100644
--- a/src/views/tainacan-i18n.php
+++ b/src/views/tainacan-i18n.php
@@ -529,6 +529,7 @@ return apply_filters( 'tainacan-i18n', [
'label_view_all_%s_collections' => __( 'View all %s collections', 'tainacan' ),
'label_view_collections_list' => __( 'View collections list', 'tainacan' ),
'label_comparator' => __( 'Comparator', 'tainacan' ),
+ 'label_comparators' => __( 'Comparators', 'tainacan' ),
'label_table_of_items' => __( 'Table of Items', 'tainacan' ),
'label_create_another_item' => __( 'Create another item', 'tainacan' ),
'label_recent_collections' => __( 'Recent Collections', 'tainacan' ),
@@ -1066,6 +1067,8 @@ return apply_filters( 'tainacan-i18n', [
'info_terms_creation_failed_due_to_value_%s' => __( 'Terms creation failed due to value: %s.', 'tainacan' ),
'info_terms_creation_failed_due_to_values_%s' => __( 'Terms creation failed due to values: %s.', 'tainacan' ),
'info_autodraft_updated' => __( 'Autodraft updated. Please create the item to keep your changes.', 'tainacan' ),
+ 'info_intersection_explainer' => __( 'Will show items if the selected value is:', 'tainacan' ),
+ 'info_intersection_rules' => __( 'The value must match both rules to appear in the filter.', 'tainacan' ),
/* Activity actions */
'action_update-metadata-value' => __( 'Item Metadata Value Updates', 'tainacan'),
From 20c2a3cc1a79ad088b3f7db4af0906b7c965a860 Mon Sep 17 00:00:00 2001
From: mateuswetah
Date: Sat, 8 Jun 2024 16:44:05 -0300
Subject: [PATCH 12/39] Adds intersection observer to watch map visibility in
geocoordinate metadatum and prevent it from being broken in certain
scenarios.
---
.../geocoordinate-item-metadatum/theme.js | 51 ++++++++++++++++++-
1 file changed, 50 insertions(+), 1 deletion(-)
diff --git a/src/views/gutenberg-blocks/blocks/geocoordinate-item-metadatum/theme.js b/src/views/gutenberg-blocks/blocks/geocoordinate-item-metadatum/theme.js
index 7608871fc..457260b55 100644
--- a/src/views/gutenberg-blocks/blocks/geocoordinate-item-metadatum/theme.js
+++ b/src/views/gutenberg-blocks/blocks/geocoordinate-item-metadatum/theme.js
@@ -7,6 +7,7 @@ import iconUrl from 'leaflet/dist/images/marker-icon.png';
import iconRetinaUrl from 'leaflet/dist/images/marker-icon-2x.png';
import shadowUrl from 'leaflet/dist/images/marker-shadow.png';
+// Defines custom marker icons
delete TainacanLeaflet.Icon.Default.prototype._getIconUrl;
TainacanLeaflet.Icon.Default.mergeOptions({
iconRetinaUrl: iconRetinaUrl,
@@ -14,6 +15,48 @@ TainacanLeaflet.Icon.Default.mergeOptions({
shadowUrl: shadowUrl
});
+// Observes the visibility of the map container to resize the map when it becomes visible
+const mapObserverOptions = {
+ root: null, // use the viewport
+ rootMargin: '0px',
+ threshold: 0.1 // 10% of the element is visible
+};
+
+// The mapObserver repeats part of the initialization logic to prevent the map from looking broke
+// when it becomes visible after being hidden, for example inside section tabs
+const mapObserver = new IntersectionObserver((entries, observer) => {
+ entries.forEach(entry => {
+ if (entry.isIntersecting) {
+ if (
+ entry &&
+ entry.target.id &&
+ window.tainacan_leaflet_maps &&
+ window.tainacan_leaflet_maps[entry.target.id]
+ ) {
+ const element = entry.target;
+
+ const children = element.children ? element.children : [];
+ if ( !children.length )
+ return;
+
+ const coordinates = [];
+ for (let i = 0; i < children.length; i++) {
+ if ( children[i].hasAttribute('data-latitude') && children[i].hasAttribute('data-longitude') )
+ coordinates.push([children[i].getAttribute('data-latitude'), children[i].getAttribute('data-longitude')]);
+ }
+
+ if ( !coordinates.length )
+ return;
+
+ const maximum_zoom = element.hasAttribute('data-maximum_zoom') ? element.getAttribute('data-maximum_zoom') : 12;
+
+ window.tainacan_leaflet_maps[element.id].invalidateSize(true);
+ window.tainacan_leaflet_maps[element.id].flyToBounds(coordinates, { maxZoom: maximum_zoom, animate: false });
+ }
+ }
+ });
+}, mapObserverOptions);
+
/* Loads and instantiates map components passed to data-module="geocoordinate-item-metadatum"*/
export default (element) => {
if (element && element.id) {
@@ -54,7 +97,13 @@ export default (element) => {
coordinates.forEach(coordinate => {
TainacanLeaflet.marker(coordinate).addTo(tainacanMap);
});
-
+
tainacanMap.flyToBounds(coordinates, { maxZoom: maximum_zoom });
+
+ mapObserver.observe(element);
+
+ // Stores referenced to the leaflet instances to manipulate them via the window object inside the observer
+ window.tainacan_leaflet_maps = typeof window.tainacan_leaflet_maps != "undefined" ? window.tainacan_leaflet_maps : {};
+ window.tainacan_leaflet_maps[element.id] = tainacanMap;
}
};
\ No newline at end of file
From 36aaa845f6a0de3926c22367a4ed008d152addf2 Mon Sep 17 00:00:00 2001
From: mateuswetah
Date: Mon, 10 Jun 2024 14:12:56 -0300
Subject: [PATCH 13/39] Small fixes to intersection filters form. #887.
---
.../components/edition/filter-edition-form.vue | 13 +++++++++----
.../dates-intersection/FormDatesIntersection.vue | 2 +-
.../FormNumericsIntersection.vue | 2 +-
3 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/src/views/admin/components/edition/filter-edition-form.vue b/src/views/admin/components/edition/filter-edition-form.vue
index 959ceb074..5b1da823a 100644
--- a/src/views/admin/components/edition/filter-edition-form.vue
+++ b/src/views/admin/components/edition/filter-edition-form.vue
@@ -292,12 +292,16 @@ export default {
}
},
created() {
-
+
this.form = this.editedFilter;
this.formErrors = this.form.formErrors != undefined ? this.form.formErrors : {};
this.formErrorMessage = this.form.formErrors != undefined ? this.form.formErrorMessage : '';
this.oldForm = JSON.parse(JSON.stringify(this.originalFilter));
+
+ if ( this.form.metadatum == undefined && this.oldForm.metadatum != undefined )
+ this.form.metadatum = this.oldForm.metadatum;
+
},
mounted() {
// Fills hook forms with it's real values
@@ -322,9 +326,11 @@ export default {
'updateFilter'
]),
saveEdition(filter) {
+
+ this.isLoading = true;
+
if ((filter.filter_type_object && filter.filter_type_object.form_component) || filter.edit_form == '') {
-
- this.isLoading = true;
+
for (let [key, value] of Object.entries(this.form)) {
if (key === 'begin_with_filter_collapsed' || key === 'display_in_repository_level_lists')
this.form[key] = (value == 'yes' || value == true) ? 'yes' : 'no';
@@ -372,7 +378,6 @@ export default {
formObj['display_in_repository_level_lists'] = 'no';
this.fillExtraFormData(formObj);
- this.isLoading = true;
this.updateFilter({ filterId: filter.id, index: this.index, options: formObj })
.then(() => {
this.form = {};
diff --git a/src/views/admin/components/filter-types/dates-intersection/FormDatesIntersection.vue b/src/views/admin/components/filter-types/dates-intersection/FormDatesIntersection.vue
index d9bea5a41..7a0aecb3e 100644
--- a/src/views/admin/components/filter-types/dates-intersection/FormDatesIntersection.vue
+++ b/src/views/admin/components/filter-types/dates-intersection/FormDatesIntersection.vue
@@ -24,7 +24,7 @@
{{ $i18n.get('instruction_select_second_date_to_compare' ) }}
{{ option.name }}
diff --git a/src/views/admin/components/filter-types/numerics-intersection/FormNumericsIntersection.vue b/src/views/admin/components/filter-types/numerics-intersection/FormNumericsIntersection.vue
index 45180670f..bcab48793 100644
--- a/src/views/admin/components/filter-types/numerics-intersection/FormNumericsIntersection.vue
+++ b/src/views/admin/components/filter-types/numerics-intersection/FormNumericsIntersection.vue
@@ -111,7 +111,7 @@
{{ $i18n.get('instruction_select_second_numeric_to_compare' ) }}
{{ option.name }}
From 49f002703100e850199f92213792c3aa42b7e495 Mon Sep 17 00:00:00 2001
From: mateuswetah
Date: Mon, 10 Jun 2024 17:06:34 -0300
Subject: [PATCH 14/39] Creates option to disable autohide of filters on mobile
screens. #893.
---
.../blocks/faceted-search/block.json | 4 +
.../blocks/faceted-search/deprecated.js | 321 ++++++++++++++++++
.../blocks/faceted-search/edit.js | 17 +-
.../blocks/faceted-search/save.js | 8 +-
.../blocks/faceted-search/theme.js | 3 +-
.../blocks/faceted-search/theme.vue | 48 ++-
6 files changed, 389 insertions(+), 12 deletions(-)
diff --git a/src/views/gutenberg-blocks/blocks/faceted-search/block.json b/src/views/gutenberg-blocks/blocks/faceted-search/block.json
index 39e7cfaa0..1da71581f 100644
--- a/src/views/gutenberg-blocks/blocks/faceted-search/block.json
+++ b/src/views/gutenberg-blocks/blocks/faceted-search/block.json
@@ -212,6 +212,10 @@
"collectionOrderByType": {
"type": "string",
"default": ""
+ },
+ "shouldNotHideFiltersOnMobile": {
+ "type": "boolean",
+ "default": false
}
},
"supports": {
diff --git a/src/views/gutenberg-blocks/blocks/faceted-search/deprecated.js b/src/views/gutenberg-blocks/blocks/faceted-search/deprecated.js
index 269016676..61ef8e1d3 100644
--- a/src/views/gutenberg-blocks/blocks/faceted-search/deprecated.js
+++ b/src/views/gutenberg-blocks/blocks/faceted-search/deprecated.js
@@ -1,6 +1,327 @@
const { useBlockProps } = wp.blockEditor;
export default [
+ /* Deprecated due to the creation of horizontal questions */
+ {
+ "attributes": {
+ "termId": {
+ "type": "string",
+ "default": null
+ },
+ "taxonomyId": {
+ "type": "string",
+ "default": null
+ },
+ "collectionId": {
+ "type": "string",
+ "default": null
+ },
+ "defaultViewMode": {
+ "type": "string",
+ "default": "masonry"
+ },
+ "enabledViewModes": {
+ "type": "array",
+ "default": []
+ },
+ "collectionDefaultViewMode": {
+ "type": "string",
+ "default": "masonry"
+ },
+ "collectionEnabledViewModes": {
+ "type": "array",
+ "default": []
+ },
+ "hideFilters": {
+ "type": "boolean",
+ "default": false
+ },
+ "hideHideFiltersButton": {
+ "type": "boolean",
+ "default": false
+ },
+ "hideSearch": {
+ "type": "boolean",
+ "default": false
+ },
+ "hideAdvancedSearch": {
+ "type": "boolean",
+ "default": false
+ },
+ "hideDisplayedMetadataButton": {
+ "type": "boolean",
+ "default": false
+ },
+ "hideSortingArea": {
+ "type": "boolean",
+ "default": false
+ },
+ "hideSortByButton": {
+ "type": "boolean",
+ "default": false
+ },
+ "hideItemsThumbnail": {
+ "type": "boolean",
+ "default": false
+ },
+ "hideExposersButton": {
+ "type": "boolean",
+ "default": false
+ },
+ "hideItemsPerPageButton": {
+ "type": "boolean",
+ "default": false
+ },
+ "defaultItemsPerPage": {
+ "type": "number",
+ "default": 12
+ },
+ "hideGoToPageButton": {
+ "type": "boolean",
+ "default": false
+ },
+ "hidePaginationArea": {
+ "type": "boolean",
+ "default": false
+ },
+ "showFiltersButtonInsideSearchControl": {
+ "type": "boolean",
+ "default": false
+ },
+ "startWithFiltersHidden": {
+ "type": "boolean",
+ "default": false
+ },
+ "filtersAsModal": {
+ "type": "boolean",
+ "default": false
+ },
+ "showInlineViewModeOptions": {
+ "type": "boolean",
+ "default": false
+ },
+ "showFullscreenWithViewModes": {
+ "type": "boolean",
+ "default": false
+ },
+ "listType": {
+ "type": "string",
+ "default": ""
+ },
+ "isCollectionModalOpen": {
+ "type": "boolean",
+ "default": false
+ },
+ "isTermModalOpen": {
+ "type": "boolean",
+ "default": false
+ },
+ "backgroundColor": {
+ "type": "string",
+ "default": "#ffffff"
+ },
+ "baseFontSize": {
+ "type": "number",
+ "default": 16
+ },
+ "filtersAreaWidth": {
+ "type": "number",
+ "default": 20
+ },
+ "inputColor": {
+ "type": "string",
+ "default": "#1d1d1d"
+ },
+ "inputBackgroundColor": {
+ "type": "string",
+ "default": "#ffffff"
+ },
+ "inputBorderColor": {
+ "type": "string",
+ "default": "#dbdbdb"
+ },
+ "labelColor": {
+ "type": "string",
+ "default": "#373839"
+ },
+ "infoColor": {
+ "type": "string",
+ "default": "#505253"
+ },
+ "headingColor": {
+ "type": "string",
+ "default": "#000000"
+ },
+ "skeletonColor": {
+ "type": "string",
+ "default": "#eeeeee"
+ },
+ "itemBackgroundColor": {
+ "type": "string",
+ "default": "#ffffff"
+ },
+ "itemHoverBackgroundColor": {
+ "type": "string",
+ "default": "#f2f2f2"
+ },
+ "itemHeadingHoverBackgroundColor": {
+ "type": "string",
+ "default": "#dbdbdb"
+ },
+ "primaryColor": {
+ "type": "string",
+ "default": "#d9eced"
+ },
+ "secondaryColor": {
+ "type": "string",
+ "default": "#187181"
+ },
+ "order": {
+ "type": "string",
+ "default": "ASC"
+ },
+ "orderBy": {
+ "type": "string",
+ "default": "date"
+ },
+ "orderByMeta": {
+ "type": "string",
+ "default": ""
+ },
+ "orderByType": {
+ "type": "string",
+ "default": ""
+ },
+ "collectionOrderBy": {
+ "type": "string",
+ "default": "date"
+ },
+ "collectionOrderByMeta": {
+ "type": "string",
+ "default": ""
+ },
+ "collectionOrderByType": {
+ "type": "string",
+ "default": ""
+ }
+ },
+ save: function({ attributes }) {
+ const {
+ termId,
+ taxonomyId,
+ collectionId,
+ defaultViewMode,
+ enabledViewModes,
+ collectionDefaultViewMode,
+ collectionEnabledViewModes,
+ hideDisplayedMetadataButton,
+ hideSortingArea,
+ hideFilters,
+ hideHideFiltersButton,
+ hideSearch,
+ hideAdvancedSearch,
+ hideSortByButton,
+ hideItemsThumbnail,
+ hidePaginationArea,
+ hideExposersButton,
+ hideItemsPerPageButton,
+ defaultItemsPerPage,
+ hideGoToPageButton,
+ showFiltersButtonInsideSearchControl,
+ startWithFiltersHidden,
+ filtersAsModal,
+ showInlineViewModeOptions,
+ showFullscreenWithViewModes,
+ listType,
+ backgroundColor,
+ baseFontSize,
+ filtersAreaWidth,
+ inputColor,
+ inputBackgroundColor,
+ inputBorderColor,
+ labelColor,
+ infoColor,
+ headingColor,
+ skeletonColor,
+ itemBackgroundColor,
+ itemHoverBackgroundColor,
+ itemHeadingHoverBackgroundColor,
+ primaryColor,
+ secondaryColor,
+ order,
+ orderBy,
+ orderByMeta,
+ orderByType,
+ collectionOrderBy,
+ collectionOrderByMeta,
+ collectionOrderByType
+ } = attributes;
+
+ let updatedListType = '' + listType;
+
+ if (updatedListType === '' && collectionId)
+ updatedListType = 'collection';
+ else if (updatedListType === '' && termId && taxonomyId)
+ updatedListType = 'term';
+
+ // Gets attributes such as style, that are automatically added by the editor hook
+ const blockProps = useBlockProps.save();
+
+ return
+
+
+
+ }
+ },
/* Deprecated during Vue 3 migration to prepend attributes with data- */
{
"attributes": {
diff --git a/src/views/gutenberg-blocks/blocks/faceted-search/edit.js b/src/views/gutenberg-blocks/blocks/faceted-search/edit.js
index ca93a1e9e..4636efb80 100644
--- a/src/views/gutenberg-blocks/blocks/faceted-search/edit.js
+++ b/src/views/gutenberg-blocks/blocks/faceted-search/edit.js
@@ -76,7 +76,8 @@ export default function({ attributes, setAttributes, isSelected, clientId }) {
orderByType,
collectionOrderBy,
collectionOrderByMeta,
- collectionOrderByType
+ collectionOrderByType,
+ shouldNotHideFiltersOnMobile
} = attributes;
// Gets blocks props from hook
@@ -89,7 +90,7 @@ export default function({ attributes, setAttributes, isSelected, clientId }) {
if ( enabledViewModes === null || !enabledViewModes.length )
enabledViewModes = Object.keys(tainacan_plugin.registered_view_modes);
- console.log('edit', collectionOrderByMeta);
+
const fontSizes = [
{
name: __( 'Tiny', 'tainacan' ),
@@ -204,7 +205,7 @@ export default function({ attributes, setAttributes, isSelected, clientId }) {
else
return;
}
-
+
return ( listType == 'preview' ?
+
{
+ shouldNotHideFiltersOnMobile = isChecked;
+ setAttributes({ shouldNotHideFiltersOnMobile: isChecked });
+ }
+ }
/>
+ data-default-orderby-type = { updatedListType == 'collection' ? (collectionOrderByType ? collectionOrderByType : '') : (orderByType ? orderByType : '') }
+ data-should-not-hide-filters-on-mobile = { shouldNotHideFiltersOnMobile ? shouldNotHideFiltersOnMobile.toString() : 'false' } >
};
\ No newline at end of file
diff --git a/src/views/gutenberg-blocks/blocks/faceted-search/theme.js b/src/views/gutenberg-blocks/blocks/faceted-search/theme.js
index 1c1ec4abc..7ca288fbf 100644
--- a/src/views/gutenberg-blocks/blocks/faceted-search/theme.js
+++ b/src/views/gutenberg-blocks/blocks/faceted-search/theme.js
@@ -130,7 +130,8 @@ export default (element) => {
startWithFiltersHidden: isParameterTrue(getDataAttribute(blockElement, 'start-with-filters-hidden')),
filtersAsModal: isParameterTrue(getDataAttribute(blockElement, 'filters-as-modal')),
showInlineViewModeOptions: isParameterTrue(getDataAttribute(blockElement, 'show-inline-view-mode-options')),
- showFullscreenWithViewModes: isParameterTrue(getDataAttribute(blockElement, 'show-fullscreen-with-view-modes'))
+ showFullscreenWithViewModes: isParameterTrue(getDataAttribute(blockElement, 'show-fullscreen-with-view-modes')),
+ shouldNotHideFiltersOnMobile: isParameterTrue(getDataAttribute(blockElement, 'should-not-hide-filters-on-mobile'))
}),
});
diff --git a/src/views/gutenberg-blocks/blocks/faceted-search/theme.vue b/src/views/gutenberg-blocks/blocks/faceted-search/theme.vue
index 5bbbfb8a1..63adc07a0 100644
--- a/src/views/gutenberg-blocks/blocks/faceted-search/theme.vue
+++ b/src/views/gutenberg-blocks/blocks/faceted-search/theme.vue
@@ -406,7 +406,44 @@
+
+
+
+
+
+
+
+
+
isLoadingItems = state" />
+
+
+
+
+
+
+
-
+
{
if (this.filtersAsModal && this.$refs['filters-modal'] && this.$refs['filters-modal'].focus)
this.$refs['filters-modal'].focus();
@@ -1129,7 +1167,7 @@
// Watches window resize to adjust filter's top position and compression on mobile
- if (!this.hideFilters) {
+ if ( !this.hideFilters && !this.shouldNotHideFiltersOnMobile ) {
this.hideFiltersOnMobile();
window.addEventListener('resize', this.hideFiltersOnMobile);
}
@@ -1589,7 +1627,7 @@
// Component
this.$emitter.off();
// Window
- if (!this.hideFilters)
+ if ( !this.hideFilters && !this.shouldNotHideFiltersOnMobile )
window.removeEventListener('resize', this.hideFiltersOnMobile);
// $root
if (!this.hideAdvancedSearch)
From fa0f35fa5c7aaccd450fbe9721e04b90cb8ab29c Mon Sep 17 00:00:00 2001
From: mateuswetah
Date: Tue, 11 Jun 2024 13:29:23 -0300
Subject: [PATCH 15/39] Basic layout and options for horizontal filters #893.
---
src/views/admin/scss/_filters-menu-modal.scss | 6 +++
.../blocks/faceted-search/block.json | 4 ++
.../blocks/faceted-search/edit.js | 12 +++++-
.../blocks/faceted-search/save.js | 6 ++-
.../theme-search/scss/_layout.scss | 42 +++++++++++++++++++
.../blocks/faceted-search/theme.js | 3 +-
.../blocks/faceted-search/theme.vue | 10 +++--
7 files changed, 75 insertions(+), 8 deletions(-)
diff --git a/src/views/admin/scss/_filters-menu-modal.scss b/src/views/admin/scss/_filters-menu-modal.scss
index 6786848bf..e02e599ad 100644
--- a/src/views/admin/scss/_filters-menu-modal.scss
+++ b/src/views/admin/scss/_filters-menu-modal.scss
@@ -36,6 +36,12 @@
}
}
+ &.horizontal-filters {
+ .modal-content {
+ padding: var(--tainacan-container-padding) var(--tainacan-one-column);
+ }
+ }
+
@media screen and (max-width: 768px) {
&:not(.filters-menu-modal) {
diff --git a/src/views/gutenberg-blocks/blocks/faceted-search/block.json b/src/views/gutenberg-blocks/blocks/faceted-search/block.json
index 1da71581f..b1c2b4128 100644
--- a/src/views/gutenberg-blocks/blocks/faceted-search/block.json
+++ b/src/views/gutenberg-blocks/blocks/faceted-search/block.json
@@ -216,6 +216,10 @@
"shouldNotHideFiltersOnMobile": {
"type": "boolean",
"default": false
+ },
+ "displayFiltersHorizontally": {
+ "type": "boolean",
+ "default": false
}
},
"supports": {
diff --git a/src/views/gutenberg-blocks/blocks/faceted-search/edit.js b/src/views/gutenberg-blocks/blocks/faceted-search/edit.js
index 4636efb80..af26d684a 100644
--- a/src/views/gutenberg-blocks/blocks/faceted-search/edit.js
+++ b/src/views/gutenberg-blocks/blocks/faceted-search/edit.js
@@ -77,7 +77,8 @@ export default function({ attributes, setAttributes, isSelected, clientId }) {
collectionOrderBy,
collectionOrderByMeta,
collectionOrderByType,
- shouldNotHideFiltersOnMobile
+ shouldNotHideFiltersOnMobile,
+ displayFiltersHorizontally
} = attributes;
// Gets blocks props from hook
@@ -519,6 +520,15 @@ export default function({ attributes, setAttributes, isSelected, clientId }) {
}
}
/>
+ {
+ displayFiltersHorizontally = isChecked;
+ setAttributes({ displayFiltersHorizontally: isChecked });
+ }
+ }
+ />
+ data-should-not-hide-filters-on-mobile = { shouldNotHideFiltersOnMobile ? shouldNotHideFiltersOnMobile.toString() : 'false' }
+ data-display-filters-horizontally = { displayFiltersHorizontally ? displayFiltersHorizontally.toString() : 'false' } >
};
\ No newline at end of file
diff --git a/src/views/gutenberg-blocks/blocks/faceted-search/theme-search/scss/_layout.scss b/src/views/gutenberg-blocks/blocks/faceted-search/theme-search/scss/_layout.scss
index 01cac3658..0a97a0cad 100644
--- a/src/views/gutenberg-blocks/blocks/faceted-search/theme-search/scss/_layout.scss
+++ b/src/views/gutenberg-blocks/blocks/faceted-search/theme-search/scss/_layout.scss
@@ -94,6 +94,10 @@
bottom: 0;
transition: top ease-in 0.75s, bottom ease-in 0.75s, position ease-in 0.75s;
+ &.horizontal-filters {
+ max-width: 100%;
+ }
+
@media screen and (max-width: 768px) {
padding: 0;
z-index: 99999;
@@ -125,6 +129,12 @@
.modal-close {
display: none;
}
+
+ &.horizontal-filters {
+ -webkit-flex: 0 1 100%;
+ -ms-flex: 0 1 100%;
+ flex: 0 1 100%;
+ }
}
}
@@ -156,6 +166,38 @@
}
}
+ &.has-horizontal-filters {
+ .items-list-area {
+ max-width: 100%;
+ }
+ #filters-modal.horizontal-filters:not(.modal) {
+ overflow: visible;
+
+ .modal-content,
+ .filters-components-list {
+ overflow: visible;
+ }
+
+ .filters-components-list {
+ margin-bottom: 0;
+
+ & > div {
+ display: inline-block;
+ vertical-align: text-top;
+ }
+ .filter-item-forms {
+ width: 200px;
+ min-width: 200px;
+ break-inside: avoid;
+ display: inline-block;
+ vertical-align: text-top;
+ padding-right: 1.5em;
+ margin-bottom: 12px;
+ }
+ }
+ }
+ }
+
@media screen and (max-width: 768px) {
&.is-filters-menu-open {
diff --git a/src/views/gutenberg-blocks/blocks/faceted-search/theme.js b/src/views/gutenberg-blocks/blocks/faceted-search/theme.js
index 7ca288fbf..aa179c9a8 100644
--- a/src/views/gutenberg-blocks/blocks/faceted-search/theme.js
+++ b/src/views/gutenberg-blocks/blocks/faceted-search/theme.js
@@ -131,7 +131,8 @@ export default (element) => {
filtersAsModal: isParameterTrue(getDataAttribute(blockElement, 'filters-as-modal')),
showInlineViewModeOptions: isParameterTrue(getDataAttribute(blockElement, 'show-inline-view-mode-options')),
showFullscreenWithViewModes: isParameterTrue(getDataAttribute(blockElement, 'show-fullscreen-with-view-modes')),
- shouldNotHideFiltersOnMobile: isParameterTrue(getDataAttribute(blockElement, 'should-not-hide-filters-on-mobile'))
+ shouldNotHideFiltersOnMobile: isParameterTrue(getDataAttribute(blockElement, 'should-not-hide-filters-on-mobile')),
+ displayFiltersHorizontally: isParameterTrue(getDataAttribute(blockElement, 'display-filters-horizontally')),
}),
});
diff --git a/src/views/gutenberg-blocks/blocks/faceted-search/theme.vue b/src/views/gutenberg-blocks/blocks/faceted-search/theme.vue
index 63adc07a0..a4d0f757e 100644
--- a/src/views/gutenberg-blocks/blocks/faceted-search/theme.vue
+++ b/src/views/gutenberg-blocks/blocks/faceted-search/theme.vue
@@ -412,7 +412,7 @@
id="filters-modal"
ref="filters-modal"
role="region"
- :class="'tainacan-modal tainacan-form filters-menu' + (filtersAsModal ? ' filters-menu-modal' : '')">
+ :class="'tainacan-modal tainacan-form filters-menu' + (displayFiltersHorizontally ? ' horizontal-filters' : '')">
@@ -452,7 +452,7 @@
:auto-focus="filtersAsModal"
:trap-focus="filtersAsModal"
full-screen
- :custom-class="'tainacan-modal tainacan-form filters-menu' + (filtersAsModal ? ' filters-menu-modal' : '')"
+ :custom-class="'tainacan-modal tainacan-form filters-menu' + (filtersAsModal ? ' filters-menu-modal' : '') + (displayFiltersHorizontally ? ' horizontal-filters' : '')"
:can-cancel="hideHideFiltersButton || !filtersAsModal ? ['x', 'outside'] : ['x', 'escape', 'outside']"
:close-button-aria-label="$i18n.get('close')">
@@ -775,7 +775,8 @@
filtersAsModal: false,
showInlineViewModeOptions: false,
showFullscreenWithViewModes: false,
- shouldNotHideFiltersOnMobile: false
+ shouldNotHideFiltersOnMobile: false,
+ displayFiltersHorizontally: false
},
data() {
return {
@@ -828,6 +829,7 @@
}),
wrapperClasses() {
return {
+ 'has-horizontal-filters': this.displayFiltersHorizontally,
'is-filters-menu-open': !this.hideFilters && this.isFiltersModalActive && !this.openAdvancedSearch,
'is-filters-menu-fixed-at-top': this.isFiltersListFixedAtTop,
'is-filters-menu-fixed-at-bottom': this.isFiltersListFixedAtBottom,
@@ -1963,7 +1965,7 @@
}
&:last-child {
- margin-right: auto;
+ margin-right: 0;
}
.label {
From 007a358a831faca13ee61c9cefd49e864020a683 Mon Sep 17 00:00:00 2001
From: mateuswetah
Date: Tue, 11 Jun 2024 22:05:00 -0300
Subject: [PATCH 16/39] Add option to hide the "collapse all" button in filters
panel. #893.
---
...ainacan-gutenberg-block-faceted-search.css | 20 +++++-
...can-gutenberg-block-faceted-search.css.map | 2 +-
.../class-tainacan-theme-helper.php | 8 ++-
.../components/search/filters-items-list.vue | 13 ++--
.../blocks/faceted-search/block.json | 4 ++
.../blocks/faceted-search/edit.js | 17 ++++-
.../blocks/faceted-search/style.scss | 30 +++++++-
.../theme-search/scss/_layout.scss | 15 ++--
.../blocks/faceted-search/theme.js | 1 +
.../blocks/faceted-search/theme.vue | 71 ++++++++++---------
10 files changed, 132 insertions(+), 49 deletions(-)
diff --git a/src/assets/css/tainacan-gutenberg-block-faceted-search.css b/src/assets/css/tainacan-gutenberg-block-faceted-search.css
index b3b4bc955..f1b3e01c4 100644
--- a/src/assets/css/tainacan-gutenberg-block-faceted-search.css
+++ b/src/assets/css/tainacan-gutenberg-block-faceted-search.css
@@ -55,6 +55,24 @@
flex-wrap: nowrap;
flex-direction: row;
flex: 1 0 auto; }
+ .wp-block-tainacan-faceted-search .items-list-placeholder .below-search-control.horizontal-filters {
+ flex-direction: column; }
+ .wp-block-tainacan-faceted-search .items-list-placeholder .below-search-control.horizontal-filters .filters {
+ flex-direction: row;
+ flex: 0 1 100%;
+ flex-wrap: wrap;
+ padding: 18px 12px 6px 12px; }
+ .wp-block-tainacan-faceted-search .items-list-placeholder .below-search-control.horizontal-filters .filters .fake-filters-heading {
+ margin-right: 90%;
+ top: -0.5em;
+ left: 0.5em; }
+ .wp-block-tainacan-faceted-search .items-list-placeholder .below-search-control.horizontal-filters .filters .fake-filters-heading + .fake-link {
+ margin-right: 95%;
+ margin-left: 12px; }
+ .wp-block-tainacan-faceted-search .items-list-placeholder .below-search-control.horizontal-filters .filters .fake-filter {
+ margin: 6px 12px;
+ display: inline-flex;
+ width: 16.666%; }
.wp-block-tainacan-faceted-search .items-list-placeholder .below-search-control .filters {
flex: 0 1 var(--tainacan-filter-menu-width-theme, 20%);
display: flex;
@@ -64,7 +82,7 @@
display: flex;
flex-direction: column;
width: 80%;
- margin: 5% 12%; }
+ margin: 5% 8%; }
.wp-block-tainacan-faceted-search .items-list-placeholder .below-search-control .filters .fake-filter .fake-text {
margin: 4px 0;
width: 35%;
diff --git a/src/assets/css/tainacan-gutenberg-block-faceted-search.css.map b/src/assets/css/tainacan-gutenberg-block-faceted-search.css.map
index 6cb06a426..a7f7a9080 100644
--- a/src/assets/css/tainacan-gutenberg-block-faceted-search.css.map
+++ b/src/assets/css/tainacan-gutenberg-block-faceted-search.css.map
@@ -1,6 +1,6 @@
{
"version": 3,
-"mappings": "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",
+"mappings": "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",
"sources": ["../../views/gutenberg-blocks/scss/gutenberg-blocks-variables.scss","../../views/gutenberg-blocks/blocks/faceted-search/style.scss"],
"names": [],
"file": "tainacan-gutenberg-block-faceted-search.css"
diff --git a/src/classes/theme-helper/class-tainacan-theme-helper.php b/src/classes/theme-helper/class-tainacan-theme-helper.php
index 422e9482d..0f1c8445a 100644
--- a/src/classes/theme-helper/class-tainacan-theme-helper.php
+++ b/src/classes/theme-helper/class-tainacan-theme-helper.php
@@ -512,6 +512,9 @@ class Theme_Helper {
* @type string $default_view_mode The default view mode
* @type bool $is_forced_view_mode Ignores user prefs to always render the choosen default view mode
* @type string[] $enabled_view_modes The list os enable view modes to display
+ * @type bool $should_not_hide_filters_on_mobile Disables the default behavior of automatically collapsing the filters inside a modal when in small screen sizes
+ * @type bool $display_filters_horizontally Display the filters in an horizontal panel above search control instead of a sidebar
+ * @type bool $hide_collapse_all_filters_button Hides the button that collapses all filters inside the filters panel
* @return string The HTML div to be used for rendering the items list vue component
*/
public function search_shortcode($args) {
@@ -617,7 +620,10 @@ class Theme_Helper {
'data-start-with-filters-hidden' => true,
'data-filters-as-modal' => true,
'data-show-inline-view-mode-options' => true,
- 'data-show-fullscreen-with-view-modes' => true
+ 'data-show-fullscreen-with-view-modes' => true,
+ 'data-should-not-hide-filters-on-mobile' => true,
+ 'data-display-filters-horizontally' => true,
+ 'data-hide-collapse-all-filters-button' => true
]
];
diff --git a/src/views/admin/components/search/filters-items-list.vue b/src/views/admin/components/search/filters-items-list.vue
index 3e7b39490..4c099bcb7 100644
--- a/src/views/admin/components/search/filters-items-list.vue
+++ b/src/views/admin/components/search/filters-items-list.vue
@@ -16,9 +16,11 @@
-
+
{
shouldNotHideFiltersOnMobile = isChecked;
@@ -529,6 +530,15 @@ export default function({ attributes, setAttributes, isSelected, clientId }) {
}
}
/>
+ {
+ hideColllapseAllFiltersButton = isChecked;
+ setAttributes({ hideColllapseAllFiltersButton: isChecked });
+ }
+ }
+ />
: null
}
-
+
{ !showFiltersButtonInsideSearchControl & !hideHideFiltersButton && !hideFilters ?
: null }
{
!hideFilters && !filtersAsModal && !startWithFiltersHidden ?
@@ -897,6 +907,7 @@ export default function({ attributes, setAttributes, isSelected, clientId }) {
}}
className="filters">
+ { !hideColllapseAllFiltersButton ?
: null }
{ Array(2).fill().map( () => {
return
diff --git a/src/views/gutenberg-blocks/blocks/faceted-search/style.scss b/src/views/gutenberg-blocks/blocks/faceted-search/style.scss
index 730818367..0a622a3ba 100644
--- a/src/views/gutenberg-blocks/blocks/faceted-search/style.scss
+++ b/src/views/gutenberg-blocks/blocks/faceted-search/style.scss
@@ -56,6 +56,33 @@
flex-direction: row;
flex: 1 0 auto;
+ &.horizontal-filters {
+ flex-direction: column;
+
+ .filters {
+ flex-direction: row;
+ flex: 0 1 100%;
+ flex-wrap: wrap;
+ padding: 18px 12px 6px 12px;
+
+ .fake-filters-heading {
+ margin-right: 90%;
+ top: -0.5em;
+ left: 0.5em;
+ }
+ .fake-filters-heading + .fake-link {
+ margin-right: 95%;
+ margin-left: 12px;
+ }
+
+ .fake-filter {
+ margin: 6px 12px;
+ display: inline-flex;
+ width: 16.666%;
+ }
+ }
+ }
+
.filters {
flex: 0 1 var(--tainacan-filter-menu-width-theme, 20%);
display: flex;
@@ -66,7 +93,8 @@
display: flex;
flex-direction: column;
width: 80%;
- margin: 5% 12%;
+ margin: 5% 8%;
+
.fake-text {
margin: 4px 0;
width: 35%;
diff --git a/src/views/gutenberg-blocks/blocks/faceted-search/theme-search/scss/_layout.scss b/src/views/gutenberg-blocks/blocks/faceted-search/theme-search/scss/_layout.scss
index 0a97a0cad..3cb9f750a 100644
--- a/src/views/gutenberg-blocks/blocks/faceted-search/theme-search/scss/_layout.scss
+++ b/src/views/gutenberg-blocks/blocks/faceted-search/theme-search/scss/_layout.scss
@@ -170,12 +170,13 @@
.items-list-area {
max-width: 100%;
}
- #filters-modal.horizontal-filters:not(.modal) {
+ #filters-modal.horizontal-filters {
overflow: visible;
.modal-content,
.filters-components-list {
overflow: visible;
+ width: 100%;
}
.filters-components-list {
@@ -186,14 +187,20 @@
vertical-align: text-top;
}
.filter-item-forms {
- width: 200px;
- min-width: 200px;
+ width: 100%;
+ min-width: 272px;
break-inside: avoid;
display: inline-block;
vertical-align: text-top;
- padding-right: 1.5em;
+ padding-right: 2.25em;
margin-bottom: 12px;
}
+
+ @media screen and (min-width: 769px) {
+ .filter-item-forms {
+ width: 272px;
+ }
+ }
}
}
}
diff --git a/src/views/gutenberg-blocks/blocks/faceted-search/theme.js b/src/views/gutenberg-blocks/blocks/faceted-search/theme.js
index aa179c9a8..ec2d46847 100644
--- a/src/views/gutenberg-blocks/blocks/faceted-search/theme.js
+++ b/src/views/gutenberg-blocks/blocks/faceted-search/theme.js
@@ -133,6 +133,7 @@ export default (element) => {
showFullscreenWithViewModes: isParameterTrue(getDataAttribute(blockElement, 'show-fullscreen-with-view-modes')),
shouldNotHideFiltersOnMobile: isParameterTrue(getDataAttribute(blockElement, 'should-not-hide-filters-on-mobile')),
displayFiltersHorizontally: isParameterTrue(getDataAttribute(blockElement, 'display-filters-horizontally')),
+ hideCollapseAllFiltersButton: isParameterTrue(getDataAttribute(blockElement, 'hide-collapse-all-filters-button')),
}),
});
diff --git a/src/views/gutenberg-blocks/blocks/faceted-search/theme.vue b/src/views/gutenberg-blocks/blocks/faceted-search/theme.vue
index a4d0f757e..4198d58e3 100644
--- a/src/views/gutenberg-blocks/blocks/faceted-search/theme.vue
+++ b/src/views/gutenberg-blocks/blocks/faceted-search/theme.vue
@@ -406,42 +406,43 @@
-
-
-
-
+
+
+
+
-
-
+
+
-
isLoadingItems = state" />
+ isLoadingItems = state" />
-
-
-
+
+
+
+
-
-
+
isLoadingItems = state" />
@@ -776,7 +778,8 @@
showInlineViewModeOptions: false,
showFullscreenWithViewModes: false,
shouldNotHideFiltersOnMobile: false,
- displayFiltersHorizontally: false
+ displayFiltersHorizontally: false,
+ hideCollapseAllFiltersButton: false,
},
data() {
return {
@@ -1172,6 +1175,8 @@
if ( !this.hideFilters && !this.shouldNotHideFiltersOnMobile ) {
this.hideFiltersOnMobile();
window.addEventListener('resize', this.hideFiltersOnMobile);
+ } else {
+ this.isFiltersModalActive = !this.startWithFiltersHidden;
}
// Uses Intersection Observer o see if the top of the list is on screen and fix filters list position
From f208741957fc713863abbc7cad803d9e5971fec7 Mon Sep 17 00:00:00 2001
From: mateuswetah
Date: Wed, 12 Jun 2024 09:00:47 -0300
Subject: [PATCH 17/39] Fixes to numeric and date intersection metadata. Adds
logic for removing secondary metadatum metaquery from tag. #887.
---
.../TainacanFilterDatesIntersection.vue | 13 ++++++++----
.../class-tainacan-dates-intersection.php | 7 +++++++
.../TainacanFilterNumericsIntersection.vue | 5 +++--
.../class-tainacan-numerics-intersection.php | 7 +++++++
.../components/search/filters-tags-list.vue | 13 +++++++-----
src/views/admin/js/event-bus-search.js | 8 ++++---
.../js/store/modules/search/mutations.js | 21 ++++++++++++++++---
7 files changed, 57 insertions(+), 17 deletions(-)
diff --git a/src/views/admin/components/filter-types/dates-intersection/TainacanFilterDatesIntersection.vue b/src/views/admin/components/filter-types/dates-intersection/TainacanFilterDatesIntersection.vue
index b46b1efeb..510942ea4 100644
--- a/src/views/admin/components/filter-types/dates-intersection/TainacanFilterDatesIntersection.vue
+++ b/src/views/admin/components/filter-types/dates-intersection/TainacanFilterDatesIntersection.vue
@@ -185,10 +185,15 @@
let dateInit = this.dateInit.getUTCFullYear() + '-' +
('00' + (this.dateInit.getUTCMonth() + 1)).slice(-2) + '-' +
('00' + this.dateInit.getUTCDate()).slice(-2);
- let dateEnd = this.dateEnd.getUTCFullYear() + '-' +
- ('00' + (this.dateEnd.getUTCMonth() + 1)).slice(-2) + '-' +
- ('00' + this.dateEnd.getUTCDate()).slice(-2);
- values = [ dateInit, dateEnd ];
+
+ if ( this.dateEnd !== null ) {
+ let dateEnd = this.dateEnd.getUTCFullYear() + '-' +
+ ('00' + (this.dateEnd.getUTCMonth() + 1)).slice(-2) + '-' +
+ ('00' + this.dateEnd.getUTCDate()).slice(-2);
+ values = [ dateInit, dateEnd ];
+ } else {
+ values = [ dateInit ];
+ }
}
if ( this.filterTypeOptions.accept_date_interval !== 'yes' ) {
diff --git a/src/views/admin/components/filter-types/dates-intersection/class-tainacan-dates-intersection.php b/src/views/admin/components/filter-types/dates-intersection/class-tainacan-dates-intersection.php
index 4e87802d4..9ad373a71 100644
--- a/src/views/admin/components/filter-types/dates-intersection/class-tainacan-dates-intersection.php
+++ b/src/views/admin/components/filter-types/dates-intersection/class-tainacan-dates-intersection.php
@@ -116,6 +116,13 @@ class Dates_Intersection_Interval_Helper {
) {
$filter_arguments['label'] = $filter_arguments['label'][0] . ' - ' . $filter_arguments['label'][1];
}
+ if (
+ isset( $filter_arguments['filter'] ) &&
+ isset( $filter_arguments['filter']['metadatum'] ) &&
+ isset( $filter_arguments['filter']['metadatum']['metadatum_name'] )
+ ) {
+ $filter_arguments['filter']['name'] = $filter_arguments['filter']['metadatum']['metadatum_name'];
+ }
if (
isset( $filter_arguments['filter'] ) &&
isset( $filter_arguments['filter']['filter_type_options'] ) &&
diff --git a/src/views/admin/components/filter-types/numerics-intersection/TainacanFilterNumericsIntersection.vue b/src/views/admin/components/filter-types/numerics-intersection/TainacanFilterNumericsIntersection.vue
index 5981bd661..f2e1dfcb8 100644
--- a/src/views/admin/components/filter-types/numerics-intersection/TainacanFilterNumericsIntersection.vue
+++ b/src/views/admin/components/filter-types/numerics-intersection/TainacanFilterNumericsIntersection.vue
@@ -101,7 +101,7 @@
compare: this.filterTypeOptions.first_comparator,
metadatum_id: this.metadatumId,
collection_id: this.collectionId,
- value: this.filterTypeOptions.accept_numeric_interval === 'yes' ? values : values[0]
+ value: values[0]
});
this.$emit('input', {
filter: 'intersection',
@@ -109,7 +109,8 @@
compare: this.filterTypeOptions.second_comparator,
metadatum_id: this.filterTypeOptions.secondary_filter_metadatum_id,
collection_id: this.collectionId,
- value: this.filterTypeOptions.accept_numeric_interval === 'yes' ? values : values[0]
+ value: values[0],
+ secondary: true
});
} else {
// Much more complicated logic to be implemented in the future. See #889
diff --git a/src/views/admin/components/filter-types/numerics-intersection/class-tainacan-numerics-intersection.php b/src/views/admin/components/filter-types/numerics-intersection/class-tainacan-numerics-intersection.php
index 6ab929e7e..3451cf38d 100644
--- a/src/views/admin/components/filter-types/numerics-intersection/class-tainacan-numerics-intersection.php
+++ b/src/views/admin/components/filter-types/numerics-intersection/class-tainacan-numerics-intersection.php
@@ -127,6 +127,13 @@ class Numerics_Intersection_Interval_Helper {
) {
$filter_arguments['label'] = $filter_arguments['label'][0] . ' - ' . $filter_arguments['label'][1];
}
+ if (
+ isset( $filter_arguments['filter'] ) &&
+ isset( $filter_arguments['filter']['metadatum'] ) &&
+ isset( $filter_arguments['filter']['metadatum']['metadatum_name'] )
+ ) {
+ $filter_arguments['filter']['name'] = $filter_arguments['filter']['metadatum']['metadatum_name'];
+ }
if (
isset( $filter_arguments['filter'] ) &&
isset( $filter_arguments['filter']['filter_type_options'] ) &&
diff --git a/src/views/admin/components/search/filters-tags-list.vue b/src/views/admin/components/search/filters-tags-list.vue
index 6f1e2159e..c80ecab41 100644
--- a/src/views/admin/components/search/filters-tags-list.vue
+++ b/src/views/admin/components/search/filters-tags-list.vue
@@ -113,7 +113,8 @@
taxonomy: tag.taxonomy,
metadatumName: this.getMetadatumName(tag),
metadatumId: tag.metadatumId,
- argType: tag.argType
+ argType: tag.argType,
+ secondaryMetadatumId: tag.secondaryMetadatumId
});
}
} else {
@@ -124,11 +125,12 @@
taxonomy: tag.taxonomy,
metadatumName: this.getMetadatumName(tag),
metadatumId: tag.metadatumId,
- argType: tag.argType
+ argType: tag.argType,
+ secondaryMetadatumId: tag.secondaryMetadatumId
});
}
});
-
+
return flattenTags;
}
},
@@ -168,7 +170,7 @@
...mapGetters('search',[
'getFilterTags'
]),
- removeMetaQuery({ filterId, value, singleLabel, label, taxonomy, metadatumId, metadatumName, argType }) {
+ removeMetaQuery({ filterId, value, singleLabel, label, taxonomy, metadatumId, metadatumName, argType, secondaryMetadatumId }) {
this.$eventBusSearch.resetPageOnStore();
this.$eventBusSearch.removeMetaFromFilterTag({
filterId: filterId,
@@ -178,7 +180,8 @@
taxonomy: taxonomy,
metadatumId: metadatumId,
metadatumName:metadatumName,
- argType: argType
+ argType: argType,
+ secondaryMetadatumId: secondaryMetadatumId
});
},
clearAllFilters() {
diff --git a/src/views/admin/js/event-bus-search.js b/src/views/admin/js/event-bus-search.js
index a9ba28c88..3147d51dc 100644
--- a/src/views/admin/js/event-bus-search.js
+++ b/src/views/admin/js/event-bus-search.js
@@ -29,7 +29,7 @@ export default {
this.updateURLQueries();
},
removeMetaFromFilterTag(filterTag) {
-
+
if (filterTag.singleLabel != undefined || filterTag.label != undefined) {
if (filterTag.argType !== 'postin') {
@@ -39,7 +39,8 @@ export default {
label: filterTag.singleLabel ? filterTag.singleLabel : filterTag.label,
isMultiValue: filterTag.singleLabel ? false : true,
taxonomy: filterTag.taxonomy,
- value: filterTag.value
+ value: filterTag.value,
+ secondaryMetadatumId: filterTag.secondaryMetadatumId
});
} else {
app.config.globalProperties.$store.dispatch('search/removeMetaQuery', {
@@ -47,7 +48,8 @@ export default {
label: filterTag.singleLabel ? filterTag.singleLabel : filterTag.label,
isMultiValue: filterTag.singleLabel ? false : true,
metadatum_id: filterTag.metadatumId,
- value: filterTag.value
+ value: filterTag.value,
+ secondaryMetadatumId: filterTag.secondaryMetadatumId
});
}
} else {
diff --git a/src/views/admin/js/store/modules/search/mutations.js b/src/views/admin/js/store/modules/search/mutations.js
index fe1d2baec..f53eacec2 100644
--- a/src/views/admin/js/store/modules/search/mutations.js
+++ b/src/views/admin/js/store/modules/search/mutations.js
@@ -91,13 +91,27 @@ export const removeMetaQuery = ( state, filter ) => {
let index = state.postquery.metaquery.findIndex( item => item.key == filter.metadatum_id);
- if (index >= 0) {
+ if ( index >= 0 ) {
if (!filter.isMultiValue && Array.isArray(state.postquery.metaquery[index].value) && state.postquery.metaquery[index].value.length > 1) {
let otherIndex = state.postquery.metaquery[index].value.findIndex(item => item == filter.value);
- if (otherIndex >= 0)
+ if ( otherIndex >= 0 )
state.postquery.metaquery[index].value.splice(otherIndex, 1)
} else
state.postquery.metaquery.splice(index, 1);
+ console.log(filter)
+ // Handles removing metaqueries from secondary filter metadata
+ if ( filter.secondaryMetadatumId ) {
+ let secondaryIndex = state.postquery.metaquery.findIndex( item => item.key == filter.secondaryMetadatumId);
+
+ if ( secondaryIndex >= 0 ) {
+ if ( !filter.isMultiValue && Array.isArray(state.postquery.metaquery[secondaryIndex].value) && state.postquery.metaquery[secondaryIndex].value.length > 1 ) {
+ let otherSecondaryIndex = state.postquery.metaquery[secondaryIndex].value.findIndex(item => item == filter.value);
+ if ( otherSecondaryIndex >= 0 )
+ state.postquery.metaquery[secondaryIndex].value.splice(otherSecondaryIndex, 1)
+ } else
+ state.postquery.metaquery.splice(secondaryIndex, 1);
+ }
+ }
}
};
@@ -188,7 +202,8 @@ export const setFilterTags = ( state, filterArguments ) => {
) ? aFilterArgument.metadatum.metadata_type_object.options.taxonomy : '',
argType: aFilterArgument.arg_type ? aFilterArgument.arg_type : '',
metadatumId: (aFilterArgument.filter && aFilterArgument.metadatum.metadatum_id) ? aFilterArgument.metadatum.metadatum_id : (aFilterArgument.metadatum.id || ''),
- metadatumName: (aFilterArgument.filter && aFilterArgument.filter.name) ? aFilterArgument.filter.name : (aFilterArgument.metadatum.name || '')
+ metadatumName: (aFilterArgument.filter && aFilterArgument.filter.name) ? aFilterArgument.filter.name : (aFilterArgument.metadatum.name || ''),
+ secondaryMetadatumId: (aFilterArgument.filter && aFilterArgument.filter.filter_type_options && aFilterArgument.filter.filter_type_options.secondary_filter_metadatum_id) ? aFilterArgument.filter.filter_type_options.secondary_filter_metadatum_id : '',
}
});
state.filter_tags = filterTags;
From 16e9579d5f4f7fcf82a5844a010d056d0e69a59a Mon Sep 17 00:00:00 2001
From: mateuswetah
Date: Wed, 12 Jun 2024 18:22:21 -0300
Subject: [PATCH 18/39] Add placeholder option to most filters. #894.
---
.../entities/class-tainacan-filter.php | 19 +++++++++-
.../repositories/class-tainacan-filters.php | 9 ++++-
.../edition/filter-edition-form.vue | 18 ++++++++++
.../TainacanFilterAutocomplete.vue | 2 +-
.../checkbox/class-tainacan-checkbox.php | 1 +
.../TainacanFilterDateInterval.vue | 4 +--
.../filter-types/date/TainacanFilterDate.vue | 2 +-
.../TainacanFilterDatesIntersection.vue | 4 +--
.../class-tainacan-filter-type.php | 36 ++++++++++++++-----
.../TainacanFilterNumericInterval.vue | 2 ++
.../TainacanFilterNumericListInterval.vue | 2 +-
.../numeric/TainacanFilterNumeric.vue | 1 +
.../TainacanFilterNumericsIntersection.vue | 2 ++
.../selectbox/TainacanFilterSelectbox.vue | 2 +-
.../taginput/TainacanFilterTaginput.vue | 2 +-
.../taxonomy/TainacanFilterTaginput.vue | 2 +-
.../class-tainacan-taxonomycheckbox.php | 1 +
.../js/store/modules/search/mutations.js | 2 +-
18 files changed, 89 insertions(+), 22 deletions(-)
diff --git a/src/classes/entities/class-tainacan-filter.php b/src/classes/entities/class-tainacan-filter.php
index 069f8f2a1..108b09c02 100644
--- a/src/classes/entities/class-tainacan-filter.php
+++ b/src/classes/entities/class-tainacan-filter.php
@@ -72,9 +72,16 @@ class Filter extends Entity {
/**
* @return mixed|null
*/
- function get_description(){
+ function get_description() {
return $this->get_mapped_property('description');
}
+
+ /**
+ * @return mixed|null
+ */
+ function get_placeholder() {
+ return $this->get_mapped_property('placeholder');
+ }
/**
* Return the filter order type
@@ -220,6 +227,16 @@ class Filter extends Entity {
$this->set_mapped_property('description', $value);
}
+ /**
+ * Define the filter placeholder
+ *
+ * @param [string] $value
+ * @return void
+ */
+ function set_placeholder($value) {
+ $this->set_mapped_property('placeholder', $value);
+ }
+
/**
* Define the filter metadatum passing an object
*
diff --git a/src/classes/repositories/class-tainacan-filters.php b/src/classes/repositories/class-tainacan-filters.php
index 6affb9fe3..06a9dc2c8 100644
--- a/src/classes/repositories/class-tainacan-filters.php
+++ b/src/classes/repositories/class-tainacan-filters.php
@@ -110,7 +110,14 @@ class Filters extends Repository {
'description' => __( 'The max number of options to be showed in filter sidebar.', 'tainacan' ),
'validation' => '',
'default' => 4
- ]
+ ],
+ 'placeholder' => [
+ 'map' => 'meta',
+ 'title' => __( 'Placeholder', 'tainacan' ),
+ 'type' => 'string',
+ 'description' => __( 'The filter input placeholder. This is a simple message that will appear inside textual input and may indicate to the user what kind of information is expected.', 'tainacan' ),
+ 'default' => '',
+ ],
] );
}
diff --git a/src/views/admin/components/edition/filter-edition-form.vue b/src/views/admin/components/edition/filter-edition-form.vue
index 5b1da823a..dfb820cfb 100644
--- a/src/views/admin/components/edition/filter-edition-form.vue
+++ b/src/views/admin/components/edition/filter-edition-form.vue
@@ -49,6 +49,24 @@
@focus="clearErrors('description')" />
+
+
+ {{ $i18n.getHelperTitle('filters', 'placeholder') }}
+
+
+
+
+
{ resetPage(); search($event); }"
@select="onSelect"
diff --git a/src/views/admin/components/filter-types/checkbox/class-tainacan-checkbox.php b/src/views/admin/components/filter-types/checkbox/class-tainacan-checkbox.php
index cd70039f5..452fae634 100644
--- a/src/views/admin/components/filter-types/checkbox/class-tainacan-checkbox.php
+++ b/src/views/admin/components/filter-types/checkbox/class-tainacan-checkbox.php
@@ -12,6 +12,7 @@ class Checkbox extends Filter_Type {
$this->set_name( __('Checkbox List', 'tainacan') );
$this->set_supported_types(['string','long_string','item', 'control']);
$this->set_component('tainacan-filter-checkbox');
+ $this->set_use_input_placeholder(false);
$this->set_preview_template('
diff --git a/src/views/admin/components/filter-types/date-interval/TainacanFilterDateInterval.vue b/src/views/admin/components/filter-types/date-interval/TainacanFilterDateInterval.vue
index 79c9ddb0a..f9a93fa60 100644
--- a/src/views/admin/components/filter-types/date-interval/TainacanFilterDateInterval.vue
+++ b/src/views/admin/components/filter-types/date-interval/TainacanFilterDateInterval.vue
@@ -3,7 +3,7 @@
get_name();
- $attributes['component'] = $this->get_component();
- $attributes['script'] = $this->get_script();
- $attributes['options'] = $this->get_options();
- $attributes['supported_types'] = $this->get_supported_types();
- $attributes['preview_template'] = $this->get_preview_template();
- $attributes['use_max_options'] = $this->get_use_max_options();
- $attributes['form_component'] = $this->get_form_component();
+ $attributes['className'] = get_class($this);
+ $attributes['name'] = $this->get_name();
+ $attributes['component'] = $this->get_component();
+ $attributes['script'] = $this->get_script();
+ $attributes['options'] = $this->get_options();
+ $attributes['supported_types'] = $this->get_supported_types();
+ $attributes['preview_template'] = $this->get_preview_template();
+ $attributes['use_max_options'] = $this->get_use_max_options();
+ $attributes['use_input_placeholder'] = $this->get_use_input_placeholder();
+ $attributes['form_component'] = $this->get_form_component();
return $attributes;
}
@@ -208,6 +218,14 @@ abstract class Filter_Type {
return $this->use_max_options;
}
+ public function set_use_input_placeholder($use_input_placeholder) {
+ $this->use_input_placeholder = $use_input_placeholder;
+ }
+
+ public function get_use_input_placeholder() {
+ return $this->use_input_placeholder;
+ }
+
/**
* Gets one option from the options array.
*
diff --git a/src/views/admin/components/filter-types/numeric-interval/TainacanFilterNumericInterval.vue b/src/views/admin/components/filter-types/numeric-interval/TainacanFilterNumericInterval.vue
index de8251007..4f37e9aec 100644
--- a/src/views/admin/components/filter-types/numeric-interval/TainacanFilterNumericInterval.vue
+++ b/src/views/admin/components/filter-types/numeric-interval/TainacanFilterNumericInterval.vue
@@ -5,6 +5,7 @@
:aria-labelledby="'filter-label-id-' + filter.id"
:aria-minus-label="$i18n.get('label_decrease')"
:aria-plus-label="$i18n.get('label_increase')"
+ :placeholder="filter.placeholder ? filter.placeholder : ''"
size="is-small"
:step="filterTypeOptions.step"
@update:model-value="($event) => { resetPage(); validadeValues($event) }"
@@ -19,6 +20,7 @@
:aria-labelledby="'filter-label-id-' + filter.id"
:aria-minus-label="$i18n.get('label_decrease')"
:aria-plus-label="$i18n.get('label_increase')"
+ :placeholder="filter.placeholder ? filter.placeholder : ''"
size="is-small"
:step="filterTypeOptions.step"
@update:model-value="($event) => { resetPage(); validadeValues($event) }" />
diff --git a/src/views/admin/components/filter-types/numeric-list-interval/TainacanFilterNumericListInterval.vue b/src/views/admin/components/filter-types/numeric-list-interval/TainacanFilterNumericListInterval.vue
index d0256781c..e27f2f0fd 100644
--- a/src/views/admin/components/filter-types/numeric-list-interval/TainacanFilterNumericListInterval.vue
+++ b/src/views/admin/components/filter-types/numeric-list-interval/TainacanFilterNumericListInterval.vue
@@ -3,7 +3,7 @@
{ resetPage; changeInterval($event) }">
{{ $i18n.get('label_selectbox_init') }}...
diff --git a/src/views/admin/components/filter-types/numeric/TainacanFilterNumeric.vue b/src/views/admin/components/filter-types/numeric/TainacanFilterNumeric.vue
index 25ca61d2a..eac5f2883 100644
--- a/src/views/admin/components/filter-types/numeric/TainacanFilterNumeric.vue
+++ b/src/views/admin/components/filter-types/numeric/TainacanFilterNumeric.vue
@@ -35,6 +35,7 @@
:aria-labelledby="'filter-label-id-' + filter.id"
:aria-minus-label="$i18n.get('label_decrease')"
:aria-plus-label="$i18n.get('label_increase')"
+ :placeholder="filter.placeholder ? filter.placeholder : ''"
size="is-small"
:step="Number(filterTypeOptions.step)"
@update:model-value="($event) => { resetPage($event); emit($event); }" />
diff --git a/src/views/admin/components/filter-types/numerics-intersection/TainacanFilterNumericsIntersection.vue b/src/views/admin/components/filter-types/numerics-intersection/TainacanFilterNumericsIntersection.vue
index f2e1dfcb8..8a7520420 100644
--- a/src/views/admin/components/filter-types/numerics-intersection/TainacanFilterNumericsIntersection.vue
+++ b/src/views/admin/components/filter-types/numerics-intersection/TainacanFilterNumericsIntersection.vue
@@ -5,6 +5,7 @@
:aria-labelledby="'filter-label-id-' + filter.id"
:aria-minus-label="$i18n.get('label_decrease')"
:aria-plus-label="$i18n.get('label_increase')"
+ :placeholder="filter.placeholder ? filter.placeholder : ''"
size="is-small"
:step="filterTypeOptions.step"
@update:model-value="($event) => { resetPage(); validadeValues($event) }"
@@ -21,6 +22,7 @@
:aria-labelledby="'filter-label-id-' + filter.id"
:aria-minus-label="$i18n.get('label_decrease')"
:aria-plus-label="$i18n.get('label_increase')"
+ :placeholder="filter.placeholder ? filter.placeholder : ''"
size="is-small"
:step="filterTypeOptions.step"
@update:model-value="($event) => { resetPage(); validadeValues($event) }" />
diff --git a/src/views/admin/components/filter-types/selectbox/TainacanFilterSelectbox.vue b/src/views/admin/components/filter-types/selectbox/TainacanFilterSelectbox.vue
index e7a260793..48773a048 100644
--- a/src/views/admin/components/filter-types/selectbox/TainacanFilterSelectbox.vue
+++ b/src/views/admin/components/filter-types/selectbox/TainacanFilterSelectbox.vue
@@ -6,7 +6,7 @@
v-if="!isLoadingOptions"
:model-value="selected"
:aria-labelledby="'filter-label-id-' + filter.id"
- :placeholder="$i18n.get('label_selectbox_init')"
+ :placeholder="filter.placeholder ? filter.placeholder : $i18n.get('label_selectbox_init')"
expanded
@update:model-value="($event) => { resetPage(); onSelect($event) }">
diff --git a/src/views/admin/components/filter-types/taginput/TainacanFilterTaginput.vue b/src/views/admin/components/filter-types/taginput/TainacanFilterTaginput.vue
index 3893d9605..b6ac80d9b 100644
--- a/src/views/admin/components/filter-types/taginput/TainacanFilterTaginput.vue
+++ b/src/views/admin/components/filter-types/taginput/TainacanFilterTaginput.vue
@@ -13,7 +13,7 @@
attached
:aria-close-label="$i18n.get('remove_value')"
:aria-labelledby="'filter-label-id-' + filter.id"
- :placeholder="getInputPlaceholder"
+ :placeholder="filter.placeholder ? filter.placeholder : getInputPlaceholder()"
check-infinite-scroll
@update:model-value="($event) => { resetPage(); onSelect($event) }"
@typing="search"
diff --git a/src/views/admin/components/filter-types/taxonomy/TainacanFilterTaginput.vue b/src/views/admin/components/filter-types/taxonomy/TainacanFilterTaginput.vue
index 268fb1374..1032ee282 100644
--- a/src/views/admin/components/filter-types/taxonomy/TainacanFilterTaginput.vue
+++ b/src/views/admin/components/filter-types/taxonomy/TainacanFilterTaginput.vue
@@ -14,7 +14,7 @@
:aria-close-label="$i18n.get('remove_value')"
:aria-labelledby="'filter-label-id-' + filter.id"
:class="{'has-selected': selected != undefined && selected != []}"
- :placeholder="$i18n.get('info_type_to_add_terms')"
+ :placeholder="filter.placeholder ? filter.placeholder : $i18n.get('info_type_to_add_terms')"
check-infinite-scroll
@typing="search"
@focus="($event) => { searchQuery = $event.target.value; performSearch(searchQuery) }"
diff --git a/src/views/admin/components/filter-types/taxonomy/class-tainacan-taxonomycheckbox.php b/src/views/admin/components/filter-types/taxonomy/class-tainacan-taxonomycheckbox.php
index b8f3b8c91..77c5326f1 100644
--- a/src/views/admin/components/filter-types/taxonomy/class-tainacan-taxonomycheckbox.php
+++ b/src/views/admin/components/filter-types/taxonomy/class-tainacan-taxonomycheckbox.php
@@ -12,6 +12,7 @@ class TaxonomyCheckbox extends Filter_Type {
$this->set_name( __('Taxonomy Checkbox List', 'tainacan') );
$this->set_supported_types(['term']);
$this->set_component('tainacan-filter-taxonomy-checkbox');
+ $this->set_use_input_placeholder(false);
$this->set_preview_template('
diff --git a/src/views/admin/js/store/modules/search/mutations.js b/src/views/admin/js/store/modules/search/mutations.js
index f53eacec2..79c0ff03f 100644
--- a/src/views/admin/js/store/modules/search/mutations.js
+++ b/src/views/admin/js/store/modules/search/mutations.js
@@ -98,7 +98,7 @@ export const removeMetaQuery = ( state, filter ) => {
state.postquery.metaquery[index].value.splice(otherIndex, 1)
} else
state.postquery.metaquery.splice(index, 1);
- console.log(filter)
+
// Handles removing metaqueries from secondary filter metadata
if ( filter.secondaryMetadatumId ) {
let secondaryIndex = state.postquery.metaquery.findIndex( item => item.key == filter.secondaryMetadatumId);
From 6f1ad642b4eb4a5861ac6d25af6886c1ae905a12 Mon Sep 17 00:00:00 2001
From: mateuswetah
Date: Thu, 13 Jun 2024 11:09:07 -0300
Subject: [PATCH 19/39] Displays filter desription in a tooltip or bellow the
name.
---
.../entities/class-tainacan-filter.php | 23 +++++-
.../repositories/class-tainacan-filters.php | 10 +++
.../edition/filter-edition-form.vue | 31 +++++++-
.../filter-types/tainacan-filter-item.vue | 73 ++++++++++++-------
.../admin/components/other/help-button.vue | 6 +-
.../blocks/faceted-search/theme.js | 2 +
6 files changed, 112 insertions(+), 33 deletions(-)
diff --git a/src/classes/entities/class-tainacan-filter.php b/src/classes/entities/class-tainacan-filter.php
index 108b09c02..2adff81d1 100644
--- a/src/classes/entities/class-tainacan-filter.php
+++ b/src/classes/entities/class-tainacan-filter.php
@@ -20,7 +20,8 @@ class Filter extends Entity {
$filter_type,
$filter_type_options,
$begin_with_filter_collapsed,
- $display_in_repository_level_lists;
+ $display_in_repository_level_lists,
+ $description_bellow_name;
static $post_type = 'tainacan-filter';
public $enabled_for_collection = true;
@@ -195,7 +196,15 @@ class Filter extends Entity {
public function get_display_in_repository_level_lists() {
return $this->get_mapped_property('display_in_repository_level_lists');
}
-
+
+ /**
+ * Return the filter description_bellow_name
+ *
+ * @return string
+ */
+ function get_description_bellow_name() {
+ return $this->get_mapped_property('description_bellow_name');
+ }
/**
* Define the filter name
@@ -301,6 +310,16 @@ class Filter extends Entity {
$this->enabled_for_collection = $value;
}
+ /**
+ * Set filter description_bellow_name
+ *
+ * @param [string] $value If the description will be displayed below the name instead of inside a tooltip (yes/no)
+ * @return void
+ */
+ function set_description_bellow_name($value) {
+ $this->set_mapped_property('description_bellow_name', $value);
+ }
+
/**
* {@inheritdoc }
diff --git a/src/classes/repositories/class-tainacan-filters.php b/src/classes/repositories/class-tainacan-filters.php
index 06a9dc2c8..68415bf13 100644
--- a/src/classes/repositories/class-tainacan-filters.php
+++ b/src/classes/repositories/class-tainacan-filters.php
@@ -118,6 +118,16 @@ class Filters extends Repository {
'description' => __( 'The filter input placeholder. This is a simple message that will appear inside textual input and may indicate to the user what kind of information is expected.', 'tainacan' ),
'default' => '',
],
+ 'description_bellow_name' => [
+ 'map' => 'meta',
+ 'title' => __( 'Description below name', 'tainacan' ),
+ 'type' => 'string',
+ 'description' => __( 'Whether the filter description should be displayed below the input label instead of inside a tooltip.', 'tainacan' ),
+ 'on_error' => __( 'Please set the "Description below name" value as "yes" or "no"', 'tainacan' ),
+ 'validation' => v::stringType()->in( [ 'yes', 'no' ] ), // yes or no
+ 'enum' => [ 'yes', 'no' ],
+ 'default' => 'no'
+ ],
] );
}
diff --git a/src/views/admin/components/edition/filter-edition-form.vue b/src/views/admin/components/edition/filter-edition-form.vue
index dfb820cfb..1486caba1 100644
--- a/src/views/admin/components/edition/filter-edition-form.vue
+++ b/src/views/admin/components/edition/filter-edition-form.vue
@@ -49,6 +49,27 @@
@focus="clearErrors('description')" />
+
+
+
+
+
+
+
{
this.form = {};
@@ -385,7 +408,7 @@ export default {
let formObj = {};
for (let [key, value] of formData.entries()) {
- if (key === 'begin_with_filter_collapsed' || key === 'display_in_repository_level_lists')
+ if (key === 'begin_with_filter_collapsed' || key === 'display_in_repository_level_lists' || key === 'description_bellow_name' )
formObj[key] = (value == 'yes' || value == true) ? 'yes' : 'no';
else
formObj[key] = value;
@@ -394,6 +417,8 @@ export default {
formObj['begin_with_filter_collapsed'] = 'no';
if (formObj['display_in_repository_level_lists'] === undefined)
formObj['display_in_repository_level_lists'] = 'no';
+ if (formObj['description_bellow_name'] === undefined)
+ formObj['description_bellow_name'] = 'no';
this.fillExtraFormData(formObj);
this.updateFilter({ filterId: filter.id, index: this.index, options: formObj })
diff --git a/src/views/admin/components/filter-types/tainacan-filter-item.vue b/src/views/admin/components/filter-types/tainacan-filter-item.vue
index 04b0e33ef..2ce80d509 100644
--- a/src/views/admin/components/filter-types/tainacan-filter-item.vue
+++ b/src/views/admin/components/filter-types/tainacan-filter-item.vue
@@ -13,17 +13,6 @@
- {{ filter.name }}
+
+ {{ filter.name }}
+
+
+
+ {{ filter.description }}
+
- {{ filter.name }}
+
+ {{ filter.name }}
+
+
@@ -218,6 +225,15 @@
outline: none;
padding: 0 !important;
margin: 0;
+
+ .tainacan-help-tooltip-trigger {
+ font-size: 1.188em;
+
+ .icon {
+ margin-right: 0px;
+ margin-left: 6px;
+ }
+ }
}
}
@@ -227,6 +243,13 @@
width: 100%;
}
+ .filter-description-help-info {
+ font-size: 0.75em;
+ color: var(--tainacan-info-color);
+ margin-top: -0.25em;
+ margin-bottom: 0.75em;
+ }
+
.taginput-container {
border-radius: var(--tainacan-input-border-radius, 1px) !important;
box-shadow: none !important;
diff --git a/src/views/admin/components/other/help-button.vue b/src/views/admin/components/other/help-button.vue
index 969233179..e95f020c7 100644
--- a/src/views/admin/components/other/help-button.vue
+++ b/src/views/admin/components/other/help-button.vue
@@ -30,8 +30,8 @@ export default {
},
computed: {
getHelperTooltipContent() {
- return `` + this.title + `
- ` + ((this.message != '' && this.message != undefined) ? this.message : this.$i18n.get('info_no_description_provided')) + `
`;
+ return ( this.title ? ( `` + this.title + `
` ) : '' ) +
+ `` + ((this.message != '' && this.message != undefined) ? this.message : this.$i18n.get('info_no_description_provided')) + `
`;
}
}
}
@@ -39,7 +39,7 @@ export default {
diff --git a/src/views/admin/components/filter-types/tainacan-filter-item.vue b/src/views/admin/components/filter-types/tainacan-filter-item.vue
index 2ce80d509..09bac0ae6 100644
--- a/src/views/admin/components/filter-types/tainacan-filter-item.vue
+++ b/src/views/admin/components/filter-types/tainacan-filter-item.vue
@@ -68,7 +68,6 @@
+ }"
+ class="collapse-label">
{{ filter.name }}
- {{ option.label }}
+
+ {{ option.label }}
+
{{ "(" + option.total_items + ")" }}
+ class="facet-item-count has-text-gray"> {{ "(" + option.total_items + ")" }}
From e81551085bc9ee00f4de042590e65031621df1e6 Mon Sep 17 00:00:00 2001
From: mateuswetah
Date: Thu, 13 Jun 2024 15:02:48 -0300
Subject: [PATCH 21/39] Fixes inconsistencies regarding mobile menu button
state.
---
src/views/admin/scss/_filters-menu-modal.scss | 2 +-
.../faceted-search/theme-search/scss/_layout.scss | 6 +-----
.../gutenberg-blocks/blocks/faceted-search/theme.vue | 11 +++++++++--
3 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/src/views/admin/scss/_filters-menu-modal.scss b/src/views/admin/scss/_filters-menu-modal.scss
index e02e599ad..4fdabe8ad 100644
--- a/src/views/admin/scss/_filters-menu-modal.scss
+++ b/src/views/admin/scss/_filters-menu-modal.scss
@@ -38,7 +38,7 @@
&.horizontal-filters {
.modal-content {
- padding: var(--tainacan-container-padding) var(--tainacan-one-column);
+ padding: calc(var(--tainacan-container-padding) - 12px) var(--tainacan-one-column) var(--tainacan-container-padding) var(--tainacan-one-column);
}
}
diff --git a/src/views/gutenberg-blocks/blocks/faceted-search/theme-search/scss/_layout.scss b/src/views/gutenberg-blocks/blocks/faceted-search/theme-search/scss/_layout.scss
index 3cb9f750a..f384bf8e6 100644
--- a/src/views/gutenberg-blocks/blocks/faceted-search/theme-search/scss/_layout.scss
+++ b/src/views/gutenberg-blocks/blocks/faceted-search/theme-search/scss/_layout.scss
@@ -192,12 +192,12 @@
break-inside: avoid;
display: inline-block;
vertical-align: text-top;
- padding-right: 2.25em;
margin-bottom: 12px;
}
@media screen and (min-width: 769px) {
.filter-item-forms {
+ padding-right: 2.25em;
width: 272px;
}
}
@@ -216,10 +216,6 @@
width: 100%;
}
- #filter-menu-compress-button {
- display: none;
- }
-
.filters-menu {
padding-top: 0;
diff --git a/src/views/gutenberg-blocks/blocks/faceted-search/theme.vue b/src/views/gutenberg-blocks/blocks/faceted-search/theme.vue
index 4198d58e3..9187da2ae 100644
--- a/src/views/gutenberg-blocks/blocks/faceted-search/theme.vue
+++ b/src/views/gutenberg-blocks/blocks/faceted-search/theme.vue
@@ -41,12 +41,19 @@
}"
aria-controls="filters-modal"
:aria-expanded="isFiltersModalActive"
- :class="hideHideFiltersButton ? 'is-hidden-tablet' : ''"
+ :class="{
+ 'is-hidden-tablet': !shouldNotHideFiltersOnMobile && hideHideFiltersButton,
+ 'is-hidden': shouldNotHideFiltersOnMobile && hideHideFiltersButton
+ }"
:aria-label="!isFiltersModalActive ? $i18n.get('label_show_filters') : $i18n.get('label_hide_filters')"
@click="isFiltersModalActive = !isFiltersModalActive">
{{ $i18n.get('filters') }}
From fbc3bc11db437429e8282a82f41b86575569ff5f Mon Sep 17 00:00:00 2001
From: mateuswetah
Date: Thu, 13 Jun 2024 18:00:26 -0300
Subject: [PATCH 22/39] Small tweaks to horizontal filters css. #893.
---
.../filter-types/numeric/TainacanFilterNumeric.vue | 2 +-
.../blocks/faceted-search/theme-search/scss/_layout.scss | 9 ++++++++-
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/src/views/admin/components/filter-types/numeric/TainacanFilterNumeric.vue b/src/views/admin/components/filter-types/numeric/TainacanFilterNumeric.vue
index eac5f2883..bb941c3d0 100644
--- a/src/views/admin/components/filter-types/numeric/TainacanFilterNumeric.vue
+++ b/src/views/admin/components/filter-types/numeric/TainacanFilterNumeric.vue
@@ -159,7 +159,7 @@
@media screen and (min-width: 769px) and (max-width: 1500px) {
flex-wrap: wrap;
- align-items: center;
+ align-items: stretch;
height: 60px;
}
diff --git a/src/views/gutenberg-blocks/blocks/faceted-search/theme-search/scss/_layout.scss b/src/views/gutenberg-blocks/blocks/faceted-search/theme-search/scss/_layout.scss
index f384bf8e6..f3b9e40ce 100644
--- a/src/views/gutenberg-blocks/blocks/faceted-search/theme-search/scss/_layout.scss
+++ b/src/views/gutenberg-blocks/blocks/faceted-search/theme-search/scss/_layout.scss
@@ -177,6 +177,8 @@
.filters-components-list {
overflow: visible;
width: 100%;
+ max-width: 100% !important;
+ margin: 0;
}
.filters-components-list {
@@ -196,10 +198,15 @@
}
@media screen and (min-width: 769px) {
+ & > div:not(:last-child) {
+ margin-right: 2.25em;
+ }
.filter-item-forms {
- padding-right: 2.25em;
width: 272px;
}
+ .filter-item-forms:not(:last-child) {
+ margin-right: 2.25em;
+ }
}
}
}
From f1fede5959fc9a8c6db969b2c7186884cb7df609 Mon Sep 17 00:00:00 2001
From: mateuswetah
Date: Fri, 14 Jun 2024 08:39:33 -0300
Subject: [PATCH 23/39] Huge fix: defines tooltip show delay correctly.
---
.../edition/item-bulk-edition-form.vue | 4 +-
.../checkbox/TainacanFilterCheckbox.vue | 11 +++++-
.../filter-types/tainacan-filter-item.vue | 2 +-
.../components/lists/activities-list.vue | 6 +--
.../components/lists/capabilities-list.vue | 6 +--
.../components/lists/collections-list.vue | 12 +++---
.../admin/components/lists/items-list.vue | 38 +++++++++----------
.../components/lists/metadata-types-list.vue | 4 +-
.../admin/components/lists/processes-list.vue | 24 ++++++------
.../components/lists/related-items-list.vue | 4 +-
.../components/lists/taxonomies-list.vue | 8 ++--
.../components/modals/bulk-edition-modal.vue | 2 +-
.../components/modals/exposers-modal.vue | 10 ++---
.../admin/components/other/help-button.vue | 2 +-
.../other/item-metadatum-errors-tooltip.vue | 2 +-
.../components/search/filters-items-list.vue | 8 ++--
src/views/admin/pages/lists/items-page.vue | 4 +-
.../components/view-mode-cards.vue | 6 +--
.../components/view-mode-list.vue | 6 +--
.../theme-search/components/view-mode-map.vue | 12 +++---
.../components/view-mode-masonry.vue | 2 +-
.../components/view-mode-records.vue | 6 +--
.../components/view-mode-slideshow.vue | 12 +++---
.../components/view-mode-table.vue | 8 ++--
.../blocks/faceted-search/theme.vue | 6 +--
25 files changed, 107 insertions(+), 98 deletions(-)
diff --git a/src/views/admin/components/edition/item-bulk-edition-form.vue b/src/views/admin/components/edition/item-bulk-edition-form.vue
index 4a0df4292..6c36974c6 100644
--- a/src/views/admin/components/edition/item-bulk-edition-form.vue
+++ b/src/views/admin/components/edition/item-bulk-edition-form.vue
@@ -110,7 +110,7 @@
v-if="item.document != '' && item.document_type != 'empty'"
v-tooltip="{
delay: {
- shown: 500,
+ show: 500,
hide: 300,
},
content: $i18n.get('label_document_uploaded'),
@@ -128,7 +128,7 @@
{{ option.label }}
diff --git a/src/views/admin/components/filter-types/tainacan-filter-item.vue b/src/views/admin/components/filter-types/tainacan-filter-item.vue
index 09bac0ae6..fcadeced1 100644
--- a/src/views/admin/components/filter-types/tainacan-filter-item.vue
+++ b/src/views/admin/components/filter-types/tainacan-filter-item.vue
@@ -70,7 +70,7 @@
` + $i18n.get('label_value_not_provided') + ` `),
@@ -534,7 +534,7 @@
` + $i18n.get('label_description_not_provided') + `
`,
@@ -678,7 +678,7 @@
0 && bgProcess.error_log && bgProcess.status === 'finished' ) "
v-tooltip="{
delay: {
- shown: 500,
+ show: 500,
hide: 300,
},
content: $i18n.get('label_process_completed_with_errors'),
@@ -182,7 +182,7 @@
v-if=" bgProcess.status === 'cancelled' "
v-tooltip="{
delay: {
- shown: 500,
+ show: 500,
hide: 300,
},
content: $i18n.get('label_process_cancelled'),
@@ -197,7 +197,7 @@
v-if=" bgProcess.status === 'paused' "
v-tooltip="{
delay: {
- shown: 500,
+ show: 500,
hide: 300,
},
content: $i18n.get('label_process_paused'),
@@ -212,7 +212,7 @@
v-if=" bgProcess.status === 'waiting' "
v-tooltip="{
delay: {
- shown: 500,
+ show: 500,
hide: 300,
},
content: $i18n.get('label_process_waiting'),
@@ -227,7 +227,7 @@
v-if=" bgProcess.status === 'waiting' "
v-tooltip="{
delay: {
- shown: 500,
+ show: 500,
hide: 300,
},
content: $i18n.get('label_delete_process'),
@@ -243,7 +243,7 @@
v-if="bgProcess.status === 'errored'"
v-tooltip="{
delay: {
- shown: 500,
+ show: 500,
hide: 300,
},
content: $i18n.get('label_process_failed'),
@@ -306,7 +306,7 @@
` + $i18n.get('label_value_not_provided') + ``,
@@ -117,7 +117,7 @@
0) ? renderListOfCollections(taxonomy.collections, taxonomy.metadata_by_collection) : $i18n.get('label_no_collections_using_taxonomy'),
@@ -191,7 +191,7 @@
diff --git a/src/views/admin/components/modals/exposers-modal.vue b/src/views/admin/components/modals/exposers-modal.vue
index fc9ef87a0..59014e06e 100644
--- a/src/views/admin/components/modals/exposers-modal.vue
+++ b/src/views/admin/components/modals/exposers-modal.vue
@@ -41,7 +41,7 @@
diff --git a/src/views/admin/components/search/filters-items-list.vue b/src/views/admin/components/search/filters-items-list.vue
index 4c099bcb7..1f566b946 100644
--- a/src/views/admin/components/search/filters-items-list.vue
+++ b/src/views/admin/components/search/filters-items-list.vue
@@ -58,7 +58,7 @@
v-if="taxonomyFilter.length > 0 && taxonomyFiltersCollectionNames != undefined && taxonomyFiltersCollectionNames[key] != undefined"
v-tooltip="{
delay: {
- shown: 500,
+ show: 500,
hide: 300,
},
content: $i18n.get('label_filters_from') + ' ' + taxonomyFiltersCollectionNames[key] + ': ',
@@ -101,7 +101,7 @@
v-if="taxonomyFilter.length > 0 && taxonomyFiltersCollectionNames != undefined && taxonomyFiltersCollectionNames[key] != undefined"
v-tooltip="{
delay: {
- shown: 500,
+ show: 500,
hide: 300,
},
content: $i18n.get('label_filters_from') + ' ' + taxonomyFiltersCollectionNames[key] + ': ',
@@ -148,7 +148,7 @@
v-if="repositoryCollectionFilter.length > 0 && repositoryCollectionNames != undefined && repositoryCollectionNames[key] != undefined"
v-tooltip="{
delay: {
- shown: 500,
+ show: 500,
hide: 300,
},
content: $i18n.get('label_filters_from') + ' ' + repositoryCollectionNames[key] + ': ',
@@ -191,7 +191,7 @@
v-if="repositoryCollectionFilter.length > 0 && repositoryCollectionNames != undefined && repositoryCollectionNames[key] != undefined"
v-tooltip="{
delay: {
- shown: 500,
+ show: 500,
hide: 300,
},
content: $i18n.get('label_filters_from') + ' ' + repositoryCollectionNames[key] + ': ',
diff --git a/src/views/admin/pages/lists/items-page.vue b/src/views/admin/pages/lists/items-page.vue
index 577200014..6a7578bc1 100644
--- a/src/views/admin/pages/lists/items-page.vue
+++ b/src/views/admin/pages/lists/items-page.vue
@@ -33,7 +33,7 @@
id="filter-menu-compress-button"
v-tooltip="{
delay: {
- shown: 500,
+ show: 500,
hide: 300,
},
content: !isFiltersModalActive ? $i18n.get('label_show_filters') : $i18n.get('label_hide_filters'),
@@ -223,7 +223,7 @@
ref="displayedMetadataDropdown"
v-tooltip="{
delay: {
- shown: 500,
+ show: 500,
hide: 300,
},
content: (totalItems <= 0 || adminViewMode == 'grid'|| adminViewMode == 'cards' || adminViewMode == 'masonry') ? (adminViewMode == 'grid'|| adminViewMode == 'cards' || adminViewMode == 'masonry') ? $i18n.get('info_current_view_mode_metadata_not_allowed') : $i18n.get('info_cant_select_metadata_without_items') : '',
diff --git a/src/views/gutenberg-blocks/blocks/faceted-search/theme-search/components/view-mode-cards.vue b/src/views/gutenberg-blocks/blocks/faceted-search/theme-search/components/view-mode-cards.vue
index 720bc0eb4..7192218b9 100644
--- a/src/views/gutenberg-blocks/blocks/faceted-search/theme-search/components/view-mode-cards.vue
+++ b/src/views/gutenberg-blocks/blocks/faceted-search/theme-search/components/view-mode-cards.vue
@@ -43,7 +43,7 @@
+
+
+
+ {{ filter.name }}
+
+
+
+
+
+ {{ filter.description }}
+
+
+
+
@@ -119,7 +151,8 @@
expandAll: true,
isLoadingItems: true,
filtersAsModal: Boolean,
- isMobileScreen: false
+ isMobileScreen: false,
+ hideCollapses: false
},
data() {
return {
@@ -137,7 +170,7 @@
watch: {
expandAll() {
this.singleCollapseOpen = this.expandAll;
- if (this.expandAll)
+ if ( this.expandAll )
this.displayFilter = true;
},
beginWithFilterCollapsed: {
@@ -212,7 +245,29 @@
.column {
padding: 0.75em 1px 0.75em 0 !important;
}
+ & > .label {
+ display: block !important;
+ width: 100%;
+ overflow-x: hidden;
+ text-overflow: ellipsis;
+ line-height: 1.4em !important;
+ border: none;
+ background-color: transparent;
+ color: var(--tainacan-label-color);
+ text-align: left;
+ outline: none;
+ padding: 0 !important;
+ margin: 0 0 8px 0;
+ .tainacan-help-tooltip-trigger {
+ font-size: 1.188em;
+
+ .icon {
+ margin-right: 0px;
+ margin-left: 6px;
+ }
+ }
+ }
.collapse {
.label {
display: inline-flex;
diff --git a/src/views/admin/components/search/filters-items-list.vue b/src/views/admin/components/search/filters-items-list.vue
index 556203823..87890c62f 100644
--- a/src/views/admin/components/search/filters-items-list.vue
+++ b/src/views/admin/components/search/filters-items-list.vue
@@ -16,10 +16,8 @@
= 0 && isRepositoryLevel ) || filters.length > 0
)"
aria-controls="filters-items-list"
:aria-expanded="!collapseAll"
@@ -35,7 +33,7 @@
-
+
+ :is-mobile-screen="isMobileScreen"
+ :hide-collapses="hideFilterCollapses" />
@@ -131,7 +130,8 @@
:expand-all="!collapseAll"
:is-repository-level="key == 'repository-filters'"
:filters-as-modal="filtersAsModal"
- :is-mobile-screen="isMobileScreen" />
+ :is-mobile-screen="isMobileScreen"
+ :hide-collapses="hideFilterCollapses" />
@@ -178,7 +178,8 @@
:expand-all="!collapseAll"
:is-repository-level="key == 'repository-filters'"
:filters-as-modal="filtersAsModal"
- :is-mobile-screen="isMobileScreen" />
+ :is-mobile-screen="isMobileScreen"
+ :hide-collapses="hideFilterCollapses" />
@@ -221,7 +222,8 @@
:expand-all="!collapseAll"
:is-repository-level="key == 'repository-filters'"
:filters-as-modal="filtersAsModal"
- :is-mobile-screen="isMobileScreen" />
+ :is-mobile-screen="isMobileScreen"
+ :hide-collapses="hideFilterCollapses" />
@@ -239,7 +241,8 @@
:expand-all="!collapseAll"
:is-repository-level="isRepositoryLevel"
:filters-as-modal="filtersAsModal"
- :is-mobile-screen="isMobileScreen" />
+ :is-mobile-screen="isMobileScreen"
+ :hide-collapses="hideFilterCollapses" />
{
- hideColllapseAllFiltersButton = isChecked;
- setAttributes({ hideColllapseAllFiltersButton: isChecked });
+ hideFilterColllapses = isChecked;
+ setAttributes({ hideFilterColllapses: isChecked });
}
}
/>
@@ -920,7 +920,7 @@ export default function({ attributes, setAttributes, isSelected, clientId }) {
}}
className="filters">
- { !hideColllapseAllFiltersButton ? : null }
+ { !hideFilterColllapses ? : null }
{ Array(2).fill().map( () => {
return
diff --git a/src/views/gutenberg-blocks/blocks/faceted-search/theme.js b/src/views/gutenberg-blocks/blocks/faceted-search/theme.js
index f7f71fb71..adbea16c2 100644
--- a/src/views/gutenberg-blocks/blocks/faceted-search/theme.js
+++ b/src/views/gutenberg-blocks/blocks/faceted-search/theme.js
@@ -134,7 +134,7 @@ export default (element) => {
showFullscreenWithViewModes: isParameterTrue(getDataAttribute(blockElement, 'show-fullscreen-with-view-modes')),
shouldNotHideFiltersOnMobile: isParameterTrue(getDataAttribute(blockElement, 'should-not-hide-filters-on-mobile')),
displayFiltersHorizontally: isParameterTrue(getDataAttribute(blockElement, 'display-filters-horizontally')),
- hideCollapseAllFiltersButton: isParameterTrue(getDataAttribute(blockElement, 'hide-collapse-all-filters-button')),
+ hideFilterCollapses: isParameterTrue(getDataAttribute(blockElement, 'hide-filter-collapses')),
}),
});
diff --git a/src/views/gutenberg-blocks/blocks/faceted-search/theme.vue b/src/views/gutenberg-blocks/blocks/faceted-search/theme.vue
index cb0e3cf54..c2c10ff21 100644
--- a/src/views/gutenberg-blocks/blocks/faceted-search/theme.vue
+++ b/src/views/gutenberg-blocks/blocks/faceted-search/theme.vue
@@ -438,7 +438,7 @@
:filters-as-modal="false"
:has-filtered="hasFiltered"
:is-mobile-screen="isMobileScreen"
- :hide-collapse-all-filters-button="hideCollapseAllFiltersButton"
+ :hide-filter-collapses="hideFilterCollapses"
@update-is-loading-items-state="(state) => isLoadingItems = state" />
@@ -483,7 +483,7 @@
:filters-as-modal="filtersAsModal"
:has-filtered="hasFiltered"
:is-mobile-screen="isMobileScreen"
- :hide-collapse-all-filters-button="hideCollapseAllFiltersButton"
+ :hide-filter-collapses="hideFilterCollapses"
@update-is-loading-items-state="(state) => isLoadingItems = state" />
@@ -786,7 +786,7 @@
showFullscreenWithViewModes: false,
shouldNotHideFiltersOnMobile: false,
displayFiltersHorizontally: false,
- hideCollapseAllFiltersButton: false,
+ hideFilterCollapses: false,
},
data() {
return {
From a1db262808efcab4ea4d710ac3f36716f113b740 Mon Sep 17 00:00:00 2001
From: mateuswetah
Date: Fri, 14 Jun 2024 14:13:11 -0300
Subject: [PATCH 27/39] Small tweak to tooltip colors.
---
src/views/admin/components/other/help-button.vue | 4 ++--
src/views/admin/scss/_tooltips.scss | 5 +++--
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/src/views/admin/components/other/help-button.vue b/src/views/admin/components/other/help-button.vue
index 9415b357f..d2b885cd1 100644
--- a/src/views/admin/components/other/help-button.vue
+++ b/src/views/admin/components/other/help-button.vue
@@ -30,8 +30,8 @@ export default {
},
computed: {
getHelperTooltipContent() {
- return ( this.title ? ( `` + this.title + `
` ) : '' ) +
- `` + ((this.message != '' && this.message != undefined) ? this.message : this.$i18n.get('info_no_description_provided')) + `
`;
+ return ( this.title ? ( `` + this.title + `
` ) : '' ) +
+ `` + ((this.message != '' && this.message != undefined) ? this.message : this.$i18n.get('info_no_description_provided')) + `
`;
}
}
}
diff --git a/src/views/admin/scss/_tooltips.scss b/src/views/admin/scss/_tooltips.scss
index 6aa09bbd6..70e97e4ce 100644
--- a/src/views/admin/scss/_tooltips.scss
+++ b/src/views/admin/scss/_tooltips.scss
@@ -316,7 +316,8 @@
.help-tooltip-header {
padding: 0.8em 0.8em 0em 0.8em;
- h5 {
+ h5,
+ p {
font-size: 0.875em !important;
font-weight: bold;
color: var(--tainacan-blue5);
@@ -335,7 +336,7 @@
overflow: visible !important;
max-height: 100% !important;
line-height: normal;
- color: var(--tainacan-blue5);
+ color: var(--tainacan-info-color);
}
}
}
From 0f4ac988329ed5fe86e185d14797b3cd21b6acad Mon Sep 17 00:00:00 2001
From: mateuswetah
Date: Mon, 17 Jun 2024 11:45:58 -0300
Subject: [PATCH 28/39] Align facets count to center in checkbox filters.
---
.../components/filter-types/checkbox/TainacanFilterCheckbox.vue | 2 +-
.../components/filter-types/taxonomy/TainacanFilterCheckbox.vue | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/views/admin/components/filter-types/checkbox/TainacanFilterCheckbox.vue b/src/views/admin/components/filter-types/checkbox/TainacanFilterCheckbox.vue
index 51577d85c..d141ea5b9 100644
--- a/src/views/admin/components/filter-types/checkbox/TainacanFilterCheckbox.vue
+++ b/src/views/admin/components/filter-types/checkbox/TainacanFilterCheckbox.vue
@@ -255,7 +255,7 @@
display: flex;
flex-wrap: nowrap;
width: 100%;
- align-items: baseline;
+ align-items: center;
}
.checkbox-label-text {
white-space: wrap;
diff --git a/src/views/admin/components/filter-types/taxonomy/TainacanFilterCheckbox.vue b/src/views/admin/components/filter-types/taxonomy/TainacanFilterCheckbox.vue
index 59d6de1fb..5314685e6 100644
--- a/src/views/admin/components/filter-types/taxonomy/TainacanFilterCheckbox.vue
+++ b/src/views/admin/components/filter-types/taxonomy/TainacanFilterCheckbox.vue
@@ -341,7 +341,7 @@
display: flex;
flex-wrap: nowrap;
width: 100%;
- align-items: baseline;
+ align-items: center;
}
.checkbox-label-text {
white-space: wrap;
From a93d786997054d2d46366b355df6e0102d1e78ac Mon Sep 17 00:00:00 2001
From: mateuswetah
Date: Thu, 20 Jun 2024 11:25:33 -0300
Subject: [PATCH 29/39] Small fixes to filter placeholder.
---
.../filter-types/taginput/TainacanFilterTaginput.vue | 2 +-
src/views/gutenberg-blocks/blocks/faceted-search/edit.js | 6 ++++--
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/views/admin/components/filter-types/taginput/TainacanFilterTaginput.vue b/src/views/admin/components/filter-types/taginput/TainacanFilterTaginput.vue
index b6ac80d9b..861a903af 100644
--- a/src/views/admin/components/filter-types/taginput/TainacanFilterTaginput.vue
+++ b/src/views/admin/components/filter-types/taginput/TainacanFilterTaginput.vue
@@ -13,7 +13,7 @@
attached
:aria-close-label="$i18n.get('remove_value')"
:aria-labelledby="'filter-label-id-' + filter.id"
- :placeholder="filter.placeholder ? filter.placeholder : getInputPlaceholder()"
+ :placeholder="filter.placeholder ? filter.placeholder : getInputPlaceholder"
check-infinite-scroll
@update:model-value="($event) => { resetPage(); onSelect($event) }"
@typing="search"
diff --git a/src/views/gutenberg-blocks/blocks/faceted-search/edit.js b/src/views/gutenberg-blocks/blocks/faceted-search/edit.js
index 61c305ee1..d362c46ba 100644
--- a/src/views/gutenberg-blocks/blocks/faceted-search/edit.js
+++ b/src/views/gutenberg-blocks/blocks/faceted-search/edit.js
@@ -523,7 +523,8 @@ export default function({ attributes, setAttributes, isSelected, clientId }) {
}
/>
{
displayFiltersHorizontally = isChecked;
@@ -532,7 +533,8 @@ export default function({ attributes, setAttributes, isSelected, clientId }) {
}
/>
{
hideFilterColllapses = isChecked;
From f5b7cbfb23360c188f3fb1a5f1a25dc22eb51c5d Mon Sep 17 00:00:00 2001
From: mateuswetah
Date: Fri, 21 Jun 2024 15:29:22 -0300
Subject: [PATCH 30/39] Creates Mosaic View Mode and fixes some alignement
issues with previous ones.
---
.../class-tainacan-collections.php | 2 +-
.../class-tainacan-theme-helper.php | 18 ++
.../admin/components/lists/items-list.vue | 182 +++++++++++++++
src/views/admin/pages/lists/items-page.vue | 33 ++-
src/views/admin/scss/_view-mode-cards.scss | 2 +-
src/views/admin/scss/_view-mode-list.scss | 3 +-
src/views/admin/scss/_view-mode-map.scss | 1 +
src/views/admin/scss/_view-mode-masonry.scss | 3 +-
src/views/admin/scss/_view-mode-mosaic.scss | 221 ++++++++++++++++++
src/views/admin/scss/_view-mode-records.scss | 3 +-
.../blocks/dynamic-items-list/theme.js | 2 +-
.../components/view-mode-mosaic.vue | 137 +++++++++++
.../theme-search/scss/_layout.scss | 1 +
.../blocks/faceted-search/theme.js | 2 +-
src/views/tainacan-i18n.php | 1 +
15 files changed, 595 insertions(+), 16 deletions(-)
create mode 100644 src/views/admin/scss/_view-mode-mosaic.scss
create mode 100644 src/views/gutenberg-blocks/blocks/faceted-search/theme-search/components/view-mode-mosaic.vue
diff --git a/src/classes/repositories/class-tainacan-collections.php b/src/classes/repositories/class-tainacan-collections.php
index 8a39617cd..d547cfefa 100644
--- a/src/classes/repositories/class-tainacan-collections.php
+++ b/src/classes/repositories/class-tainacan-collections.php
@@ -132,7 +132,7 @@ class Collections extends Repository {
'title' => __( 'Enabled view modes', 'tainacan' ),
'type' => 'array',
'description' => __( 'Which visualization modes will be available for the public to choose from', 'tainacan' ),
- 'default' => [ 'table', 'cards' ],
+ 'default' => [ 'table', 'cards', 'masonry' ],
'items' => [ 'type' => 'string' ],
//'validation' => v::stringType(),
],
diff --git a/src/classes/theme-helper/class-tainacan-theme-helper.php b/src/classes/theme-helper/class-tainacan-theme-helper.php
index 051499878..5c422ff8c 100644
--- a/src/classes/theme-helper/class-tainacan-theme-helper.php
+++ b/src/classes/theme-helper/class-tainacan-theme-helper.php
@@ -2485,5 +2485,23 @@ class Theme_Helper {
'requires_thumbnail' => false,
'placeholder_template' => $map_view_mode_placeholder
]);
+
+ $this->register_view_mode('mosaic', [
+ 'label' => __('Mosaic', 'tainacan'),
+ 'dynamic_metadata' => false,
+ 'description' => __('A mosaic view, similar to Flickr and Google Photos, which will display images without cropping.', 'tainacan'),
+ 'icon' => ' ',
+ 'type' => 'component',
+ 'implements_skeleton' => true,
+ 'placeholder_template' => '' .
+ array_reduce( range(0,11), function($container, $i) {
+ $container .= '
+
+
+ ';
+ return $container;
+ }) .
+ ' '
+ ]);
}
}
diff --git a/src/views/admin/components/lists/items-list.vue b/src/views/admin/components/lists/items-list.vue
index da167dd1d..043399001 100644
--- a/src/views/admin/components/lists/items-list.vue
+++ b/src/views/admin/components/lists/items-list.vue
@@ -1979,6 +1979,181 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ $i18n.get('label_select_item') }}
+
+
+
+
+
+
+
+
+
+
+
@@ -2674,6 +2849,12 @@ export default {
duration: 3000
});
}
+ },
+ getAcceptableWidthBasedOnRatio(thumbnail, size, defaultSize) {
+ const width = this.$thumbHelper.getWidth(thumbnail, size, defaultSize);
+ const height = this.$thumbHelper.getHeight(thumbnail, size, defaultSize);
+
+ return (width / height) > 0.7 ? width : ( height * 0.7 );
}
}
}
@@ -2685,6 +2866,7 @@ export default {
@import "../../scss/_tables.scss";
@import "../../scss/_view-mode-cards.scss";
@import "../../scss/_view-mode-masonry.scss";
+ @import "../../scss/_view-mode-mosaic.scss";
@import "../../scss/_view-mode-grid.scss";
@import "../../scss/_view-mode-records.scss";
@import "../../scss/_view-mode-list.scss";
diff --git a/src/views/admin/pages/lists/items-page.vue b/src/views/admin/pages/lists/items-page.vue
index 6a7578bc1..8f9738e7d 100644
--- a/src/views/admin/pages/lists/items-page.vue
+++ b/src/views/admin/pages/lists/items-page.vue
@@ -226,13 +226,13 @@
show: 500,
hide: 300,
},
- content: (totalItems <= 0 || adminViewMode == 'grid'|| adminViewMode == 'cards' || adminViewMode == 'masonry') ? (adminViewMode == 'grid'|| adminViewMode == 'cards' || adminViewMode == 'masonry') ? $i18n.get('info_current_view_mode_metadata_not_allowed') : $i18n.get('info_cant_select_metadata_without_items') : '',
+ content: (totalItems <= 0 || adminViewMode == 'grid'|| adminViewMode == 'cards' || adminViewMode == 'masonry' || adminViewMode == 'mosaic') ? (adminViewMode == 'grid'|| adminViewMode == 'cards' || adminViewMode == 'masonry' || adminViewMode == 'mosaic') ? $i18n.get('info_current_view_mode_metadata_not_allowed') : $i18n.get('info_cant_select_metadata_without_items') : '',
autoHide: false,
placement: 'auto-start',
popperClass: ['tainacan-tooltip', 'tooltip', isRepositoryLevel ? 'tainacan-repository-tooltip' : '']
}"
:mobile-modal="true"
- :disabled="totalItems <= 0 || adminViewMode == 'grid'|| adminViewMode == 'cards' || adminViewMode == 'masonry'"
+ :disabled="totalItems <= 0 || adminViewMode == 'grid'|| adminViewMode == 'cards' || adminViewMode == 'masonry' || adminViewMode == 'mosaic'"
class="show metadata-options-dropdown"
aria-role="list"
trap-focus>
@@ -383,12 +383,15 @@
{{ $i18n.get('label_cards') }}
+
+
+
+
+ {{ $i18n.get('label_mosaic') }}
+
= 0 ? currentAdminViewMode : 'table';
+ return ['table', 'cards', 'records', 'grid', 'masonry', 'list', 'map', 'mosaic'].indexOf(currentAdminViewMode) >= 0 ? currentAdminViewMode : 'table';
},
orderByName() {
const metadatumName = this.$orderByHelper.getOrderByMetadatumName({
@@ -994,6 +1008,7 @@
existingViewMode == 'list' ||
existingViewMode == 'grid' ||
existingViewMode == 'masonry'||
+ existingViewMode == 'mosaic'||
existingViewMode == 'map')
this.$eventBusSearch.setInitialAdminViewMode(this.$userPrefs.get(prefsAdminViewMode));
else
diff --git a/src/views/admin/scss/_view-mode-cards.scss b/src/views/admin/scss/_view-mode-cards.scss
index 8197ab5f7..53a9ff59f 100644
--- a/src/views/admin/scss/_view-mode-cards.scss
+++ b/src/views/admin/scss/_view-mode-cards.scss
@@ -140,7 +140,7 @@
.metadata-title {
flex-shrink: 0;
padding: 0.6em 7em 0.5em 2.75em;
- min-height: 40px;
+ min-height: 1.5em;
position: relative;
font-size: 1em !important;
text-overflow: ellipsis;
diff --git a/src/views/admin/scss/_view-mode-list.scss b/src/views/admin/scss/_view-mode-list.scss
index 533184739..b643e0071 100644
--- a/src/views/admin/scss/_view-mode-list.scss
+++ b/src/views/admin/scss/_view-mode-list.scss
@@ -27,6 +27,7 @@
:deep(img) {
height: auto;
+ max-width: 100%;
}
&:hover {
@@ -111,7 +112,7 @@
.metadata-title {
flex-shrink: 0;
padding: 0.5em 7em 0.5em 2.75em;
- min-height: 40px;
+ min-height: 1.5em;
position: relative;
font-size: 1em !important;
text-overflow: ellipsis;
diff --git a/src/views/admin/scss/_view-mode-map.scss b/src/views/admin/scss/_view-mode-map.scss
index 90250ff87..d703b768a 100644
--- a/src/views/admin/scss/_view-mode-map.scss
+++ b/src/views/admin/scss/_view-mode-map.scss
@@ -264,6 +264,7 @@
z-index: 1;
}
.metadata-title {
+ box-sizing: border-box;
flex-shrink: 0;
padding: 0.25em 1.125em;
font-size: 1.0em !important;
diff --git a/src/views/admin/scss/_view-mode-masonry.scss b/src/views/admin/scss/_view-mode-masonry.scss
index c3a5e8855..b301b1b5e 100644
--- a/src/views/admin/scss/_view-mode-masonry.scss
+++ b/src/views/admin/scss/_view-mode-masonry.scss
@@ -110,6 +110,7 @@
:deep(img) {
height: auto;
+ max-width: 100%;
}
&:hover:not(.skeleton) {
@@ -191,7 +192,7 @@
flex-shrink: 0;
margin: 0px 6px 0px 24px;
padding: 8px 1em;
- min-height: 41px;
+ min-height: calc(1em + 8px);
cursor: pointer;
position: relative;
diff --git a/src/views/admin/scss/_view-mode-mosaic.scss b/src/views/admin/scss/_view-mode-mosaic.scss
new file mode 100644
index 000000000..6a81447e8
--- /dev/null
+++ b/src/views/admin/scss/_view-mode-mosaic.scss
@@ -0,0 +1,221 @@
+.tainacan-mosaic-container,
+.tainacan-mosaic-container--skeleton {
+ --tainacan-mosaic-view-mode-gap: 12px;
+ --tainacan-mosaic-view-mode-min-height: 180px;
+ display: flex;
+ flex-wrap: wrap;
+ grid-gap: calc(2em + 16px) var(--tainacan-mosaic-view-mode-gap, 12px);
+ list-style: none;
+ height: auto;
+ min-height: 0px; /* While most view modes set this to 50vh, this causes a bug for this one if there are few items to display */
+ margin: 0;
+ margin-bottom: calc(2em + 16px + var(--tainacan-container-padding));
+ padding: 0;
+ list-style: none;
+ animation-name: appear;
+ animation-duration: 0.5s;
+
+ &::after {
+ content: " ";
+ flex-grow: 1000000000;
+ }
+
+ & > li,
+ & > .skeleton {
+ flex-grow: calc(var(--tainacan-mosaic-item-width, 300) * (100000 / var(--tainacan-mosaic-item-height, 300)));
+ flex-basis: calc(var(--tainacan-mosaic-view-mode-min-height, 180) * (var(--tainacan-mosaic-item-width, 300) / var(--tainacan-mosaic-item-height, 300)));
+ aspect-ratio: var(--tainacan-mosaic-item-width, 300) / var(--tainacan-mosaic-item-height, 300);
+ position: relative;
+ margin: 0 !important;
+ padding: 0 !important;
+
+ :deep(img) {
+ position: absolute;
+ width: auto;
+ height: 100%;
+ }
+
+ :deep(canvas.child) {
+ aspect-ratio: var(--tainacan-mosaic-item-width, 300) / var(--tainacan-mosaic-item-height, 300);
+ }
+
+ &:hover:not(.skeleton) {
+ background-color: var(--tainacan-item-heading-hover-background-color);
+ }
+ &.selected-mosaic-item:not(.skeleton) {
+ background-color: var(--tainacan-turquoise1);
+ }
+ &:not(.skeleton) {
+ background-color: var(--tainacan-item-background-color);
+ }
+
+ .tainacan-mosaic-item {
+ position: absolute;
+ top: 0;
+ left: 0;
+ right: 0;
+ bottom: 0;
+ }
+
+ .mosaic-item-checkbox {
+ position: absolute;
+ margin-top: 8px;
+ margin-left: 1em;
+ z-index: 9;
+ }
+ .actions-area {
+ position: relative;
+ float: right;
+ width: 100%;
+ height: 0px;
+ display: flex;
+ justify-content: flex-end;
+ visibility: hidden;
+ overflow: hidden;
+ opacity: 0.0;
+ padding: 8px;
+ margin-top: -25px;
+ background-color: var(--tainacan-item-heading-hover-background-color);
+ transition: visibility 0.2s ease, opacity 0.3s ease, height 0.2s ease, margin-top 0.1s ease;
+
+ a {
+ margin-left: 8px;
+ opacity: 0;
+ transition: opacity 0.3s ease-in;
+ }
+ }
+ &:hover,
+ &:focus,
+ &:focus-within,
+ &:focus-visible,
+ & > a:focus,
+ & > a:focus-within,
+ & > a:focus-visible {
+ background: var(--tainacan-item-hover-background-color);
+
+ .actions-area {
+ visibility: visible;
+ opacity: 1.0;
+ height: 42px;
+ margin-top: 0px;
+ background-color: var(--tainacan-item-heading-hover-background-color);
+
+ a {
+ opacity: 1;
+ }
+ }
+ }
+ &.selected-mosaic-item {
+ .actions-area {
+ background-color: var(--tainacan-turquoise1);
+ }
+ }
+
+ .tainacan-mosaic-item-thumbnail {
+ background-size: cover;
+ background-color: var(--tainacan-item-background-color);
+ background-blend-mode: multiply;
+ border-radius: 0px;
+ min-width: 100%;
+ display: flex;
+ justify-content: center;
+
+ &:hover {
+ cursor: pointer;
+ }
+ }
+
+ .metadata-title {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ flex-shrink: 0;
+ margin: 0;
+ padding: 8px 1em;
+ min-height: calc(1em + 8px);
+ width: 100%;
+ cursor: pointer;
+ position: absolute;
+ top: 100%;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ overflow: hidden;
+
+ p {
+ font-size: 0.875em !important;
+ color: var(--tainacan-heading-color) !important;
+ text-align: left !important;
+ margin-bottom: 0 !important;
+ line-height: 1.5em;
+ word-break: break-word;
+ margin: 0;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ overflow: hidden;
+ }
+
+ .slideshow-icon {
+ color: var(--tainacan-info-color);
+ position: absolute;
+ right: 5px;
+ top: 8px;
+ transform: scale(0.0);
+ transition: transform 0.2s ease;
+ }
+ .icon:not(.slideshow-icon) {
+ float: left;
+ margin-top: -1px;
+ }
+ }
+
+
+ &:hover,
+ &:focus,
+ &:focus-within,
+ &:focus-visible,
+ & > a:focus,
+ & > a:focus-within,
+ & > a:focus-visible {
+ .metadata-title {
+ background: var(--tainacan-item-heading-hover-background-color);
+
+ .slideshow-icon {
+ transform: scale(1.0);
+ }
+ }
+ }
+ }
+
+ &.hide-items-selection {
+ .tainacan-mosaic-item {
+ &:hover { background-color: transparent; cursor: default; }
+ &:hover .tainacan-mosaic-item-thumbnail { cursor: default; }
+ }
+ }
+
+ &.has-title-inside {
+ gap: var(--tainacan-mosaic-view-mode-gap, 12px);
+
+ & > li {
+ .metadata-title {
+ top: unset;
+ bottom: 0;
+ white-space: wrap;
+ overflow: visible;
+ text-overflow: none;
+
+ p {
+ white-space: wrap;
+ overflow: visible;
+ text-overflow: none;
+ }
+ }
+ &:not(:hover):not(:focus):not(:focus-within):not(:focus-visible),
+ & > a:not(:hover):not(:focus):not(:focus-within):not(:focus-visible) {
+ .metadata-title {
+ display: none;
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/views/admin/scss/_view-mode-records.scss b/src/views/admin/scss/_view-mode-records.scss
index 6d58fcfb1..0e53b5bc6 100644
--- a/src/views/admin/scss/_view-mode-records.scss
+++ b/src/views/admin/scss/_view-mode-records.scss
@@ -75,6 +75,7 @@
:deep(img) {
height: auto;
+ max-width: 100%;
}
&:hover {
@@ -150,7 +151,7 @@
flex-shrink: 0;
padding: 0.5em 7em 0.5em 2.75em;
font-size: 1.0em !important;
- min-height: 40px;
+ min-height: 1.5em;
position: relative;
text-overflow: ellipsis;
white-space: nowrap;
diff --git a/src/views/gutenberg-blocks/blocks/dynamic-items-list/theme.js b/src/views/gutenberg-blocks/blocks/dynamic-items-list/theme.js
index be4258f7e..fd782b60b 100644
--- a/src/views/gutenberg-blocks/blocks/dynamic-items-list/theme.js
+++ b/src/views/gutenberg-blocks/blocks/dynamic-items-list/theme.js
@@ -28,7 +28,7 @@ export default (element) => {
let registeredViewModes =
( tainacan_blocks && tainacan_blocks.registered_view_modes && tainacan_blocks.registered_view_modes.length ) ?
tainacan_blocks.registered_view_modes :
- [ 'table', 'cards', 'records', 'masonry', 'list', 'map' ];
+ [ 'table', 'cards', 'records', 'masonry', 'mosaic', 'list', 'map'];
// At first, we consider that all registered view modes are included.
let possibleViewModes = registeredViewModes.filter((aViewMode) => aViewMode === 'slideshow');
diff --git a/src/views/gutenberg-blocks/blocks/faceted-search/theme-search/components/view-mode-mosaic.vue b/src/views/gutenberg-blocks/blocks/faceted-search/theme-search/components/view-mode-mosaic.vue
new file mode 100644
index 000000000..9b3a61a15
--- /dev/null
+++ b/src/views/gutenberg-blocks/blocks/faceted-search/theme-search/components/view-mode-mosaic.vue
@@ -0,0 +1,137 @@
+
+
+
+
+
+
+
+
+
diff --git a/src/views/gutenberg-blocks/blocks/faceted-search/theme-search/scss/_layout.scss b/src/views/gutenberg-blocks/blocks/faceted-search/theme-search/scss/_layout.scss
index e28c61ec8..250ae221e 100644
--- a/src/views/gutenberg-blocks/blocks/faceted-search/theme-search/scss/_layout.scss
+++ b/src/views/gutenberg-blocks/blocks/faceted-search/theme-search/scss/_layout.scss
@@ -179,6 +179,7 @@
width: 100%;
max-width: 100% !important;
margin: 0;
+ box-sizing: border-box;
}
.filters-components-list {
diff --git a/src/views/gutenberg-blocks/blocks/faceted-search/theme.js b/src/views/gutenberg-blocks/blocks/faceted-search/theme.js
index adbea16c2..5b9b05ccd 100644
--- a/src/views/gutenberg-blocks/blocks/faceted-search/theme.js
+++ b/src/views/gutenberg-blocks/blocks/faceted-search/theme.js
@@ -77,7 +77,7 @@ export default (element) => {
const registeredViewModes =
( tainacan_plugin && tainacan_plugin.registered_view_modes && tainacan_plugin.registered_view_modes.length ) ?
tainacan_plugin.registered_view_modes :
- [ 'table', 'cards', 'records', 'masonry', 'slideshow', 'list', 'map' ];
+ [ 'table', 'cards', 'records', 'masonry', 'mosaic', 'slideshow', 'list', 'map'];
// At first, we consider that all registered view modes are included.
let possibleViewModes = registeredViewModes;
diff --git a/src/views/tainacan-i18n.php b/src/views/tainacan-i18n.php
index ca131e628..7b81b20f0 100644
--- a/src/views/tainacan-i18n.php
+++ b/src/views/tainacan-i18n.php
@@ -336,6 +336,7 @@ return apply_filters( 'tainacan-i18n', [
'label_grid' => __( 'Thumbnails', 'tainacan' ),
'label_table' => __( 'Table', 'tainacan' ),
'label_cards' => __( 'Cards', 'tainacan' ),
+ 'label_mosaic' => __( 'Mosaic', 'tainacan' ),
/* translators: The 'records' view mode, in the sense of a catalog file */
'label_records' => __( 'Records', 'tainacan' ),
'label_masonry' => __( 'Masonry', 'tainacan' ),
From a3af691f48e137a62fcc60f98ec2a8de4aa0d81b Mon Sep 17 00:00:00 2001
From: mateuswetah
Date: Mon, 24 Jun 2024 17:00:53 -0300
Subject: [PATCH 31/39] Fixes misspelling of hide filter collapses option.
---
.../theme-helper/class-tainacan-theme-helper.php | 2 +-
src/views/admin/scss/_view-mode-mosaic.scss | 4 ++--
.../gutenberg-blocks/blocks/faceted-search/block.json | 2 +-
.../gutenberg-blocks/blocks/faceted-search/edit.js | 10 +++++-----
.../gutenberg-blocks/blocks/faceted-search/save.js | 4 +++-
5 files changed, 12 insertions(+), 10 deletions(-)
diff --git a/src/classes/theme-helper/class-tainacan-theme-helper.php b/src/classes/theme-helper/class-tainacan-theme-helper.php
index 5c422ff8c..49690a75a 100644
--- a/src/classes/theme-helper/class-tainacan-theme-helper.php
+++ b/src/classes/theme-helper/class-tainacan-theme-helper.php
@@ -37,7 +37,7 @@ class Theme_Helper {
// Replace collections permalink to post type archive if cover not enabled
add_filter('post_type_link', array($this, 'permalink_filter'), 10, 3);
- // Replace single query to the page content set as cover for the colllection
+ // Replace single query to the page content set as cover for the collection
// Redirect to post type archive if no cover page is set
add_action('wp', array($this, 'collection_single_redirect'));
diff --git a/src/views/admin/scss/_view-mode-mosaic.scss b/src/views/admin/scss/_view-mode-mosaic.scss
index 6a81447e8..6032d82fc 100644
--- a/src/views/admin/scss/_view-mode-mosaic.scss
+++ b/src/views/admin/scss/_view-mode-mosaic.scss
@@ -4,12 +4,12 @@
--tainacan-mosaic-view-mode-min-height: 180px;
display: flex;
flex-wrap: wrap;
- grid-gap: calc(2em + 16px) var(--tainacan-mosaic-view-mode-gap, 12px);
+ grid-gap: calc(2em + 18px) var(--tainacan-mosaic-view-mode-gap, 12px);
list-style: none;
height: auto;
min-height: 0px; /* While most view modes set this to 50vh, this causes a bug for this one if there are few items to display */
margin: 0;
- margin-bottom: calc(2em + 16px + var(--tainacan-container-padding));
+ margin-bottom: calc(2em + 18px + var(--tainacan-container-padding));
padding: 0;
list-style: none;
animation-name: appear;
diff --git a/src/views/gutenberg-blocks/blocks/faceted-search/block.json b/src/views/gutenberg-blocks/blocks/faceted-search/block.json
index ec7ca34be..6afd94a89 100644
--- a/src/views/gutenberg-blocks/blocks/faceted-search/block.json
+++ b/src/views/gutenberg-blocks/blocks/faceted-search/block.json
@@ -221,7 +221,7 @@
"type": "boolean",
"default": false
},
- "hideFilterColllapses": {
+ "hideFilterCollapses": {
"type": "boolean",
"default": false
},
diff --git a/src/views/gutenberg-blocks/blocks/faceted-search/edit.js b/src/views/gutenberg-blocks/blocks/faceted-search/edit.js
index d362c46ba..e8c2e60ce 100644
--- a/src/views/gutenberg-blocks/blocks/faceted-search/edit.js
+++ b/src/views/gutenberg-blocks/blocks/faceted-search/edit.js
@@ -79,7 +79,7 @@ export default function({ attributes, setAttributes, isSelected, clientId }) {
collectionOrderByType,
shouldNotHideFiltersOnMobile,
displayFiltersHorizontally,
- hideFilterColllapses,
+ hideFilterCollapses,
filtersInlineWidth
} = attributes;
@@ -535,10 +535,10 @@ export default function({ attributes, setAttributes, isSelected, clientId }) {
{
- hideFilterColllapses = isChecked;
- setAttributes({ hideFilterColllapses: isChecked });
+ hideFilterCollapses = isChecked;
+ setAttributes({ hideFilterCollapses: isChecked });
}
}
/>
@@ -922,7 +922,7 @@ export default function({ attributes, setAttributes, isSelected, clientId }) {
}}
className="filters">
- { !hideFilterColllapses ? : null }
+ { !hideFilterCollapses ? : null }
{ Array(2).fill().map( () => {
return
diff --git a/src/views/gutenberg-blocks/blocks/faceted-search/save.js b/src/views/gutenberg-blocks/blocks/faceted-search/save.js
index 49ab288f5..6a3427bd1 100644
--- a/src/views/gutenberg-blocks/blocks/faceted-search/save.js
+++ b/src/views/gutenberg-blocks/blocks/faceted-search/save.js
@@ -52,6 +52,7 @@ export default function({ attributes }) {
collectionOrderByType,
shouldNotHideFiltersOnMobile,
displayFiltersHorizontally,
+ hideFilterCollapses,
filtersInlineWidth
} = attributes;
@@ -64,7 +65,7 @@ export default function({ attributes }) {
// Gets attributes such as style, that are automatically added by the editor hook
const blockProps = useBlockProps.save();
-
+ console.log(hideFilterCollapses)
return
From 200823937296c80b6fb5b508714e3ceef7a7c40f Mon Sep 17 00:00:00 2001
From: mateuswetah
Date: Mon, 24 Jun 2024 17:06:25 -0300
Subject: [PATCH 32/39] Removes console log.
---
src/views/gutenberg-blocks/blocks/faceted-search/save.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/views/gutenberg-blocks/blocks/faceted-search/save.js b/src/views/gutenberg-blocks/blocks/faceted-search/save.js
index 6a3427bd1..ffdbbcb7d 100644
--- a/src/views/gutenberg-blocks/blocks/faceted-search/save.js
+++ b/src/views/gutenberg-blocks/blocks/faceted-search/save.js
@@ -65,7 +65,7 @@ export default function({ attributes }) {
// Gets attributes such as style, that are automatically added by the editor hook
const blockProps = useBlockProps.save();
- console.log(hideFilterCollapses)
+
return
Date: Tue, 25 Jun 2024 16:14:11 -0300
Subject: [PATCH 33/39] Replaces all 'patch' usages by 'put' on requests
---
.../metadata-types/taxonomy/TainacanTaxonomy.vue | 4 ++--
.../admin/js/store/modules/bgprocess/actions.js | 2 +-
.../admin/js/store/modules/capability/actions.js | 6 +++---
.../admin/js/store/modules/collection/actions.js | 6 +++---
.../admin/js/store/modules/exporter/actions.js | 2 +-
src/views/admin/js/store/modules/filter/actions.js | 2 +-
src/views/admin/js/store/modules/item/actions.js | 14 +++++++-------
.../admin/js/store/modules/metadata/actions.js | 4 ++--
.../admin/js/store/modules/taxonomy/actions.js | 6 +++---
9 files changed, 23 insertions(+), 23 deletions(-)
diff --git a/src/views/admin/components/metadata-types/taxonomy/TainacanTaxonomy.vue b/src/views/admin/components/metadata-types/taxonomy/TainacanTaxonomy.vue
index e43e38619..43b648ad0 100644
--- a/src/views/admin/components/metadata-types/taxonomy/TainacanTaxonomy.vue
+++ b/src/views/admin/components/metadata-types/taxonomy/TainacanTaxonomy.vue
@@ -234,7 +234,7 @@
let val = this.valueComponent;
if ((!Array.isArray(val) || val.length == 0) && this.itemMetadatum.metadatum.multiple === 'no') {
- tainacanApi.patch(`/item/${this.itemMetadatum.item.id}/metadata/${this.itemMetadatum.metadatum.id}`, {
+ tainacanApi.put(`/item/${this.itemMetadatum.item.id}/metadata/${this.itemMetadatum.metadatum.id}`, {
values: term.id,
}).then(() => {
this.isAddingNewTermVaue = false;
@@ -244,7 +244,7 @@
} else {
val = val ? val : [];
val.push( this.getComponent == ('tainacan-taxonomy-checkbox' || 'tainacan-taxonomy-radio') ? term.id : {'label': term.name, 'value': term.id} );
- tainacanApi.patch(`/item/${this.itemMetadatum.item.id}/metadata/${this.itemMetadatum.metadatum.id}`, {
+ tainacanApi.put(`/item/${this.itemMetadatum.item.id}/metadata/${this.itemMetadatum.metadatum.id}`, {
values: val,
}).then(() => {
this.isAddingNewTermVaue = false;
diff --git a/src/views/admin/js/store/modules/bgprocess/actions.js b/src/views/admin/js/store/modules/bgprocess/actions.js
index 3acb7c65a..0a55e1924 100644
--- a/src/views/admin/js/store/modules/bgprocess/actions.js
+++ b/src/views/admin/js/store/modules/bgprocess/actions.js
@@ -46,7 +46,7 @@ export const fetchProcesses = ({ commit }, {page, processesPerPage, shouldUpdate
export const updateProcess = ({ commit }, { id, status }) => {
return new Promise((resolve, reject) => {
- axios.tainacanApi.patch(`/bg-processes/${id}/`, {
+ axios.tainacanApi.put(`/bg-processes/${id}/`, {
status: status,
})
.then( res => {
diff --git a/src/views/admin/js/store/modules/capability/actions.js b/src/views/admin/js/store/modules/capability/actions.js
index 4c438234c..eedf6a718 100644
--- a/src/views/admin/js/store/modules/capability/actions.js
+++ b/src/views/admin/js/store/modules/capability/actions.js
@@ -3,7 +3,7 @@ import axios from '../../../axios'
// ROLES
export const addCapabilityToRole = ({ commit }, { capabilityKey, role }) => {
return new Promise(( resolve, reject ) => {
- axios.tainacanApi.patch('/roles/' + role + '?add_cap=' + capabilityKey)
+ axios.tainacanApi.put('/roles/' + role + '?add_cap=' + capabilityKey)
.then( res => {
let role = res.data;
commit('addCapabilityToRole', {capabilityKey, role });
@@ -17,7 +17,7 @@ export const addCapabilityToRole = ({ commit }, { capabilityKey, role }) => {
export const removeCapabilityFromRole = ({ commit }, { capabilityKey, role }) => {
return new Promise(( resolve, reject ) => {
- axios.tainacanApi.patch('/roles/' + role + '?remove_cap=' + capabilityKey)
+ axios.tainacanApi.put('/roles/' + role + '?remove_cap=' + capabilityKey)
.then( res => {
let role = res.data;
commit('removeCapabilityFromRole', {capabilityKey, role });
@@ -79,7 +79,7 @@ export const updateRole = ({ commit }, role) => {
return new Promise((resolve, reject) => {
- axios.tainacanApi.patch('/roles/' + role.slug, role)
+ axios.tainacanApi.put('/roles/' + role.slug, role)
.then(res => {
const updatedRole = res.data
commit('setRole', updatedRole);
diff --git a/src/views/admin/js/store/modules/collection/actions.js b/src/views/admin/js/store/modules/collection/actions.js
index 4593cd748..b5ef67b1e 100644
--- a/src/views/admin/js/store/modules/collection/actions.js
+++ b/src/views/admin/js/store/modules/collection/actions.js
@@ -348,7 +348,7 @@ export const updateCollection = ({ commit }, {
collection
}) => {
return new Promise((resolve, reject) => {
- axios.tainacanApi.patch('/collections/' + collection_id + '?context=edit', collection).then( res => {
+ axios.tainacanApi.put('/collections/' + collection_id + '?context=edit', collection).then( res => {
commit('setCollection', collection);
resolve( res.data );
}).catch( error => {
@@ -416,7 +416,7 @@ export const fetchAttachments = ({ commit }, collection_id) => {
export const updateThumbnail = ({ commit }, { collectionId, thumbnailId }) => {
return new Promise((resolve, reject) => {
- axios.tainacanApi.patch('/collections/' + collectionId + '?context=edit', {
+ axios.tainacanApi.put('/collections/' + collectionId + '?context=edit', {
_thumbnail_id: thumbnailId
}).then( res => {
let collection = res.data
@@ -431,7 +431,7 @@ export const updateThumbnail = ({ commit }, { collectionId, thumbnailId }) => {
export const updateHeaderImage = ({ commit }, { collectionId, headerImageId }) => {
return new Promise((resolve, reject) => {
- axios.tainacanApi.patch('/collections/' + collectionId + '?context=edit', {
+ axios.tainacanApi.put('/collections/' + collectionId + '?context=edit', {
header_image_id: headerImageId + ''
}).then( res => {
let collection = res.data
diff --git a/src/views/admin/js/store/modules/exporter/actions.js b/src/views/admin/js/store/modules/exporter/actions.js
index f6b9db814..1d094e160 100644
--- a/src/views/admin/js/store/modules/exporter/actions.js
+++ b/src/views/admin/js/store/modules/exporter/actions.js
@@ -27,7 +27,7 @@ export const createExporterSession = ({commit}, slug) => {
export const updateExporterSession = ({commit}, exporterSessionUpdated) => {
return new Promise(( resolve, reject ) => {
- tainacanApi.patch(`/exporters/session/${exporterSessionUpdated.id}`, exporterSessionUpdated.body)
+ tainacanApi.put(`/exporters/session/${exporterSessionUpdated.id}`, exporterSessionUpdated.body)
.then(response => {
commit('setExporterSession');
resolve( response.data );
diff --git a/src/views/admin/js/store/modules/filter/actions.js b/src/views/admin/js/store/modules/filter/actions.js
index d7408e88a..9eff7b307 100644
--- a/src/views/admin/js/store/modules/filter/actions.js
+++ b/src/views/admin/js/store/modules/filter/actions.js
@@ -128,7 +128,7 @@ export const addTemporaryFilter = ({ commit }, filter ) => {
export const updateCollectionFiltersOrder = ({ commit }, { collectionId, filtersOrder }) => {
return new Promise((resolve, reject) => {
- axios.tainacanApi.patch('/collections/' + collectionId + '/filters_order?context=edit', {
+ axios.tainacanApi.put('/collections/' + collectionId + '/filters_order?context=edit', {
filters_order: filtersOrder
}).then( res => {
commit('collection/setCollection', res.data, { root: true });
diff --git a/src/views/admin/js/store/modules/item/actions.js b/src/views/admin/js/store/modules/item/actions.js
index 39a702cf8..e41f0b032 100644
--- a/src/views/admin/js/store/modules/item/actions.js
+++ b/src/views/admin/js/store/modules/item/actions.js
@@ -8,7 +8,7 @@ export const updateItemMetadatum = ({ commit }, { item_id, metadatum_id, values,
body['parent_meta_id'] = parent_meta_id;
return new Promise((resolve, reject) => {
- axios.tainacanApi.patch(`/item/${item_id}/metadata/${metadatum_id}`, body)
+ axios.tainacanApi.put(`/item/${item_id}/metadata/${metadatum_id}`, body)
.then( res => {
let itemMetadatum = res.data;
commit('setSingleMetadatum', itemMetadatum);
@@ -45,7 +45,7 @@ export const fetchItemMetadata = ({ commit }, item_id) => {
export const fetchCompoundFirstParentMetaId = ({ commit }, { item_id, metadatum_id }) => {
return new Promise((resolve, reject) => {
- axios.tainacanApi.patch(`/item/${item_id}/metadata/${metadatum_id}`, { value: [] })
+ axios.tainacanApi.put(`/item/${item_id}/metadata/${metadatum_id}`, { value: [] })
.then( res => {
const parentMetaId = res.data.parent_meta_id;
resolve(parentMetaId);
@@ -157,7 +157,7 @@ export const sendItem = ( { commit }, item) => {
export const updateItem = ({ commit }, item) => {
return new Promise((resolve, reject) => {
- axios.tainacanApi.patch('/items/' + item.id, item)
+ axios.tainacanApi.put('/items/' + item.id, item)
.then( res => {
commit('setItem', res.data);
commit('setLastUpdated');
@@ -191,7 +191,7 @@ export const updateItemDocument = ({ commit }, { item_id, document, document_typ
params['document_options'] = document_options;
return new Promise((resolve, reject) => {
- axios.tainacanApi.patch('/items/' + item_id, params).then( res => {
+ axios.tainacanApi.put('/items/' + item_id, params).then( res => {
let item = res.data;
commit('setItem', item);
@@ -246,7 +246,7 @@ export const sendAttachment = ( { commit }, { item_id, file }) => {
export const removeAttachmentFromItem = ( { commit }, attachmentId) => {
commit('cleanAttachment');
return new Promise(( resolve, reject ) => {
- axios.wpApi.patch('/media/' + attachmentId, {
+ axios.wpApi.put('/media/' + attachmentId, {
post: 0
})
.then( res => {
@@ -306,7 +306,7 @@ export const fetchAttachments = ({ commit }, { page, attachmentsPerPage, itemId,
export const updateThumbnail = ({ commit }, { itemId, thumbnailId, thumbnailAlt }) => {
return new Promise((resolve, reject) => {
- axios.tainacanApi.patch('/items/' + itemId, {
+ axios.tainacanApi.put('/items/' + itemId, {
_thumbnail_id: thumbnailId
}).then( res => {
let item = res.data
@@ -322,7 +322,7 @@ export const updateThumbnail = ({ commit }, { itemId, thumbnailId, thumbnailAlt
export const updateThumbnailAlt = ({ commit }, { thumbnailId, thumbnailAlt }) => {
return new Promise((resolve, reject) => {
- axios.wpApi.patch('/media/' + thumbnailId + '?force=true', {
+ axios.wpApi.put('/media/' + thumbnailId + '?force=true', {
alt_text: thumbnailAlt
}).then( res => {
let thumbnail = res.data;
diff --git a/src/views/admin/js/store/modules/metadata/actions.js b/src/views/admin/js/store/modules/metadata/actions.js
index f172625c9..15e3fc894 100644
--- a/src/views/admin/js/store/modules/metadata/actions.js
+++ b/src/views/admin/js/store/modules/metadata/actions.js
@@ -202,7 +202,7 @@ export const cleanMetadata = ({commit}) => {
export const updateCollectionMetadataOrder = ({ commit }, { collectionId, metadataOrder, metadataSectionId }) => {
return new Promise((resolve, reject) => {
- axios.tainacanApi.patch('/collections/' + collectionId + '/metadata_section/' + metadataSectionId + '/metadata_order?context=edit', {
+ axios.tainacanApi.put('/collections/' + collectionId + '/metadata_section/' + metadataSectionId + '/metadata_order?context=edit', {
metadata_order: metadataOrder
}).then(res => {
commit('collection/setCollection', res.data, { root: true });
@@ -390,7 +390,7 @@ export const updateMetadataSections = ({commit}, metadataSections) => {
export const updateCollectionMetadataSectionsOrder = ({ commit }, {collectionId, metadataSectionsOrder }) => {
return new Promise((resolve, reject) => {
- axios.tainacanApi.patch('/collections/' + collectionId + '/metadata_section_order?context=edit', {
+ axios.tainacanApi.put('/collections/' + collectionId + '/metadata_section_order?context=edit', {
metadata_section_order: metadataSectionsOrder
}).then(res => {
commit('collection/setCollection', res.data, { root: true });
diff --git a/src/views/admin/js/store/modules/taxonomy/actions.js b/src/views/admin/js/store/modules/taxonomy/actions.js
index 768f7f47b..ff13b29b9 100644
--- a/src/views/admin/js/store/modules/taxonomy/actions.js
+++ b/src/views/admin/js/store/modules/taxonomy/actions.js
@@ -33,7 +33,7 @@ export const deleteTaxonomy = ({ commit }, { taxonomyId, isPermanently }) => {
export const updateTaxonomy = ({ commit }, taxonomy) => {
return new Promise(( resolve, reject ) => {
- axios.tainacanApi.patch(`/taxonomies/${taxonomy.taxonomyId}`, taxonomy)
+ axios.tainacanApi.put(`/taxonomies/${taxonomy.taxonomyId}`, taxonomy)
.then( res => {
let taxonomy = res.data;
commit('setTaxonomy', taxonomy);
@@ -191,7 +191,7 @@ export const updateTerm = ({}, { taxonomyId, term, itemId, metadatumId }) => {
term['metadatum_id'] = metadatumId;
return new Promise(( resolve, reject ) => {
- axios.tainacanApi.patch(`/taxonomy/${taxonomyId}/terms/${term.id}`, term)
+ axios.tainacanApi.put(`/taxonomy/${taxonomyId}/terms/${term.id}`, term)
.then( res => {
const updatedTerm = res.data;
resolve( updatedTerm );
@@ -254,7 +254,7 @@ export const changeTermsParent = ({}, { taxonomyId, newParentTerm, terms, parent
query += `&include=${terms}`;
return new Promise(( resolve, reject ) => {
- axios.tainacanApi.patch(`/taxonomy/${taxonomyId}/terms/newparent/${newParentTerm}?${query}`)
+ axios.tainacanApi.put(`/taxonomy/${taxonomyId}/terms/newparent/${newParentTerm}?${query}`)
.then(res => {
const terms = res.data;
resolve( terms );
From fdaf1cf9a32ae4d0296b2be41d0b68999337ca50 Mon Sep 17 00:00:00 2001
From: mateuswetah
Date: Wed, 26 Jun 2024 15:57:56 -0300
Subject: [PATCH 34/39] Adds check for permalinks structure before loading the
Tainacan Admin.
---
src/views/admin/admin.vue | 126 +++++++++++-------
.../admin/components/other/custom-dialog.vue | 6 +-
src/views/class-tainacan-admin.php | 3 +-
src/views/tainacan-i18n.php | 5 +-
4 files changed, 88 insertions(+), 52 deletions(-)
diff --git a/src/views/admin/admin.vue b/src/views/admin/admin.vue
index 8e9747a1d..c498570d4 100644
--- a/src/views/admin/admin.vue
+++ b/src/views/admin/admin.vue
@@ -5,46 +5,48 @@
:class="{
'tainacan-admin-mobile-app-mode': $adminOptions.mobileAppMode
}">
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -70,7 +72,8 @@
return {
isMenuCompressed: false,
isRepositoryLevel : true,
- activeRoute: '/collections'
+ activeRoute: '/collections',
+ hasPermalinksStructure: false
}
},
computed: {
@@ -105,19 +108,44 @@
}
},
created() {
- this.$statusHelper.loadStatuses();
- this.$userPrefs.init();
- this.isMenuCompressed = (this.$route.params.collectionId != undefined);
- this.activeRoute = this.$route.name;
- this.isRepositoryLevel = this.$route.params.collectionId == undefined;
- if (jQuery && jQuery( document )) {
- jQuery( document ).ajaxError(this.onHeartBitError);
+ this.hasPermalinksStructure = tainacan_plugin.has_permalinks_structure;
+
+ if ( this.hasPermalinksStructure ) {
+ this.$statusHelper.loadStatuses();
+ this.$userPrefs.init();
+ this.isMenuCompressed = (this.$route.params.collectionId != undefined);
+ this.activeRoute = this.$route.name;
+ this.isRepositoryLevel = this.$route.params.collectionId == undefined;
+
+ if (jQuery && jQuery( document )) {
+ jQuery( document ).ajaxError(this.onHeartBitError);
+ }
+ } else {
+ this.onPermalinksError();
}
},
methods: {
+ onPermalinksError() {
+ this.$buefy.modal.open({
+ component: CustomDialog,
+ props: {
+ title: this.$i18n.get('error_permalinks_label'),
+ message: this.$i18n.getWithVariables('error_permalinks_detail', [ '', ' ' ]),
+ hideCancel: true,
+ confirmText: this.$i18n.get('label_go_to_permalinks'),
+ onConfirm: () => {
+ window.location.href = tainacan_plugin.admin_url + 'options-permalink.php';
+ }
+ },
+ ariaRole: 'alertdialog',
+ ariaModal: true,
+ customClass: 'tainacan-modal',
+ canCancel: false,
+ });
+ },
onHeartBitError(event, jqxhr, settings) {
- if (settings && settings.url == '/wp-admin/admin-ajax.php') {
+ if (settings && settings.url == tainacan_plugin.admin_url + 'admin-ajax.php') {
this.$buefy.snackbar.open({
message: this.$i18n.get('error_connectivity'),
type: 'is-danger',
diff --git a/src/views/admin/components/other/custom-dialog.vue b/src/views/admin/components/other/custom-dialog.vue
index e9839783f..9c302f96b 100644
--- a/src/views/admin/components/other/custom-dialog.vue
+++ b/src/views/admin/components/other/custom-dialog.vue
@@ -51,7 +51,7 @@
type="submit"
class="button is-success"
@click="onConfirm(); $emit('close');">
- {{ $i18n.get('continue') }}
+ {{ confirmText ? confirmText : $i18n.get('continue') }}
@@ -66,6 +66,10 @@
title: String,
message: String,
icon: String,
+ confirmText: {
+ type: String,
+ default: ''
+ },
onConfirm: {
type: Function,
default: () => {}
diff --git a/src/views/class-tainacan-admin.php b/src/views/class-tainacan-admin.php
index 86525f16a..114a35d5c 100644
--- a/src/views/class-tainacan-admin.php
+++ b/src/views/class-tainacan-admin.php
@@ -354,7 +354,8 @@ class Admin {
'wp_elasticpress' => \Tainacan\Elastic_Press::get_instance()->is_active(),
'item_submission_captcha_site_key' => get_option("tnc_option_recaptch_site_key"),
'tainacan_enable_core_metadata_on_advanced_search' => ( !defined('TAINACAN_DISABLE_CORE_METADATA_ON_ADVANCED_SEARCH') || false === TAINACAN_DISABLE_CORE_METADATA_ON_ADVANCED_SEARCH ),
- 'tainacan_enable_relationship_metaquery' => ( defined('TAINACAN_ENABLE_RELATIONSHIP_METAQUERY') && true === TAINACAN_ENABLE_RELATIONSHIP_METAQUERY )
+ 'tainacan_enable_relationship_metaquery' => ( defined('TAINACAN_ENABLE_RELATIONSHIP_METAQUERY') && true === TAINACAN_ENABLE_RELATIONSHIP_METAQUERY ),
+ 'has_permalinks_structure' => get_option('permalink_structure') !== ''
];
$maps = [
diff --git a/src/views/tainacan-i18n.php b/src/views/tainacan-i18n.php
index 7b81b20f0..8962b6f0a 100644
--- a/src/views/tainacan-i18n.php
+++ b/src/views/tainacan-i18n.php
@@ -709,7 +709,8 @@ return apply_filters( 'tainacan-i18n', [
'label_item_submission_options' => __( 'Item submission options', 'tainacan' ),
'label_metadata_related_features' => __( 'Metadata related features', 'tainacan' ),
'label_preview' => __( 'Preview', 'tainacan' ),
-
+ 'label_go_to_permalinks' => __( 'Go to permalinks', 'tainacan' ),
+
// Instructions. More complex sentences to guide user and placeholders
'instruction_delete_selected_collections' => __( 'Delete selected collections', 'tainacan' ),
'instruction_delete_selected_items' => __( 'Delete selected items', 'tainacan' ),
@@ -1118,6 +1119,7 @@ return apply_filters( 'tainacan-i18n', [
/* Errors displayed on the interface bottom notifications */
'error_connectivity_label' => __('Connectivity issue', 'tainacan'),
'error_connectivity' => __('It is possible that you are disconnected or the server is not working properly.', 'tainacan'),
+ 'error_permalinks_label' => __('Permalinks issue', 'tainacan'),
'error_400' => __('Some request went wrong due to invalid syntax.', 'tainacan'),
'error_401' => __('You must authenticate to access this information. Try logging in again on the WordPress Admin panel.', 'tainacan'),
'error_403' => __('It seems that you are not allowed to access this content.', 'tainacan'),
@@ -1130,6 +1132,7 @@ return apply_filters( 'tainacan-i18n', [
'error_511' => __('You must authenticate to get access this information. Try logging in again on the WordPress Admin panel.', 'tainacan'),
'error_other' => __('Something went wrong here. You may want to try again or contact the Administrator.', 'tainacan'),
'error_connectivity_detail' => __('The WordPress Heartbit API sends requests periodically to the server to update some information. The latest request failed for some reason. It can be the case of a lost connection or bad communication between the browser and the server.', 'tainacan'),
+ 'error_permalinks_detail' => __( 'Tainacan requires your Permalink settings to be configured. Please visit %sPermalink settings%s and define it to an option such as "postname".', 'tainacan' ),
'error_400_detail' => __('The server could not understand the request due to invalid syntax. This is possibly an issue with Tainacan and should be reported to its developers.', 'tainacan'),
'error_401_detail' => __('You must authenticate to get access this information. Even if you have access to the Tainacan admin panel, it may be the case that your session cookies were lost. Try reloading the page or logging again on the WordPress Admin panel.', 'tainacan'),
'error_403_detail' => __('It seems that you are not allowed to access this content. Your user might have a role with insufficient capabilities. If that is not the case, check if you are correctly logged in on the WordPress Admin panel.', 'tainacan'),
From 27766c5ff76076b41e4a74a4d128a83fcceef9dc Mon Sep 17 00:00:00 2001
From: mateuswetah
Date: Fri, 28 Jun 2024 11:09:35 -0300
Subject: [PATCH 35/39] Updates to mosaic view mode: move checkbox to bottom.
#900
---
.../admin/components/lists/items-list.vue | 55 +++++++++----------
src/views/admin/scss/_view-mode-mosaic.scss | 12 ++--
2 files changed, 33 insertions(+), 34 deletions(-)
diff --git a/src/views/admin/components/lists/items-list.vue b/src/views/admin/components/lists/items-list.vue
index 043399001..00992fc69 100644
--- a/src/views/admin/components/lists/items-list.vue
+++ b/src/views/admin/components/lists/items-list.vue
@@ -2016,38 +2016,35 @@
:transition-duration="500"
/>
-
-
-
-
-
-
-
-
- {{ $i18n.get('label_select_item') }}
-
-
-