Implemented meal plan sections (closes #370)

This commit is contained in:
Bernd Bestel
2021-07-15 17:54:48 +02:00
parent 1bacd8e13d
commit 2d2700cacb
17 changed files with 798 additions and 248 deletions

View File

@@ -188,7 +188,8 @@
data-placement="right"
title="{{ $__t('Meal plan') }}"
data-nav-for-page="mealplan">
<a class="nav-link discrete-link"
<a id="meal-plan-nav-link"
class="nav-link discrete-link"
href="{{ $U('/mealplan') }}">
<i class="fas fa-paper-plane"></i>
<span class="nav-link-text">{{ $__t('Meal plan') }}</span>

View File

@@ -24,6 +24,39 @@
max-height: 140px;
}
.fc-time-grid-container,
hr.fc-divider {
display: none;
}
.fc-axis {
width: 25px !important;
}
.fc-axis div {
transform: translateX(-50%) translateY(-50%) rotate(-90deg);
font-weight: bold;
font-size: 1.8em;
letter-spacing: 0.1em;
position: absolute;
top: 50%;
left: 0;
margin-left: 15px;
}
.fc-content-skeleton {
padding-bottom: 0 !important;
}
.calendar[data-primary-section='false'] .fc-toolbar.fc-header-toolbar,
.calendar[data-primary-section='false'] .fc-head {
display: none;
}
.calendar[data-primary-section='false'] {
border-top: #d6d6d6 solid 5px;
}
@media (min-width: 400px) {
.table-inline-menu.dropdown-menu {
width: 200px !important;
@@ -47,17 +80,56 @@
<div class="row">
<div class="col">
<h2 class="title">@yield('title')</h2>
<div class="title-related-links">
<h2 class="title">@yield('title')</h2>
<div class="float-right">
<button class="btn btn-outline-dark d-md-none mt-2 order-1 order-md-3"
type="button"
data-toggle="collapse"
data-target="#related-links">
<i class="fas fa-ellipsis-v"></i>
</button>
</div>
<div class="related-links collapse d-md-flex order-2 width-xs-sm-100"
id="related-links">
<a class="btn btn-outline-secondary m-1 mt-md-0 mb-md-0 float-right"
href="{{ $U('/mealplansections') }}">
{{ $__t('Configure sections') }}
</a>
</div>
</div>
</div>
</div>
<hr class="my-2">
@foreach($usedMealplanSections as $mealplanSection)
<div class="row">
<div class="col">
<div id="calendar"></div>
<div class="calendar"
data-section-id="{{ $mealplanSection->id }}"
data-section-name="{{ $mealplanSection->name }}"
data-primary-section="{{ BoolToString($loop->first) }}"
{{-- $loop->last doesn't work however, is always null... --}}
data-last-section="{{ BoolToString(array_values(array_slice($usedMealplanSections->fetchAll(), -1))[0]->id == $mealplanSection->id) }}">
</div>
</div>
</div>
@endforeach
{{-- Default empty calendar/section when no single meal plan entry is in the given date range --}}
@if($usedMealplanSections->count() === 0)
<div class="row">
<div class="col">
<div class="calendar"
data-section-id="-1"
data-section-name=""
data-primary-section="true"
data-last-section="true">
</div>
</div>
</div>
@endif
<div class="modal fade"
id="add-recipe-modal"
@@ -87,6 +159,18 @@
'additionalCssClasses' => 'locale-number-input locale-number-quantity-amount'
))
<div class="form-group">
<label for="period_type">{{ $__t('Section') }}</label>
<select class="custom-control custom-select"
id="section_id_recipe"
name="section_id_recipe"
required>
@foreach($mealplanSections as $mealplanSection)
<option value="{{ $mealplanSection->id }}">{{ $mealplanSection->name }}</option>
@endforeach
</select>
</div>
<input type="hidden"
id="day"
name="day"
@@ -130,6 +214,18 @@
name="note"></textarea>
</div>
<div class="form-group">
<label for="period_type">{{ $__t('Section') }}</label>
<select class="custom-control custom-select"
id="section_id_note"
name="section_id_note"
required>
@foreach($mealplanSections as $mealplanSection)
<option value="{{ $mealplanSection->id }}">{{ $mealplanSection->name }}</option>
@endforeach
</select>
</div>
<input type="hidden"
name="type"
value="note">
@@ -171,6 +267,18 @@
'additionalGroupCssClasses' => 'mb-0'
))
<div class="form-group">
<label for="period_type">{{ $__t('Section') }}</label>
<select class="custom-control custom-select"
id="section_id_product"
name="section_id_product"
required>
@foreach($mealplanSections as $mealplanSection)
<option value="{{ $mealplanSection->id }}">{{ $mealplanSection->name }}</option>
@endforeach
</select>
</div>
<input type="hidden"
name="type"
value="product">

View File

@@ -0,0 +1,62 @@
@extends('layout.default')
@if($mode == 'edit')
@section('title', $__t('Edit meal plan section'))
@else
@section('title', $__t('Create meal plan section'))
@endif
@section('viewJsName', 'mealplansectionform')
@section('content')
<div class="row">
<div class="col">
<h2 class="title">@yield('title')</h2>
</div>
</div>
<hr class="my-2">
<div class="row">
<div class="col-lg-6 col-12">
<script>
Grocy.EditMode = '{{ $mode }}';
</script>
@if($mode == 'edit')
<script>
Grocy.EditObjectId = {{ $mealplanSection->id }};
</script>
@endif
<form id="mealplansection-form"
novalidate>
<div class="form-group">
<label for="name">{{ $__t('Name') }}</label>
<input type="text"
class="form-control"
required
id="name"
name="name"
value="@if($mode == 'edit'){{ $mealplanSection->name }}@endif">
<div class="invalid-feedback">{{ $__t('A name is required') }}</div>
</div>
@php if($mode == 'edit' && !empty($mealplanSection->sort_number)) { $value = $mealplanSection->sort_number; } else { $value = ''; } @endphp
@include('components.numberpicker', array(
'id' => 'sort_number',
'label' => 'Sort number',
'min' => 0,
'value' => $value,
'isRequired' => false,
'hint' => $__t('Sections will be ordered by that number on the meal plan')
))
<button id="save-mealplansection-button"
class="btn btn-success">{{ $__t('Save') }}</button>
</form>
</div>
</div>
@stop

View File

@@ -0,0 +1,111 @@
@extends('layout.default')
@section('title', $__t('Meal plan sections'))
@section('activeNav', 'mealplansections')
@section('viewJsName', 'mealplansections')
@section('content')
<div class="row">
<div class="col">
<div class="title-related-links">
<h2 class="title">@yield('title')</h2>
<div class="float-right">
<button class="btn btn-outline-dark d-md-none mt-2 order-1 order-md-3"
type="button"
data-toggle="collapse"
data-target="#table-filter-row">
<i class="fas fa-filter"></i>
</button>
<button class="btn btn-outline-dark d-md-none mt-2 order-1 order-md-3"
type="button"
data-toggle="collapse"
data-target="#related-links">
<i class="fas fa-ellipsis-v"></i>
</button>
</div>
<div class="related-links collapse d-md-flex order-2 width-xs-sm-100"
id="related-links">
<a class="btn btn-primary responsive-button m-1 mt-md-0 mb-md-0 float-right show-as-dialog-link"
href="{{ $U('/mealplansection/new?embedded') }}">
{{ $__t('Add') }}
</a>
</div>
</div>
</div>
</div>
<hr class="my-2">
<div class="row collapse d-md-flex"
id="table-filter-row">
<div class="col-12 col-md-6 col-xl-3">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fas fa-search"></i></span>
</div>
<input type="text"
id="search"
class="form-control"
placeholder="{{ $__t('Search') }}">
</div>
</div>
<div class="col">
<div class="float-right">
<a id="clear-filter-button"
class="btn btn-sm btn-outline-info"
href="#">
{{ $__t('Clear filter') }}
</a>
</div>
</div>
</div>
<div class="row">
<div class="col">
<table id="mealplansections-table"
class="table table-sm table-striped nowrap w-100">
<thead>
<tr>
<th class="border-right"><a class="text-muted change-table-columns-visibility-button"
data-toggle="tooltip"
data-toggle="tooltip"
title="{{ $__t('Table options') }}"
data-table-selector="#mealplansections-table"
href="#"><i class="fas fa-eye"></i></a>
</th>
<th>{{ $__t('Name') }}</th>
<th>{{ $__t('Sort number') }}</th>
</tr>
</thead>
<tbody class="d-none">
@foreach($mealplanSections as $mealplanSection)
<tr>
<td class="fit-content border-right">
<a class="btn btn-info btn-sm show-as-dialog-link"
href="{{ $U('/mealplansection/') }}{{ $mealplanSection->id }}?embedded"
data-toggle="tooltip"
title="{{ $__t('Edit this item') }}">
<i class="fas fa-edit"></i>
</a>
<a class="btn btn-danger btn-sm mealplansection-delete-button"
href="#"
data-mealplansection-id="{{ $mealplanSection->id }}"
data-mealplansection-name="{{ $mealplanSection->name }}"
data-toggle="tooltip"
title="{{ $__t('Delete this item') }}">
<i class="fas fa-trash"></i>
</a>
</td>
<td>
{{ $mealplanSection->name }}
</td>
<td>
{{ $mealplanSection->sort_number }}
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
@stop