From bf25b6a972f8ed15d6ece0e92a1d607ea4b6973d Mon Sep 17 00:00:00 2001 From: Lanto Razafindrabe Date: Thu, 26 Oct 2023 11:00:35 +0300 Subject: [PATCH 1/2] TA#58503 [FIX] web_search_date_range : filter ID issue --- web_search_date_range/__manifest__.py | 2 +- .../static/src/js/control_panel_model_extension.js | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/web_search_date_range/__manifest__.py b/web_search_date_range/__manifest__.py index a8ff782..24b51e4 100644 --- a/web_search_date_range/__manifest__.py +++ b/web_search_date_range/__manifest__.py @@ -3,7 +3,7 @@ { 'name': 'Web Search Date Range', - 'version': '1.0.0', + 'version': '1.0.1', 'author': 'Numigi', 'maintainer': 'Numigi', 'website': 'https://bit.ly/numigi-com', diff --git a/web_search_date_range/static/src/js/control_panel_model_extension.js b/web_search_date_range/static/src/js/control_panel_model_extension.js index 0f162b2..df0dd3e 100644 --- a/web_search_date_range/static/src/js/control_panel_model_extension.js +++ b/web_search_date_range/static/src/js/control_panel_model_extension.js @@ -48,7 +48,12 @@ class ControlPanelExtension extends ControlPanel { } toggleFilterWithOptions(filterId, optionId) { - const filter = this.state.filters[filterId]; + var filter = this.state.filters[filterId]; + if(filter == undefined){ + filterId = filterId - 1 + filter = this.state.filters[filterId]; + } + if (!filter.isRelativeDateFilter) { return super.toggleFilterWithOptions(filterId, optionId) } @@ -60,6 +65,9 @@ class ControlPanelExtension extends ControlPanel { if (index >= 0) { this.state.query.splice(index, 1); } else { + if(filter.id != filterId){ + filter.id = filter.id - 1; + } this.state.query.push({ groupId: filter.groupId, filterId, optionId }); } } From de4fe3abd023e0fedc8b9940d48cf7972ce8254a Mon Sep 17 00:00:00 2001 From: Majda EL MARIOULI Date: Thu, 26 Oct 2023 10:31:12 -0400 Subject: [PATCH 2/2] Improve Code Quality --- .../static/src/js/control_panel_model_extension.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web_search_date_range/static/src/js/control_panel_model_extension.js b/web_search_date_range/static/src/js/control_panel_model_extension.js index df0dd3e..8e36c79 100644 --- a/web_search_date_range/static/src/js/control_panel_model_extension.js +++ b/web_search_date_range/static/src/js/control_panel_model_extension.js @@ -49,7 +49,7 @@ class ControlPanelExtension extends ControlPanel { toggleFilterWithOptions(filterId, optionId) { var filter = this.state.filters[filterId]; - if(filter == undefined){ + if(filter === undefined){ filterId = filterId - 1 filter = this.state.filters[filterId]; } @@ -65,7 +65,7 @@ class ControlPanelExtension extends ControlPanel { if (index >= 0) { this.state.query.splice(index, 1); } else { - if(filter.id != filterId){ + if(filter.id !== filterId){ filter.id = filter.id - 1; } this.state.query.push({ groupId: filter.groupId, filterId, optionId });