|
365 | 365 | <nav x-show="!showSelectedSubmissions" |
366 | 366 | class="flex flex-wrap gap-2 items-center menu-filters" |
367 | 367 | > |
368 | | - <div id="filterupdated" aria-label="Filter by Updated" class="flex items-center"> |
| 368 | + <div id="filtersubmitted" aria-label="Filter by Submitted" class="flex items-center" data-query="submitted"> |
| 369 | + <button class="flex justify-between items-center py-1 w-full font-medium text-gray-600 border cursor-pointer md:p-0 md:border-none hover:bg-gray-50 ps-2 pe-2 md:pe-4 md:hover:bg-transparent md:hover:text-blue-700"> |
| 370 | + {% trans "Submitted" %} |
| 371 | + {% heroicon_mini "chevron-down" aria_hidden="true" width=18 height=18 class="hidden md:inline-block" %} |
| 372 | + </button> |
| 373 | + </div> |
| 374 | + <div id="filterupdated" aria-label="Filter by Updated" class="flex items-center" data-query="updated"> |
369 | 375 | <button class="flex justify-between items-center py-1 w-full font-medium text-gray-600 border cursor-pointer md:p-0 md:border-none hover:bg-gray-50 ps-2 pe-2 md:pe-4 md:hover:bg-transparent md:hover:text-blue-700"> |
370 | 376 | {% trans "Updated" %} |
371 | 377 | {% heroicon_mini "chevron-down" aria_hidden="true" width=18 height=18 class="hidden md:inline-block" %} |
372 | 378 | </button> |
373 | | - |
374 | 379 | </div> |
375 | 380 |
|
376 | 381 | {% dropdown_menu title="Status" heading="Filter by current status" enable_search=True %} |
@@ -609,23 +614,28 @@ <h2 class='text-2xl'>{% trans "No results matched your search" %}</h2> |
609 | 614 | var start = moment().subtract(29, 'days'); |
610 | 615 | var end = moment(); |
611 | 616 |
|
612 | | - $('#filterupdated').daterangepicker({ |
613 | | - startDate: start, |
614 | | - endDate: end, |
615 | | - ranges: { |
616 | | - '{% trans "Today" %}': [moment(), moment()], |
617 | | - '{% trans "Yesterday" %}': [moment().subtract(1, 'days'), moment().subtract(1, 'days')], |
618 | | - '{% trans "Last 7 Days" %}': [moment().subtract(6, 'days'), moment()], |
619 | | - '{% trans "Last 30 Days" %}': [moment().subtract(29, 'days'), moment()], |
620 | | - '{% trans "This Month" %}': [moment().startOf('month'), moment().endOf('month')], |
621 | | - '{% trans "Last Month" %}': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')] |
622 | | - } |
623 | | - }); |
624 | | - |
625 | | - $('#filterupdated').on('apply.daterangepicker', function(ev, picker) { |
626 | | - $('#search-navbar').val(`updated:>=${picker.startDate.format('YYYY-MM-DD')} updated:<=${picker.endDate.format('YYYY-MM-DD')}`); |
627 | | - $('#search-navbar').closest('form').trigger('submit'); |
628 | | - }); |
| 617 | + // Add the picker for all elements that need it |
| 618 | + $.each(['#filterupdated', '#filtersubmitted'], (index, element) => { |
| 619 | + $(element).daterangepicker({ |
| 620 | + startDate: start, |
| 621 | + endDate: end, |
| 622 | + ranges: { |
| 623 | + '{% trans "Today" %}': [moment(), moment()], |
| 624 | + '{% trans "Yesterday" %}': [moment().subtract(1, 'days'), moment().subtract(1, 'days')], |
| 625 | + '{% trans "Last 7 Days" %}': [moment().subtract(6, 'days'), moment()], |
| 626 | + '{% trans "Last 30 Days" %}': [moment().subtract(29, 'days'), moment()], |
| 627 | + '{% trans "This Month" %}': [moment().startOf('month'), moment().endOf('month')], |
| 628 | + '{% trans "Last Month" %}': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')] |
| 629 | + } |
| 630 | + }); |
| 631 | + |
| 632 | + var query = $(element).attr("data-query"); |
| 633 | + |
| 634 | + $(element).on('apply.daterangepicker', function(ev, picker) { |
| 635 | + $('#search-navbar').val(`${query}:>=${picker.startDate.format('YYYY-MM-DD')} ${query}:<=${picker.endDate.format('YYYY-MM-DD')}`); |
| 636 | + $('#search-navbar').closest('form').trigger('submit'); |
| 637 | + }); |
| 638 | + }) |
629 | 639 | }); |
630 | 640 | </script> |
631 | 641 | {% endblock %} |
0 commit comments