1
0
mirror of https://github.com/janeczku/calibre-web synced 2024-12-25 09:30:31 +00:00

Fix entries of user table are visible if database has no tags

This commit is contained in:
Ozzie Isaacs 2021-07-23 19:46:01 +02:00
parent 3c8bfc31e4
commit 3b81ea37f4

View File

@ -661,33 +661,34 @@ function move_header_elements() {
} }
}); });
$(".multi_selector").selectpicker(); $(".multi_selector").selectpicker();
if ($(".multi_head").length) {
if (! $._data($(".multi_head").get(0), "events") ) { if (!$._data($(".multi_head").get(0), "events")) {
// Functions have to be here, otherwise the callbacks are not fired if visible columns are changed // Functions have to be here, otherwise the callbacks are not fired if visible columns are changed
$(".multi_head").on("click", function () { $(".multi_head").on("click", function () {
var val = $(this).data("set"); var val = $(this).data("set");
var field = $(this).data("name"); var field = $(this).data("name");
var result = $('#user-table').bootstrapTable('getSelections').map(a => a.id); var result = $('#user-table').bootstrapTable('getSelections').map(a => a.id);
var values = $("#" + field).val(); var values = $("#" + field).val();
confirmDialog( confirmDialog(
"restrictions", "restrictions",
"GeneralChangeModal", "GeneralChangeModal",
0, 0,
function () { function () {
$.ajax({ $.ajax({
method: "post", method: "post",
url: window.location.pathname + "/../../ajax/editlistusers/" + field, url: window.location.pathname + "/../../ajax/editlistusers/" + field,
data: {"pk": result, "value": values, "action": val}, data: {"pk": result, "value": values, "action": val},
success: function (data) { success: function (data) {
handleListServerResponse(data); handleListServerResponse(data);
}, },
error: function (data) { error: function (data) {
handleListServerResponse([{type: "danger", message: data.responseText}]) handleListServerResponse([{type: "danger", message: data.responseText}])
}, },
}); });
} }
); );
}); });
}
} }
$("#user_delete_selection").click(function () { $("#user_delete_selection").click(function () {
@ -699,38 +700,41 @@ function move_header_elements() {
$("#select_default_language").on("change", function () { $("#select_default_language").on("change", function () {
selectHeader(this, "default_language"); selectHeader(this, "default_language");
}); });
if ($(".check_head").length) {
if (! $._data($(".check_head").get(0), "events") ) { if (!$._data($(".check_head").get(0), "events")) {
$(".check_head").on("change", function () { $(".check_head").on("change", function () {
var val = $(this).data("set"); var val = $(this).data("set");
var name = $(this).data("name"); var name = $(this).data("name");
var data = $(this).data("val"); var data = $(this).data("val");
checkboxHeader(val, name, data); checkboxHeader(val, name, data);
}); });
}
} }
if (! $._data($(".button_head").get(0), "events") ) { if ($(".button_head").length) {
$(".button_head").on("click", function () { if (!$._data($(".button_head").get(0), "events")) {
var result = $('#user-table').bootstrapTable('getSelections').map(a => a.id); $(".button_head").on("click", function () {
confirmDialog( var result = $('#user-table').bootstrapTable('getSelections').map(a => a.id);
"btndeluser", confirmDialog(
"GeneralDeleteModal", "btndeluser",
0, "GeneralDeleteModal",
function () { 0,
$.ajax({ function () {
method: "post", $.ajax({
url: window.location.pathname + "/../../ajax/deleteuser", method: "post",
data: {"userid": result}, url: window.location.pathname + "/../../ajax/deleteuser",
success: function (data) { data: {"userid": result},
selections = selections.filter((el) => !result.includes(el)); success: function (data) {
handleListServerResponse(data); selections = selections.filter((el) => !result.includes(el));
}, handleListServerResponse(data);
error: function (data) { },
handleListServerResponse([{type: "danger", message: data.responseText}]) error: function (data) {
}, handleListServerResponse([{type: "danger", message: data.responseText}])
}); },
} });
); }
}); );
});
}
} }
} }