@@ -55,10 +55,20 @@ <h2 class="section-header">{{ heading }}</h2>
5555< div >
5656 {% get_filtered_query request filter.form as filtered_query %}
5757 {% if filtered_query %}
58+ < < < < < < < HEAD
5859 < div class ="flex flex-wrap gap-2 items-center my-2 ">
5960 < a href ="./ " class ="btn btn-ghost btn-sm btn-link link-hover ">
6061 {% trans "Clear current filters & sorts" %}
6162 {% heroicon_micro "x-mark" aria_hidden="true" class="size-4" %}
63+ =======
64+ < div class ="flex flex-wrap gap-2 items-center mt-2 ">
65+ < a
66+ href ="./ "
67+ class ="btn btn-ghost btn-sm btn-link link-hover "
68+ >
69+ {% heroicon_mini "x-mark" aria_hidden="true" fill="currentColor" %}
70+ {% trans "Clear current filters & sorts" %}
71+ > > > > > > > 6e8728a68 (Removed minified daterangepicker, made filter table populate initial values if they exist)
6272 </ a >
6373
6474 {% for query in filtered_query %}
@@ -104,7 +114,7 @@ <h2 class="section-header">{{ heading }}</h2>
104114 {% enddropdown_menu %}
105115 {% else %}
106116 {% dropdown_menu title=field.label heading=field|get_dropdown_heading position="right" %}
107- < calendar-range class ="mx-auto cally " onchange ="updateURL(this.value, '{{field_name}}') ">
117+ < calendar-range class ="mx-auto cally " onchange ="updateURL(this.value, '{{field_name}}') " data-field-name =' {{field_name}} ' >
108118 {% heroicon_micro "chevron-left" aria_label="Previous" slot="previous" aria_hidden=true size=18 %}
109119 {% heroicon_micro "chevron-right" aria_label="Next" slot="next" aria_hidden=true size=18 %}
110120 < calendar-month > </ calendar-month >
@@ -130,6 +140,23 @@ <h2 class="section-header">{{ heading }}</h2>
130140 window . history . pushState ( { } , '' , url ) ;
131141 location . reload ( ) ; // Reload to apply the filter
132142 }
143+
144+ document . addEventListener ( "DOMContentLoaded" , function ( ) {
145+ // Get all date pickers and set their initial range values based on the URL params
146+ document . querySelectorAll ( ".cally" ) . forEach ( ( datepicker ) => {
147+ const fieldName = datepicker . getAttribute ( "data-field-name" ) ;
148+
149+ const params = new URL ( window . location ) . searchParams ;
150+
151+ const startDate = params . get ( `${ fieldName } _after` ) ;
152+ const endDate = params . get ( `${ fieldName } _before` ) ;
153+
154+ if ( startDate && endDate ) {
155+ datepicker . value = `${ startDate } /${ endDate } `
156+ }
157+
158+ } )
159+ } )
133160 </ script >
134161 {% endif %}
135162 </ nav >
0 commit comments