mirror of
https://github.com/grocy/grocy.git
synced 2025-08-20 04:12:59 +00:00
Implemented multiple/named shopping lists (closes #190)
This commit is contained in:
@@ -20,8 +20,8 @@
|
||||
<div class="col">
|
||||
<h1>
|
||||
@yield('title')
|
||||
<a class="btn btn-outline-dark responsive-button" href="{{ $U('/shoppinglistitem/new') }}">
|
||||
<i class="fas fa-plus"></i> {{ $L('Add') }}
|
||||
<a class="btn btn-outline-dark responsive-button" href="{{ $U('/shoppinglistitem/new?list=' . $selectedShoppingListId) }}">
|
||||
<i class="fas fa-plus"></i> {{ $L('Add item') }}
|
||||
</a>
|
||||
<a id="clear-shopping-list" class="btn btn-outline-danger responsive-button @if($listItems->count() == 0) disabled @endif" href="#">
|
||||
<i class="fas fa-trash"></i> {{ $L('Clear list') }}
|
||||
@@ -37,6 +37,26 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mt-3">
|
||||
<div class="col-xs-12 col-md-4">
|
||||
<label for="selected-shopping-list">{{ $L('Selected shopping list') }}</label>
|
||||
<select class="form-control" id="selected-shopping-list">
|
||||
@foreach($shoppingLists as $shoppingList)
|
||||
<option @if($shoppingList->id == $selectedShoppingListId) selected="selected" @endif value="{{ $shoppingList->id }}">{{ $shoppingList->name }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-xs-12 col-md-4">
|
||||
<label for="selected-shopping-list"> </label><br>
|
||||
<a class="btn btn-outline-dark responsive-button" href="{{ $U('/shoppinglist/new') }}">
|
||||
<i class="fas fa-plus"></i> {{ $L('New shopping list') }}
|
||||
</a>
|
||||
<a id="delete-selected-shopping-list" class="btn btn-outline-danger responsive-button @if($selectedShoppingListId == 1) disabled @endif" href="#">
|
||||
<i class="fas fa-trash"></i> {{ $L('Delete shopping list') }}
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mt-3">
|
||||
<div class="col-xs-12 col-md-4">
|
||||
<label for="search">{{ $L('Search') }}</label> <i class="fas fa-search"></i>
|
||||
@@ -67,7 +87,7 @@
|
||||
@foreach($listItems as $listItem)
|
||||
<tr id="shoppinglistitem-{{ $listItem->id }}-row" class="@if(FindObjectInArrayByPropertyValue($missingProducts, 'id', $listItem->product_id) !== null) table-info @endif">
|
||||
<td class="fit-content border-right">
|
||||
<a class="btn btn-sm btn-info" href="{{ $U('/shoppinglistitem/') }}{{ $listItem->id }}">
|
||||
<a class="btn btn-sm btn-info" href="{{ $U('/shoppinglistitem/') . $listItem->id . '?list=' . $selectedShoppingListId }}">
|
||||
<i class="fas fa-edit"></i>
|
||||
</a>
|
||||
<a class="btn btn-sm btn-danger shoppinglist-delete-button" href="#" data-shoppinglist-id="{{ $listItem->id }}">
|
||||
|
@@ -1,56 +1,40 @@
|
||||
@extends('layout.default')
|
||||
|
||||
@if($mode == 'edit')
|
||||
@section('title', $L('Edit shopping list item'))
|
||||
@section('title', $L('Edit shopping list'))
|
||||
@else
|
||||
@section('title', $L('Create shopping list item'))
|
||||
@section('title', $L('Create shopping list'))
|
||||
@endif
|
||||
|
||||
@section('viewJsName', 'shoppinglistform')
|
||||
|
||||
@section('content')
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-md-6 col-xl-4 pb-3">
|
||||
<div class="col-lg-6 col-xs-12">
|
||||
<h1>@yield('title')</h1>
|
||||
|
||||
<script>Grocy.EditMode = '{{ $mode }}';</script>
|
||||
|
||||
@if($mode == 'edit')
|
||||
<script>Grocy.EditObjectId = {{ $listItem->id }};</script>
|
||||
<script>Grocy.EditObjectId = {{ $shoppingList->id }};</script>
|
||||
@endif
|
||||
|
||||
<form id="shoppinglist-form" novalidate>
|
||||
|
||||
@php if($mode == 'edit') { $productId = $listItem->product_id; } else { $productId = ''; } @endphp
|
||||
@include('components.productpicker', array(
|
||||
'products' => $products,
|
||||
'nextInputSelector' => '#amount',
|
||||
'isRequired' => false,
|
||||
'prefillById' => $productId
|
||||
))
|
||||
|
||||
@php if($mode == 'edit') { $value = $listItem->amount; } else { $value = 1; } @endphp
|
||||
@include('components.numberpicker', array(
|
||||
'id' => 'amount',
|
||||
'label' => 'Amount',
|
||||
'hintId' => 'amount_qu_unit',
|
||||
'min' => 0,
|
||||
'value' => $value,
|
||||
'invalidFeedback' => $L('The amount cannot be lower than #1', '1')
|
||||
))
|
||||
<form id="shopping-list-form" novalidate>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="note">{{ $L('Note') }}</label>
|
||||
<textarea class="form-control" rows="2" id="note" name="note">@if($mode == 'edit'){{ $listItem->note }}@endif</textarea>
|
||||
<label for="name">{{ $L('Name') }}</label>
|
||||
<input type="text" class="form-control" required id="name" name="name" value="@if($mode == 'edit'){{ $shoppingList->name }}@endif">
|
||||
<div class="invalid-feedback">{{ $L('A name is required') }}</div>
|
||||
</div>
|
||||
|
||||
<button id="save-shoppinglist-button" class="btn btn-success">{{ $L('Save') }}</button>
|
||||
<div class="form-group">
|
||||
<label for="description">{{ $L('Description') }}</label>
|
||||
<textarea class="form-control" rows="2" id="description" name="description">@if($mode == 'edit'){{ $shoppingList->description }}@endif</textarea>
|
||||
</div>
|
||||
|
||||
<button id="save-shopping-list-button" class="btn btn-success">{{ $L('Save') }}</button>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="col-xs-12 col-md-6 col-xl-4">
|
||||
@include('components.productcard')
|
||||
</div>
|
||||
</div>
|
||||
@stop
|
||||
|
56
views/shoppinglistitemform.blade.php
Normal file
56
views/shoppinglistitemform.blade.php
Normal file
@@ -0,0 +1,56 @@
|
||||
@extends('layout.default')
|
||||
|
||||
@if($mode == 'edit')
|
||||
@section('title', $L('Edit shopping list item'))
|
||||
@else
|
||||
@section('title', $L('Create shopping list item'))
|
||||
@endif
|
||||
|
||||
@section('viewJsName', 'shoppinglistitemform')
|
||||
|
||||
@section('content')
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-md-6 col-xl-4 pb-3">
|
||||
<h1>@yield('title')</h1>
|
||||
|
||||
<script>Grocy.EditMode = '{{ $mode }}';</script>
|
||||
|
||||
@if($mode == 'edit')
|
||||
<script>Grocy.EditObjectId = {{ $listItem->id }};</script>
|
||||
@endif
|
||||
|
||||
<form id="shoppinglist-form" novalidate>
|
||||
|
||||
@php if($mode == 'edit') { $productId = $listItem->product_id; } else { $productId = ''; } @endphp
|
||||
@include('components.productpicker', array(
|
||||
'products' => $products,
|
||||
'nextInputSelector' => '#amount',
|
||||
'isRequired' => false,
|
||||
'prefillById' => $productId
|
||||
))
|
||||
|
||||
@php if($mode == 'edit') { $value = $listItem->amount; } else { $value = 1; } @endphp
|
||||
@include('components.numberpicker', array(
|
||||
'id' => 'amount',
|
||||
'label' => 'Amount',
|
||||
'hintId' => 'amount_qu_unit',
|
||||
'min' => 0,
|
||||
'value' => $value,
|
||||
'invalidFeedback' => $L('The amount cannot be lower than #1', '1')
|
||||
))
|
||||
|
||||
<div class="form-group">
|
||||
<label for="note">{{ $L('Note') }}</label>
|
||||
<textarea class="form-control" rows="2" id="note" name="note">@if($mode == 'edit'){{ $listItem->note }}@endif</textarea>
|
||||
</div>
|
||||
|
||||
<button id="save-shoppinglist-button" class="btn btn-success">{{ $L('Save') }}</button>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="col-xs-12 col-md-6 col-xl-4">
|
||||
@include('components.productcard')
|
||||
</div>
|
||||
</div>
|
||||
@stop
|
Reference in New Issue
Block a user