mirror of
https://github.com/janeczku/calibre-web
synced 2024-12-25 17:40:31 +00:00
Update list user editor (#1938)
This commit is contained in:
parent
19797d5d23
commit
de7f039b99
@ -130,16 +130,6 @@ $("#back").click(function() {
|
||||
|
||||
function confirmDialog(id, dialogid, dataValue, yesFn, noFn) {
|
||||
var $confirm = $("#" + dialogid);
|
||||
$confirm.modal('show');
|
||||
$.ajax({
|
||||
method:"get",
|
||||
dataType: "json",
|
||||
url: getPath() + "/ajax/loaddialogtexts/" + id,
|
||||
success: function success(data) {
|
||||
$("#header-"+ dialogid).html(data.header);
|
||||
$("#text-"+ dialogid).html(data.main);
|
||||
}
|
||||
});
|
||||
$("#btnConfirmYes-"+ dialogid).off('click').click(function () {
|
||||
yesFn(dataValue);
|
||||
$confirm.modal("hide");
|
||||
@ -150,6 +140,16 @@ function confirmDialog(id, dialogid, dataValue, yesFn, noFn) {
|
||||
}
|
||||
$confirm.modal("hide");
|
||||
});
|
||||
$.ajax({
|
||||
method:"get",
|
||||
dataType: "json",
|
||||
url: getPath() + "/ajax/loaddialogtexts/" + id,
|
||||
success: function success(data) {
|
||||
$("#header-"+ dialogid).html(data.header);
|
||||
$("#text-"+ dialogid).html(data.main);
|
||||
}
|
||||
});
|
||||
$confirm.modal('show');
|
||||
}
|
||||
|
||||
$("#delete_confirm").click(function() {
|
||||
|
@ -19,6 +19,7 @@
|
||||
/* global getPath, confirmDialog */
|
||||
|
||||
var selections = [];
|
||||
var reload = false;
|
||||
|
||||
$(function() {
|
||||
$("#books-table").on("check.bs.table check-all.bs.table uncheck.bs.table uncheck-all.bs.table",
|
||||
@ -456,7 +457,6 @@ $(function() {
|
||||
},
|
||||
onLoadSuccess: function () {
|
||||
loadSuccess();
|
||||
move_header_elements();
|
||||
},
|
||||
onColumnSwitch: function () {
|
||||
var visible = $("#user-table").bootstrapTable("getVisibleColumns");
|
||||
@ -500,35 +500,6 @@ $(function() {
|
||||
var func = $.inArray(e.type, ["check", "check-all"]) > -1 ? "union" : "difference";
|
||||
selections = window._[func](selections, ids);
|
||||
handle_header_buttons();
|
||||
/*if (selections.length < 1) {
|
||||
$("#user_delete_selection").addClass("disabled");
|
||||
$("#user_delete_selection").attr("aria-disabled", true);
|
||||
$(".check_head").attr("aria-disabled", true);
|
||||
$(".check_head").attr("disabled", true);
|
||||
$(".check_head").prop('checked', false);
|
||||
$(".button_head").attr("aria-disabled", true);
|
||||
$(".button_head").addClass("disabled");
|
||||
$(".multi_head").attr("aria-disabled", true);
|
||||
$(".multi_head").addClass("hidden");
|
||||
$(".multi_selector").attr("aria-disabled", true);
|
||||
$(".multi_selector").attr("disabled", true);
|
||||
$('.multi_selector').selectpicker('deselectAll');
|
||||
$('.multi_selector').selectpicker('refresh');
|
||||
$(".header_select").attr("disabled", true);
|
||||
} else {
|
||||
$("#user_delete_selection").removeClass("disabled");
|
||||
$("#user_delete_selection").attr("aria-disabled", false);
|
||||
$(".check_head").attr("aria-disabled", false);
|
||||
$(".check_head").removeAttr("disabled");
|
||||
$(".button_head").attr("aria-disabled", false);
|
||||
$(".button_head").removeClass("disabled");
|
||||
$(".multi_head").attr("aria-disabled", false);
|
||||
$(".multi_head").removeClass("hidden");
|
||||
$(".multi_selector").attr("aria-disabled", false);
|
||||
$(".multi_selector").removeAttr("disabled");
|
||||
$('.multi_selector').selectpicker('refresh');
|
||||
$(".header_select").removeAttr("disabled");
|
||||
}*/
|
||||
});
|
||||
});
|
||||
|
||||
@ -545,8 +516,6 @@ function handle_header_buttons () {
|
||||
$(".multi_head").addClass("hidden");
|
||||
$(".multi_selector").attr("aria-disabled", true);
|
||||
$(".multi_selector").attr("disabled", true);
|
||||
$('.multi_selector').selectpicker('deselectAll');
|
||||
$('.multi_selector').selectpicker('refresh');
|
||||
$(".header_select").attr("disabled", true);
|
||||
} else {
|
||||
$("#user_delete_selection").removeClass("disabled");
|
||||
@ -629,6 +598,11 @@ function loadSuccess() {
|
||||
$(".header_select").each(function() {
|
||||
$(this).prop("selectedIndex", 0);
|
||||
});
|
||||
$(".header_select").each(function() {
|
||||
$(this).prop("selectedIndex", 0);
|
||||
});
|
||||
$('.multi_selector').selectpicker('deselectAll');
|
||||
$('.multi_selector').selectpicker('refresh');
|
||||
$(".editable[data-name='locale'][data-pk='"+guest.data("pk")+"']").editable("disable");
|
||||
$(".editable[data-name='locale'][data-pk='"+guest.data("pk")+"']").hide();
|
||||
$("input[data-name='admin_role'][data-pk='"+guest.data("pk")+"']").prop("disabled", true);
|
||||
@ -639,95 +613,94 @@ function loadSuccess() {
|
||||
}
|
||||
|
||||
function move_header_elements() {
|
||||
$(".header_select").each(function() {
|
||||
var item = $(this).parent();
|
||||
var parent = item.parent().parent();
|
||||
if (parent.prop('nodeName') === "TH") {
|
||||
item.prependTo(parent);
|
||||
}
|
||||
});
|
||||
$(".form-check").each(function() {
|
||||
var item = $(this).parent();
|
||||
var parent = item.parent().parent();
|
||||
if (parent.prop('nodeName') === "TH") {
|
||||
item.prependTo(parent);
|
||||
}
|
||||
});
|
||||
$(".multi_select").each(function() {
|
||||
var item = $(this);
|
||||
var parent = item.parent().parent();
|
||||
if (parent.prop('nodeName') === "TH") {
|
||||
item.prependTo(parent);
|
||||
item.addClass("myselect");
|
||||
}
|
||||
});
|
||||
$(".multi_selector").selectpicker();
|
||||
|
||||
// Functions have to be here, otherwise the callbacks are not fired if visible columns are changed
|
||||
$(".multi_head").on("click",function() {
|
||||
var val = $(this).data("set");
|
||||
var field = $(this).data("name");
|
||||
var result = $('#user-table').bootstrapTable('getSelections').map(a => a.id);
|
||||
var values = $("#" + field).val();
|
||||
confirmDialog(
|
||||
"restrictions",
|
||||
"GeneralChangeModal",
|
||||
0,
|
||||
function() {
|
||||
$.ajax({
|
||||
method:"post",
|
||||
url: window.location.pathname + "/../../ajax/editlistusers/" + field,
|
||||
data: {"pk": result, "value": values, "action": val},
|
||||
success: function (data) {
|
||||
handleListServerResponse(data);
|
||||
},
|
||||
error: function (data) {
|
||||
handleListServerResponse([{type:"danger", message:data.responseText}])
|
||||
},
|
||||
});
|
||||
$(".header_select").each(function () {
|
||||
var item = $(this).parent();
|
||||
var parent = item.parent().parent();
|
||||
if (parent.prop('nodeName') === "TH") {
|
||||
item.prependTo(parent);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
$("#user_delete_selection").click(function() {
|
||||
$("#user-table").bootstrapTable("uncheckAll");
|
||||
});
|
||||
$("#select_locale").on("change",function() {
|
||||
selectHeader(this, "locale");
|
||||
});
|
||||
$("#select_default_language").on("change",function() {
|
||||
selectHeader(this, "default_language");
|
||||
});
|
||||
$(".check_head").on("change",function() {
|
||||
var val = $(this).data("set");
|
||||
var name = $(this).data("name");
|
||||
var data = $(this).data("val");
|
||||
checkboxHeader(val, name, data);
|
||||
});
|
||||
|
||||
$(".button_head").on("click",function() {
|
||||
var result = $('#user-table').bootstrapTable('getSelections').map(a => a.id);
|
||||
confirmDialog(
|
||||
"btndeluser",
|
||||
"GeneralDeleteModal",
|
||||
0,
|
||||
function() {
|
||||
$.ajax({
|
||||
method:"post",
|
||||
url: window.location.pathname + "/../../ajax/deleteuser",
|
||||
data: {"userid": result},
|
||||
success: function (data) {
|
||||
selections = selections.filter( ( el ) => !result.includes( el ) );
|
||||
handleListServerResponse(data);
|
||||
},
|
||||
error: function (data) {
|
||||
handleListServerResponse([{type:"danger", message:data.responseText}])
|
||||
},
|
||||
});
|
||||
});
|
||||
$(".form-check").each(function () {
|
||||
var item = $(this).parent();
|
||||
var parent = item.parent().parent();
|
||||
if (parent.prop('nodeName') === "TH") {
|
||||
item.prependTo(parent);
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
$(".multi_select").each(function () {
|
||||
var item = $(this);
|
||||
var parent = item.parent().parent();
|
||||
if (parent.prop('nodeName') === "TH") {
|
||||
item.prependTo(parent);
|
||||
item.addClass("myselect");
|
||||
}
|
||||
});
|
||||
$(".multi_selector").selectpicker();
|
||||
|
||||
// Functions have to be here, otherwise the callbacks are not fired if visible columns are changed
|
||||
$(".multi_head").on("click", function () {
|
||||
var val = $(this).data("set");
|
||||
var field = $(this).data("name");
|
||||
var result = $('#user-table').bootstrapTable('getSelections').map(a => a.id);
|
||||
var values = $("#" + field).val();
|
||||
confirmDialog(
|
||||
"restrictions",
|
||||
"GeneralChangeModal",
|
||||
0,
|
||||
function () {
|
||||
$.ajax({
|
||||
method: "post",
|
||||
url: window.location.pathname + "/../../ajax/editlistusers/" + field,
|
||||
data: {"pk": result, "value": values, "action": val},
|
||||
success: function (data) {
|
||||
handleListServerResponse(data);
|
||||
},
|
||||
error: function (data) {
|
||||
handleListServerResponse([{type: "danger", message: data.responseText}])
|
||||
},
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
$("#user_delete_selection").click(function () {
|
||||
$("#user-table").bootstrapTable("uncheckAll");
|
||||
});
|
||||
$("#select_locale").on("change", function () {
|
||||
selectHeader(this, "locale");
|
||||
});
|
||||
$("#select_default_language").on("change", function () {
|
||||
selectHeader(this, "default_language");
|
||||
});
|
||||
$(".check_head").on("change", function () {
|
||||
var val = $(this).data("set");
|
||||
var name = $(this).data("name");
|
||||
var data = $(this).data("val");
|
||||
checkboxHeader(val, name, data);
|
||||
});
|
||||
|
||||
$(".button_head").on("click", function () {
|
||||
var result = $('#user-table').bootstrapTable('getSelections').map(a => a.id);
|
||||
confirmDialog(
|
||||
"btndeluser",
|
||||
"GeneralDeleteModal",
|
||||
0,
|
||||
function () {
|
||||
$.ajax({
|
||||
method: "post",
|
||||
url: window.location.pathname + "/../../ajax/deleteuser",
|
||||
data: {"userid": result},
|
||||
success: function (data) {
|
||||
selections = selections.filter((el) => !result.includes(el));
|
||||
handleListServerResponse(data);
|
||||
},
|
||||
error: function (data) {
|
||||
handleListServerResponse([{type: "danger", message: data.responseText}])
|
||||
},
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
function handleListServerResponse (data) {
|
||||
|
Loading…
Reference in New Issue
Block a user