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 @@ - + + +