Renamed habits to chores as this is more what it is about

This commit is contained in:
Bernd Bestel
2018-09-22 13:26:58 +02:00
parent bd3c63218b
commit 4075067a10
31 changed files with 653 additions and 622 deletions

View File

@@ -1,12 +1,12 @@
@extends('layout.default')
@if($mode == 'edit')
@section('title', $L('Edit habit'))
@section('title', $L('Edit chore'))
@else
@section('title', $L('Create habit'))
@section('title', $L('Create chore'))
@endif
@section('viewJsName', 'habitform')
@section('viewJsName', 'choreform')
@section('content')
<div class="row">
@@ -16,44 +16,44 @@
<script>Grocy.EditMode = '{{ $mode }}';</script>
@if($mode == 'edit')
<script>Grocy.EditObjectId = {{ $habit->id }};</script>
<script>Grocy.EditObjectId = {{ $chore->id }};</script>
@endif
<form id="habit-form" novalidate>
<form id="chore-form" novalidate>
<div class="form-group">
<label for="name">{{ $L('Name') }}</label>
<input type="text" class="form-control" required id="name" name="name" value="@if($mode == 'edit'){{ $habit->name }}@endif">
<input type="text" class="form-control" required id="name" name="name" value="@if($mode == 'edit'){{ $chore->name }}@endif">
<div class="invalid-feedback">{{ $L('A name is required') }}</div>
</div>
<div class="form-group">
<label for="description">{{ $L('Description') }}</label>
<textarea class="form-control" rows="2" id="description" name="description">@if($mode == 'edit'){{ $habit->description }}@endif</textarea>
<textarea class="form-control" rows="2" id="description" name="description">@if($mode == 'edit'){{ $chore->description }}@endif</textarea>
</div>
<div class="form-group">
<label for="period_type">{{ $L('Period type') }}</label>
<select required class="form-control input-group-habit-period-type" id="period_type" name="period_type">
<select required class="form-control input-group-chore-period-type" id="period_type" name="period_type">
@foreach($periodTypes as $periodType)
<option @if($mode == 'edit' && $periodType == $habit->period_type) selected="selected" @endif value="{{ $periodType }}">{{ $L($periodType) }}</option>
<option @if($mode == 'edit' && $periodType == $chore->period_type) selected="selected" @endif value="{{ $periodType }}">{{ $L($periodType) }}</option>
@endforeach
</select>
<div class="invalid-feedback">{{ $L('A period type is required') }}</div>
</div>
@php if($mode == 'edit') { $value = $habit->period_days; } else { $value = 0; } @endphp
@php if($mode == 'edit') { $value = $chore->period_days; } else { $value = 0; } @endphp
@include('components.numberpicker', array(
'id' => 'period_days',
'label' => 'Period days',
'value' => $value,
'min' => '0',
'additionalCssClasses' => 'input-group-habit-period-type',
'additionalCssClasses' => 'input-group-chore-period-type',
'invalidFeedback' => $L('This cannot be negative'),
'additionalHtmlElements' => '<p id="habit-period-type-info" class="form-text text-muted small d-none"></p>'
'additionalHtmlElements' => '<p id="chore-period-type-info" class="form-text text-muted small d-none"></p>'
))
<button id="save-habit-button" type="submit" class="btn btn-success">{{ $L('Save') }}</button>
<button id="save-chore-button" type="submit" class="btn btn-success">{{ $L('Save') }}</button>
</form>
</div>

View File

@@ -1,15 +1,15 @@
@extends('layout.default')
@section('title', $L('Habits'))
@section('activeNav', 'habits')
@section('viewJsName', 'habits')
@section('title', $L('Chores'))
@section('activeNav', 'chores')
@section('viewJsName', 'chores')
@section('content')
<div class="row">
<div class="col">
<h1>
@yield('title')
<a class="btn btn-outline-dark" href="{{ $U('/habit/new') }}">
<a class="btn btn-outline-dark" href="{{ $U('/chore/new') }}">
<i class="fas fa-plus"></i>&nbsp;{{ $L('Add') }}
</a>
</h1>
@@ -25,7 +25,7 @@
<div class="row">
<div class="col">
<table id="habits-table" class="table table-sm table-striped dt-responsive">
<table id="chores-table" class="table table-sm table-striped dt-responsive">
<thead>
<tr>
<th>#</th>
@@ -36,27 +36,27 @@
</tr>
</thead>
<tbody>
@foreach($habits as $habit)
@foreach($chores as $chore)
<tr>
<td class="fit-content">
<a class="btn btn-info btn-sm" href="{{ $U('/habit/') }}{{ $habit->id }}">
<a class="btn btn-info btn-sm" href="{{ $U('/chore/') }}{{ $chore->id }}">
<i class="fas fa-edit"></i>
</a>
<a class="btn btn-danger btn-sm habit-delete-button" href="#" data-habit-id="{{ $habit->id }}" data-habit-name="{{ $habit->name }}">
<a class="btn btn-danger btn-sm chore-delete-button" href="#" data-chore-id="{{ $chore->id }}" data-chore-name="{{ $chore->name }}">
<i class="fas fa-trash"></i>
</a>
</td>
<td>
{{ $habit->name }}
{{ $chore->name }}
</td>
<td>
{{ $L($habit->period_type) }}
{{ $L($chore->period_type) }}
</td>
<td>
{{ $habit->period_days }}
{{ $chore->period_days }}
</td>
<td>
{{ $habit->description }}
{{ $chore->description }}
</td>
</tr>
@endforeach

View File

@@ -1,8 +1,8 @@
@extends('layout.default')
@section('title', $L('Habits analysis'))
@section('activeNav', 'habitsanalysis')
@section('viewJsName', 'habitsanalysis')
@section('title', $L('Chores analysis'))
@section('activeNav', 'choresanalysis')
@section('viewJsName', 'choresanalysis')
@section('content')
<div class="row">
@@ -13,11 +13,11 @@
<div class="row mt-3">
<div class="col-xs-12 col-md-6 col-xl-3">
<label for="habit-filter">{{ $L('Filter by habit') }}</label> <i class="fas fa-filter"></i>
<select class="form-control" id="habit-filter">
<label for="chore-filter">{{ $L('Filter by chore') }}</label> <i class="fas fa-filter"></i>
<select class="form-control" id="chore-filter">
<option value="all">{{ $L('All') }}</option>
@foreach($habits as $habit)
<option value="{{ $habit->id }}">{{ $habit->name }}</option>
@foreach($chores as $chore)
<option value="{{ $chore->id }}">{{ $chore->name }}</option>
@endforeach
</select>
</div>
@@ -29,27 +29,27 @@
<div class="row">
<div class="col">
<table id="habits-analysis-table" class="table table-sm table-striped dt-responsive">
<table id="chores-analysis-table" class="table table-sm table-striped dt-responsive">
<thead>
<tr>
<th>{{ $L('Habit') }}</th>
<th>{{ $L('Chore') }}</th>
<th>{{ $L('Tracked time') }}</th>
<th>{{ $L('Done by') }}</th>
</tr>
</thead>
<tbody>
@foreach($habitsLog as $habitLogEntry)
@foreach($choresLog as $choreLogEntry)
<tr>
<td>
{{ FindObjectInArrayByPropertyValue($habits, 'id', $habitLogEntry->habit_id)->name }}
{{ FindObjectInArrayByPropertyValue($chores, 'id', $choreLogEntry->chore_id)->name }}
</td>
<td>
{{ $habitLogEntry->tracked_time }}
<time class="timeago timeago-contextual" datetime="{{ $habitLogEntry->tracked_time }}"></time>
{{ $choreLogEntry->tracked_time }}
<time class="timeago timeago-contextual" datetime="{{ $choreLogEntry->tracked_time }}"></time>
</td>
<td>
@if ($habitLogEntry->done_by_user_id !== null && !empty($habitLogEntry->done_by_user_id))
{{ GetUserDisplayName(FindObjectInArrayByPropertyValue($users, 'id', $habitLogEntry->done_by_user_id)) }}
@if ($choreLogEntry->done_by_user_id !== null && !empty($choreLogEntry->done_by_user_id))
{{ GetUserDisplayName(FindObjectInArrayByPropertyValue($users, 'id', $choreLogEntry->done_by_user_id)) }}
@else
{{ $L('Unknown') }}
@endif

View File

@@ -0,0 +1,72 @@
@extends('layout.default')
@section('title', $L('Chores overview'))
@section('activeNav', 'choresoverview')
@section('viewJsName', 'choresoverview')
@push('pageScripts')
<script src="{{ $U('/node_modules/jquery-ui-dist/jquery-ui.min.js?v=', true) }}{{ $version }}"></script>
@endpush
@section('content')
<div class="row">
<div class="col">
<h1>@yield('title')</h1>
<p id="info-due-chores" data-next-x-days="{{ $nextXDays }}" class="btn btn-lg btn-warning no-real-button responsive-button mr-2"></p>
<p id="info-overdue-chores" class="btn btn-lg btn-danger no-real-button responsive-button"></p>
</div>
</div>
<div class="row mt-3">
<div class="col-xs-12 col-md-6 col-xl-3">
<label for="search">{{ $L('Search') }}</label> <i class="fas fa-search"></i>
<input type="text" class="form-control" id="search">
</div>
</div>
<div class="row">
<div class="col">
<table id="chores-overview-table" class="table table-sm table-striped dt-responsive">
<thead>
<tr>
<th>#</th>
<th>{{ $L('Chore') }}</th>
<th>{{ $L('Next estimated tracking') }}</th>
<th>{{ $L('Last tracked') }}</th>
</tr>
</thead>
<tbody>
@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">
<td class="fit-content">
<a class="btn btn-success btn-sm track-chore-button" href="#" data-toggle="tooltip" title="{{ $L('Track execution of chore #1', FindObjectInArrayByPropertyValue($chores, 'id', $curentChoreEntry->chore_id)->name) }}"
data-chore-id="{{ $curentChoreEntry->chore_id }}"
data-chore-name="{{ FindObjectInArrayByPropertyValue($chores, 'id', $curentChoreEntry->chore_id)->name }}">
<i class="fas fa-play"></i>
</a>
<a class="btn btn-info btn-sm" href="{{ $U('/choresanalysis?chore=') }}{{ $curentChoreEntry->chore_id }}">
<i class="fas fa-chart-line"></i>
</a>
</td>
<td>
{{ 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)
<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
...
@endif
</td>
<td>
<span id="chore-{{ $curentChoreEntry->chore_id }}-last-tracked-time">{{ $curentChoreEntry->last_tracked_time }}</span>
<time id="chore-{{ $curentChoreEntry->chore_id }}-last-tracked-time-timeago" class="timeago timeago-contextual" datetime="{{ $curentChoreEntry->last_tracked_time }}"></time>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
@stop

View File

@@ -1,25 +1,25 @@
@extends('layout.default')
@section('title', $L('Habit tracking'))
@section('activeNav', 'habittracking')
@section('viewJsName', 'habittracking')
@section('title', $L('Chore tracking'))
@section('activeNav', 'choretracking')
@section('viewJsName', 'choretracking')
@section('content')
<div class="row">
<div class="col-xs-12 col-md-6 col-xl-4 pb-3">
<h1>@yield('title')</h1>
<form id="habittracking-form" novalidate>
<form id="choretracking-form" novalidate>
<div class="form-group">
<label for="habit_id">{{ $L('Habit') }}</label>
<select class="form-control combobox" id="habit_id" name="habit_id" required>
<label for="chore_id">{{ $L('Chore') }}</label>
<select class="form-control combobox" id="chore_id" name="chore_id" required>
<option value=""></option>
@foreach($habits as $habit)
<option value="{{ $habit->id }}">{{ $habit->name }}</option>
@foreach($chores as $chore)
<option value="{{ $chore->id }}">{{ $chore->name }}</option>
@endforeach
</select>
<div class="invalid-feedback">{{ $L('You have to select a habit') }}</div>
<div class="invalid-feedback">{{ $L('You have to select a chore') }}</div>
</div>
@include('components.datetimepicker', array(
@@ -39,13 +39,13 @@
'prefillByUserId' => GROCY_USER_ID
))
<button id="save-habittracking-button" type="submit" class="btn btn-success">{{ $L('OK') }}</button>
<button id="save-choretracking-button" type="submit" class="btn btn-success">{{ $L('OK') }}</button>
</form>
</div>
<div class="col-xs-12 col-md-6 col-xl-4">
@include('components.habitcard')
@include('components.chorecard')
</div>
</div>
@stop

View File

@@ -0,0 +1,15 @@
@push('componentScripts')
<script src="{{ $U('/viewjs/components/chorecard.js', true) }}?v={{ $version }}"></script>
@endpush
<div class="card">
<div class="card-header">
<i class="fas fa-refresh"></i> {{ $L('Chore overview') }}
</div>
<div class="card-body">
<h3><span id="chorecard-chore-name"></span></h3>
<strong>{{ $L('Tracked count') }}:</strong> <span id="chorecard-chore-tracked-count"></span><br>
<strong>{{ $L('Last tracked') }}:</strong> <span id="chorecard-chore-last-tracked"></span> <time id="chorecard-chore-last-tracked-timeago" class="timeago timeago-contextual"></time><br>
<strong>{{ $L('Last done by') }}:</strong> <span id="chorecard-chore-last-done-by"></span>
</div>
</div>

View File

@@ -1,15 +0,0 @@
@push('componentScripts')
<script src="{{ $U('/viewjs/components/habitcard.js', true) }}?v={{ $version }}"></script>
@endpush
<div class="card">
<div class="card-header">
<i class="fas fa-refresh"></i> {{ $L('Habit overview') }}
</div>
<div class="card-body">
<h3><span id="habitcard-habit-name"></span></h3>
<strong>{{ $L('Tracked count') }}:</strong> <span id="habitcard-habit-tracked-count"></span><br>
<strong>{{ $L('Last tracked') }}:</strong> <span id="habitcard-habit-last-tracked"></span> <time id="habitcard-habit-last-tracked-timeago" class="timeago timeago-contextual"></time><br>
<strong>{{ $L('Last done by') }}:</strong> <span id="habitcard-habit-last-done-by"></span>
</div>
</div>

View File

@@ -1,72 +0,0 @@
@extends('layout.default')
@section('title', $L('Habits overview'))
@section('activeNav', 'habitsoverview')
@section('viewJsName', 'habitsoverview')
@push('pageScripts')
<script src="{{ $U('/node_modules/jquery-ui-dist/jquery-ui.min.js?v=', true) }}{{ $version }}"></script>
@endpush
@section('content')
<div class="row">
<div class="col">
<h1>@yield('title')</h1>
<p id="info-due-habits" data-next-x-days="{{ $nextXDays }}" class="btn btn-lg btn-warning no-real-button responsive-button mr-2"></p>
<p id="info-overdue-habits" class="btn btn-lg btn-danger no-real-button responsive-button"></p>
</div>
</div>
<div class="row mt-3">
<div class="col-xs-12 col-md-6 col-xl-3">
<label for="search">{{ $L('Search') }}</label> <i class="fas fa-search"></i>
<input type="text" class="form-control" id="search">
</div>
</div>
<div class="row">
<div class="col">
<table id="habits-overview-table" class="table table-sm table-striped dt-responsive">
<thead>
<tr>
<th>#</th>
<th>{{ $L('Habit') }}</th>
<th>{{ $L('Next estimated tracking') }}</th>
<th>{{ $L('Last tracked') }}</th>
</tr>
</thead>
<tbody>
@foreach($currentHabits as $curentHabitEntry)
<tr id="habit-{{ $curentHabitEntry->habit_id }}-row" class="@if(FindObjectInArrayByPropertyValue($habits, 'id', $curentHabitEntry->habit_id)->period_type === \Grocy\Services\HabitsService::HABIT_TYPE_DYNAMIC_REGULAR && $curentHabitEntry->next_estimated_execution_time < date('Y-m-d H:i:s')) table-danger @elseif(FindObjectInArrayByPropertyValue($habits, 'id', $curentHabitEntry->habit_id)->period_type === \Grocy\Services\HabitsService::HABIT_TYPE_DYNAMIC_REGULAR && $curentHabitEntry->next_estimated_execution_time < date('Y-m-d H:i:s', strtotime("+$nextXDays days"))) table-warning @endif">
<td class="fit-content">
<a class="btn btn-success btn-sm track-habit-button" href="#" data-toggle="tooltip" title="{{ $L('Track execution of habit #1', FindObjectInArrayByPropertyValue($habits, 'id', $curentHabitEntry->habit_id)->name) }}"
data-habit-id="{{ $curentHabitEntry->habit_id }}"
data-habit-name="{{ FindObjectInArrayByPropertyValue($habits, 'id', $curentHabitEntry->habit_id)->name }}">
<i class="fas fa-play"></i>
</a>
<a class="btn btn-info btn-sm" href="{{ $U('/habitsanalysis?habit=') }}{{ $curentHabitEntry->habit_id }}">
<i class="fas fa-chart-line"></i>
</a>
</td>
<td>
{{ FindObjectInArrayByPropertyValue($habits, 'id', $curentHabitEntry->habit_id)->name }}
</td>
<td>
@if(FindObjectInArrayByPropertyValue($habits, 'id', $curentHabitEntry->habit_id)->period_type === \Grocy\Services\HabitsService::HABIT_TYPE_DYNAMIC_REGULAR)
<span id="habit-{{ $curentHabitEntry->habit_id }}-next-execution-time">{{ $curentHabitEntry->next_estimated_execution_time }}</span>
<time id="habit-{{ $curentHabitEntry->habit_id }}-next-execution-time-timeago" class="timeago timeago-contextual" datetime="{{ $curentHabitEntry->next_estimated_execution_time }}"></time>
@else
...
@endif
</td>
<td>
<span id="habit-{{ $curentHabitEntry->habit_id }}-last-tracked-time">{{ $curentHabitEntry->last_tracked_time }}</span>
<time id="habit-{{ $curentHabitEntry->habit_id }}-last-tracked-time-timeago" class="timeago timeago-contextual" datetime="{{ $curentHabitEntry->last_tracked_time }}"></time>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
@stop

View File

@@ -60,10 +60,10 @@
<span class="nav-link-text">{{ $L('Stock overview') }}</span>
</a>
</li>
<li class="nav-item" data-toggle="tooltip" data-placement="right" title="{{ $L('Habits overview') }}" data-nav-for-page="habitsoverview">
<a class="nav-link discrete-link" href="{{ $U('/habitsoverview') }}">
<li class="nav-item" data-toggle="tooltip" data-placement="right" title="{{ $L('Chores overview') }}" data-nav-for-page="choresoverview">
<a class="nav-link discrete-link" href="{{ $U('/choresoverview') }}">
<i class="fas fa-tachometer-alt"></i>
<span class="nav-link-text">{{ $L('Habits overview') }}</span>
<span class="nav-link-text">{{ $L('Chores overview') }}</span>
</a>
</li>
<li class="nav-item" data-toggle="tooltip" data-placement="right" title="{{ $L('Batteries overview') }}" data-nav-for-page="batteriesoverview">
@@ -103,10 +103,10 @@
<span class="nav-link-text">{{ $L('Inventory') }}</span>
</a>
</li>
<li class="nav-item" data-toggle="tooltip" data-placement="right" title="{{ $L('Habit tracking') }}" data-nav-for-page="habittracking">
<a class="nav-link discrete-link" href="{{ $U('/habittracking') }}">
<li class="nav-item" data-toggle="tooltip" data-placement="right" title="{{ $L('Chore tracking') }}" data-nav-for-page="choretracking">
<a class="nav-link discrete-link" href="{{ $U('/choretracking') }}">
<i class="fas fa-play"></i>
<span class="nav-link-text">{{ $L('Habit tracking') }}</span>
<span class="nav-link-text">{{ $L('Chore tracking') }}</span>
</a>
</li>
<li class="nav-item" data-toggle="tooltip" data-placement="right" title="{{ $L('Battery tracking') }}" data-nav-for-page="batterytracking">
@@ -140,10 +140,10 @@
<span class="nav-link-text">{{ $L('Quantity units') }}</span>
</a>
</li>
<li data-nav-for-page="habits" data-sub-menu-of="#top-nav-manager-master-data">
<a class="nav-link discrete-link" href="{{ $U('/habits') }}">
<li data-nav-for-page="chores" data-sub-menu-of="#top-nav-manager-master-data">
<a class="nav-link discrete-link" href="{{ $U('/chores') }}">
<i class="fas fa-sync-alt"></i>
<span class="nav-link-text">{{ $L('Habits') }}</span>
<span class="nav-link-text">{{ $L('Chores') }}</span>
</a>
</li>
<li data-nav-for-page="batteries" data-sub-menu-of="#top-nav-manager-master-data">