From bc487b4867829277c5e18ad5faad6e136335f44a Mon Sep 17 00:00:00 2001 From: Bernd Bestel Date: Tue, 17 Sep 2019 16:50:29 +0200 Subject: [PATCH] Make it possible to also filter by chore assignments on the chore overview page (references #253) --- localization/strings.pot | 3 +++ public/viewjs/choresoverview.js | 32 ++++++++++++++++++++++++++++++++ views/choresoverview.blade.php | 18 ++++++++++++++++-- 3 files changed, 51 insertions(+), 2 deletions(-) diff --git a/localization/strings.pot b/localization/strings.pot index c6fe570c..66dd6af1 100644 --- a/localization/strings.pot +++ b/localization/strings.pot @@ -1414,3 +1414,6 @@ msgstr "" msgid "assigned to %s" msgstr "" + +msgid "Filter by assignment" +msgstr "" diff --git a/public/viewjs/choresoverview.js b/public/viewjs/choresoverview.js index fc93ce6e..1c4f9cee 100644 --- a/public/viewjs/choresoverview.js +++ b/public/viewjs/choresoverview.js @@ -46,6 +46,25 @@ $("#status-filter").on("change", function() choresOverviewTable.column(5).search(value).draw(); }); +$("#user-filter").on("change", function() +{ + var value = $(this).val(); + if (value === "all") + { + value = ""; + } + + // Transfer CSS classes of selected element to dropdown element (for background) + $(this).attr("class", $("#" + $(this).attr("id") + " option[value='" + value + "']").attr("class") + " form-control"); + + choresOverviewTable.column(6).search(value).draw(); + + if (!value.isEmpty()) + { + UpdateUriParam("user", $("#user-filter option:selected").data("user-id")); + } +}); + $(".status-filter-button").on("click", function() { var value = $(this).data("status-filter"); @@ -53,6 +72,13 @@ $(".status-filter-button").on("click", function() $("#status-filter").trigger("change"); }); +$(".user-filter-button").on("click", function() +{ + var value = $(this).data("user-display-name-filter"); + $("#user-filter").val(value); + $("#user-filter").trigger("change"); +}); + $(document).on('click', '.track-chore-button', function(e) { e.preventDefault(); @@ -200,4 +226,10 @@ function RefreshStatistics() ); } +if (GetUriParam("user") !== undefined) +{ + $("#user-filter").val("xx" + GetUriParam("user") + "xx"); + $("#user-filter").trigger("change"); +} + RefreshStatistics(); diff --git a/views/choresoverview.blade.php b/views/choresoverview.blade.php index 33febe05..d7f9d55e 100644 --- a/views/choresoverview.blade.php +++ b/views/choresoverview.blade.php @@ -18,7 +18,7 @@

-

+

@@ -33,7 +33,15 @@ - + + +
+ +
@@ -49,6 +57,7 @@ {{ $__t('Last tracked') }} {{ $__t('Assigned to') }} Hidden status + Hidden assigned to user id @include('components.userfields_thead', array( 'userfields' => $userfields @@ -110,6 +119,11 @@ @if(FindObjectInArrayByPropertyValue($chores, 'id', $curentChoreEntry->chore_id)->period_type !== \Grocy\Services\ChoresService::CHORE_PERIOD_TYPE_MANUALLY && $curentChoreEntry->next_estimated_execution_time < date('Y-m-d H:i:s')) overdue @elseif(FindObjectInArrayByPropertyValue($chores, 'id', $curentChoreEntry->chore_id)->period_type !== \Grocy\Services\ChoresService::CHORE_PERIOD_TYPE_MANUALLY && $curentChoreEntry->next_estimated_execution_time < date('Y-m-d H:i:s', strtotime("+$nextXDays days"))) duesoon @endif @if($curentChoreEntry->next_execution_assigned_to_user_id == GROCY_USER_ID) assigned-to-me @endif + + @if(!empty($curentChoreEntry->next_execution_assigned_to_user_id)) + xx{{ $curentChoreEntry->next_execution_assigned_to_user_id }}xx + @endif + @include('components.userfields_tbody', array( 'userfields' => $userfields,