From b572a44b13b6e5c6f5f54d0be513440d30b4e028 Mon Sep 17 00:00:00 2001 From: lrljoe Date: Thu, 16 Mar 2023 03:26:24 +0000 Subject: [PATCH] Fixes for Always Open Filters --- .../components/tools/filters/datePicker.blade.php | 10 ++++++---- .../components/tools/filters/dateRange.blade.php | 10 ++++++---- .../components/tools/filters/numberRange.blade.php | 11 +++++++---- .../components/tools/filters/slimSelect.blade.php | 8 +++++--- .../components/tools/filters/smartSelect.blade.php | 10 ++++++---- 5 files changed, 30 insertions(+), 19 deletions(-) diff --git a/resources/views/components/tools/filters/datePicker.blade.php b/resources/views/components/tools/filters/datePicker.blade.php index 4270d973..d0082def 100755 --- a/resources/views/components/tools/filters/datePicker.blade.php +++ b/resources/views/components/tools/filters/datePicker.blade.php @@ -40,14 +40,16 @@ document.getElementById('{{ $filterLabelPath }}-labelInternal').classList.remove('d-none'); } @if ($theme === 'tailwind') for (let i = 0; i < this.twMenuElements.length; i++) { - if (this.twMenuElements.item(i).getAttribute('x-data') != '{ open: true, childElementOpen: true }') { - this.twMenuElements.item(i).setAttribute('x-data', '{ open: true, childElementOpen: true }'); + if (!this.twMenuElements.item(i).getAttribute('x-data').includes('childElementOpen')) + { + this.twMenuElements.item(i).setAttribute('x-data', '{ open: false, childElementOpen: true }'); this.twMenuElements.item(i).setAttribute('x-on:mousedown.away', 'if (!childElementOpen) { open = false }'); } } @endif @if ($theme === 'bootstrap-4' || $theme === 'bootstrap-5') for (let i = 0; i < this.bsMenuElements.length; i++) { - if (this.bsMenuElements.item(i).getAttribute('x-data') != '{ open: true, childElementOpen: true }') { - this.bsMenuElements.item(i).setAttribute('x-data', '{ open: true, childElementOpen: true }'); + if (!this.bsMenuElements.item(i).getAttribute('x-data').includes('childElementOpen')) + { + this.bsMenuElements.item(i).setAttribute('x-data', '{ open: false, childElementOpen: false }'); this.bsMenuElements.item(i).setAttribute('x-on:mousedown.away', 'if (!childElementOpen) { open = false }'); } } @endif diff --git a/resources/views/components/tools/filters/dateRange.blade.php b/resources/views/components/tools/filters/dateRange.blade.php index 3ff35a6b..019e1375 100755 --- a/resources/views/components/tools/filters/dateRange.blade.php +++ b/resources/views/components/tools/filters/dateRange.blade.php @@ -60,14 +60,16 @@ } @if ($theme === 'tailwind') for (let i = 0; i < this.twMenuElements.length; i++) { - if (this.twMenuElements.item(i).getAttribute('x-data') != '{ open: true, childElementOpen: true }') { - this.twMenuElements.item(i).setAttribute('x-data', '{ open: true, childElementOpen: true }'); + if (!this.twMenuElements.item(i).getAttribute('x-data').includes('childElementOpen')) + { + this.twMenuElements.item(i).setAttribute('x-data', '{ open: false, childElementOpen: true }'); this.twMenuElements.item(i).setAttribute('x-on:mousedown.away', 'if (!childElementOpen) { open = false }'); } } @endif @if ($theme === 'bootstrap-4' || $theme === 'bootstrap-5') for (let i = 0; i < this.bsMenuElements.length; i++) { - if (this.bsMenuElements.item(i).getAttribute('x-data') != '{ open: true, childElementOpen: true }') { - this.bsMenuElements.item(i).setAttribute('x-data', '{ open: true, childElementOpen: true }'); + if (!this.bsMenuElements.item(i).getAttribute('x-data').includes('childElementOpen')) + { + this.bsMenuElements.item(i).setAttribute('x-data', '{ open: false, childElementOpen: false }'); this.bsMenuElements.item(i).setAttribute('x-on:mousedown.away', 'if (!childElementOpen) { open = false }'); } } @endif diff --git a/resources/views/components/tools/filters/numberRange.blade.php b/resources/views/components/tools/filters/numberRange.blade.php index 0100e3f1..a6e535cd 100755 --- a/resources/views/components/tools/filters/numberRange.blade.php +++ b/resources/views/components/tools/filters/numberRange.blade.php @@ -54,17 +54,20 @@ document.getElementById('{{ $filterLabelPath }}-labelInternal').classList.remove('d-none'); } @if ($theme === 'tailwind') for (let i = 0; i < this.twMenuElements.length; i++) { - if (this.twMenuElements.item(i).getAttribute('x-data') != '{ open: true, childElementOpen: true }') { - this.twMenuElements.item(i).setAttribute('x-data', '{ open: true, childElementOpen: true }'); + if (!this.twMenuElements.item(i).getAttribute('x-data').includes('childElementOpen')) + { + this.twMenuElements.item(i).setAttribute('x-data', '{ open: false, childElementOpen: true }'); this.twMenuElements.item(i).setAttribute('x-on:mousedown.away', 'if (!childElementOpen) { open = false }'); } } @endif @if ($theme === 'bootstrap-4' || $theme === 'bootstrap-5') for (let i = 0; i < this.bsMenuElements.length; i++) { - if (this.bsMenuElements.item(i).getAttribute('x-data') != '{ open: true, childElementOpen: true }') { - this.bsMenuElements.item(i).setAttribute('x-data', '{ open: true, childElementOpen: true }'); + if (!this.bsMenuElements.item(i).getAttribute('x-data').includes('childElementOpen')) + { + this.bsMenuElements.item(i).setAttribute('x-data', '{ open: false, childElementOpen: false }'); this.bsMenuElements.item(i).setAttribute('x-on:mousedown.away', 'if (!childElementOpen) { open = false }'); } } @endif + }, updateStyles() { document.getElementById('{{ $filterBasePath }}').style.setProperty('--value-b', $refs.filterMin.value); diff --git a/resources/views/components/tools/filters/slimSelect.blade.php b/resources/views/components/tools/filters/slimSelect.blade.php index 148726fc..f8c847f6 100755 --- a/resources/views/components/tools/filters/slimSelect.blade.php +++ b/resources/views/components/tools/filters/slimSelect.blade.php @@ -41,14 +41,16 @@ document.getElementById('{{ $filterLabelPath }}-labelInternal').classList.remove('d-none'); } @if ($theme === 'tailwind') for (let i = 0; i < this.twMenuElements.length; i++) { - if (this.twMenuElements.item(i).getAttribute('x-data') != '{ open: true, childElementOpen: true }') { + if (!this.twMenuElements.item(i).getAttribute('x-data').includes('childElementOpen')) + { this.twMenuElements.item(i).setAttribute('x-data', '{ open: true, childElementOpen: true }'); this.twMenuElements.item(i).setAttribute('x-on:mousedown.away', 'if (!childElementOpen) { open = false }'); } } @endif @if ($theme === 'bootstrap-4' || $theme === 'bootstrap-5') for (let i = 0; i < this.bsMenuElements.length; i++) { - if (this.bsMenuElements.item(i).getAttribute('x-data') != '{ open: true, childElementOpen: true }') { - this.bsMenuElements.item(i).setAttribute('x-data', '{ open: true, childElementOpen: true }'); + if (!this.bsMenuElements.item(i).getAttribute('x-data').includes('childElementOpen')) + { + this.bsMenuElements.item(i).setAttribute('x-data', '{ open: false, childElementOpen: false }'); this.bsMenuElements.item(i).setAttribute('x-on:mousedown.away', 'if (!childElementOpen) { open = false }'); } } @endif diff --git a/resources/views/components/tools/filters/smartSelect.blade.php b/resources/views/components/tools/filters/smartSelect.blade.php index 3226c549..f2928132 100755 --- a/resources/views/components/tools/filters/smartSelect.blade.php +++ b/resources/views/components/tools/filters/smartSelect.blade.php @@ -44,14 +44,16 @@ document.getElementById('{{ $filterLabelPath }}-labelInternal').classList.remove('d-none'); } @if ($theme === 'tailwind') for (let i = 0; i < this.twMenuElements.length; i++) { - if (this.twMenuElements.item(i).getAttribute('x-data') != '{ open: true, childElementOpen: true }') { - this.twMenuElements.item(i).setAttribute('x-data', '{ open: true, childElementOpen: true }'); + if (!this.twMenuElements.item(i).getAttribute('x-data').includes('childElementOpen')) + { + this.twMenuElements.item(i).setAttribute('x-data', '{ open: false, childElementOpen: true }'); this.twMenuElements.item(i).setAttribute('x-on:mousedown.away', 'if (!childElementOpen) { open = false }'); } } @endif @if ($theme === 'bootstrap-4' || $theme === 'bootstrap-5') for (let i = 0; i < this.bsMenuElements.length; i++) { - if (this.bsMenuElements.item(i).getAttribute('x-data') != '{ open: true, childElementOpen: true }') { - this.bsMenuElements.item(i).setAttribute('x-data', '{ open: true, childElementOpen: true }'); + if (!this.bsMenuElements.item(i).getAttribute('x-data').includes('childElementOpen')) + { + this.bsMenuElements.item(i).setAttribute('x-data', '{ open: false, childElementOpen: false }'); this.bsMenuElements.item(i).setAttribute('x-on:mousedown.away', 'if (!childElementOpen) { open = false }'); } } @endif