From 7401971884637d469c11ddf374fb86b35e35eaeb Mon Sep 17 00:00:00 2001 From: Bernd Bestel Date: Mon, 24 Sep 2018 19:13:53 +0200 Subject: [PATCH] Make info bars clickable and add a filter for them on all overview pages (references #60) --- localization/de.php | 6 ++++++ public/css/grocy.css | 4 ---- public/viewjs/batteriesoverview.js | 21 +++++++++++++++++++++ public/viewjs/choresoverview.js | 21 +++++++++++++++++++++ public/viewjs/shoppinglist.js | 21 +++++++++++++++++++++ public/viewjs/stockoverview.js | 21 +++++++++++++++++++++ public/viewjs/tasks.js | 21 +++++++++++++++++++++ views/batteriesoverview.blade.php | 16 ++++++++++++++-- views/choresoverview.blade.php | 16 ++++++++++++++-- views/shoppinglist.blade.php | 23 +++++++++++++++++++---- views/stockoverview.blade.php | 19 ++++++++++++++++--- views/tasks.blade.php | 16 ++++++++++++++-- 12 files changed, 188 insertions(+), 17 deletions(-) diff --git a/localization/de.php b/localization/de.php index 3239bd87..aadbc31e 100644 --- a/localization/de.php +++ b/localization/de.php @@ -243,6 +243,12 @@ return array( 'Are you sure to delete product group "#1"?' => 'Produktgruppe "#1" wirklich löschen?', 'Stay logged in permanently' => 'Dauerhaft angemeldet bleiben', 'When not set, you will get logged out at latest after 30 days' => 'Wenn nicht gesetzt, wirst du spätestens nach 30 Tagen automatisch abgemeldet', + 'Filter by status' => 'Nach Status filtern', + 'Below min. stock amount' => 'Unter Mindestbestand', + 'Expiring soon' => 'Bald ablaufend', + 'Already expired' => 'Bereits abgelaufen', + 'Due soon' => 'Bald fällig', + 'Overdue' => 'Überfällig', //Constants 'manually' => 'Manuell', diff --git a/public/css/grocy.css b/public/css/grocy.css index 5b5cb2c0..1dd11fc6 100644 --- a/public/css/grocy.css +++ b/public/css/grocy.css @@ -11,10 +11,6 @@ body { white-space: normal; } -.no-real-button { - pointer-events: none; -} - .timeago-contextual { font-style: italic; font-size: 0.8em; diff --git a/public/viewjs/batteriesoverview.js b/public/viewjs/batteriesoverview.js index 46293d1d..afd07f2e 100644 --- a/public/viewjs/batteriesoverview.js +++ b/public/viewjs/batteriesoverview.js @@ -25,6 +25,27 @@ $("#search").on("keyup", function() batteriesOverviewTable.search(value).draw(); }); +$("#status-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"); + + batteriesOverviewTable.column(4).search(value).draw(); +}); + +$(".status-filter-button").on("click", function() +{ + var value = $(this).data("status-filter"); + $("#status-filter").val(value); + $("#status-filter").trigger("change"); +}); + $(document).on('click', '.track-charge-cycle-button', function(e) { e.preventDefault(); diff --git a/public/viewjs/choresoverview.js b/public/viewjs/choresoverview.js index 32e82426..19cff53f 100644 --- a/public/viewjs/choresoverview.js +++ b/public/viewjs/choresoverview.js @@ -25,6 +25,27 @@ $("#search").on("keyup", function() choresOverviewTable.search(value).draw(); }); +$("#status-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(4).search(value).draw(); +}); + +$(".status-filter-button").on("click", function() +{ + var value = $(this).data("status-filter"); + $("#status-filter").val(value); + $("#status-filter").trigger("change"); +}); + $(document).on('click', '.track-chore-button', function(e) { e.preventDefault(); diff --git a/public/viewjs/shoppinglist.js b/public/viewjs/shoppinglist.js index 05839692..f4c6fe40 100644 --- a/public/viewjs/shoppinglist.js +++ b/public/viewjs/shoppinglist.js @@ -30,6 +30,27 @@ $("#search").on("keyup", function() shoppingListTable.search(value).draw(); }); +$("#status-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"); + + shoppingListTable.column(4).search(value).draw(); +}); + +$(".status-filter-button").on("click", function() +{ + var value = $(this).data("status-filter"); + $("#status-filter").val(value); + $("#status-filter").trigger("change"); +}); + $(document).on('click', '.shoppinglist-delete-button', function (e) { e.preventDefault(); diff --git a/public/viewjs/stockoverview.js b/public/viewjs/stockoverview.js index 4d4b40c1..37becc0f 100644 --- a/public/viewjs/stockoverview.js +++ b/public/viewjs/stockoverview.js @@ -26,6 +26,27 @@ $("#location-filter").on("change", function() stockOverviewTable.column(4).search(value).draw(); }); +$("#status-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"); + + stockOverviewTable.column(5).search(value).draw(); +}); + +$(".status-filter-button").on("click", function() +{ + var value = $(this).data("status-filter"); + $("#status-filter").val(value); + $("#status-filter").trigger("change"); +}); + $("#search").on("keyup", function() { var value = $(this).val(); diff --git a/public/viewjs/tasks.js b/public/viewjs/tasks.js index d11b6498..c6c72f16 100644 --- a/public/viewjs/tasks.js +++ b/public/viewjs/tasks.js @@ -29,6 +29,27 @@ $("#search").on("keyup", function() tasksTable.search(value).draw(); }); +$("#status-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"); + + tasksTable.column(5).search(value).draw(); +}); + +$(".status-filter-button").on("click", function() +{ + var value = $(this).data("status-filter"); + $("#status-filter").val(value); + $("#status-filter").trigger("change"); +}); + $(document).on('click', '.do-task-button', function(e) { e.preventDefault(); diff --git a/views/batteriesoverview.blade.php b/views/batteriesoverview.blade.php index 41365005..80e9485f 100644 --- a/views/batteriesoverview.blade.php +++ b/views/batteriesoverview.blade.php @@ -12,12 +12,20 @@

@yield('title')

-

-

+

+

+
+ + +
@@ -33,6 +41,7 @@ {{ $L('Battery') }} {{ $L('Last charged') }} {{ $L('Next planned charge cycle') }} + Hidden status @@ -60,6 +69,9 @@ ... @endif + + "@if(FindObjectInArrayByPropertyValue($batteries, 'id', $curentBatteryEntry->battery_id)->charge_interval_days > 0 && $curentBatteryEntry->next_estimated_charge_time < date('Y-m-d H:i:s')) overdue @elseif(FindObjectInArrayByPropertyValue($batteries, 'id', $curentBatteryEntry->battery_id)->charge_interval_days > 0 && $curentBatteryEntry->next_estimated_charge_time < date('Y-m-d H:i:s', strtotime("+$nextXDays days"))) duesoon @endif + @endforeach diff --git a/views/choresoverview.blade.php b/views/choresoverview.blade.php index 94e5ae8a..b149d0fc 100644 --- a/views/choresoverview.blade.php +++ b/views/choresoverview.blade.php @@ -12,12 +12,20 @@

@yield('title')

-

-

+

+

+
+ + +
@@ -33,6 +41,7 @@ {{ $L('Chore') }} {{ $L('Next estimated tracking') }} {{ $L('Last tracked') }} + Hidden status @@ -63,6 +72,9 @@ {{ $curentChoreEntry->last_tracked_time }} + + @if(FindObjectInArrayByPropertyValue($chores, 'id', $curentChoreEntry->chore_id)->period_type === \Grocy\Services\ChoresService::CHORE_TYPE_DYNAMIC_REGULAR && $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_TYPE_DYNAMIC_REGULAR && $curentChoreEntry->next_estimated_execution_time < date('Y-m-d H:i:s', strtotime("+$nextXDays days"))) duesoon @endif + @endforeach diff --git a/views/shoppinglist.blade.php b/views/shoppinglist.blade.php index 7753ff75..358ebd6a 100644 --- a/views/shoppinglist.blade.php +++ b/views/shoppinglist.blade.php @@ -29,15 +29,26 @@ {{ $L('Add products that are below defined min. stock amount') }} -

{{ Pluralize(count($missingProducts), $L('#1 product is below defined min. stock amount', count($missingProducts)), $L('#1 products are below defined min. stock amount', count($missingProducts))) }}

+

{{ Pluralize(count($missingProducts), $L('#1 product is below defined min. stock amount', count($missingProducts)), $L('#1 products are below defined min. stock amount', count($missingProducts))) }}

+
+
+ +
+
+ + +
+
+ +
- - - @@ -45,6 +56,7 @@ + @@ -67,6 +79,9 @@ + @endforeach diff --git a/views/stockoverview.blade.php b/views/stockoverview.blade.php index 6f7871f8..7079f46c 100644 --- a/views/stockoverview.blade.php +++ b/views/stockoverview.blade.php @@ -12,9 +12,9 @@

@yield('title')

-

-

-

+

+

+

@@ -28,6 +28,15 @@ @endforeach +
+ + +
@@ -44,6 +53,7 @@
+ @@ -78,6 +88,9 @@ + @endforeach diff --git a/views/tasks.blade.php b/views/tasks.blade.php index 7bad8d06..bb7e64c4 100644 --- a/views/tasks.blade.php +++ b/views/tasks.blade.php @@ -23,12 +23,20 @@ {{ $L('Add') }} -

-

+

+

+
+ + +
@@ -53,6 +61,7 @@
+ @@ -86,6 +95,9 @@ + @endforeach
{{ $L('Product') }} / {{ $L('Note') }} {{ $L('Amount') }} Hiden product groupHidden status
@if(!empty(FindObjectInArrayByPropertyValue($products, 'id', $listItem->product_id)->product_group_id)) {{ FindObjectInArrayByPropertyValue($productGroups, 'id', FindObjectInArrayByPropertyValue($products, 'id', $listItem->product_id)->product_group_id)->name }} @else {{ $L('Ungrouped') }} @endif + @if(FindObjectInArrayByPropertyValue($missingProducts, 'id', $listItem->product_id) !== null) belowminstockamount @endif +
{{ $L('Amount') }} {{ $L('Next best before date') }} Hidden locationHidden status
{{ FindObjectInArrayByPropertyValue($locations, 'id', FindObjectInArrayByPropertyValue($products, 'id', $currentStockEntry->product_id)->location_id)->name }} + @if($currentStockEntry->best_before_date < date('Y-m-d', strtotime('-1 days'))) expired @elseif($currentStockEntry->best_before_date < date('Y-m-d', strtotime("+$nextXDays days"))) expiring @elseif (FindObjectInArrayByPropertyValue($missingProducts, 'id', $currentStockEntry->product_id) !== null) belowminstockamount @endif +
{{ $L('Due') }} Hidden category {{ $L('Assigned to') }}Hidden status
@if($task->assigned_to_user_id != null) {{ GetUserDisplayName(FindObjectInArrayByPropertyValue($users, 'id', $task->assigned_to_user_id)) }} @endif + @if($task->done == 1) text-muted @endif @if(!empty($task->due_date) && $task->due_date < date('Y-m-d')) overdue @elseif(!empty($task->due_date) && $task->due_date < date('Y-m-d', strtotime("+$nextXDays days"))) duesoon @endif +