merge remote

This commit is contained in:
cbartondock
2021-04-06 13:05:55 -04:00
146 changed files with 12642 additions and 7757 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 509 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

File diff suppressed because one or more lines are too long
+1
View File
@@ -56,6 +56,7 @@ a,
.book-remove,
.editable-empty,
.editable-empty:hover { color: #45b29d; }
.book-remove:hover { color: #23527c; }
.user-remove:hover { color: #23527c; }
.btn-default a { color: #444; }
.panel-title > a { text-decoration: none; }
+8
View File
@@ -15,6 +15,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
var direction = $("#asc").data('order'); // 0=Descending order; 1= ascending order
var $list = $("#list").isotope({
itemSelector: ".book",
layoutMode: "fitRows",
@@ -24,6 +26,9 @@ var $list = $("#list").isotope({
});
$("#desc").click(function() {
if (direction === 0) {
return;
}
var page = $(this).data("id");
$.ajax({
method:"post",
@@ -39,6 +44,9 @@ $("#desc").click(function() {
});
$("#asc").click(function() {
if (direction === 1) {
return;
}
var page = $(this).data("id");
$.ajax({
method:"post",
+1 -1
View File
@@ -15,7 +15,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
var direction = 0; // Descending order
var direction = $("#asc").data('order'); // 0=Descending order; 1= ascending order
var sort = 0; // Show sorted entries
$("#sort_name").click(function() {
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+9 -9
View File
@@ -114,26 +114,23 @@ $(document).ready(function() {
}
});
function confirmDialog(id, dataValue, yesFn, noFn) {
var $confirm = $("#GeneralDeleteModal");
// var dataValue= e.data('value'); // target.data('value');
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").html(data.header);
$("#text").html(data.main);
$("#header-"+ dialogid).html(data.header);
$("#text-"+ dialogid).html(data.main);
}
});
$("#btnConfirmYes").off('click').click(function () {
$("#btnConfirmYes-"+ dialogid).off('click').click(function () {
yesFn(dataValue);
$confirm.modal("hide");
});
$("#btnConfirmNo").off('click').click(function () {
$("#btnConfirmNo-"+ dialogid).off('click').click(function () {
if (typeof noFn !== 'undefined') {
noFn(dataValue);
}
@@ -485,6 +482,7 @@ $(function() {
$("#config_delete_kobo_token").click(function() {
confirmDialog(
$(this).attr('id'),
"GeneralDeleteModal",
$(this).data('value'),
function (value) {
$.ajax({
@@ -513,6 +511,7 @@ $(function() {
$("#btndeluser").click(function() {
confirmDialog(
$(this).attr('id'),
"GeneralDeleteModal",
$(this).data('value'),
function(value){
var subform = $('#user_submit').closest("form");
@@ -531,6 +530,7 @@ $(function() {
$("#delete_shelf").click(function() {
confirmDialog(
$(this).attr('id'),
"GeneralDeleteModal",
$(this).data('value'),
function(value){
window.location.href = window.location.pathname + "/../../shelf/delete/" + value
+382 -27
View File
@@ -94,14 +94,23 @@ $(function() {
editable: {
mode: "inline",
emptytext: "<span class='glyphicon glyphicon-plus'></span>",
success: function (response, __) {
if (!response.success) return response.msg;
return {newValue: response.newValue};
},
params: function (params) {
params.checkA = $('#autoupdate_authorsort').prop('checked');
params.checkT = $('#autoupdate_titlesort').prop('checked');
return params
}
}
};
}
var validateText = $(this).attr("data-edit-validate");
if (validateText) {
element.editable.validate = function (value) {
if ($.trim(value) === "") return validateText;
};
var validateText = $(this).attr("data-edit-validate");
if (validateText) {
element.editable.validate = function (value) {
if ($.trim(value) === "") return validateText;
};
}
}
column.push(element);
});
@@ -117,7 +126,7 @@ $(function() {
search: true,
showColumns: true,
searchAlign: "left",
showSearchButton : false,
showSearchButton : true,
searchOnEnterKey: true,
checkboxHeader: false,
maintainMetaData: true,
@@ -128,7 +137,8 @@ $(function() {
},
// eslint-disable-next-line no-unused-vars
onEditableSave: function (field, row, oldvalue, $el) {
if (field === "title" || field === "authors") {
if ($.inArray(field, [ "title", "sort" ]) !== -1 && $('#autoupdate_titlesort').prop('checked')
|| $.inArray(field, [ "authors", "author_sort" ]) !== -1 && $('#autoupdate_authorsort').prop('checked')) {
$.ajax({
method:"get",
dataType: "json",
@@ -236,16 +246,16 @@ $(function() {
}
$("#domain-allow-table").on("click-cell.bs.table", function (field, value, row, $element) {
if (value === 2) {
confirmDialog("btndeletedomain", $element.id, domainHandle);
confirmDialog("btndeletedomain", "GeneralDeleteModal", $element.id, domainHandle);
}
});
$("#domain-deny-table").on("click-cell.bs.table", function (field, value, row, $element) {
if (value === 2) {
confirmDialog("btndeletedomain", $element.id, domainHandle);
confirmDialog("btndeletedomain", "GeneralDeleteModal", $element.id, domainHandle);
}
});
$("#restrictModal").on("hidden.bs.modal", function () {
$("#restrictModal").on("hidden.bs.modal", function (e) {
// Destroy table and remove hooks for buttons
$("#restrict-elements-table").unbind();
$("#restrict-elements-table").bootstrapTable("destroy");
@@ -254,8 +264,54 @@ $(function() {
$("#h2").addClass("hidden");
$("#h3").addClass("hidden");
$("#h4").addClass("hidden");
$("#add_element").val("");
});
function startTable(type, userId) {
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;
}
$("#restrict-elements-table").bootstrapTable({
formatNoMatches: function () {
return "";
@@ -269,6 +325,10 @@ $(function() {
return {classes: "bg-dark-danger"};
}
},
onLoadSuccess: function () {
$(".no-records-found").addClass("hidden");
$(".fixed-table-loading").addClass("hidden");
},
onClickCell: function (field, value, row) {
if (field === 3) {
$.ajax ({
@@ -322,28 +382,192 @@ $(function() {
return;
});
}
$("#get_column_values").on("click", function() {
startTable(1, 0);
$("#h2").removeClass("hidden");
$("#restrictModal").on("show.bs.modal", function(e) {
var target = $(e.relatedTarget).attr('id');
var dataId;
$(e.relatedTarget).one('focus', function(e){$(this).blur();});
//$(e.relatedTarget).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);
});
$("#get_tags").on("click", function() {
startTable(0, 0);
$("#h1").removeClass("hidden");
});
$("#get_user_column_values").on("click", function() {
startTable(3, $(this).data("id"));
$("#h4").removeClass("hidden");
// 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);
});
$("#get_user_tags").on("click", function() {
startTable(2, $(this).data("id"));
$(this)[0].blur();
$("#h3").removeClass("hidden");
$("#user-table").bootstrapTable({
sidePagination: "server",
pagination: true,
paginationLoop: false,
paginationDetailHAlign: " hidden",
paginationHAlign: "left",
idField: "id",
uniqueId: "id",
search: true,
showColumns: true,
searchAlign: "left",
showSearchButton : true,
searchOnEnterKey: true,
checkboxHeader: true,
maintainMetaData: true,
responseHandler: responseHandler,
columns: user_column,
formatNoMatches: function () {
return "";
},
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();
var index = elText.lastIndexOf('\n', elText.length - 2);
if ( index > -1) {
elText = elText.substr(index);
}
$(this).next().text(elText);
});
},
onLoadSuccess: function () {
var guest = $(".editable[data-name='name'][data-value='Guest']");
guest.editable("disable");
$(".editable[data-name='locale'][data-pk='"+guest.data("pk")+"']").editable("disable");
$("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);
// ToDo: Disable delete
},
// eslint-disable-next-line no-unused-vars
/*onEditableSave: function (field, row, oldvalue, $el) {
if (field === "title" || field === "authors") {
$.ajax({
method:"get",
dataType: "json",
url: window.location.pathname + "/../../ajax/sort_value/" + field + "/" + row.id,
success: function success(data) {
var key = Object.keys(data)[0];
$("#books-table").bootstrapTable("updateCellByUniqueId", {
id: row.id,
field: key,
value: data[key]
});
// console.log(data);
}
});
}
},*/
// eslint-disable-next-line no-unused-vars
onColumnSwitch: function (field, checked) {
var visible = $("#user-table").bootstrapTable("getVisibleColumns");
var hidden = $("#user-table").bootstrapTable("getHiddenColumns");
var st = "";
visible.forEach(function(item) {
st += "\"" + item.name + "\":\"" + "true" + "\",";
});
hidden.forEach(function(item) {
st += "\"" + item.name + "\":\"" + "false" + "\",";
});
st = st.slice(0, -1);
$.ajax({
method:"post",
contentType: "application/json; charset=utf-8",
dataType: "json",
url: window.location.pathname + "/../../ajax/user_table_settings",
data: "{" + st + "}",
});
},
});
$("#user_delete_selection").click(function() {
$("#user-table").bootstrapTable("uncheckAll");
});
function user_handle (userId) {
$.ajax({
method:"post",
url: window.location.pathname + "/../../ajax/deleteuser",
data: {"userid":userId}
});
$.ajax({
method:"get",
url: window.location.pathname + "/../../ajax/listusers",
async: true,
timeout: 900,
success:function(data) {
$("#user-table").bootstrapTable("load", data);
}
});
}
$("#user-table").on("click-cell.bs.table", function (field, value, row, $element) {
if (value === "denied_column_value") {
ConfirmDialog("btndeluser", "GeneralDeleteModal", $element.id, user_handle);
}
});
$("#user-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 < 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");
$(".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");
$(".header_select").removeAttr("disabled");
}
});
});
/* Function for deleting domain restrictions */
function TableActions (value, row) {
return [
@@ -354,7 +578,10 @@ function TableActions (value, row) {
].join("");
}
function editEntry(param)
{
console.log(param);
}
/* Function for deleting domain restrictions */
function RestrictionActions (value, row) {
return [
@@ -373,6 +600,15 @@ function EbookActions (value, row) {
].join("");
}
/* Function for deleting books */
function UserActions (value, row) {
return [
"<div class=\"user-remove\" data-target=\"#GeneralDeleteModal\" title=\"Remove\">",
"<i class=\"glyphicon glyphicon-trash\"></i>",
"</div>"
].join("");
}
/* Function for keeping checked rows */
function responseHandler(res) {
$.each(res.rows, function (i, row) {
@@ -380,3 +616,122 @@ function responseHandler(res) {
});
return res;
}
function singleUserFormatter(value, row) {
return '<a class="btn btn-default" href="/admin/user/' + row.id + '">' + this.buttontext + '</a>'
}
function checkboxFormatter(value, row, index){
if(value & this.column)
return '<input type="checkbox" class="chk" data-pk="' + row.id + '" data-name="' + this.name + '" checked onchange="checkboxChange(this, ' + row.id + ', \'' + this.field + '\', ' + this.column + ')">';
else
return '<input type="checkbox" class="chk" data-pk="' + row.id + '" data-name="' + this.name + '" onchange="checkboxChange(this, ' + row.id + ', \'' + this.field + '\', ' + this.column + ')">';
}
function checkboxChange(checkbox, userId, field, field_index) {
$.ajax({
method:"post",
url: window.location.pathname + "/../../ajax/editlistusers/" + field,
data: {"pk":userId, "field_index":field_index, "value": checkbox.checked}
/*<div className="editable-buttons">
<button type="button" className="btn btn-default btn-sm editable-cancel"><i
className="glyphicon glyphicon-remove"></i></button>
</div>*/
/*<div className="editable-error-block help-block" style="">Text to show</div>*/
});
$.ajax({
method:"get",
url: window.location.pathname + "/../../ajax/listusers",
async: true,
timeout: 900,
success:function(data) {
$("#user-table").bootstrapTable("load", data);
}
});
}
function deactivateHeaderButtons(e) {
$("#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");
$(".header_select").attr("disabled", true);
}
function selectHeader(element, field) {
if (element.value !== "None") {
confirmDialog(element.id, "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, "value": element.value},
success: function () {
$.ajax({
method: "get",
url: window.location.pathname + "/../../ajax/listusers",
async: true,
timeout: 900,
success: function (data) {
$("#user-table").bootstrapTable("load", data);
deactivateHeaderButtons();
}
});
}
});
});
}
}
function checkboxHeader(CheckboxState, field, field_index) {
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},
success: function () {
$.ajax({
method: "get",
url: window.location.pathname + "/../../ajax/listusers",
async: true,
timeout: 900,
success: function (data) {
$("#user-table").bootstrapTable("load", data);
$("#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");
$(".header_select").attr("disabled", true);
}
});
}
});
});
}
function user_handle (userId) {
$.ajax({
method:"post",
url: window.location.pathname + "/../../ajax/deleteuser",
data: {"userid":userId}
});
$.ajax({
method:"get",
url: window.location.pathname + "/../../ajax/listusers",
async: true,
timeout: 900,
success:function(data) {
$("#user-table").bootstrapTable("load", data);
}
});
}
function test(){
console.log("hello");
}