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)
|
||||
{
|
||||
$("#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();
|
||||
if (value === "all")
|
||||
|
|
@ -212,17 +216,84 @@ class GrocyFrontendHelpers
|
|||
dataTable.column(column).search(value).draw();
|
||||
});
|
||||
|
||||
$(".status-filter-message").on("click", function()
|
||||
$("." + key + "-filter-message").on("click", function()
|
||||
{
|
||||
var value = $(this).data("status-filter");
|
||||
$("#status-filter").val(value);
|
||||
$("#status-filter").trigger("change");
|
||||
var value = $(this).data(key + "-filter");
|
||||
$("#" + key + "-filter").val(value);
|
||||
$("#" + key + "-filter").trigger("change");
|
||||
});
|
||||
|
||||
$("#clear-filter-button").on("click", function()
|
||||
{
|
||||
$("#status-filter").val("all");
|
||||
$("#status-filter").trigger("change");
|
||||
$("#" + key + "-filter").val(resetValue);
|
||||
$("#" + 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)
|
||||
});
|
||||
$('#chores-overview-table tbody').removeClass("d-none");
|
||||
Grocy.FrontendHelpers.InitDataTable(choresOverviewTable, null, function()
|
||||
{
|
||||
$("#search").val("");
|
||||
$("#user-filter").val("all");
|
||||
choresOverviewTable.column(6).search("").draw();
|
||||
choresOverviewTable.search("").draw();
|
||||
RemoveUriParam("user");
|
||||
});
|
||||
|
||||
|
||||
Grocy.FrontendHelpers.MakeFilterForColumn("#status-filter", 5, choresOverviewTable, null, true);
|
||||
Grocy.FrontendHelpers.InitDataTable(choresOverviewTable);
|
||||
Grocy.FrontendHelpers.MakeValueFilter("status", 5, choresOverviewTable);
|
||||
Grocy.FrontendHelpers.MakeValueFilter("user", 6, choresOverviewTable, "");
|
||||
|
||||
$("#user-filter").on("change", function()
|
||||
{
|
||||
var value = $(this).val();
|
||||
if (value === "all")
|
||||
{
|
||||
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())
|
||||
var user = $(this).val();
|
||||
if (user !== null && !user.isEmpty())
|
||||
{
|
||||
UpdateUriParam("user", $("#user-filter option:selected").data("user-id"));
|
||||
}
|
||||
});
|
||||
|
||||
$(".status-filter-message").on("click", function()
|
||||
{
|
||||
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");
|
||||
else
|
||||
{
|
||||
RemoveUriParam("user")
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on('click', '.track-chore-button', function(e)
|
||||
|
|
|
|||
|
|
@ -65,42 +65,14 @@ function DisplayEquipment(id)
|
|||
);
|
||||
}
|
||||
|
||||
$(document).on('click', '.equipment-delete-button', function(e)
|
||||
{
|
||||
var objectName = $(e.currentTarget).attr('data-equipment-name');
|
||||
var objectId = $(e.currentTarget).attr('data-equipment-id');
|
||||
|
||||
bootbox.confirm({
|
||||
message: __t('Are you sure to delete equipment "%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/equipment/' + objectId, {},
|
||||
function(result)
|
||||
{
|
||||
window.location.href = U('/equipment');
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
console.error(xhr);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
Grocy.FrontendHelpers.MakeDeleteConfirmBox(
|
||||
'Are you sure to delete equipment "%s"?',
|
||||
'.equipment-delete-button',
|
||||
'data-equipment-name',
|
||||
'data-equipment-id',
|
||||
'objects/equipment/',
|
||||
'/equipment'
|
||||
);
|
||||
|
||||
$("#selectedEquipmentInstructionManualToggleFullscreenButton").on('click', function(e)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -8,39 +8,11 @@
|
|||
$('#locations-table tbody').removeClass("d-none");
|
||||
Grocy.FrontendHelpers.InitDataTable(locationsTable);
|
||||
|
||||
$(document).on('click', '.location-delete-button', function(e)
|
||||
{
|
||||
var objectName = $(e.currentTarget).attr('data-location-name');
|
||||
var objectId = $(e.currentTarget).attr('data-location-id');
|
||||
|
||||
bootbox.confirm({
|
||||
message: __t('Are you sure to delete location "%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/locations/' + objectId, {},
|
||||
function(result)
|
||||
{
|
||||
window.location.href = U('/locations');
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
console.error(xhr);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
Grocy.FrontendHelpers.MakeDeleteConfirmBox(
|
||||
'Are you sure to delete location "%s"?',
|
||||
'.location-delete-button',
|
||||
'data-location-name',
|
||||
'data-location-id',
|
||||
'objects/locations/',
|
||||
'/locations'
|
||||
);
|
||||
|
|
@ -16,42 +16,14 @@ if (createdApiKeyId !== undefined)
|
|||
animateCSS("#apiKeyRow_" + createdApiKeyId, "pulse");
|
||||
}
|
||||
|
||||
$(document).on('click', '.apikey-delete-button', function(e)
|
||||
{
|
||||
var objectName = $(e.currentTarget).attr('data-apikey-apikey');
|
||||
var objectId = $(e.currentTarget).attr('data-apikey-id');
|
||||
|
||||
bootbox.confirm({
|
||||
message: __t('Are you sure to delete API key "%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/api_keys/' + objectId, {},
|
||||
function(result)
|
||||
{
|
||||
window.location.href = U('/manageapikeys');
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
console.error(xhr);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
Grocy.FrontendHelpers.MakeDeleteConfirmBox(
|
||||
'Are you sure to delete API key "%s"?',
|
||||
'.apikey-delete-button',
|
||||
'data-apikey-apikey',
|
||||
'data-apikey-id',
|
||||
'objects/api_keys/',
|
||||
'/manageapikeys'
|
||||
);
|
||||
|
||||
function QrCodeForApiKey(apiKeyType, apiKey)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -7,43 +7,15 @@
|
|||
});
|
||||
$('#productgroups-table tbody').removeClass("d-none");
|
||||
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)
|
||||
{
|
||||
var data = e.originalEvent.data;
|
||||
|
|
|
|||
|
|
@ -17,51 +17,25 @@ Grocy.FrontendHelpers.InitDataTable(productsTable, null, function()
|
|||
})
|
||||
|
||||
Grocy.FrontendHelpers.MakeFilterForColumn("#product-group-filter", 6, productsTable);
|
||||
|
||||
if (typeof GetUriParam("product-group") !== "undefined")
|
||||
{
|
||||
$("#product-group-filter").val(GetUriParam("product-group"));
|
||||
$("#product-group-filter").trigger("change");
|
||||
}
|
||||
|
||||
$(document).on('click', '.product-delete-button', function(e)
|
||||
{
|
||||
var objectName = $(e.currentTarget).attr('data-product-name');
|
||||
var objectId = $(e.currentTarget).attr('data-product-id');
|
||||
|
||||
bootbox.confirm({
|
||||
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,
|
||||
buttons: {
|
||||
confirm: {
|
||||
label: __t('Yes'),
|
||||
className: 'btn-success'
|
||||
},
|
||||
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);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
Grocy.FrontendHelpers.MakeDeleteConfirmBox(
|
||||
(objectId, objectName) =>
|
||||
{
|
||||
return __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.');
|
||||
},
|
||||
'.product-delete-button',
|
||||
'data-product-name',
|
||||
'data-product-id',
|
||||
'objects/products/',
|
||||
'/products'
|
||||
);
|
||||
|
||||
$("#show-disabled").change(function()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -7,40 +7,11 @@
|
|||
});
|
||||
$('#quantityunits-table tbody').removeClass("d-none");
|
||||
Grocy.FrontendHelpers.InitDataTable(quantityUnitsTable);
|
||||
|
||||
$(document).on('click', '.quantityunit-delete-button', function(e)
|
||||
{
|
||||
var objectName = $(e.currentTarget).attr('data-quantityunit-name');
|
||||
var objectId = $(e.currentTarget).attr('data-quantityunit-id');
|
||||
|
||||
bootbox.confirm({
|
||||
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);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
Grocy.FrontendHelpers.MakeDeleteConfirmBox(
|
||||
'Are you sure to delete quantity unit "%s"?',
|
||||
'.quantityunit-delete-button',
|
||||
'data-quantityunit-name',
|
||||
'data-quantityunit-id',
|
||||
'objects/quantity_units/',
|
||||
'/quantityunits'
|
||||
);
|
||||
|
|
@ -99,44 +99,14 @@ $("#status-filter").on("change", function()
|
|||
}
|
||||
});
|
||||
|
||||
$(".recipe-delete").on('click', function(e)
|
||||
{
|
||||
e.preventDefault();
|
||||
|
||||
var objectName = $(e.currentTarget).attr('data-recipe-name');
|
||||
var objectId = $(e.currentTarget).attr('data-recipe-id');
|
||||
|
||||
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);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
Grocy.FrontendHelpers.MakeDeleteConfirmBox(
|
||||
'Are you sure to delete recipe "%s"?',
|
||||
'.recipe-delete',
|
||||
'data-recipe-name',
|
||||
'data-recipe-id',
|
||||
'objects/recipes/',
|
||||
'/recipes'
|
||||
);
|
||||
|
||||
$(document).on('click', '.recipe-shopping-list', function(e)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -8,39 +8,11 @@ var locationsTable = $('#shoppinglocations-table').DataTable({
|
|||
$('#shoppinglocations-table tbody').removeClass("d-none");
|
||||
Grocy.FrontendHelpers.InitDataTable(locationsTable);
|
||||
|
||||
$(document).on('click', '.shoppinglocation-delete-button', function(e)
|
||||
{
|
||||
var objectName = $(e.currentTarget).attr('data-shoppinglocation-name');
|
||||
var objectId = $(e.currentTarget).attr('data-shoppinglocation-id');
|
||||
|
||||
bootbox.confirm({
|
||||
message: __t('Are you sure to delete store "%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/shopping_locations/' + objectId, {},
|
||||
function(result)
|
||||
{
|
||||
window.location.href = U('/shoppinglocations');
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
console.error(xhr);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
Grocy.FrontendHelpers.MakeDeleteConfirmBox(
|
||||
'Are you sure to delete store "%s"?',
|
||||
'.shoppinglocation-delete-button',
|
||||
'data-shoppinglocation-name',
|
||||
'data-shoppinglocation-id',
|
||||
'objects/shopping_locations/',
|
||||
'/shoppinglocations'
|
||||
);
|
||||
|
|
@ -8,39 +8,11 @@
|
|||
$('#taskcategories-table tbody').removeClass("d-none");
|
||||
Grocy.FrontendHelpers.InitDataTable(categoriesTable);
|
||||
|
||||
$(document).on('click', '.task-category-delete-button', function(e)
|
||||
{
|
||||
var objectName = $(e.currentTarget).attr('data-category-name');
|
||||
var objectId = $(e.currentTarget).attr('data-category-id');
|
||||
|
||||
bootbox.confirm({
|
||||
message: __t('Are you sure to delete task category "%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/task_categories/' + objectId, {},
|
||||
function(result)
|
||||
{
|
||||
window.location.href = U('/taskcategories');
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
console.error(xhr);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
Grocy.FrontendHelpers.MakeDeleteConfirmBox(
|
||||
'Are you sure to delete task category "%s"?',
|
||||
'.task-category-delete-button',
|
||||
'data-category-name',
|
||||
'data-category-id',
|
||||
'objects/task_categories/',
|
||||
'/taskcategories'
|
||||
);
|
||||
|
|
@ -90,48 +90,21 @@ $(document).on('click', '.undo-task-button', function(e)
|
|||
);
|
||||
});
|
||||
|
||||
$(document).on('click', '.delete-task-button', function(e)
|
||||
{
|
||||
e.preventDefault();
|
||||
|
||||
var objectName = $(e.currentTarget).attr('data-task-name');
|
||||
var objectId = $(e.currentTarget).attr('data-task-id');
|
||||
|
||||
bootbox.confirm({
|
||||
message: __t('Are you sure to delete task "%s"?', objectName),
|
||||
closeButton: false,
|
||||
buttons: {
|
||||
confirm: {
|
||||
label: __t('Yes'),
|
||||
className: 'btn-success'
|
||||
},
|
||||
cancel: {
|
||||
label: __t('No'),
|
||||
className: 'btn-danger'
|
||||
}
|
||||
},
|
||||
callback: function(result)
|
||||
Grocy.FrontendHelpers.MakeDeleteConfirmBox(
|
||||
'Are you sure to delete task "%s"?',
|
||||
'.delete-task-button',
|
||||
'data-task-name',
|
||||
'data-task-id',
|
||||
'objects/tasks/',
|
||||
(result, objectId, objectName) =>
|
||||
{
|
||||
animateCSS("#task-" + objectId + "-row", "fadeOut", function()
|
||||
{
|
||||
if (result === true)
|
||||
{
|
||||
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);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
$("#task-" + objectId + "-row").tooltip("hide");
|
||||
$("#task-" + objectId + "-row").remove();
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
$("#show-done-tasks").change(function()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -8,39 +8,11 @@
|
|||
$('#userentities-table tbody').removeClass("d-none");
|
||||
Grocy.FrontendHelpers.InitDataTable(userentitiesTable);
|
||||
|
||||
$(document).on('click', '.userentity-delete-button', function(e)
|
||||
{
|
||||
var objectName = $(e.currentTarget).attr('data-userentity-name');
|
||||
var objectId = $(e.currentTarget).attr('data-userentity-id');
|
||||
|
||||
bootbox.confirm({
|
||||
message: __t('Are you sure to delete userentity "%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/userentities/' + objectId, {},
|
||||
function(result)
|
||||
{
|
||||
window.location.href = U('/userentities');
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
console.error(xhr);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
Grocy.FrontendHelpers.MakeDeleteConfirmBox(
|
||||
'Are you sure to delete userentity "%s"?',
|
||||
'.userentity-delete-button',
|
||||
'data-userentity-name',
|
||||
'data-userentity-id',
|
||||
'objects/userentities/',
|
||||
'/userentities'
|
||||
);
|
||||
|
|
@ -27,42 +27,14 @@ $("#entity-filter").on("change", function()
|
|||
$("#new-userfield-button").attr("href", U("/userfield/new?embedded&entity=" + value));
|
||||
});
|
||||
|
||||
$(document).on('click', '.userfield-delete-button', function(e)
|
||||
{
|
||||
var objectName = $(e.currentTarget).attr('data-userfield-name');
|
||||
var objectId = $(e.currentTarget).attr('data-userfield-id');
|
||||
|
||||
bootbox.confirm({
|
||||
message: __t('Are you sure to delete user field "%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/userfields/' + objectId, {},
|
||||
function(result)
|
||||
{
|
||||
window.location.href = U('/userfields');
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
console.error(xhr);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
Grocy.FrontendHelpers.MakeDeleteConfirmBox(
|
||||
'Are you sure to delete user field "%s"?',
|
||||
'.userfield-delete-button',
|
||||
'data-userfield-name',
|
||||
'data-userfield-id',
|
||||
'objects/userfields/',
|
||||
'/userfields'
|
||||
);
|
||||
|
||||
if (GetUriParam("entity") != undefined && !GetUriParam("entity").isEmpty())
|
||||
{
|
||||
|
|
|
|||
|
|
@ -8,38 +8,11 @@
|
|||
$('#userobjects-table tbody').removeClass("d-none");
|
||||
Grocy.FrontendHelpers.InitDataTable(userobjectsTable);
|
||||
|
||||
$(document).on('click', '.userobject-delete-button', function(e)
|
||||
{
|
||||
var objectId = $(e.currentTarget).attr('data-userobject-id');
|
||||
|
||||
bootbox.confirm({
|
||||
message: __t('Are you sure to delete this userobject?'),
|
||||
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/userobjects/' + objectId, {},
|
||||
function(result)
|
||||
{
|
||||
window.location.reload();
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
console.error(xhr);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
Grocy.FrontendHelpers.MakeDeleteConfirmBox(
|
||||
'Are you sure to delete this userobject?',
|
||||
'.userobject-delete-button',
|
||||
'data-userobject-id',
|
||||
'data-userobject-id',
|
||||
'objects/userobjects/',
|
||||
() => window.location.reload()
|
||||
);
|
||||
|
|
@ -8,39 +8,11 @@
|
|||
$('#users-table tbody').removeClass("d-none");
|
||||
Grocy.FrontendHelpers.InitDataTable(usersTable);
|
||||
|
||||
$(document).on('click', '.user-delete-button', function(e)
|
||||
{
|
||||
var objectName = $(e.currentTarget).attr('data-user-username');
|
||||
var objectId = $(e.currentTarget).attr('data-user-id');
|
||||
|
||||
bootbox.confirm({
|
||||
message: __t('Are you sure to delete user "%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('users/' + objectId, {},
|
||||
function(result)
|
||||
{
|
||||
window.location.href = U('/users');
|
||||
},
|
||||
function(xhr)
|
||||
{
|
||||
console.error(xhr);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
Grocy.FrontendHelpers.MakeDeleteConfirmBox(
|
||||
'Are you sure to delete user "%s"?',
|
||||
'.user-delete-button',
|
||||
'data-user-username',
|
||||
'data-user-id',
|
||||
'users/',
|
||||
'/users'
|
||||
);
|
||||
Loading…
Reference in New Issue
Block a user