Make it possible to also filter by chore assignments on the chore overview page (references #253)

This commit is contained in:
Bernd Bestel 2019-09-17 16:50:29 +02:00
parent b5761ae544
commit bc487b4867
No known key found for this signature in database
GPG Key ID: 71BD34C0D4891300
3 changed files with 51 additions and 2 deletions

View File

@ -1414,3 +1414,6 @@ msgstr ""
msgid "assigned to %s"
msgstr ""
msgid "Filter by assignment"
msgstr ""

View File

@ -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();

View File

@ -18,7 +18,7 @@
</h1>
<p id="info-due-chores" data-status-filter="duesoon" data-next-x-days="{{ $nextXDays }}" class="btn btn-lg btn-warning status-filter-button responsive-button mr-2"></p>
<p id="info-overdue-chores" data-status-filter="overdue" class="btn btn-lg btn-danger status-filter-button responsive-button mr-2"></p>
<p id="info-assigned-to-me-chores" data-status-filter="assigned-to-me" class="btn btn-lg btn-secondary status-filter-button responsive-button"></p>
<p id="info-assigned-to-me-chores" data-user-display-name-filter="{{ GetUserDisplayName(FindObjectInArrayByPropertyValue($users, 'id', GROCY_USER_ID)) }}" class="btn btn-lg btn-secondary user-filter-button responsive-button"></p>
</div>
</div>
@ -33,7 +33,15 @@
<option class="bg-white" value="all">{{ $__t('All') }}</option>
<option class="bg-warning" value="duesoon">{{ $__t('Due soon') }}</option>
<option class="bg-danger" value="overdue">{{ $__t('Overdue') }}</option>
<option class="bg-secondary text-white" value="assigned-to-me">{{ $__t('Assigned to me') }}</option>
</select>
</div>
<div class="col-xs-12 col-md-6 col-xl-3">
<label for="user-filter">{{ $__t('Filter by assignment') }}</label> <i class="fas fa-filter"></i>
<select class="form-control" id="user-filter">
<option></option>
@foreach($users as $user)
<option class="@if($user->id == GROCY_USER_ID) bg-secondary text-white @endif" data-user-id="{{ $user->id }}" value="xx{{ $user->id }}xx">{{ $user->display_name }}</option>
@endforeach
</select>
</div>
</div>
@ -49,6 +57,7 @@
<th>{{ $__t('Last tracked') }}</th>
<th>{{ $__t('Assigned to') }}</th>
<th class="d-none">Hidden status</th>
<th class="d-none">Hidden assigned to user id</th>
@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
</td>
<td class="d-none">
@if(!empty($curentChoreEntry->next_execution_assigned_to_user_id))
xx{{ $curentChoreEntry->next_execution_assigned_to_user_id }}xx
@endif
</td>
@include('components.userfields_tbody', array(
'userfields' => $userfields,