mirror of
https://github.com/grocy/grocy.git
synced 2026-04-05 12:26:15 +02:00
viewjs: Move delete confirmation box to frontendhelper
More code deduplication.
This commit is contained in:
parent
3b342f90db
commit
87ee45f0b1
|
|
@ -198,7 +198,11 @@ class GrocyFrontendHelpers
|
||||||
}
|
}
|
||||||
MakeStatusFilter(dataTable, column)
|
MakeStatusFilter(dataTable, column)
|
||||||
{
|
{
|
||||||
$("#status-filter").on("change", function()
|
return this.MakeValueFilter("status", column, dataTable)
|
||||||
|
}
|
||||||
|
MakeValueFilter(key, column, dataTable, resetValue = "all")
|
||||||
|
{
|
||||||
|
$("#" + key + "-filter").on("change", function()
|
||||||
{
|
{
|
||||||
var value = $(this).val();
|
var value = $(this).val();
|
||||||
if (value === "all")
|
if (value === "all")
|
||||||
|
|
@ -212,17 +216,84 @@ class GrocyFrontendHelpers
|
||||||
dataTable.column(column).search(value).draw();
|
dataTable.column(column).search(value).draw();
|
||||||
});
|
});
|
||||||
|
|
||||||
$(".status-filter-message").on("click", function()
|
$("." + key + "-filter-message").on("click", function()
|
||||||
{
|
{
|
||||||
var value = $(this).data("status-filter");
|
var value = $(this).data(key + "-filter");
|
||||||
$("#status-filter").val(value);
|
$("#" + key + "-filter").val(value);
|
||||||
$("#status-filter").trigger("change");
|
$("#" + key + "-filter").trigger("change");
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#clear-filter-button").on("click", function()
|
$("#clear-filter-button").on("click", function()
|
||||||
{
|
{
|
||||||
$("#status-filter").val("all");
|
$("#" + key + "-filter").val(resetValue);
|
||||||
$("#status-filter").trigger("change");
|
$("#" + key + "-filter").trigger("change");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
MakeDeleteConfirmBox(message, selector, attrName, attrId, apiEndpoint, redirectUrl)
|
||||||
|
{
|
||||||
|
if (!apiEndpoint.endsWith('/'))
|
||||||
|
{
|
||||||
|
apiEndpoint += '/';
|
||||||
|
}
|
||||||
|
if (redirectUrl instanceof String && !redirectUrl.startsWith('/'))
|
||||||
|
{
|
||||||
|
redirectUrl = '/' + redirectUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
var self = this;
|
||||||
|
$(document).on('click', selector, function(e)
|
||||||
|
{
|
||||||
|
var target = $(e.currentTarget);
|
||||||
|
var objectName = target.attr(attrName);
|
||||||
|
var objectId = target.attr(attrId);
|
||||||
|
|
||||||
|
if (message instanceof Function)
|
||||||
|
{
|
||||||
|
message = message(objectId, objectName);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
message = self.Grocy.translate(message, objectName)
|
||||||
|
}
|
||||||
|
|
||||||
|
bootbox.confirm({
|
||||||
|
message: message,
|
||||||
|
closeButton: false,
|
||||||
|
buttons: {
|
||||||
|
confirm: {
|
||||||
|
label: self.Grocy.translate('Yes'),
|
||||||
|
className: 'btn-success'
|
||||||
|
},
|
||||||
|
cancel: {
|
||||||
|
label: self.Grocy.translate('No'),
|
||||||
|
className: 'btn-danger'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
callback: function(result)
|
||||||
|
{
|
||||||
|
if (result === true)
|
||||||
|
{
|
||||||
|
self.Api.Delete(apiEndpoint + objectId, {},
|
||||||
|
function(result)
|
||||||
|
{
|
||||||
|
if (redirectUrl instanceof Function)
|
||||||
|
{
|
||||||
|
redirectUrl(result, objectId, objectName);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
window.location.href = self.Grocy.FormatUrl(redirectUrl);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
function(xhr)
|
||||||
|
{
|
||||||
|
console.error(xhr);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,49 +9,21 @@
|
||||||
].concat($.fn.dataTable.defaults.columnDefs)
|
].concat($.fn.dataTable.defaults.columnDefs)
|
||||||
});
|
});
|
||||||
$('#chores-overview-table tbody').removeClass("d-none");
|
$('#chores-overview-table tbody').removeClass("d-none");
|
||||||
Grocy.FrontendHelpers.InitDataTable(choresOverviewTable, null, function()
|
Grocy.FrontendHelpers.InitDataTable(choresOverviewTable);
|
||||||
{
|
Grocy.FrontendHelpers.MakeValueFilter("status", 5, choresOverviewTable);
|
||||||
$("#search").val("");
|
Grocy.FrontendHelpers.MakeValueFilter("user", 6, choresOverviewTable, "");
|
||||||
$("#user-filter").val("all");
|
|
||||||
choresOverviewTable.column(6).search("").draw();
|
|
||||||
choresOverviewTable.search("").draw();
|
|
||||||
RemoveUriParam("user");
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
Grocy.FrontendHelpers.MakeFilterForColumn("#status-filter", 5, choresOverviewTable, null, true);
|
|
||||||
|
|
||||||
$("#user-filter").on("change", function()
|
$("#user-filter").on("change", function()
|
||||||
{
|
{
|
||||||
var value = $(this).val();
|
var user = $(this).val();
|
||||||
if (value === "all")
|
if (user !== null && !user.isEmpty())
|
||||||
{
|
|
||||||
value = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
// Transfer CSS classes of selected element to dropdown element (for background)
|
|
||||||
$(this).attr("class", $("#" + $(this).attr("id") + " option[value='" + value + "']").attr("class") + " form-control");
|
|
||||||
|
|
||||||
choresOverviewTable.column(6).search(value).draw();
|
|
||||||
|
|
||||||
if (!value.isEmpty())
|
|
||||||
{
|
{
|
||||||
UpdateUriParam("user", $("#user-filter option:selected").data("user-id"));
|
UpdateUriParam("user", $("#user-filter option:selected").data("user-id"));
|
||||||
}
|
}
|
||||||
});
|
else
|
||||||
|
{
|
||||||
$(".status-filter-message").on("click", function()
|
RemoveUriParam("user")
|
||||||
{
|
}
|
||||||
var value = $(this).data("status-filter");
|
|
||||||
$("#status-filter").val(value);
|
|
||||||
$("#status-filter").trigger("change");
|
|
||||||
});
|
|
||||||
|
|
||||||
$(".user-filter-message").on("click", function()
|
|
||||||
{
|
|
||||||
var value = $(this).data("user-filter");
|
|
||||||
$("#user-filter").val(value);
|
|
||||||
$("#user-filter").trigger("change");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).on('click', '.track-chore-button', function(e)
|
$(document).on('click', '.track-chore-button', function(e)
|
||||||
|
|
|
||||||
|
|
@ -65,42 +65,14 @@ function DisplayEquipment(id)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$(document).on('click', '.equipment-delete-button', function(e)
|
Grocy.FrontendHelpers.MakeDeleteConfirmBox(
|
||||||
{
|
'Are you sure to delete equipment "%s"?',
|
||||||
var objectName = $(e.currentTarget).attr('data-equipment-name');
|
'.equipment-delete-button',
|
||||||
var objectId = $(e.currentTarget).attr('data-equipment-id');
|
'data-equipment-name',
|
||||||
|
'data-equipment-id',
|
||||||
bootbox.confirm({
|
'objects/equipment/',
|
||||||
message: __t('Are you sure to delete equipment "%s"?', objectName),
|
'/equipment'
|
||||||
closeButton: false,
|
);
|
||||||
buttons: {
|
|
||||||
confirm: {
|
|
||||||
label: __t('Yes'),
|
|
||||||
className: 'btn-success'
|
|
||||||
},
|
|
||||||
cancel: {
|
|
||||||
label: __t('No'),
|
|
||||||
className: 'btn-danger'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
callback: function(result)
|
|
||||||
{
|
|
||||||
if (result === true)
|
|
||||||
{
|
|
||||||
Grocy.Api.Delete('objects/equipment/' + objectId, {},
|
|
||||||
function(result)
|
|
||||||
{
|
|
||||||
window.location.href = U('/equipment');
|
|
||||||
},
|
|
||||||
function(xhr)
|
|
||||||
{
|
|
||||||
console.error(xhr);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
$("#selectedEquipmentInstructionManualToggleFullscreenButton").on('click', function(e)
|
$("#selectedEquipmentInstructionManualToggleFullscreenButton").on('click', function(e)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -8,39 +8,11 @@
|
||||||
$('#locations-table tbody').removeClass("d-none");
|
$('#locations-table tbody').removeClass("d-none");
|
||||||
Grocy.FrontendHelpers.InitDataTable(locationsTable);
|
Grocy.FrontendHelpers.InitDataTable(locationsTable);
|
||||||
|
|
||||||
$(document).on('click', '.location-delete-button', function(e)
|
Grocy.FrontendHelpers.MakeDeleteConfirmBox(
|
||||||
{
|
'Are you sure to delete location "%s"?',
|
||||||
var objectName = $(e.currentTarget).attr('data-location-name');
|
'.location-delete-button',
|
||||||
var objectId = $(e.currentTarget).attr('data-location-id');
|
'data-location-name',
|
||||||
|
'data-location-id',
|
||||||
bootbox.confirm({
|
'objects/locations/',
|
||||||
message: __t('Are you sure to delete location "%s"?', objectName),
|
'/locations'
|
||||||
closeButton: false,
|
);
|
||||||
buttons: {
|
|
||||||
confirm: {
|
|
||||||
label: __t('Yes'),
|
|
||||||
className: 'btn-success'
|
|
||||||
},
|
|
||||||
cancel: {
|
|
||||||
label: __t('No'),
|
|
||||||
className: 'btn-danger'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
callback: function(result)
|
|
||||||
{
|
|
||||||
if (result === true)
|
|
||||||
{
|
|
||||||
Grocy.Api.Delete('objects/locations/' + objectId, {},
|
|
||||||
function(result)
|
|
||||||
{
|
|
||||||
window.location.href = U('/locations');
|
|
||||||
},
|
|
||||||
function(xhr)
|
|
||||||
{
|
|
||||||
console.error(xhr);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
@ -16,42 +16,14 @@ if (createdApiKeyId !== undefined)
|
||||||
animateCSS("#apiKeyRow_" + createdApiKeyId, "pulse");
|
animateCSS("#apiKeyRow_" + createdApiKeyId, "pulse");
|
||||||
}
|
}
|
||||||
|
|
||||||
$(document).on('click', '.apikey-delete-button', function(e)
|
Grocy.FrontendHelpers.MakeDeleteConfirmBox(
|
||||||
{
|
'Are you sure to delete API key "%s"?',
|
||||||
var objectName = $(e.currentTarget).attr('data-apikey-apikey');
|
'.apikey-delete-button',
|
||||||
var objectId = $(e.currentTarget).attr('data-apikey-id');
|
'data-apikey-apikey',
|
||||||
|
'data-apikey-id',
|
||||||
bootbox.confirm({
|
'objects/api_keys/',
|
||||||
message: __t('Are you sure to delete API key "%s"?', objectName),
|
'/manageapikeys'
|
||||||
closeButton: false,
|
);
|
||||||
buttons: {
|
|
||||||
confirm: {
|
|
||||||
label: __t('Yes'),
|
|
||||||
className: 'btn-success'
|
|
||||||
},
|
|
||||||
cancel: {
|
|
||||||
label: __t('No'),
|
|
||||||
className: 'btn-danger'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
callback: function(result)
|
|
||||||
{
|
|
||||||
if (result === true)
|
|
||||||
{
|
|
||||||
Grocy.Api.Delete('objects/api_keys/' + objectId, {},
|
|
||||||
function(result)
|
|
||||||
{
|
|
||||||
window.location.href = U('/manageapikeys');
|
|
||||||
},
|
|
||||||
function(xhr)
|
|
||||||
{
|
|
||||||
console.error(xhr);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
function QrCodeForApiKey(apiKeyType, apiKey)
|
function QrCodeForApiKey(apiKeyType, apiKey)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -7,43 +7,15 @@
|
||||||
});
|
});
|
||||||
$('#productgroups-table tbody').removeClass("d-none");
|
$('#productgroups-table tbody').removeClass("d-none");
|
||||||
Grocy.FrontendHelpers.InitDataTable(groupsTable);
|
Grocy.FrontendHelpers.InitDataTable(groupsTable);
|
||||||
|
Grocy.FrontendHelpers.MakeDeleteConfirmBox(
|
||||||
|
'Are you sure to delete product group "%s"?',
|
||||||
|
'.product-group-delete-button',
|
||||||
|
'data-group-name',
|
||||||
|
'data-group-id',
|
||||||
|
'objects/product_groups/',
|
||||||
|
'/productgroups'
|
||||||
|
);
|
||||||
|
|
||||||
$(document).on('click', '.product-group-delete-button', function(e)
|
|
||||||
{
|
|
||||||
var objectName = $(e.currentTarget).attr('data-group-name');
|
|
||||||
var objectId = $(e.currentTarget).attr('data-group-id');
|
|
||||||
|
|
||||||
bootbox.confirm({
|
|
||||||
message: __t('Are you sure to delete product group "%s"?', objectName),
|
|
||||||
closeButton: false,
|
|
||||||
buttons: {
|
|
||||||
confirm: {
|
|
||||||
label: __t('Yes'),
|
|
||||||
className: 'btn-success'
|
|
||||||
},
|
|
||||||
cancel: {
|
|
||||||
label: __t('No'),
|
|
||||||
className: 'btn-danger'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
callback: function(result)
|
|
||||||
{
|
|
||||||
if (result === true)
|
|
||||||
{
|
|
||||||
Grocy.Api.Delete('objects/product_groups/' + objectId, {},
|
|
||||||
function(result)
|
|
||||||
{
|
|
||||||
window.location.href = U('/productgroups');
|
|
||||||
},
|
|
||||||
function(xhr)
|
|
||||||
{
|
|
||||||
console.error(xhr);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
$(window).on("message", function(e)
|
$(window).on("message", function(e)
|
||||||
{
|
{
|
||||||
var data = e.originalEvent.data;
|
var data = e.originalEvent.data;
|
||||||
|
|
|
||||||
|
|
@ -17,51 +17,25 @@ Grocy.FrontendHelpers.InitDataTable(productsTable, null, function()
|
||||||
})
|
})
|
||||||
|
|
||||||
Grocy.FrontendHelpers.MakeFilterForColumn("#product-group-filter", 6, productsTable);
|
Grocy.FrontendHelpers.MakeFilterForColumn("#product-group-filter", 6, productsTable);
|
||||||
|
|
||||||
if (typeof GetUriParam("product-group") !== "undefined")
|
if (typeof GetUriParam("product-group") !== "undefined")
|
||||||
{
|
{
|
||||||
$("#product-group-filter").val(GetUriParam("product-group"));
|
$("#product-group-filter").val(GetUriParam("product-group"));
|
||||||
$("#product-group-filter").trigger("change");
|
$("#product-group-filter").trigger("change");
|
||||||
}
|
}
|
||||||
|
|
||||||
$(document).on('click', '.product-delete-button', function(e)
|
Grocy.FrontendHelpers.MakeDeleteConfirmBox(
|
||||||
{
|
(objectId, objectName) =>
|
||||||
var objectName = $(e.currentTarget).attr('data-product-name');
|
{
|
||||||
var objectId = $(e.currentTarget).attr('data-product-id');
|
return __t('Are you sure to delete product "%s"?', objectName) +
|
||||||
|
'<br><br>' +
|
||||||
bootbox.confirm({
|
__t('This also removes any stock amount, the journal and all other references of this product - consider disabling it instead, if you want to keep that and just hide the product.');
|
||||||
message: __t('Are you sure to delete product "%s"?', objectName) + '<br><br>' + __t('This also removes any stock amount, the journal and all other references of this product - consider disabling it instead, if you want to keep that and just hide the product.'),
|
},
|
||||||
closeButton: false,
|
'.product-delete-button',
|
||||||
buttons: {
|
'data-product-name',
|
||||||
confirm: {
|
'data-product-id',
|
||||||
label: __t('Yes'),
|
'objects/products/',
|
||||||
className: 'btn-success'
|
'/products'
|
||||||
},
|
);
|
||||||
cancel: {
|
|
||||||
label: __t('No'),
|
|
||||||
className: 'btn-danger'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
callback: function(result)
|
|
||||||
{
|
|
||||||
if (result === true)
|
|
||||||
{
|
|
||||||
var jsonData = {};
|
|
||||||
jsonData.active = 0;
|
|
||||||
Grocy.Api.Delete('objects/products/' + objectId, {},
|
|
||||||
function(result)
|
|
||||||
{
|
|
||||||
window.location.href = U('/products');
|
|
||||||
},
|
|
||||||
function(xhr)
|
|
||||||
{
|
|
||||||
console.error(xhr);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
$("#show-disabled").change(function()
|
$("#show-disabled").change(function()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -7,40 +7,11 @@
|
||||||
});
|
});
|
||||||
$('#quantityunits-table tbody').removeClass("d-none");
|
$('#quantityunits-table tbody').removeClass("d-none");
|
||||||
Grocy.FrontendHelpers.InitDataTable(quantityUnitsTable);
|
Grocy.FrontendHelpers.InitDataTable(quantityUnitsTable);
|
||||||
|
Grocy.FrontendHelpers.MakeDeleteConfirmBox(
|
||||||
$(document).on('click', '.quantityunit-delete-button', function(e)
|
'Are you sure to delete quantity unit "%s"?',
|
||||||
{
|
'.quantityunit-delete-button',
|
||||||
var objectName = $(e.currentTarget).attr('data-quantityunit-name');
|
'data-quantityunit-name',
|
||||||
var objectId = $(e.currentTarget).attr('data-quantityunit-id');
|
'data-quantityunit-id',
|
||||||
|
'objects/quantity_units/',
|
||||||
bootbox.confirm({
|
'/quantityunits'
|
||||||
message: __t('Are you sure to delete quantity unit "%s"?', objectName),
|
);
|
||||||
closeButton: false,
|
|
||||||
buttons: {
|
|
||||||
confirm: {
|
|
||||||
label: 'Yes',
|
|
||||||
className: 'btn-success'
|
|
||||||
},
|
|
||||||
cancel: {
|
|
||||||
label: 'No',
|
|
||||||
className: 'btn-danger'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
callback: function(result)
|
|
||||||
{
|
|
||||||
if (result === true)
|
|
||||||
{
|
|
||||||
Grocy.Api.Delete('objects/quantity_units/' + objectId, {},
|
|
||||||
function(result)
|
|
||||||
{
|
|
||||||
window.location.href = U('/quantityunits');
|
|
||||||
},
|
|
||||||
function(xhr)
|
|
||||||
{
|
|
||||||
console.error(xhr);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
@ -99,44 +99,14 @@ $("#status-filter").on("change", function()
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$(".recipe-delete").on('click', function(e)
|
Grocy.FrontendHelpers.MakeDeleteConfirmBox(
|
||||||
{
|
'Are you sure to delete recipe "%s"?',
|
||||||
e.preventDefault();
|
'.recipe-delete',
|
||||||
|
'data-recipe-name',
|
||||||
var objectName = $(e.currentTarget).attr('data-recipe-name');
|
'data-recipe-id',
|
||||||
var objectId = $(e.currentTarget).attr('data-recipe-id');
|
'objects/recipes/',
|
||||||
|
'/recipes'
|
||||||
bootbox.confirm({
|
);
|
||||||
message: __t('Are you sure to delete recipe "%s"?', objectName),
|
|
||||||
closeButton: false,
|
|
||||||
buttons: {
|
|
||||||
confirm: {
|
|
||||||
label: __t('Yes'),
|
|
||||||
className: 'btn-success'
|
|
||||||
},
|
|
||||||
cancel: {
|
|
||||||
label: __t('No'),
|
|
||||||
className: 'btn-danger'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
callback: function(result)
|
|
||||||
{
|
|
||||||
if (result === true)
|
|
||||||
{
|
|
||||||
Grocy.Api.Delete('objects/recipes/' + objectId, {},
|
|
||||||
function(result)
|
|
||||||
{
|
|
||||||
window.location.href = U('/recipes');
|
|
||||||
},
|
|
||||||
function(xhr)
|
|
||||||
{
|
|
||||||
console.error(xhr);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
$(document).on('click', '.recipe-shopping-list', function(e)
|
$(document).on('click', '.recipe-shopping-list', function(e)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -8,39 +8,11 @@ var locationsTable = $('#shoppinglocations-table').DataTable({
|
||||||
$('#shoppinglocations-table tbody').removeClass("d-none");
|
$('#shoppinglocations-table tbody').removeClass("d-none");
|
||||||
Grocy.FrontendHelpers.InitDataTable(locationsTable);
|
Grocy.FrontendHelpers.InitDataTable(locationsTable);
|
||||||
|
|
||||||
$(document).on('click', '.shoppinglocation-delete-button', function(e)
|
Grocy.FrontendHelpers.MakeDeleteConfirmBox(
|
||||||
{
|
'Are you sure to delete store "%s"?',
|
||||||
var objectName = $(e.currentTarget).attr('data-shoppinglocation-name');
|
'.shoppinglocation-delete-button',
|
||||||
var objectId = $(e.currentTarget).attr('data-shoppinglocation-id');
|
'data-shoppinglocation-name',
|
||||||
|
'data-shoppinglocation-id',
|
||||||
bootbox.confirm({
|
'objects/shopping_locations/',
|
||||||
message: __t('Are you sure to delete store "%s"?', objectName),
|
'/shoppinglocations'
|
||||||
closeButton: false,
|
);
|
||||||
buttons: {
|
|
||||||
confirm: {
|
|
||||||
label: __t('Yes'),
|
|
||||||
className: 'btn-success'
|
|
||||||
},
|
|
||||||
cancel: {
|
|
||||||
label: __t('No'),
|
|
||||||
className: 'btn-danger'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
callback: function(result)
|
|
||||||
{
|
|
||||||
if (result === true)
|
|
||||||
{
|
|
||||||
Grocy.Api.Delete('objects/shopping_locations/' + objectId, {},
|
|
||||||
function(result)
|
|
||||||
{
|
|
||||||
window.location.href = U('/shoppinglocations');
|
|
||||||
},
|
|
||||||
function(xhr)
|
|
||||||
{
|
|
||||||
console.error(xhr);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
@ -8,39 +8,11 @@
|
||||||
$('#taskcategories-table tbody').removeClass("d-none");
|
$('#taskcategories-table tbody').removeClass("d-none");
|
||||||
Grocy.FrontendHelpers.InitDataTable(categoriesTable);
|
Grocy.FrontendHelpers.InitDataTable(categoriesTable);
|
||||||
|
|
||||||
$(document).on('click', '.task-category-delete-button', function(e)
|
Grocy.FrontendHelpers.MakeDeleteConfirmBox(
|
||||||
{
|
'Are you sure to delete task category "%s"?',
|
||||||
var objectName = $(e.currentTarget).attr('data-category-name');
|
'.task-category-delete-button',
|
||||||
var objectId = $(e.currentTarget).attr('data-category-id');
|
'data-category-name',
|
||||||
|
'data-category-id',
|
||||||
bootbox.confirm({
|
'objects/task_categories/',
|
||||||
message: __t('Are you sure to delete task category "%s"?', objectName),
|
'/taskcategories'
|
||||||
closeButton: false,
|
);
|
||||||
buttons: {
|
|
||||||
confirm: {
|
|
||||||
label: __t('Yes'),
|
|
||||||
className: 'btn-success'
|
|
||||||
},
|
|
||||||
cancel: {
|
|
||||||
label: __t('No'),
|
|
||||||
className: 'btn-danger'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
callback: function(result)
|
|
||||||
{
|
|
||||||
if (result === true)
|
|
||||||
{
|
|
||||||
Grocy.Api.Delete('objects/task_categories/' + objectId, {},
|
|
||||||
function(result)
|
|
||||||
{
|
|
||||||
window.location.href = U('/taskcategories');
|
|
||||||
},
|
|
||||||
function(xhr)
|
|
||||||
{
|
|
||||||
console.error(xhr);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
@ -90,48 +90,21 @@ $(document).on('click', '.undo-task-button', function(e)
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).on('click', '.delete-task-button', function(e)
|
Grocy.FrontendHelpers.MakeDeleteConfirmBox(
|
||||||
{
|
'Are you sure to delete task "%s"?',
|
||||||
e.preventDefault();
|
'.delete-task-button',
|
||||||
|
'data-task-name',
|
||||||
var objectName = $(e.currentTarget).attr('data-task-name');
|
'data-task-id',
|
||||||
var objectId = $(e.currentTarget).attr('data-task-id');
|
'objects/tasks/',
|
||||||
|
(result, objectId, objectName) =>
|
||||||
bootbox.confirm({
|
{
|
||||||
message: __t('Are you sure to delete task "%s"?', objectName),
|
animateCSS("#task-" + objectId + "-row", "fadeOut", function()
|
||||||
closeButton: false,
|
|
||||||
buttons: {
|
|
||||||
confirm: {
|
|
||||||
label: __t('Yes'),
|
|
||||||
className: 'btn-success'
|
|
||||||
},
|
|
||||||
cancel: {
|
|
||||||
label: __t('No'),
|
|
||||||
className: 'btn-danger'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
callback: function(result)
|
|
||||||
{
|
{
|
||||||
if (result === true)
|
$("#task-" + objectId + "-row").tooltip("hide");
|
||||||
{
|
$("#task-" + objectId + "-row").remove();
|
||||||
Grocy.Api.Delete('objects/tasks/' + objectId, {},
|
});
|
||||||
function(result)
|
}
|
||||||
{
|
);
|
||||||
animateCSS("#task-" + objectId + "-row", "fadeOut", function()
|
|
||||||
{
|
|
||||||
$("#task-" + objectId + "-row").tooltip("hide");
|
|
||||||
$("#task-" + objectId + "-row").remove();
|
|
||||||
});
|
|
||||||
},
|
|
||||||
function(xhr)
|
|
||||||
{
|
|
||||||
console.error(xhr);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
$("#show-done-tasks").change(function()
|
$("#show-done-tasks").change(function()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -8,39 +8,11 @@
|
||||||
$('#userentities-table tbody').removeClass("d-none");
|
$('#userentities-table tbody').removeClass("d-none");
|
||||||
Grocy.FrontendHelpers.InitDataTable(userentitiesTable);
|
Grocy.FrontendHelpers.InitDataTable(userentitiesTable);
|
||||||
|
|
||||||
$(document).on('click', '.userentity-delete-button', function(e)
|
Grocy.FrontendHelpers.MakeDeleteConfirmBox(
|
||||||
{
|
'Are you sure to delete userentity "%s"?',
|
||||||
var objectName = $(e.currentTarget).attr('data-userentity-name');
|
'.userentity-delete-button',
|
||||||
var objectId = $(e.currentTarget).attr('data-userentity-id');
|
'data-userentity-name',
|
||||||
|
'data-userentity-id',
|
||||||
bootbox.confirm({
|
'objects/userentities/',
|
||||||
message: __t('Are you sure to delete userentity "%s"?', objectName),
|
'/userentities'
|
||||||
closeButton: false,
|
);
|
||||||
buttons: {
|
|
||||||
confirm: {
|
|
||||||
label: __t('Yes'),
|
|
||||||
className: 'btn-success'
|
|
||||||
},
|
|
||||||
cancel: {
|
|
||||||
label: __t('No'),
|
|
||||||
className: 'btn-danger'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
callback: function(result)
|
|
||||||
{
|
|
||||||
if (result === true)
|
|
||||||
{
|
|
||||||
Grocy.Api.Delete('objects/userentities/' + objectId, {},
|
|
||||||
function(result)
|
|
||||||
{
|
|
||||||
window.location.href = U('/userentities');
|
|
||||||
},
|
|
||||||
function(xhr)
|
|
||||||
{
|
|
||||||
console.error(xhr);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
@ -27,42 +27,14 @@ $("#entity-filter").on("change", function()
|
||||||
$("#new-userfield-button").attr("href", U("/userfield/new?embedded&entity=" + value));
|
$("#new-userfield-button").attr("href", U("/userfield/new?embedded&entity=" + value));
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).on('click', '.userfield-delete-button', function(e)
|
Grocy.FrontendHelpers.MakeDeleteConfirmBox(
|
||||||
{
|
'Are you sure to delete user field "%s"?',
|
||||||
var objectName = $(e.currentTarget).attr('data-userfield-name');
|
'.userfield-delete-button',
|
||||||
var objectId = $(e.currentTarget).attr('data-userfield-id');
|
'data-userfield-name',
|
||||||
|
'data-userfield-id',
|
||||||
bootbox.confirm({
|
'objects/userfields/',
|
||||||
message: __t('Are you sure to delete user field "%s"?', objectName),
|
'/userfields'
|
||||||
closeButton: false,
|
);
|
||||||
buttons: {
|
|
||||||
confirm: {
|
|
||||||
label: __t('Yes'),
|
|
||||||
className: 'btn-success'
|
|
||||||
},
|
|
||||||
cancel: {
|
|
||||||
label: __t('No'),
|
|
||||||
className: 'btn-danger'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
callback: function(result)
|
|
||||||
{
|
|
||||||
if (result === true)
|
|
||||||
{
|
|
||||||
Grocy.Api.Delete('objects/userfields/' + objectId, {},
|
|
||||||
function(result)
|
|
||||||
{
|
|
||||||
window.location.href = U('/userfields');
|
|
||||||
},
|
|
||||||
function(xhr)
|
|
||||||
{
|
|
||||||
console.error(xhr);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
if (GetUriParam("entity") != undefined && !GetUriParam("entity").isEmpty())
|
if (GetUriParam("entity") != undefined && !GetUriParam("entity").isEmpty())
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -8,38 +8,11 @@
|
||||||
$('#userobjects-table tbody').removeClass("d-none");
|
$('#userobjects-table tbody').removeClass("d-none");
|
||||||
Grocy.FrontendHelpers.InitDataTable(userobjectsTable);
|
Grocy.FrontendHelpers.InitDataTable(userobjectsTable);
|
||||||
|
|
||||||
$(document).on('click', '.userobject-delete-button', function(e)
|
Grocy.FrontendHelpers.MakeDeleteConfirmBox(
|
||||||
{
|
'Are you sure to delete this userobject?',
|
||||||
var objectId = $(e.currentTarget).attr('data-userobject-id');
|
'.userobject-delete-button',
|
||||||
|
'data-userobject-id',
|
||||||
bootbox.confirm({
|
'data-userobject-id',
|
||||||
message: __t('Are you sure to delete this userobject?'),
|
'objects/userobjects/',
|
||||||
closeButton: false,
|
() => window.location.reload()
|
||||||
buttons: {
|
);
|
||||||
confirm: {
|
|
||||||
label: __t('Yes'),
|
|
||||||
className: 'btn-success'
|
|
||||||
},
|
|
||||||
cancel: {
|
|
||||||
label: __t('No'),
|
|
||||||
className: 'btn-danger'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
callback: function(result)
|
|
||||||
{
|
|
||||||
if (result === true)
|
|
||||||
{
|
|
||||||
Grocy.Api.Delete('objects/userobjects/' + objectId, {},
|
|
||||||
function(result)
|
|
||||||
{
|
|
||||||
window.location.reload();
|
|
||||||
},
|
|
||||||
function(xhr)
|
|
||||||
{
|
|
||||||
console.error(xhr);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
@ -8,39 +8,11 @@
|
||||||
$('#users-table tbody').removeClass("d-none");
|
$('#users-table tbody').removeClass("d-none");
|
||||||
Grocy.FrontendHelpers.InitDataTable(usersTable);
|
Grocy.FrontendHelpers.InitDataTable(usersTable);
|
||||||
|
|
||||||
$(document).on('click', '.user-delete-button', function(e)
|
Grocy.FrontendHelpers.MakeDeleteConfirmBox(
|
||||||
{
|
'Are you sure to delete user "%s"?',
|
||||||
var objectName = $(e.currentTarget).attr('data-user-username');
|
'.user-delete-button',
|
||||||
var objectId = $(e.currentTarget).attr('data-user-id');
|
'data-user-username',
|
||||||
|
'data-user-id',
|
||||||
bootbox.confirm({
|
'users/',
|
||||||
message: __t('Are you sure to delete user "%s"?', objectName),
|
'/users'
|
||||||
closeButton: false,
|
);
|
||||||
buttons: {
|
|
||||||
confirm: {
|
|
||||||
label: __t('Yes'),
|
|
||||||
className: 'btn-success'
|
|
||||||
},
|
|
||||||
cancel: {
|
|
||||||
label: __t('No'),
|
|
||||||
className: 'btn-danger'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
callback: function(result)
|
|
||||||
{
|
|
||||||
if (result === true)
|
|
||||||
{
|
|
||||||
Grocy.Api.Delete('users/' + objectId, {},
|
|
||||||
function(result)
|
|
||||||
{
|
|
||||||
window.location.href = U('/users');
|
|
||||||
},
|
|
||||||
function(xhr)
|
|
||||||
{
|
|
||||||
console.error(xhr);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
Loading…
Reference in New Issue
Block a user