From 6f5695d3ef7b69e65b7ee604719fb224f2fc54cf Mon Sep 17 00:00:00 2001 From: JackDandy Date: Mon, 18 Sep 2023 11:49:17 +0100 Subject: [PATCH] Add search of grouped options in shows drop down at view-show. Select child options were not considered in show name matching. --- CHANGES.md | 1 + gui/slick/js/displayShow.js | 27 ++++++++++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index cf9d9fd1..1c22ad67 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -10,6 +10,7 @@ * Fix regex that was not using py312 notation * Change sort backlog and manual segment search results episode number * Change sort episodes when set to wanted on display show page +* Add search of grouped options in shows drop down at view-show ### 3.29.8 (2023-09-12 08:10:00 UTC) diff --git a/gui/slick/js/displayShow.js b/gui/slick/js/displayShow.js index e5838be2..abd39f74 100644 --- a/gui/slick/js/displayShow.js +++ b/gui/slick/js/displayShow.js @@ -59,8 +59,33 @@ $(document).ready(function() { } // `params.term` should be the term that is used for searching - // `data.text` is the text that is displayed for the data object var param_term = params.term.toLowerCase().trim().replace(white_space_regex, ''); + + if ('undefined' !== typeof data.children) { + // `data.children` contains options to match against + var filteredChildren = []; + $.each(data.children, function (idx, child) { + // `child.text` is the text that is displayed for the data object + var param_data = child.text.toLowerCase().trim().replace(white_space_regex, ''); + + if (fuzzysearch(param_term, param_data)) { + filteredChildren.push(child); + } + }); + + // If any of the group's children match, + // then set the matched children on the group and return the group object + if (filteredChildren.length) { + var modifiedData = $.extend({}, data, true); + modifiedData.children = filteredChildren; + + // You can return modified objects from here + // This includes matching the `children` how you want in nested data sets + return modifiedData; + } + } + + // `data.text` is the text that is displayed for the data object var param_data = data.text.toLowerCase().trim().replace(white_space_regex, ''); if (fuzzysearch(param_term, param_data)) { var modifiedData = $.extend({}, data, true);