From cf2e6f10399677759143df2fd54fe2663a2a83b3 Mon Sep 17 00:00:00 2001 From: Bernd Bestel Date: Thu, 26 Sep 2019 17:20:25 +0200 Subject: [PATCH] Added a sub feature flag to disable chore assignments when not needed --- changelog/53_UNRELEASED_2019-xx-xx.md | 3 +++ config-dist.php | 1 + public/viewjs/choreform.js | 6 +++++- public/viewjs/choretracking.js | 2 +- views/choreform.blade.php | 5 +++++ views/choresjournal.blade.php | 4 ++++ views/choresoverview.blade.php | 14 +++++++++++++- views/choretracking.blade.php | 4 ++++ views/components/chorecard.blade.php | 2 ++ 9 files changed, 38 insertions(+), 3 deletions(-) diff --git a/changelog/53_UNRELEASED_2019-xx-xx.md b/changelog/53_UNRELEASED_2019-xx-xx.md index 868e93fa..989ccdb1 100644 --- a/changelog/53_UNRELEASED_2019-xx-xx.md +++ b/changelog/53_UNRELEASED_2019-xx-xx.md @@ -9,6 +9,9 @@ - It's now possible to display a recipe directly from the meal plan (new "eye button") (thanks @kriddles) - Improved the responsiveness of the meal plan and calendar page by automatically switching to a day calendar view on smaller screens (thanks for the idea @kriddles) +### Chores improvements +- There is now a new sub feature flag `FEATURE_FLAG_CHORES_ASSIGNMENTS` to disable chore assignments if you don't need them (defaults to `true`, so no changed behavior when not configured) + ### Calendar improvements - The calendar now also contains all planned recipes from the meal plan on the corresponding day - Improved that dates in the iCal calendar export now include the server timezone diff --git a/config-dist.php b/config-dist.php index 53817a24..c83286bb 100644 --- a/config-dist.php +++ b/config-dist.php @@ -124,6 +124,7 @@ Setting('FEATURE_FLAG_STOCK_PRICE_TRACKING', true); Setting('FEATURE_FLAG_STOCK_LOCATION_TRACKING', true); Setting('FEATURE_FLAG_STOCK_BEST_BEFORE_DATE_TRACKING', true); Setting('FEATURE_FLAG_STOCK_PRODUCT_OPENED_TRACKING', true); +Setting('FEATURE_FLAG_CHORES_ASSIGNMENTS', true); # Feature settings diff --git a/public/viewjs/choreform.js b/public/viewjs/choreform.js index 730a2bcd..1bd77713 100644 --- a/public/viewjs/choreform.js +++ b/public/viewjs/choreform.js @@ -3,7 +3,11 @@ e.preventDefault(); var jsonData = $('#chore-form').serializeJSON({ checkboxUncheckedValue: "0" }); - jsonData.assignment_config = $("#assignment_config").val().join(","); + if (Grocy.FeatureFlags.GROCY_FEATURE_FLAG_CHORES_ASSIGNMENTS) + { + jsonData.assignment_config = $("#assignment_config").val().join(","); + } + Grocy.FrontendHelpers.BeginUiBusy("chore-form"); if (Grocy.EditMode === 'create') diff --git a/public/viewjs/choretracking.js b/public/viewjs/choretracking.js index 6218008b..05b60fa9 100644 --- a/public/viewjs/choretracking.js +++ b/public/viewjs/choretracking.js @@ -8,7 +8,7 @@ Grocy.Api.Get('chores/' + jsonForm.chore_id, function (choreDetails) { - Grocy.Api.Post('chores/' + jsonForm.chore_id + '/execute', { 'tracked_time': Grocy.Components.DateTimePicker.GetValue(), 'done_by': Grocy.Components.UserPicker.GetValue() }, + Grocy.Api.Post('chores/' + jsonForm.chore_id + '/execute', { 'tracked_time': Grocy.Components.DateTimePicker.GetValue(), 'done_by': $("#user_id").val() }, function(result) { Grocy.FrontendHelpers.EndUiBusy("choretracking-form"); diff --git a/views/choreform.blade.php b/views/choreform.blade.php index e965d1eb..0287b65e 100644 --- a/views/choreform.blade.php +++ b/views/choreform.blade.php @@ -86,6 +86,7 @@ + @if(GROCY_FEATURE_FLAG_CHORES_ASSIGNMENTS)
{{ $__t('This assignment type requires that at least one is assigned') }}
+ @else + + + @endif
diff --git a/views/choresjournal.blade.php b/views/choresjournal.blade.php index 96cab621..e686a797 100644 --- a/views/choresjournal.blade.php +++ b/views/choresjournal.blade.php @@ -35,7 +35,9 @@ {{ $__t('Chore') }} {{ $__t('Tracked time') }} + @if(GROCY_FEATURE_FLAG_CHORES_ASSIGNMENTS) {{ $__t('Done by') }} + @endif @@ -58,6 +60,7 @@ {{ $choreLogEntry->tracked_time }} + @if(GROCY_FEATURE_FLAG_CHORES_ASSIGNMENTS) @if ($choreLogEntry->done_by_user_id !== null && !empty($choreLogEntry->done_by_user_id)) {{ GetUserDisplayName(FindObjectInArrayByPropertyValue($users, 'id', $choreLogEntry->done_by_user_id)) }} @@ -65,6 +68,7 @@ {{ $__t('Unknown') }} @endif + @endif @endforeach diff --git a/views/choresoverview.blade.php b/views/choresoverview.blade.php index d6e6b721..abfdc843 100644 --- a/views/choresoverview.blade.php +++ b/views/choresoverview.blade.php @@ -18,7 +18,9 @@

+ @if(GROCY_FEATURE_FLAG_CHORES_ASSIGNMENTS)

+ @endif
@@ -35,15 +37,17 @@ + @if(GROCY_FEATURE_FLAG_CHORES_ASSIGNMENTS)
+ @endif
@@ -55,9 +59,13 @@ {{ $__t('Chore') }} {{ $__t('Next estimated tracking') }} {{ $__t('Last tracked') }} + @if(GROCY_FEATURE_FLAG_CHORES_ASSIGNMENTS) {{ $__t('Assigned to') }} + @endif Hidden status + @if(GROCY_FEATURE_FLAG_CHORES_ASSIGNMENTS) Hidden assigned to user id + @endif @include('components.userfields_thead', array( 'userfields' => $userfields @@ -106,6 +114,7 @@ {{ $curentChoreEntry->last_tracked_time }} + @if(GROCY_FEATURE_FLAG_CHORES_ASSIGNMENTS) @if(!empty($curentChoreEntry->next_execution_assigned_to_user_id)) @@ -115,14 +124,17 @@ @endif + @endif @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(GROCY_FEATURE_FLAG_CHORES_ASSIGNMENTS) @if(!empty($curentChoreEntry->next_execution_assigned_to_user_id)) xx{{ $curentChoreEntry->next_execution_assigned_to_user_id }}xx @endif + @endif @include('components.userfields_tbody', array( 'userfields' => $userfields, diff --git a/views/choretracking.blade.php b/views/choretracking.blade.php index 48cce595..53f578f7 100644 --- a/views/choretracking.blade.php +++ b/views/choretracking.blade.php @@ -32,12 +32,16 @@ 'invalidFeedback' => $__t('This can only be before now') )) + @if(GROCY_FEATURE_FLAG_CHORES_ASSIGNMENTS) @include('components.userpicker', array( 'label' => 'Done by', 'users' => $users, 'nextInputSelector' => '#user_id', 'prefillByUserId' => GROCY_USER_ID )) + @else + + @endif diff --git a/views/components/chorecard.blade.php b/views/components/chorecard.blade.php index fdb1ce8d..6a04def9 100644 --- a/views/components/chorecard.blade.php +++ b/views/components/chorecard.blade.php @@ -13,6 +13,8 @@

{{ $__t('Tracked count') }}:
{{ $__t('Last tracked') }}:
+ @if(GROCY_FEATURE_FLAG_CHORES_ASSIGNMENTS) {{ $__t('Last done by') }}: + @endif