mirror of
https://github.com/grocy/grocy.git
synced 2025-08-20 04:12:59 +00:00
Make it possible to switch shopping list items between shopping lists (closes #284)
This commit is contained in:
@@ -5,3 +5,4 @@
|
|||||||
- Improved recipes API - added new endpoints to get stock fulfillment information (thanks @Aerex)
|
- Improved recipes API - added new endpoints to get stock fulfillment information (thanks @Aerex)
|
||||||
- Improved date display for products that never expires (instead of "2999-12-31" now just "Never" will be shown)
|
- Improved date display for products that never expires (instead of "2999-12-31" now just "Never" will be shown)
|
||||||
- Improved date display for dates of today and no time (instead of the hours since midnight now just "Today" will be shown)
|
- Improved date display for dates of today and no time (instead of the hours since midnight now just "Today" will be shown)
|
||||||
|
- Improved shopping list handling, items can now be switched between lists (there is a shopping list dropdown on the item edit page)
|
||||||
|
@@ -222,6 +222,7 @@ class StockController extends BaseController
|
|||||||
{
|
{
|
||||||
return $this->AppContainer->view->render($response, 'shoppinglistitemform', [
|
return $this->AppContainer->view->render($response, 'shoppinglistitemform', [
|
||||||
'products' => $this->Database->products()->orderBy('name'),
|
'products' => $this->Database->products()->orderBy('name'),
|
||||||
|
'shoppingLists' => $this->Database->shopping_lists()->orderBy('name'),
|
||||||
'mode' => 'create'
|
'mode' => 'create'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
@@ -230,6 +231,7 @@ class StockController extends BaseController
|
|||||||
return $this->AppContainer->view->render($response, 'shoppinglistitemform', [
|
return $this->AppContainer->view->render($response, 'shoppinglistitemform', [
|
||||||
'listItem' => $this->Database->shopping_list($args['itemId']),
|
'listItem' => $this->Database->shopping_list($args['itemId']),
|
||||||
'products' => $this->Database->products()->orderBy('name'),
|
'products' => $this->Database->products()->orderBy('name'),
|
||||||
|
'shoppingLists' => $this->Database->shopping_lists()->orderBy('name'),
|
||||||
'mode' => 'edit'
|
'mode' => 'edit'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
@@ -3,7 +3,6 @@
|
|||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
var jsonData = $('#shoppinglist-form').serializeJSON();
|
var jsonData = $('#shoppinglist-form').serializeJSON();
|
||||||
jsonData.shopping_list_id = GetUriParam("list");
|
|
||||||
Grocy.FrontendHelpers.BeginUiBusy("shoppinglist-form");
|
Grocy.FrontendHelpers.BeginUiBusy("shoppinglist-form");
|
||||||
|
|
||||||
if (Grocy.EditMode === 'create')
|
if (Grocy.EditMode === 'create')
|
||||||
@@ -11,7 +10,7 @@
|
|||||||
Grocy.Api.Post('objects/shopping_list', jsonData,
|
Grocy.Api.Post('objects/shopping_list', jsonData,
|
||||||
function(result)
|
function(result)
|
||||||
{
|
{
|
||||||
window.location.href = U('/shoppinglist?list=' + GetUriParam("list"));
|
window.location.href = U('/shoppinglist?list=' + $("#shopping_list_id").val().toString());
|
||||||
},
|
},
|
||||||
function(xhr)
|
function(xhr)
|
||||||
{
|
{
|
||||||
@@ -25,7 +24,7 @@
|
|||||||
Grocy.Api.Put('objects/shopping_list/' + Grocy.EditObjectId, jsonData,
|
Grocy.Api.Put('objects/shopping_list/' + Grocy.EditObjectId, jsonData,
|
||||||
function(result)
|
function(result)
|
||||||
{
|
{
|
||||||
window.location.href = U('/shoppinglist?list=' + GetUriParam("list"));
|
window.location.href = U('/shoppinglist?list=' + $("#shopping_list_id").val().toString());
|
||||||
},
|
},
|
||||||
function(xhr)
|
function(xhr)
|
||||||
{
|
{
|
||||||
@@ -93,12 +92,12 @@ $('#amount').on('focus', function(e)
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#shoppinglist-form input').keyup(function (event)
|
$('#shoppinglist-form input').keyup(function(event)
|
||||||
{
|
{
|
||||||
Grocy.FrontendHelpers.ValidateForm('shoppinglist-form');
|
Grocy.FrontendHelpers.ValidateForm('shoppinglist-form');
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#shoppinglist-form input').keydown(function (event)
|
$('#shoppinglist-form input').keydown(function(event)
|
||||||
{
|
{
|
||||||
if (event.keyCode === 13) //Enter
|
if (event.keyCode === 13) //Enter
|
||||||
{
|
{
|
||||||
@@ -114,3 +113,8 @@ $('#shoppinglist-form input').keydown(function (event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (GetUriParam("list") !== undefined)
|
||||||
|
{
|
||||||
|
$("#shopping_list_id").val(GetUriParam("list"));
|
||||||
|
}
|
||||||
|
@@ -21,6 +21,15 @@
|
|||||||
|
|
||||||
<form id="shoppinglist-form" novalidate>
|
<form id="shoppinglist-form" novalidate>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="product_group_id">{{ $__t('Shopping list') }}</label>
|
||||||
|
<select class="form-control" id="shopping_list_id" name="shopping_list_id">
|
||||||
|
@foreach($shoppingLists as $shoppingList)
|
||||||
|
<option @if($mode == 'edit' && $shoppingList->id == $listItem->shopping_list_id) selected="selected" @endif value="{{ $shoppingList->id }}">{{ $shoppingList->name }}</option>
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
@php if($mode == 'edit') { $productId = $listItem->product_id; } else { $productId = ''; } @endphp
|
@php if($mode == 'edit') { $productId = $listItem->product_id; } else { $productId = ''; } @endphp
|
||||||
@include('components.productpicker', array(
|
@include('components.productpicker', array(
|
||||||
'products' => $products,
|
'products' => $products,
|
||||||
|
Reference in New Issue
Block a user