Implemented daily/weekly/monthly recurrence patterns for chores (closes #151)

This commit is contained in:
Bernd Bestel
2019-04-22 14:01:31 +02:00
parent d72fe69a17
commit 77f3b80540
10 changed files with 131 additions and 16 deletions

View File

@@ -50,9 +50,43 @@
'min' => '0',
'additionalCssClasses' => 'input-group-chore-period-type',
'invalidFeedback' => $L('This cannot be negative'),
'hintId' => 'chore-period-type-info'
'hintId' => 'chore-period-type-info',
'additionalGroupCssClasses' => 'period-type-input period-type-dynamic-regular period-type-monthly'
))
<div class="form-group period-type-input period-type-weekly">
<div class="form-check form-check-inline">
<input class="form-check-input input-group-chore-period-type" type="checkbox" id="monday" value="monday">
<label class="form-check-label" for="monday">{{ $L('Monday') }}</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input input-group-chore-period-type" type="checkbox" id="tuesday" value="tuesday">
<label class="form-check-label" for="tuesday">{{ $L('Tuesday') }}</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input input-group-chore-period-type" type="checkbox" id="wednesday" value="wednesday">
<label class="form-check-label" for="wednesday">{{ $L('Wednesday') }}</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input input-group-chore-period-type" type="checkbox" id="thursday" value="thursday">
<label class="form-check-label" for="thursday">{{ $L('Thursday') }}</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input input-group-chore-period-type" type="checkbox" id="friday" value="friday">
<label class="form-check-label" for="friday">{{ $L('Friday') }}</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input input-group-chore-period-type" type="checkbox" id="saturday" value="saturday">
<label class="form-check-label" for="saturday">{{ $L('Saturday') }}</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input input-group-chore-period-type" type="checkbox" id="sunday" value="sunday">
<label class="form-check-label" for="sunday">{{ $L('Sunday') }}</label>
</div>
</div>
<input type="hidden" id="period_config" name="period_config" value="@if($mode == 'edit'){{ $chore->period_config }}@endif">
<button id="save-chore-button" class="btn btn-success">{{ $L('Save') }}</button>
</form>

View File

@@ -31,7 +31,6 @@
<th class="border-right"></th>
<th>{{ $L('Name') }}</th>
<th>{{ $L('Period type') }}</th>
<th>{{ $L('Period days') }}</th>
<th>{{ $L('Description') }}</th>
</tr>
</thead>
@@ -52,9 +51,6 @@
<td>
{{ $L($chore->period_type) }}
</td>
<td>
{{ $chore->period_days }}
</td>
<td>
{{ $chore->description }}
</td>

View File

@@ -50,7 +50,7 @@
</thead>
<tbody class="d-none">
@foreach($currentChores as $curentChoreEntry)
<tr id="chore-{{ $curentChoreEntry->chore_id }}-row" class="@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')) table-danger @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"))) table-warning @endif">
<tr id="chore-{{ $curentChoreEntry->chore_id }}-row" class="@if(FindObjectInArrayByPropertyValue($chores, 'id', $curentChoreEntry->chore_id)->period_type !== \Grocy\Services\ChoresService::CHORE_TYPE_MANUALLY && $curentChoreEntry->next_estimated_execution_time < date('Y-m-d H:i:s')) table-danger @elseif(FindObjectInArrayByPropertyValue($chores, 'id', $curentChoreEntry->chore_id)->period_type !== \Grocy\Services\ChoresService::CHORE_TYPE_MANUALLY && $curentChoreEntry->next_estimated_execution_time < date('Y-m-d H:i:s', strtotime("+$nextXDays days"))) table-warning @endif">
<td class="fit-content border-right">
<a class="btn btn-success btn-sm track-chore-button" href="#" data-toggle="tooltip" data-placement="left" title="{{ $L('Track execution of chore #1', FindObjectInArrayByPropertyValue($chores, 'id', $curentChoreEntry->chore_id)->name) }}"
data-chore-id="{{ $curentChoreEntry->chore_id }}"
@@ -78,7 +78,7 @@
{{ FindObjectInArrayByPropertyValue($chores, 'id', $curentChoreEntry->chore_id)->name }}
</td>
<td>
@if(FindObjectInArrayByPropertyValue($chores, 'id', $curentChoreEntry->chore_id)->period_type === \Grocy\Services\ChoresService::CHORE_TYPE_DYNAMIC_REGULAR)
@if(FindObjectInArrayByPropertyValue($chores, 'id', $curentChoreEntry->chore_id)->period_type !== \Grocy\Services\ChoresService::CHORE_TYPE_MANUALLY)
<span id="chore-{{ $curentChoreEntry->chore_id }}-next-execution-time">{{ $curentChoreEntry->next_estimated_execution_time }}</span>
<time id="chore-{{ $curentChoreEntry->chore_id }}-next-execution-time-timeago" class="timeago timeago-contextual" datetime="{{ $curentChoreEntry->next_estimated_execution_time }}"></time>
@else
@@ -90,7 +90,7 @@
<time id="chore-{{ $curentChoreEntry->chore_id }}-last-tracked-time-timeago" class="timeago timeago-contextual" datetime="{{ $curentChoreEntry->last_tracked_time }}"></time>
</td>
<td class="d-none">
@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
@if(FindObjectInArrayByPropertyValue($chores, 'id', $curentChoreEntry->chore_id)->period_type !== \Grocy\Services\ChoresService::CHORE_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_TYPE_MANUALLY && $curentChoreEntry->next_estimated_execution_time < date('Y-m-d H:i:s', strtotime("+$nextXDays days"))) duesoon @endif
</td>
</tr>
@endforeach