From 634711ca3a4142ad326111799541a7a1202405a5 Mon Sep 17 00:00:00 2001 From: Linty Date: Thu, 19 Sep 2024 18:00:07 +0200 Subject: [PATCH] fixes #2229 created date filter, handle parent and child dates Add and outline check for parent date and grey check for child dates --- themes/default/js/mcs.js | 32 ++++--------------- .../template/include/search_filters.inc.tpl | 6 ++-- 2 files changed, 10 insertions(+), 28 deletions(-) diff --git a/themes/default/js/mcs.js b/themes/default/js/mcs.js index 281f4d6c1..f2cbc4263 100644 --- a/themes/default/js/mcs.js +++ b/themes/default/js/mcs.js @@ -189,7 +189,6 @@ $(document).ready(function () { // On custom date input select $(".custom_posted_date .date_posted-option input").change(function() { - const parentOption = $(this).parent(); const currentYear = $(this).data('year'); const selector = `.custom_posted_date #container_${currentYear}`; @@ -256,6 +255,10 @@ $(document).ready(function () { date_created_str += ', '; } }); + + $('.date_created-option.year').each(function () { + updateDateFilters(`.custom_created_date #${$(this).attr('id')}`); + }); } // change badge label if filter not empty @@ -297,30 +300,9 @@ $(document).ready(function () { // On custom date input select $(".custom_created_date .date_created-option input").change(function() { - var parentOption = $(this).parent() - - if($(this).is(":checked")){ - // Toggle tick icon on selected date in custom list - $(this).siblings('label').find('.checked-icon').show(); - - // Add class selected to selected option, - // We want to find which are selected to handle the others - $(this).addClass('selected') - $(parentOption).addClass('selected') - $(parentOption).find('.mcs-icon').addClass('selected') - } - else - { - // Toggle tick icon on selected date in custom list - $(this).siblings('label').find('.checked-icon').hide(); - - // Add class selected to selected option, - // We want to find which are selected to handle the others - $(this).removeClass('selected') - $(parentOption).removeClass('selected') - $(parentOption).find('.mcs-icon').removeClass('selected') - } - // if this is selected then disable selecting children, and display grey tick + const currentYear = $(this).data('year'); + const selector = `.custom_created_date #container_${currentYear}`; + updateDateFilters(selector); // Used to select custom in preset list if dates are selected if($('.custom_created_date input:checked').length > 0) diff --git a/themes/default/template/include/search_filters.inc.tpl b/themes/default/template/include/search_filters.inc.tpl index 16cd3d564..a3ccf6891 100644 --- a/themes/default/template/include/search_filters.inc.tpl +++ b/themes/default/template/include/search_filters.inc.tpl @@ -403,7 +403,7 @@ const prefix_icon = 'gallery-icon-'; {foreach from=$LIST_DATE_CREATED key=y item=year}
- +