mirror of
https://github.com/grocy/grocy.git
synced 2025-08-20 20:26:42 +00:00
dialogs for shopping list (#1103)
This commit is contained in:
@@ -447,3 +447,13 @@ if ($(window).width() < 768 & window.location.hash !== "#compact" && !BoolVal(Gr
|
|||||||
{
|
{
|
||||||
$("#shopping-list-compact-view-button").click();
|
$("#shopping-list-compact-view-button").click();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$(window).on("message", function(e)
|
||||||
|
{
|
||||||
|
var data = e.originalEvent.data;
|
||||||
|
|
||||||
|
if (data.Message === "ShoppingListChanged")
|
||||||
|
{
|
||||||
|
window.location.href = U('/shoppinglist?list=' + data.Payload);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
@@ -10,12 +10,14 @@
|
|||||||
Grocy.Api.Post('objects/shopping_lists', jsonData,
|
Grocy.Api.Post('objects/shopping_lists', jsonData,
|
||||||
function(result)
|
function(result)
|
||||||
{
|
{
|
||||||
window.location.href = U('/shoppinglist?list=' + result.created_object_id);
|
window.parent.postMessage(WindowMessageBag("ShoppingListChanged", result.created_object_id), Grocy.BaseUrl);
|
||||||
|
window.parent.postMessage(WindowMessageBag("Ready"), Grocy.BaseUrl);
|
||||||
|
window.parent.postMessage(WindowMessageBag("CloseAllModals"), Grocy.BaseUrl);
|
||||||
},
|
},
|
||||||
function(xhr)
|
function(xhr)
|
||||||
{
|
{
|
||||||
Grocy.FrontendHelpers.EndUiBusy("shopping-list-form");
|
Grocy.FrontendHelpers.EndUiBusy("shopping-list-form");
|
||||||
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response)
|
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -24,12 +26,14 @@
|
|||||||
Grocy.Api.Put('objects/shopping_lists/' + Grocy.EditObjectId, jsonData,
|
Grocy.Api.Put('objects/shopping_lists/' + Grocy.EditObjectId, jsonData,
|
||||||
function(result)
|
function(result)
|
||||||
{
|
{
|
||||||
window.location.href = U('/shoppinglist');
|
window.parent.postMessage(WindowMessageBag("ShoppingListChanged", Grocy.EditObjectId), Grocy.BaseUrl);
|
||||||
|
window.parent.postMessage(WindowMessageBag("Ready"), Grocy.BaseUrl);
|
||||||
|
window.parent.postMessage(WindowMessageBag("CloseAllModals"), Grocy.BaseUrl);
|
||||||
},
|
},
|
||||||
function(xhr)
|
function(xhr)
|
||||||
{
|
{
|
||||||
Grocy.FrontendHelpers.EndUiBusy("shopping-list-form");
|
Grocy.FrontendHelpers.EndUiBusy("shopping-list-form");
|
||||||
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response)
|
Grocy.FrontendHelpers.ShowGenericError('Error while saving, probably this item already exists', xhr.response);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@@ -19,6 +19,7 @@
|
|||||||
function(productDetails)
|
function(productDetails)
|
||||||
{
|
{
|
||||||
window.parent.postMessage(WindowMessageBag("ShowSuccessMessage", __t("Added %1$s of %2$s to the shopping list \"%3$s\"", jsonData.product_amount + " " + __n(jsonData.product_amount, productDetails.quantity_unit_purchase.name, productDetails.quantity_unit_purchase.name_plural), productDetails.product.name, $("#shopping_list_id option:selected").text())), Grocy.BaseUrl);
|
window.parent.postMessage(WindowMessageBag("ShowSuccessMessage", __t("Added %1$s of %2$s to the shopping list \"%3$s\"", jsonData.product_amount + " " + __n(jsonData.product_amount, productDetails.quantity_unit_purchase.name, productDetails.quantity_unit_purchase.name_plural), productDetails.product.name, $("#shopping_list_id option:selected").text())), Grocy.BaseUrl);
|
||||||
|
window.parent.postMessage(WindowMessageBag("ShoppingListChanged", $("#shopping_list_id").val().toString()), Grocy.BaseUrl);
|
||||||
window.parent.postMessage(WindowMessageBag("CloseAllModals"), Grocy.BaseUrl);
|
window.parent.postMessage(WindowMessageBag("CloseAllModals"), Grocy.BaseUrl);
|
||||||
},
|
},
|
||||||
function(xhr)
|
function(xhr)
|
||||||
@@ -51,6 +52,7 @@
|
|||||||
function(productDetails)
|
function(productDetails)
|
||||||
{
|
{
|
||||||
window.parent.postMessage(WindowMessageBag("ShowSuccessMessage", __t("Added %1$s of %2$s to the shopping list \"%3$s\"", jsonData.amount + " " + __n(jsonData.amount, productDetails.quantity_unit_purchase.name, productDetails.quantity_unit_purchase.name_plural), productDetails.product.name, $("#shopping_list_id option:selected").text())), Grocy.BaseUrl);
|
window.parent.postMessage(WindowMessageBag("ShowSuccessMessage", __t("Added %1$s of %2$s to the shopping list \"%3$s\"", jsonData.amount + " " + __n(jsonData.amount, productDetails.quantity_unit_purchase.name, productDetails.quantity_unit_purchase.name_plural), productDetails.product.name, $("#shopping_list_id option:selected").text())), Grocy.BaseUrl);
|
||||||
|
window.parent.postMessage(WindowMessageBag("ShoppingListChanged", $("#shopping_list_id").val().toString()), Grocy.BaseUrl);
|
||||||
window.parent.postMessage(WindowMessageBag("CloseAllModals"), Grocy.BaseUrl);
|
window.parent.postMessage(WindowMessageBag("CloseAllModals"), Grocy.BaseUrl);
|
||||||
},
|
},
|
||||||
function(xhr)
|
function(xhr)
|
||||||
@@ -82,6 +84,7 @@
|
|||||||
function(productDetails)
|
function(productDetails)
|
||||||
{
|
{
|
||||||
window.parent.postMessage(WindowMessageBag("ShowSuccessMessage", __t("Added %1$s of %2$s to the shopping list \"%3$s\"", jsonData.amount + " " + __n(jsonData.amount, productDetails.quantity_unit_purchase.name, productDetails.quantity_unit_purchase.name_plural), productDetails.product.name, $("#shopping_list_id option:selected").text())), Grocy.BaseUrl);
|
window.parent.postMessage(WindowMessageBag("ShowSuccessMessage", __t("Added %1$s of %2$s to the shopping list \"%3$s\"", jsonData.amount + " " + __n(jsonData.amount, productDetails.quantity_unit_purchase.name, productDetails.quantity_unit_purchase.name_plural), productDetails.product.name, $("#shopping_list_id option:selected").text())), Grocy.BaseUrl);
|
||||||
|
window.parent.postMessage(WindowMessageBag("ShoppingListChanged", $("#shopping_list_id").val().toString()), Grocy.BaseUrl);
|
||||||
window.parent.postMessage(WindowMessageBag("CloseAllModals"), Grocy.BaseUrl);
|
window.parent.postMessage(WindowMessageBag("CloseAllModals"), Grocy.BaseUrl);
|
||||||
},
|
},
|
||||||
function(xhr)
|
function(xhr)
|
||||||
|
@@ -40,10 +40,14 @@
|
|||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="d-inline-block mb-1">
|
<div class="d-inline-block mb-1">
|
||||||
<a class="btn btn-outline-dark btn-sm responsive-button"
|
<a class="btn btn-outline-dark btn-sm responsive-button show-as-dialog-link"
|
||||||
href="{{ $U('/shoppinglist/new') }}">
|
href="{{ $U('/shoppinglist/new?embedded') }}">
|
||||||
{{ $__t('New shopping list') }}
|
{{ $__t('New shopping list') }}
|
||||||
</a>
|
</a>
|
||||||
|
<a class="btn btn-outline-dark btn-sm responsive-button show-as-dialog-link @if($selectedShoppingListId == 1) disabled @endif"
|
||||||
|
href="{{ $U('/shoppinglist/' . $selectedShoppingListId . '?embedded') }}">
|
||||||
|
{{ $__t('Edit shopping list') }}
|
||||||
|
</a>
|
||||||
<a id="delete-selected-shopping-list"
|
<a id="delete-selected-shopping-list"
|
||||||
class="btn btn-outline-danger btn-sm responsive-button @if($selectedShoppingListId == 1) disabled @endif"
|
class="btn btn-outline-danger btn-sm responsive-button @if($selectedShoppingListId == 1) disabled @endif"
|
||||||
href="#">
|
href="#">
|
||||||
@@ -77,8 +81,8 @@
|
|||||||
|
|
||||||
<div class="row mt-3 d-print-none hide-on-fullscreen-card">
|
<div class="row mt-3 d-print-none hide-on-fullscreen-card">
|
||||||
<div class="col-md-12 mb-2">
|
<div class="col-md-12 mb-2">
|
||||||
<a class="btn btn-primary responsive-button btn-sm mb-1"
|
<a class="btn btn-primary responsive-button btn-sm mb-1 show-as-dialog-link"
|
||||||
href="{{ $U('/shoppinglistitem/new?list=' . $selectedShoppingListId) }}">
|
href="{{ $U('/shoppinglistitem/new?embedded&list=' . $selectedShoppingListId) }}">
|
||||||
{{ $__t('Add item') }}
|
{{ $__t('Add item') }}
|
||||||
</a>
|
</a>
|
||||||
<a id="clear-shopping-list"
|
<a id="clear-shopping-list"
|
||||||
@@ -174,8 +178,8 @@
|
|||||||
title="{{ $__t('Mark this item as done') }}">
|
title="{{ $__t('Mark this item as done') }}">
|
||||||
<i class="fas fa-check"></i>
|
<i class="fas fa-check"></i>
|
||||||
</a>
|
</a>
|
||||||
<a class="btn btn-sm btn-info"
|
<a class="btn btn-sm btn-info show-as-dialog-link"
|
||||||
href="{{ $U('/shoppinglistitem/') . $listItem->id . '?list=' . $selectedShoppingListId }}"
|
href="{{ $U('/shoppinglistitem/' . $listItem->id . '?embedded&list=' . $selectedShoppingListId ) }}"
|
||||||
data-toggle="tooltip"
|
data-toggle="tooltip"
|
||||||
data-placement="right"
|
data-placement="right"
|
||||||
title="{{ $__t('Edit this item') }}">
|
title="{{ $__t('Edit this item') }}">
|
||||||
|
Reference in New Issue
Block a user