2019-01-20 19:37:45 +01:00
|
|
|
/* This file is part of the Calibre-Web (https://github.com/janeczku/calibre-web)
|
2020-08-22 10:27:09 +02:00
|
|
|
* Copyright (C) 2020 OzzieIsaacs
|
2019-01-20 19:37:45 +01:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2020-06-11 21:19:09 +02:00
|
|
|
/* exported TableActions, RestrictionActions, EbookActions, responseHandler */
|
2021-03-14 14:29:40 +01:00
|
|
|
/* global getPath, confirmDialog */
|
2020-06-11 21:19:09 +02:00
|
|
|
|
|
|
|
var selections = [];
|
2021-04-27 20:01:17 +02:00
|
|
|
var reload = false;
|
2019-07-13 20:45:48 +02:00
|
|
|
|
2018-08-28 09:42:19 +02:00
|
|
|
$(function() {
|
2020-06-11 21:19:09 +02:00
|
|
|
$("#books-table").on("check.bs.table check-all.bs.table uncheck.bs.table uncheck-all.bs.table",
|
|
|
|
function (e, rowsAfter, rowsBefore) {
|
|
|
|
var rows = rowsAfter;
|
|
|
|
|
|
|
|
if (e.type === "uncheck-all") {
|
|
|
|
rows = rowsBefore;
|
|
|
|
}
|
|
|
|
|
|
|
|
var ids = $.map(!$.isArray(rows) ? [rows] : rows, function (row) {
|
|
|
|
return row.id;
|
|
|
|
});
|
|
|
|
|
|
|
|
var func = $.inArray(e.type, ["check", "check-all"]) > -1 ? "union" : "difference";
|
|
|
|
selections = window._[func](selections, ids);
|
|
|
|
if (selections.length >= 2) {
|
|
|
|
$("#merge_books").removeClass("disabled");
|
|
|
|
$("#merge_books").attr("aria-disabled", false);
|
|
|
|
} else {
|
|
|
|
$("#merge_books").addClass("disabled");
|
|
|
|
$("#merge_books").attr("aria-disabled", true);
|
|
|
|
}
|
2020-06-12 16:15:54 +02:00
|
|
|
if (selections.length < 1) {
|
|
|
|
$("#delete_selection").addClass("disabled");
|
|
|
|
$("#delete_selection").attr("aria-disabled", true);
|
2021-05-28 18:22:29 +02:00
|
|
|
$("#table_xchange").addClass("disabled");
|
|
|
|
$("#table_xchange").attr("aria-disabled", true);
|
2020-12-13 09:53:18 +01:00
|
|
|
} else {
|
2020-06-12 16:15:54 +02:00
|
|
|
$("#delete_selection").removeClass("disabled");
|
|
|
|
$("#delete_selection").attr("aria-disabled", false);
|
2021-05-28 18:22:29 +02:00
|
|
|
$("#table_xchange").removeClass("disabled");
|
|
|
|
$("#table_xchange").attr("aria-disabled", false);
|
|
|
|
|
2020-06-12 16:15:54 +02:00
|
|
|
}
|
2020-06-11 21:19:09 +02:00
|
|
|
});
|
2020-06-12 16:15:54 +02:00
|
|
|
$("#delete_selection").click(function() {
|
2020-12-13 09:53:18 +01:00
|
|
|
$("#books-table").bootstrapTable("uncheckAll");
|
2020-06-12 16:15:54 +02:00
|
|
|
});
|
2020-06-11 21:19:09 +02:00
|
|
|
|
2020-06-20 13:46:12 +02:00
|
|
|
$("#merge_confirm").click(function() {
|
2020-06-11 21:19:09 +02:00
|
|
|
$.ajax({
|
|
|
|
method:"post",
|
|
|
|
contentType: "application/json; charset=utf-8",
|
|
|
|
dataType: "json",
|
2021-05-29 19:18:43 +02:00
|
|
|
url: window.location.pathname + "/../ajax/mergebooks",
|
2020-06-11 21:19:09 +02:00
|
|
|
data: JSON.stringify({"Merge_books":selections}),
|
|
|
|
success: function success() {
|
2020-12-13 09:53:18 +01:00
|
|
|
$("#books-table").bootstrapTable("refresh");
|
|
|
|
$("#books-table").bootstrapTable("uncheckAll");
|
2020-08-22 10:27:09 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
$("#merge_books").click(function() {
|
|
|
|
$.ajax({
|
|
|
|
method:"post",
|
|
|
|
contentType: "application/json; charset=utf-8",
|
|
|
|
dataType: "json",
|
2021-05-29 19:18:43 +02:00
|
|
|
url: window.location.pathname + "/../ajax/simulatemerge",
|
2020-08-22 10:27:09 +02:00
|
|
|
data: JSON.stringify({"Merge_books":selections}),
|
2020-12-13 09:53:18 +01:00
|
|
|
success: function success(booTitles) {
|
|
|
|
$.each(booTitles.from, function(i, item) {
|
2020-08-22 10:27:09 +02:00
|
|
|
$("<span>- " + item + "</span>").appendTo("#merge_from");
|
|
|
|
});
|
2020-12-13 09:53:18 +01:00
|
|
|
$("#merge_to").text("- " + booTitles.to);
|
2020-08-22 10:27:09 +02:00
|
|
|
|
2020-06-11 21:19:09 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2021-05-28 18:22:29 +02:00
|
|
|
$("#table_xchange").click(function() {
|
|
|
|
$.ajax({
|
|
|
|
method:"post",
|
|
|
|
contentType: "application/json; charset=utf-8",
|
|
|
|
dataType: "json",
|
2021-05-29 19:18:43 +02:00
|
|
|
url: window.location.pathname + "/../ajax/xchange",
|
2021-05-28 18:22:29 +02:00
|
|
|
data: JSON.stringify({"xchange":selections}),
|
|
|
|
success: function success() {
|
|
|
|
$("#books-table").bootstrapTable("refresh");
|
|
|
|
$("#books-table").bootstrapTable("uncheckAll");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2020-06-11 21:19:09 +02:00
|
|
|
var column = [];
|
2020-06-11 21:36:12 +02:00
|
|
|
$("#books-table > thead > tr > th").each(function() {
|
|
|
|
var element = {};
|
|
|
|
if ($(this).attr("data-edit")) {
|
|
|
|
element = {
|
|
|
|
editable: {
|
|
|
|
mode: "inline",
|
|
|
|
emptytext: "<span class='glyphicon glyphicon-plus'></span>",
|
2021-04-02 16:41:34 +02:00
|
|
|
success: function (response, __) {
|
2021-04-03 14:21:38 +02:00
|
|
|
if (!response.success) return response.msg;
|
2021-04-02 16:41:34 +02:00
|
|
|
return {newValue: response.newValue};
|
2021-04-03 14:21:38 +02:00
|
|
|
},
|
|
|
|
params: function (params) {
|
|
|
|
params.checkA = $('#autoupdate_authorsort').prop('checked');
|
|
|
|
params.checkT = $('#autoupdate_titlesort').prop('checked');
|
|
|
|
return params
|
2021-04-02 16:41:34 +02:00
|
|
|
}
|
2020-06-11 21:36:12 +02:00
|
|
|
}
|
|
|
|
};
|
2021-04-03 14:21:38 +02:00
|
|
|
var validateText = $(this).attr("data-edit-validate");
|
|
|
|
if (validateText) {
|
|
|
|
element.editable.validate = function (value) {
|
|
|
|
if ($.trim(value) === "") return validateText;
|
|
|
|
};
|
|
|
|
}
|
2020-06-11 21:19:09 +02:00
|
|
|
}
|
2020-06-11 21:36:12 +02:00
|
|
|
column.push(element);
|
2020-06-11 21:19:09 +02:00
|
|
|
});
|
2020-06-12 13:45:07 +02:00
|
|
|
|
2020-06-11 21:36:12 +02:00
|
|
|
$("#books-table").bootstrapTable({
|
2020-06-11 21:19:09 +02:00
|
|
|
sidePagination: "server",
|
2021-05-28 18:48:46 +02:00
|
|
|
pageList: "[10, 25, 50, 100]",
|
2021-04-12 18:23:25 +02:00
|
|
|
queryParams: queryParams,
|
2020-06-11 21:19:09 +02:00
|
|
|
pagination: true,
|
2020-10-04 19:23:06 +02:00
|
|
|
paginationLoop: false,
|
2021-05-28 18:48:46 +02:00
|
|
|
paginationDetailHAlign: "right",
|
2020-06-11 21:19:09 +02:00
|
|
|
paginationHAlign: "left",
|
|
|
|
idField: "id",
|
2020-06-12 13:45:07 +02:00
|
|
|
uniqueId: "id",
|
2020-06-11 21:19:09 +02:00
|
|
|
search: true,
|
|
|
|
showColumns: true,
|
|
|
|
searchAlign: "left",
|
2021-02-13 13:17:02 +01:00
|
|
|
showSearchButton : true,
|
2020-06-11 21:19:09 +02:00
|
|
|
searchOnEnterKey: true,
|
|
|
|
checkboxHeader: false,
|
|
|
|
maintainMetaData: true,
|
|
|
|
responseHandler: responseHandler,
|
|
|
|
columns: column,
|
2020-06-06 21:21:10 +02:00
|
|
|
formatNoMatches: function () {
|
|
|
|
return "";
|
2020-06-11 21:19:09 +02:00
|
|
|
},
|
2020-12-13 09:53:18 +01:00
|
|
|
// eslint-disable-next-line no-unused-vars
|
2020-06-12 13:45:07 +02:00
|
|
|
onEditableSave: function (field, row, oldvalue, $el) {
|
2021-04-03 14:21:38 +02:00
|
|
|
if ($.inArray(field, [ "title", "sort" ]) !== -1 && $('#autoupdate_titlesort').prop('checked')
|
|
|
|
|| $.inArray(field, [ "authors", "author_sort" ]) !== -1 && $('#autoupdate_authorsort').prop('checked')) {
|
2020-12-13 09:53:18 +01:00
|
|
|
$.ajax({
|
|
|
|
method:"get",
|
|
|
|
dataType: "json",
|
2021-05-29 19:18:43 +02:00
|
|
|
url: window.location.pathname + "/../ajax/sort_value/" + field + "/" + row.id,
|
2020-12-13 09:53:18 +01:00
|
|
|
success: function success(data) {
|
|
|
|
var key = Object.keys(data)[0];
|
|
|
|
$("#books-table").bootstrapTable("updateCellByUniqueId", {
|
|
|
|
id: row.id,
|
|
|
|
field: key,
|
|
|
|
value: data[key]
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2020-06-12 13:45:07 +02:00
|
|
|
},
|
2020-12-13 09:53:18 +01:00
|
|
|
// eslint-disable-next-line no-unused-vars
|
2020-06-12 13:45:07 +02:00
|
|
|
onColumnSwitch: function (field, checked) {
|
2020-12-13 09:53:18 +01:00
|
|
|
var visible = $("#books-table").bootstrapTable("getVisibleColumns");
|
|
|
|
var hidden = $("#books-table").bootstrapTable("getHiddenColumns");
|
|
|
|
var st = "";
|
2020-06-12 16:15:54 +02:00
|
|
|
visible.forEach(function(item) {
|
2020-12-13 09:53:18 +01:00
|
|
|
st += "\"" + item.field + "\":\"" + "true" + "\",";
|
2020-06-12 16:15:54 +02:00
|
|
|
});
|
|
|
|
hidden.forEach(function(item) {
|
2020-12-13 09:53:18 +01:00
|
|
|
st += "\"" + item.field + "\":\"" + "false" + "\",";
|
2020-06-12 16:15:54 +02:00
|
|
|
});
|
|
|
|
st = st.slice(0, -1);
|
2020-06-12 13:45:07 +02:00
|
|
|
$.ajax({
|
|
|
|
method:"post",
|
|
|
|
contentType: "application/json; charset=utf-8",
|
|
|
|
dataType: "json",
|
2021-05-29 19:18:43 +02:00
|
|
|
url: window.location.pathname + "/../ajax/table_settings",
|
2020-06-12 16:15:54 +02:00
|
|
|
data: "{" + st + "}",
|
|
|
|
});
|
|
|
|
},
|
2020-06-06 21:21:10 +02:00
|
|
|
});
|
|
|
|
|
2019-12-29 13:54:52 +01:00
|
|
|
$("#domain_allow_submit").click(function(event) {
|
2018-08-28 09:42:19 +02:00
|
|
|
event.preventDefault();
|
2019-12-29 13:54:52 +01:00
|
|
|
$("#domain_add_allow").ajaxForm();
|
2018-08-28 09:42:19 +02:00
|
|
|
$(this).closest("form").submit();
|
2019-07-13 20:45:48 +02:00
|
|
|
$.ajax ({
|
2018-08-28 09:42:19 +02:00
|
|
|
method:"get",
|
2019-12-29 13:54:52 +01:00
|
|
|
url: window.location.pathname + "/../../ajax/domainlist/1",
|
2018-08-28 09:42:19 +02:00
|
|
|
async: true,
|
|
|
|
timeout: 900,
|
2019-07-13 20:45:48 +02:00
|
|
|
success:function(data) {
|
2019-12-29 13:54:52 +01:00
|
|
|
$("#domain-allow-table").bootstrapTable("load", data);
|
2018-08-28 09:42:19 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
2020-06-11 21:36:12 +02:00
|
|
|
|
2019-12-29 13:54:52 +01:00
|
|
|
$("#domain-allow-table").bootstrapTable({
|
|
|
|
formatNoMatches: function () {
|
|
|
|
return "";
|
|
|
|
},
|
|
|
|
striped: false
|
|
|
|
});
|
|
|
|
$("#domain_deny_submit").click(function(event) {
|
|
|
|
event.preventDefault();
|
|
|
|
$("#domain_add_deny").ajaxForm();
|
|
|
|
$(this).closest("form").submit();
|
|
|
|
$.ajax ({
|
|
|
|
method:"get",
|
|
|
|
url: window.location.pathname + "/../../ajax/domainlist/0",
|
|
|
|
async: true,
|
|
|
|
timeout: 900,
|
|
|
|
success:function(data) {
|
|
|
|
$("#domain-deny-table").bootstrapTable("load", data);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
$("#domain-deny-table").bootstrapTable({
|
2019-01-08 07:58:22 +01:00
|
|
|
formatNoMatches: function () {
|
|
|
|
return "";
|
2019-03-05 16:31:09 +01:00
|
|
|
},
|
|
|
|
striped: false
|
2018-08-28 09:42:19 +02:00
|
|
|
});
|
2020-12-20 19:17:29 +01:00
|
|
|
|
2021-03-14 14:29:40 +01:00
|
|
|
function domainHandle(domainId) {
|
2018-08-28 09:42:19 +02:00
|
|
|
$.ajax({
|
|
|
|
method:"post",
|
|
|
|
url: window.location.pathname + "/../../ajax/deletedomain",
|
|
|
|
data: {"domainid":domainId}
|
|
|
|
});
|
|
|
|
$.ajax({
|
|
|
|
method:"get",
|
2019-12-29 13:54:52 +01:00
|
|
|
url: window.location.pathname + "/../../ajax/domainlist/1",
|
2018-08-28 09:42:19 +02:00
|
|
|
async: true,
|
|
|
|
timeout: 900,
|
2019-03-05 16:31:09 +01:00
|
|
|
success:function(data) {
|
2019-12-29 13:54:52 +01:00
|
|
|
$("#domain-allow-table").bootstrapTable("load", data);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
$.ajax({
|
|
|
|
method:"get",
|
|
|
|
url: window.location.pathname + "/../../ajax/domainlist/0",
|
|
|
|
async: true,
|
|
|
|
timeout: 900,
|
|
|
|
success:function(data) {
|
|
|
|
$("#domain-deny-table").bootstrapTable("load", data);
|
2018-08-28 09:42:19 +02:00
|
|
|
}
|
|
|
|
});
|
2020-12-20 19:17:29 +01:00
|
|
|
}
|
|
|
|
$("#domain-allow-table").on("click-cell.bs.table", function (field, value, row, $element) {
|
|
|
|
if (value === 2) {
|
2021-03-16 15:40:58 +01:00
|
|
|
confirmDialog("btndeletedomain", "GeneralDeleteModal", $element.id, domainHandle);
|
2020-12-20 19:17:29 +01:00
|
|
|
}
|
2018-08-28 09:42:19 +02:00
|
|
|
});
|
2020-12-20 19:17:29 +01:00
|
|
|
$("#domain-deny-table").on("click-cell.bs.table", function (field, value, row, $element) {
|
|
|
|
if (value === 2) {
|
2021-03-16 15:40:58 +01:00
|
|
|
confirmDialog("btndeletedomain", "GeneralDeleteModal", $element.id, domainHandle);
|
2020-12-20 19:17:29 +01:00
|
|
|
}
|
2018-08-28 09:42:19 +02:00
|
|
|
});
|
2020-01-01 17:26:47 +01:00
|
|
|
|
2021-03-16 15:03:38 +01:00
|
|
|
$("#restrictModal").on("hidden.bs.modal", function (e) {
|
2020-01-05 16:43:48 +01:00
|
|
|
// Destroy table and remove hooks for buttons
|
|
|
|
$("#restrict-elements-table").unbind();
|
2020-03-29 16:22:11 +02:00
|
|
|
$("#restrict-elements-table").bootstrapTable("destroy");
|
2020-01-05 16:43:48 +01:00
|
|
|
$("[id^=submit_]").unbind();
|
2020-03-29 16:22:11 +02:00
|
|
|
$("#h1").addClass("hidden");
|
|
|
|
$("#h2").addClass("hidden");
|
|
|
|
$("#h3").addClass("hidden");
|
|
|
|
$("#h4").addClass("hidden");
|
2021-03-16 15:03:38 +01:00
|
|
|
$("#add_element").val("");
|
2020-01-01 17:26:47 +01:00
|
|
|
});
|
2021-03-16 15:03:38 +01:00
|
|
|
|
|
|
|
function startTable(target, userId) {
|
|
|
|
var type = 0;
|
|
|
|
switch(target) {
|
|
|
|
case "get_column_values":
|
|
|
|
type = 1;
|
|
|
|
$("#h2").removeClass("hidden");
|
|
|
|
break;
|
|
|
|
case "get_tags":
|
|
|
|
type = 0;
|
|
|
|
$("#h1").removeClass("hidden");
|
|
|
|
break;
|
|
|
|
case "get_user_column_values":
|
|
|
|
type = 3;
|
|
|
|
$("#h4").removeClass("hidden");
|
|
|
|
break;
|
|
|
|
case "get_user_tags":
|
|
|
|
type = 2;
|
|
|
|
$("#h3").removeClass("hidden");
|
|
|
|
break;
|
|
|
|
case "denied_tags":
|
|
|
|
type = 2;
|
|
|
|
$("#h2").removeClass("hidden");
|
|
|
|
$("#submit_allow").addClass("hidden");
|
|
|
|
$("#submit_restrict").removeClass("hidden");
|
|
|
|
break;
|
|
|
|
case "allowed_tags":
|
|
|
|
type = 2;
|
|
|
|
$("#h2").removeClass("hidden");
|
|
|
|
$("#submit_restrict").addClass("hidden");
|
|
|
|
$("#submit_allow").removeClass("hidden");
|
|
|
|
break;
|
|
|
|
case "allowed_column_value":
|
|
|
|
type = 3;
|
|
|
|
$("#h2").removeClass("hidden");
|
|
|
|
$("#submit_restrict").addClass("hidden");
|
|
|
|
$("#submit_allow").removeClass("hidden");
|
|
|
|
break;
|
|
|
|
case "denied_column_value":
|
|
|
|
type = 3;
|
|
|
|
$("#h2").removeClass("hidden");
|
|
|
|
$("#submit_allow").addClass("hidden");
|
|
|
|
$("#submit_restrict").removeClass("hidden");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2020-01-01 17:26:47 +01:00
|
|
|
$("#restrict-elements-table").bootstrapTable({
|
|
|
|
formatNoMatches: function () {
|
|
|
|
return "";
|
|
|
|
},
|
2021-03-14 14:29:40 +01:00
|
|
|
url: getPath() + "/ajax/listrestriction/" + type + "/" + userId,
|
2020-04-27 20:01:13 +02:00
|
|
|
rowStyle: function(row) {
|
2020-03-29 16:22:11 +02:00
|
|
|
if (row.id.charAt(0) === "a") {
|
|
|
|
return {classes: "bg-primary"};
|
|
|
|
} else {
|
|
|
|
return {classes: "bg-dark-danger"};
|
2020-01-05 16:43:48 +01:00
|
|
|
}
|
|
|
|
},
|
2021-03-16 15:03:38 +01:00
|
|
|
onLoadSuccess: function () {
|
|
|
|
$(".no-records-found").addClass("hidden");
|
|
|
|
$(".fixed-table-loading").addClass("hidden");
|
|
|
|
},
|
2020-04-27 20:01:13 +02:00
|
|
|
onClickCell: function (field, value, row) {
|
|
|
|
if (field === 3) {
|
2020-01-01 17:26:47 +01:00
|
|
|
$.ajax ({
|
2020-03-29 16:22:11 +02:00
|
|
|
type: "Post",
|
2020-05-11 18:41:16 +02:00
|
|
|
data: "id=" + row.id + "&type=" + row.type + "&Element=" + encodeURIComponent(row.Element),
|
2021-03-14 14:29:40 +01:00
|
|
|
url: getPath() + "/ajax/deleterestriction/" + type + "/" + userId,
|
2020-01-01 17:26:47 +01:00
|
|
|
async: true,
|
|
|
|
timeout: 900,
|
2020-04-27 20:01:13 +02:00
|
|
|
success:function() {
|
2020-01-01 17:26:47 +01:00
|
|
|
$.ajax({
|
|
|
|
method:"get",
|
2021-03-14 14:29:40 +01:00
|
|
|
url: getPath() + "/ajax/listrestriction/" + type + "/" + userId,
|
2020-01-01 17:26:47 +01:00
|
|
|
async: true,
|
|
|
|
timeout: 900,
|
|
|
|
success:function(data) {
|
|
|
|
$("#restrict-elements-table").bootstrapTable("load", data);
|
|
|
|
}
|
|
|
|
});
|
2020-01-05 16:43:48 +01:00
|
|
|
}
|
|
|
|
});
|
2020-01-01 17:26:47 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
striped: false
|
|
|
|
});
|
2020-03-29 16:22:11 +02:00
|
|
|
$("#restrict-elements-table").removeClass("table-hover");
|
2020-04-27 20:01:13 +02:00
|
|
|
$("#restrict-elements-table").on("editable-save.bs.table", function (e, field, row) {
|
2020-01-05 16:43:48 +01:00
|
|
|
$.ajax({
|
2021-03-14 14:29:40 +01:00
|
|
|
url: getPath() + "/ajax/editrestriction/" + type + "/" + userId,
|
2020-03-29 16:22:11 +02:00
|
|
|
type: "Post",
|
2020-04-24 21:05:56 +02:00
|
|
|
data: row
|
2020-01-05 16:43:48 +01:00
|
|
|
});
|
|
|
|
});
|
2020-04-27 20:01:13 +02:00
|
|
|
$("[id^=submit_]").click(function() {
|
2020-01-05 16:43:48 +01:00
|
|
|
$(this)[0].blur();
|
2020-01-01 17:26:47 +01:00
|
|
|
$.ajax({
|
2021-03-14 14:29:40 +01:00
|
|
|
url: getPath() + "/ajax/addrestriction/" + type + "/" + userId,
|
2020-03-29 16:22:11 +02:00
|
|
|
type: "Post",
|
2020-01-01 17:26:47 +01:00
|
|
|
data: $(this).closest("form").serialize() + "&" + $(this)[0].name + "=",
|
|
|
|
success: function () {
|
2020-03-29 16:22:11 +02:00
|
|
|
$.ajax ({
|
|
|
|
method:"get",
|
2021-03-14 14:29:40 +01:00
|
|
|
url: getPath() + "/ajax/listrestriction/" + type + "/" + userId,
|
2020-03-29 16:22:11 +02:00
|
|
|
async: true,
|
|
|
|
timeout: 900,
|
|
|
|
success:function(data) {
|
|
|
|
$("#restrict-elements-table").bootstrapTable("load", data);
|
|
|
|
}
|
2020-01-01 17:26:47 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-03-16 15:03:38 +01:00
|
|
|
$("#restrictModal").on("show.bs.modal", function(e) {
|
|
|
|
var target = $(e.relatedTarget).attr('id');
|
|
|
|
var dataId;
|
|
|
|
$(e.relatedTarget).one('focus', function(e){$(this).blur();});
|
|
|
|
if ($(e.relatedTarget).hasClass("button_head")) {
|
|
|
|
dataId = $('#user-table').bootstrapTable('getSelections').map(a => a.id);
|
|
|
|
} else {
|
|
|
|
dataId = $(e.relatedTarget).data("id");
|
|
|
|
}
|
|
|
|
startTable(target, dataId);
|
2020-01-05 16:43:48 +01:00
|
|
|
});
|
|
|
|
|
2021-01-31 10:17:40 +01:00
|
|
|
// User table handling
|
|
|
|
var user_column = [];
|
|
|
|
$("#user-table > thead > tr > th").each(function() {
|
|
|
|
var element = {};
|
|
|
|
if ($(this).attr("data-edit")) {
|
|
|
|
element = {
|
|
|
|
editable: {
|
|
|
|
mode: "inline",
|
|
|
|
emptytext: "<span class='glyphicon glyphicon-plus'></span>",
|
|
|
|
error: function(response) {
|
|
|
|
return response.responseText;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
var validateText = $(this).attr("data-edit-validate");
|
|
|
|
if (validateText) {
|
|
|
|
element.editable.validate = function (value) {
|
|
|
|
if ($.trim(value) === "") return validateText;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
user_column.push(element);
|
|
|
|
});
|
|
|
|
|
|
|
|
$("#user-table").bootstrapTable({
|
|
|
|
sidePagination: "server",
|
2021-04-11 19:59:20 +02:00
|
|
|
queryParams: queryParams,
|
2021-01-31 10:17:40 +01:00
|
|
|
pagination: true,
|
|
|
|
paginationLoop: false,
|
|
|
|
paginationDetailHAlign: " hidden",
|
|
|
|
paginationHAlign: "left",
|
|
|
|
idField: "id",
|
|
|
|
uniqueId: "id",
|
|
|
|
search: true,
|
|
|
|
showColumns: true,
|
|
|
|
searchAlign: "left",
|
2021-02-13 13:17:02 +01:00
|
|
|
showSearchButton : true,
|
2021-01-31 10:17:40 +01:00
|
|
|
searchOnEnterKey: true,
|
2021-02-13 13:17:02 +01:00
|
|
|
checkboxHeader: true,
|
2021-01-31 10:17:40 +01:00
|
|
|
maintainMetaData: true,
|
|
|
|
responseHandler: responseHandler,
|
|
|
|
columns: user_column,
|
|
|
|
formatNoMatches: function () {
|
|
|
|
return "";
|
|
|
|
},
|
2021-02-13 13:17:02 +01:00
|
|
|
onPostBody () {
|
|
|
|
// Remove all checkboxes from Headers for showing the texts in the column selector
|
|
|
|
$('.columns [data-field]').each(function(){
|
|
|
|
var elText = $(this).next().text();
|
|
|
|
$(this).next().empty();
|
2021-02-20 14:18:27 +01:00
|
|
|
var index = elText.lastIndexOf('\n', elText.length - 2);
|
|
|
|
if ( index > -1) {
|
|
|
|
elText = elText.substr(index);
|
|
|
|
}
|
2021-02-13 13:17:02 +01:00
|
|
|
$(this).next().text(elText);
|
|
|
|
});
|
|
|
|
},
|
2021-04-18 12:01:11 +02:00
|
|
|
onPostHeader () {
|
2021-04-25 10:42:41 +02:00
|
|
|
move_header_elements();
|
2021-04-04 19:40:34 +02:00
|
|
|
},
|
2021-04-18 12:01:11 +02:00
|
|
|
onLoadSuccess: function () {
|
|
|
|
loadSuccess();
|
2021-04-11 19:59:20 +02:00
|
|
|
},
|
|
|
|
onColumnSwitch: function () {
|
2021-01-31 10:17:40 +01:00
|
|
|
var visible = $("#user-table").bootstrapTable("getVisibleColumns");
|
|
|
|
var hidden = $("#user-table").bootstrapTable("getHiddenColumns");
|
|
|
|
var st = "";
|
|
|
|
visible.forEach(function(item) {
|
2021-02-13 13:17:02 +01:00
|
|
|
st += "\"" + item.name + "\":\"" + "true" + "\",";
|
2021-01-31 10:17:40 +01:00
|
|
|
});
|
|
|
|
hidden.forEach(function(item) {
|
2021-02-13 13:17:02 +01:00
|
|
|
st += "\"" + item.name + "\":\"" + "false" + "\",";
|
2021-01-31 10:17:40 +01:00
|
|
|
});
|
|
|
|
st = st.slice(0, -1);
|
2021-02-13 13:17:02 +01:00
|
|
|
$.ajax({
|
2021-01-31 10:17:40 +01:00
|
|
|
method:"post",
|
|
|
|
contentType: "application/json; charset=utf-8",
|
|
|
|
dataType: "json",
|
2021-02-13 13:17:02 +01:00
|
|
|
url: window.location.pathname + "/../../ajax/user_table_settings",
|
2021-01-31 10:17:40 +01:00
|
|
|
data: "{" + st + "}",
|
2021-02-13 13:17:02 +01:00
|
|
|
});
|
2021-04-25 10:42:41 +02:00
|
|
|
handle_header_buttons();
|
2021-01-31 10:17:40 +01:00
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2021-02-13 13:17:02 +01:00
|
|
|
$("#user-table").on("click-cell.bs.table", function (field, value, row, $element) {
|
|
|
|
if (value === "denied_column_value") {
|
2021-03-16 15:40:58 +01:00
|
|
|
ConfirmDialog("btndeluser", "GeneralDeleteModal", $element.id, user_handle);
|
2021-02-13 13:17:02 +01:00
|
|
|
}
|
|
|
|
});
|
2021-01-31 14:54:45 +01:00
|
|
|
|
2021-02-14 13:09:31 +01:00
|
|
|
$("#user-table").on("check.bs.table check-all.bs.table uncheck.bs.table uncheck-all.bs.table",
|
2021-01-31 10:17:40 +01:00
|
|
|
function (e, rowsAfter, rowsBefore) {
|
|
|
|
var rows = rowsAfter;
|
|
|
|
|
|
|
|
if (e.type === "uncheck-all") {
|
|
|
|
rows = rowsBefore;
|
|
|
|
}
|
|
|
|
|
|
|
|
var ids = $.map(!$.isArray(rows) ? [rows] : rows, function (row) {
|
|
|
|
return row.id;
|
|
|
|
});
|
2021-02-14 13:09:31 +01:00
|
|
|
var func = $.inArray(e.type, ["check", "check-all"]) > -1 ? "union" : "difference";
|
|
|
|
selections = window._[func](selections, ids);
|
2021-04-25 10:42:41 +02:00
|
|
|
handle_header_buttons();
|
2021-02-14 13:09:31 +01:00
|
|
|
});
|
2018-08-28 09:42:19 +02:00
|
|
|
});
|
|
|
|
|
2021-04-25 10:42:41 +02:00
|
|
|
function 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);
|
|
|
|
$(".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");
|
|
|
|
}
|
|
|
|
}
|
2019-04-14 14:08:49 +02:00
|
|
|
/* Function for deleting domain restrictions */
|
2020-04-27 20:01:13 +02:00
|
|
|
function TableActions (value, row) {
|
2018-08-28 09:42:19 +02:00
|
|
|
return [
|
2020-12-20 19:17:29 +01:00
|
|
|
"<a class=\"danger remove\" data-value=\"" + row.id
|
2019-01-08 07:58:22 +01:00
|
|
|
+ "\" title=\"Remove\">",
|
|
|
|
"<i class=\"glyphicon glyphicon-trash\"></i>",
|
|
|
|
"</a>"
|
|
|
|
].join("");
|
2019-04-14 14:08:49 +02:00
|
|
|
}
|
2020-01-01 17:26:47 +01:00
|
|
|
|
|
|
|
/* Function for deleting domain restrictions */
|
2020-04-27 20:01:13 +02:00
|
|
|
function RestrictionActions (value, row) {
|
2020-01-01 17:26:47 +01:00
|
|
|
return [
|
|
|
|
"<div class=\"danger remove\" data-restriction-id=\"" + row.id + "\" title=\"Remove\">",
|
|
|
|
"<i class=\"glyphicon glyphicon-trash\"></i>",
|
|
|
|
"</div>"
|
|
|
|
].join("");
|
|
|
|
}
|
2020-06-06 21:21:10 +02:00
|
|
|
|
|
|
|
/* Function for deleting books */
|
|
|
|
function EbookActions (value, row) {
|
|
|
|
return [
|
2020-06-18 20:39:45 +02:00
|
|
|
"<div class=\"book-remove\" data-toggle=\"modal\" data-target=\"#deleteModal\" data-ajax=\"1\" data-delete-id=\"" + row.id + "\" title=\"Remove\">",
|
2020-06-06 21:21:10 +02:00
|
|
|
"<i class=\"glyphicon glyphicon-trash\"></i>",
|
|
|
|
"</div>"
|
|
|
|
].join("");
|
|
|
|
}
|
2020-06-11 21:19:09 +02:00
|
|
|
|
2021-04-18 12:01:11 +02:00
|
|
|
/* Function for deleting Users */
|
2021-01-31 14:54:45 +01:00
|
|
|
function UserActions (value, row) {
|
|
|
|
return [
|
2021-04-10 11:32:11 +02:00
|
|
|
"<div class=\"user-remove\" data-value=\"delete\" onclick=\"deleteUser(this, '" + row.id + "')\" data-pk=\"" + row.id + "\" title=\"Remove\">",
|
2021-01-31 14:54:45 +01:00
|
|
|
"<i class=\"glyphicon glyphicon-trash\"></i>",
|
|
|
|
"</div>"
|
|
|
|
].join("");
|
|
|
|
}
|
|
|
|
|
2020-06-11 21:19:09 +02:00
|
|
|
/* Function for keeping checked rows */
|
|
|
|
function responseHandler(res) {
|
|
|
|
$.each(res.rows, function (i, row) {
|
|
|
|
row.state = $.inArray(row.id, selections) !== -1;
|
|
|
|
});
|
|
|
|
return res;
|
|
|
|
}
|
2021-01-31 14:54:45 +01:00
|
|
|
|
|
|
|
function singleUserFormatter(value, row) {
|
2021-04-17 18:30:55 +02:00
|
|
|
return '<a class="btn btn-default" onclick="storeLocation()" href="' + window.location.pathname + '/../../admin/user/' + row.id + '">' + this.buttontext + '</a>'
|
2021-01-31 14:54:45 +01:00
|
|
|
}
|
|
|
|
|
2021-05-15 10:45:51 +02:00
|
|
|
function checkboxFormatter(value, row){
|
2021-01-31 14:54:45 +01:00
|
|
|
if(value & this.column)
|
2021-04-08 19:37:08 +02:00
|
|
|
return '<input type="checkbox" class="chk" data-pk="' + row.id + '" data-name="' + this.field + '" checked onchange="checkboxChange(this, ' + row.id + ', \'' + this.name + '\', ' + this.column + ')">';
|
2021-01-31 14:54:45 +01:00
|
|
|
else
|
2021-04-08 19:37:08 +02:00
|
|
|
return '<input type="checkbox" class="chk" data-pk="' + row.id + '" data-name="' + this.field + '" onchange="checkboxChange(this, ' + row.id + ', \'' + this.name + '\', ' + this.column + ')">';
|
2021-01-31 14:54:45 +01:00
|
|
|
}
|
2021-05-15 10:45:51 +02:00
|
|
|
function singlecheckboxFormatter(value, row){
|
|
|
|
if(value)
|
|
|
|
return '<input type="checkbox" class="chk" data-pk="' + row.id + '" data-name="' + this.field + '" checked onchange="checkboxChange(this, ' + row.id + ', \'' + this.name + '\', 0)">';
|
|
|
|
else
|
|
|
|
return '<input type="checkbox" class="chk" data-pk="' + row.id + '" data-name="' + this.field + '" onchange="checkboxChange(this, ' + row.id + ', \'' + this.name + '\', 0)">';
|
|
|
|
}
|
|
|
|
|
2021-01-31 14:54:45 +01:00
|
|
|
|
2021-04-22 19:14:56 +02:00
|
|
|
/* Do some hiding disabling after user list is loaded */
|
2021-04-18 12:01:11 +02:00
|
|
|
function loadSuccess() {
|
|
|
|
var guest = $(".editable[data-name='name'][data-value='Guest']");
|
|
|
|
guest.editable("disable");
|
2021-04-25 10:42:41 +02:00
|
|
|
$("input:radio.check_head:checked").each(function() {
|
|
|
|
$(this).prop('checked', false);
|
|
|
|
});
|
|
|
|
$(".header_select").each(function() {
|
|
|
|
$(this).prop("selectedIndex", 0);
|
|
|
|
});
|
2021-04-27 20:01:17 +02:00
|
|
|
$(".header_select").each(function() {
|
|
|
|
$(this).prop("selectedIndex", 0);
|
|
|
|
});
|
|
|
|
$('.multi_selector').selectpicker('deselectAll');
|
|
|
|
$('.multi_selector').selectpicker('refresh');
|
2021-04-18 12:01:11 +02:00
|
|
|
$(".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);
|
|
|
|
$("input[data-name='passwd_role'][data-pk='"+guest.data("pk")+"']").prop("disabled", true);
|
|
|
|
$("input[data-name='edit_shelf_role'][data-pk='"+guest.data("pk")+"']").prop("disabled", true);
|
|
|
|
$("input[data-name='sidebar_read_and_unread'][data-pk='"+guest.data("pk")+"']").prop("disabled", true);
|
|
|
|
$(".user-remove[data-pk='"+guest.data("pk")+"']").hide();
|
|
|
|
}
|
|
|
|
|
2021-04-25 10:42:41 +02:00
|
|
|
function move_header_elements() {
|
2021-05-01 08:36:15 +02:00
|
|
|
$(".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();
|
2021-07-23 19:46:01 +02:00
|
|
|
if ($(".multi_head").length) {
|
|
|
|
if (!$._data($(".multi_head").get(0), "events")) {
|
|
|
|
// 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}])
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
|
|
|
);
|
|
|
|
});
|
|
|
|
}
|
2021-05-01 08:36:15 +02:00
|
|
|
}
|
2021-04-27 20:01:17 +02:00
|
|
|
|
2021-05-01 08:36:15 +02:00
|
|
|
$("#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");
|
|
|
|
});
|
2021-07-23 19:46:01 +02:00
|
|
|
if ($(".check_head").length) {
|
|
|
|
if (!$._data($(".check_head").get(0), "events")) {
|
|
|
|
$(".check_head").on("change", function () {
|
|
|
|
var val = $(this).data("set");
|
|
|
|
var name = $(this).data("name");
|
|
|
|
var data = $(this).data("val");
|
|
|
|
checkboxHeader(val, name, data);
|
|
|
|
});
|
|
|
|
}
|
2021-05-01 08:36:15 +02:00
|
|
|
}
|
2021-07-23 19:46:01 +02:00
|
|
|
if ($(".button_head").length) {
|
|
|
|
if (!$._data($(".button_head").get(0), "events")) {
|
|
|
|
$(".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}])
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
|
|
|
);
|
|
|
|
});
|
|
|
|
}
|
2021-05-01 08:36:15 +02:00
|
|
|
}
|
2021-04-25 10:42:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function handleListServerResponse (data) {
|
2021-04-18 12:01:11 +02:00
|
|
|
$("#flash_success").remove();
|
|
|
|
$("#flash_danger").remove();
|
|
|
|
if (!jQuery.isEmptyObject(data)) {
|
2021-04-21 19:23:11 +02:00
|
|
|
data.forEach(function(item) {
|
|
|
|
$(".navbar").after('<div class="row-fluid text-center" style="margin-top: -20px;">' +
|
|
|
|
'<div id="flash_' + item.type + '" class="alert alert-' + item.type + '">' + item.message + '</div>' +
|
|
|
|
'</div>');
|
|
|
|
});
|
2021-04-18 12:01:11 +02:00
|
|
|
}
|
2021-04-21 19:23:11 +02:00
|
|
|
$("#user-table").bootstrapTable("refresh");
|
2021-04-18 12:01:11 +02:00
|
|
|
}
|
|
|
|
|
2021-02-14 13:09:31 +01:00
|
|
|
function checkboxChange(checkbox, userId, field, field_index) {
|
|
|
|
$.ajax({
|
2021-04-12 19:04:27 +02:00
|
|
|
method: "post",
|
2021-02-14 13:09:31 +01:00
|
|
|
url: window.location.pathname + "/../../ajax/editlistusers/" + field,
|
2021-04-12 19:04:27 +02:00
|
|
|
data: {"pk": userId, "field_index": field_index, "value": checkbox.checked},
|
2021-04-18 12:01:11 +02:00
|
|
|
error: function(data) {
|
2021-04-26 19:03:01 +02:00
|
|
|
handleListServerResponse([{type:"danger", message:data.responseText}])
|
2021-04-18 12:01:11 +02:00
|
|
|
},
|
|
|
|
success: handleListServerResponse
|
2021-01-31 14:54:45 +01:00
|
|
|
});
|
|
|
|
}
|
2021-04-12 19:04:27 +02:00
|
|
|
|
2021-03-16 15:03:38 +01:00
|
|
|
function selectHeader(element, field) {
|
2021-03-16 15:40:58 +01:00
|
|
|
if (element.value !== "None") {
|
|
|
|
confirmDialog(element.id, "GeneralChangeModal", 0, function () {
|
|
|
|
var result = $('#user-table').bootstrapTable('getSelections').map(a => a.id);
|
2021-03-16 15:03:38 +01:00
|
|
|
$.ajax({
|
2021-03-16 15:40:58 +01:00
|
|
|
method: "post",
|
|
|
|
url: window.location.pathname + "/../../ajax/editlistusers/" + field,
|
|
|
|
data: {"pk": result, "value": element.value},
|
2021-04-18 12:01:11 +02:00
|
|
|
error: function (data) {
|
2021-04-26 19:03:01 +02:00
|
|
|
handleListServerResponse([{type:"danger", message:data.responseText}])
|
2021-04-18 12:01:11 +02:00
|
|
|
},
|
|
|
|
success: handleListServerResponse,
|
2021-03-16 15:03:38 +01:00
|
|
|
});
|
2021-04-25 10:42:41 +02:00
|
|
|
},function() {
|
|
|
|
$(element).prop("selectedIndex", 0);
|
2021-03-16 15:40:58 +01:00
|
|
|
});
|
|
|
|
}
|
2021-03-16 15:03:38 +01:00
|
|
|
}
|
|
|
|
|
2021-02-20 14:18:27 +01:00
|
|
|
function checkboxHeader(CheckboxState, field, field_index) {
|
2021-03-16 15:40:58 +01:00
|
|
|
confirmDialog(field, "GeneralChangeModal", 0, function() {
|
|
|
|
var result = $('#user-table').bootstrapTable('getSelections').map(a => a.id);
|
|
|
|
$.ajax({
|
|
|
|
method: "post",
|
|
|
|
url: window.location.pathname + "/../../ajax/editlistusers/" + field,
|
|
|
|
data: {"pk": result, "field_index": field_index, "value": CheckboxState},
|
2021-04-18 12:01:11 +02:00
|
|
|
error: function (data) {
|
2021-04-26 19:03:01 +02:00
|
|
|
handleListServerResponse([{type:"danger", message:data.responseText}])
|
2021-04-18 12:01:11 +02:00
|
|
|
},
|
|
|
|
success: function (data) {
|
|
|
|
handleListServerResponse (data, true)
|
|
|
|
},
|
2021-03-16 15:40:58 +01:00
|
|
|
});
|
2021-04-25 10:42:41 +02:00
|
|
|
},function() {
|
|
|
|
$("input:radio.check_head:checked").each(function() {
|
|
|
|
$(this).prop('checked', false);
|
|
|
|
});
|
2021-02-14 13:09:31 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-04-21 19:23:11 +02:00
|
|
|
function deleteUser(a,id){
|
2021-04-10 11:32:11 +02:00
|
|
|
confirmDialog(
|
|
|
|
"btndeluser",
|
|
|
|
"GeneralDeleteModal",
|
|
|
|
0,
|
|
|
|
function() {
|
|
|
|
$.ajax({
|
|
|
|
method:"post",
|
|
|
|
url: window.location.pathname + "/../../ajax/deleteuser",
|
2021-04-21 19:23:11 +02:00
|
|
|
data: {"userid":id},
|
|
|
|
success: function (data) {
|
|
|
|
userId = parseInt(id, 10);
|
|
|
|
selections = selections.filter(item => item !== userId);
|
|
|
|
handleListServerResponse(data);
|
|
|
|
},
|
2021-04-18 12:01:11 +02:00
|
|
|
error: function (data) {
|
2021-04-26 19:03:01 +02:00
|
|
|
handleListServerResponse([{type:"danger", message:data.responseText}])
|
2021-04-18 12:01:11 +02:00
|
|
|
},
|
2021-04-10 11:32:11 +02:00
|
|
|
});
|
2021-02-14 13:09:31 +01:00
|
|
|
}
|
2021-04-10 11:32:11 +02:00
|
|
|
);
|
2021-02-20 14:18:27 +01:00
|
|
|
}
|
2021-02-14 13:09:31 +01:00
|
|
|
|
2021-04-11 19:59:20 +02:00
|
|
|
function queryParams(params)
|
|
|
|
{
|
|
|
|
params.state = JSON.stringify(selections);
|
|
|
|
return params;
|
|
|
|
}
|
2021-04-08 19:37:08 +02:00
|
|
|
|
2021-04-17 18:30:55 +02:00
|
|
|
function storeLocation() {
|
|
|
|
window.sessionStorage.setItem("back", window.location.pathname);
|
2021-02-13 13:17:02 +01:00
|
|
|
}
|
2021-04-25 10:42:41 +02:00
|
|
|
|
|
|
|
function user_handle (userId) {
|
|
|
|
$.ajax({
|
|
|
|
method:"post",
|
|
|
|
url: window.location.pathname + "/../../ajax/deleteuser",
|
|
|
|
data: {"userid":userId}
|
|
|
|
});
|
|
|
|
$("#user-table").bootstrapTable("refresh");
|
|
|
|
}
|