mirror of
				https://github.com/janeczku/calibre-web
				synced 2025-10-31 15:23:02 +00:00 
			
		
		
		
	Update list user editor (#1938)
This commit is contained in:
		| @@ -130,16 +130,6 @@ $("#back").click(function() { | |||||||
|  |  | ||||||
| function confirmDialog(id, dialogid, dataValue, yesFn, noFn) { | function confirmDialog(id, dialogid, dataValue, yesFn, noFn) { | ||||||
|     var $confirm = $("#" + dialogid); |     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 () { |     $("#btnConfirmYes-"+ dialogid).off('click').click(function () { | ||||||
|         yesFn(dataValue); |         yesFn(dataValue); | ||||||
|         $confirm.modal("hide"); |         $confirm.modal("hide"); | ||||||
| @@ -150,6 +140,16 @@ function confirmDialog(id, dialogid, dataValue, yesFn, noFn) { | |||||||
|         } |         } | ||||||
|         $confirm.modal("hide"); |         $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() { | $("#delete_confirm").click(function() { | ||||||
|   | |||||||
| @@ -19,6 +19,7 @@ | |||||||
| /* global getPath, confirmDialog */ | /* global getPath, confirmDialog */ | ||||||
|  |  | ||||||
| var selections = []; | var selections = []; | ||||||
|  | var reload = false; | ||||||
|  |  | ||||||
| $(function() { | $(function() { | ||||||
|     $("#books-table").on("check.bs.table check-all.bs.table uncheck.bs.table uncheck-all.bs.table", |     $("#books-table").on("check.bs.table check-all.bs.table uncheck.bs.table uncheck-all.bs.table", | ||||||
| @@ -456,7 +457,6 @@ $(function() { | |||||||
|         }, |         }, | ||||||
|         onLoadSuccess: function () { |         onLoadSuccess: function () { | ||||||
|             loadSuccess(); |             loadSuccess(); | ||||||
|             move_header_elements(); |  | ||||||
|         }, |         }, | ||||||
|         onColumnSwitch: function () { |         onColumnSwitch: function () { | ||||||
|             var visible = $("#user-table").bootstrapTable("getVisibleColumns"); |             var visible = $("#user-table").bootstrapTable("getVisibleColumns"); | ||||||
| @@ -500,35 +500,6 @@ $(function() { | |||||||
|         var func = $.inArray(e.type, ["check", "check-all"]) > -1 ? "union" : "difference"; |         var func = $.inArray(e.type, ["check", "check-all"]) > -1 ? "union" : "difference"; | ||||||
|         selections = window._[func](selections, ids); |         selections = window._[func](selections, ids); | ||||||
|         handle_header_buttons(); |         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_head").addClass("hidden"); | ||||||
|         $(".multi_selector").attr("aria-disabled", true); |         $(".multi_selector").attr("aria-disabled", true); | ||||||
|         $(".multi_selector").attr("disabled", true); |         $(".multi_selector").attr("disabled", true); | ||||||
|         $('.multi_selector').selectpicker('deselectAll'); |  | ||||||
|         $('.multi_selector').selectpicker('refresh'); |  | ||||||
|         $(".header_select").attr("disabled", true); |         $(".header_select").attr("disabled", true); | ||||||
|     } else { |     } else { | ||||||
|         $("#user_delete_selection").removeClass("disabled"); |         $("#user_delete_selection").removeClass("disabled"); | ||||||
| @@ -629,6 +598,11 @@ function loadSuccess() { | |||||||
|     $(".header_select").each(function() { |     $(".header_select").each(function() { | ||||||
|         $(this).prop("selectedIndex", 0); |         $(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")+"']").editable("disable"); | ||||||
|     $(".editable[data-name='locale'][data-pk='"+guest.data("pk")+"']").hide(); |     $(".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='admin_role'][data-pk='"+guest.data("pk")+"']").prop("disabled", true); | ||||||
| @@ -639,21 +613,21 @@ function loadSuccess() { | |||||||
| } | } | ||||||
|  |  | ||||||
| function move_header_elements() { | function move_header_elements() { | ||||||
|     $(".header_select").each(function() { |         $(".header_select").each(function () { | ||||||
|             var item = $(this).parent(); |             var item = $(this).parent(); | ||||||
|             var parent = item.parent().parent(); |             var parent = item.parent().parent(); | ||||||
|             if (parent.prop('nodeName') === "TH") { |             if (parent.prop('nodeName') === "TH") { | ||||||
|                 item.prependTo(parent); |                 item.prependTo(parent); | ||||||
|             } |             } | ||||||
|         }); |         }); | ||||||
|     $(".form-check").each(function() { |         $(".form-check").each(function () { | ||||||
|             var item = $(this).parent(); |             var item = $(this).parent(); | ||||||
|             var parent = item.parent().parent(); |             var parent = item.parent().parent(); | ||||||
|             if (parent.prop('nodeName') === "TH") { |             if (parent.prop('nodeName') === "TH") { | ||||||
|                 item.prependTo(parent); |                 item.prependTo(parent); | ||||||
|             } |             } | ||||||
|         }); |         }); | ||||||
|     $(".multi_select").each(function() { |         $(".multi_select").each(function () { | ||||||
|             var item = $(this); |             var item = $(this); | ||||||
|             var parent = item.parent().parent(); |             var parent = item.parent().parent(); | ||||||
|             if (parent.prop('nodeName') === "TH") { |             if (parent.prop('nodeName') === "TH") { | ||||||
| @@ -664,7 +638,7 @@ function move_header_elements() { | |||||||
|         $(".multi_selector").selectpicker(); |         $(".multi_selector").selectpicker(); | ||||||
|  |  | ||||||
|         // 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); | ||||||
| @@ -673,61 +647,60 @@ function move_header_elements() { | |||||||
|                 "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 () { | ||||||
|             $("#user-table").bootstrapTable("uncheckAll"); |             $("#user-table").bootstrapTable("uncheckAll"); | ||||||
|         }); |         }); | ||||||
|     $("#select_locale").on("change",function() { |         $("#select_locale").on("change", function () { | ||||||
|             selectHeader(this, "locale"); |             selectHeader(this, "locale"); | ||||||
|         }); |         }); | ||||||
|     $("#select_default_language").on("change",function() { |         $("#select_default_language").on("change", function () { | ||||||
|             selectHeader(this, "default_language"); |             selectHeader(this, "default_language"); | ||||||
|         }); |         }); | ||||||
|     $(".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); | ||||||
|         }); |         }); | ||||||
|  |  | ||||||
|     $(".button_head").on("click",function() { |         $(".button_head").on("click", function () { | ||||||
|             var result = $('#user-table').bootstrapTable('getSelections').map(a => a.id); |             var result = $('#user-table').bootstrapTable('getSelections').map(a => a.id); | ||||||
|             confirmDialog( |             confirmDialog( | ||||||
|                 "btndeluser", |                 "btndeluser", | ||||||
|                 "GeneralDeleteModal", |                 "GeneralDeleteModal", | ||||||
|                 0, |                 0, | ||||||
|             function() { |                 function () { | ||||||
|                     $.ajax({ |                     $.ajax({ | ||||||
|                     method:"post", |                         method: "post", | ||||||
|                         url: window.location.pathname + "/../../ajax/deleteuser", |                         url: window.location.pathname + "/../../ajax/deleteuser", | ||||||
|                         data: {"userid": result}, |                         data: {"userid": result}, | ||||||
|                         success: function (data) { |                         success: function (data) { | ||||||
|                         selections = selections.filter( ( el ) => !result.includes( el ) ); |                             selections = selections.filter((el) => !result.includes(el)); | ||||||
|                             handleListServerResponse(data); |                             handleListServerResponse(data); | ||||||
|                         }, |                         }, | ||||||
|                         error: function (data) { |                         error: function (data) { | ||||||
|                         handleListServerResponse([{type:"danger", message:data.responseText}]) |                             handleListServerResponse([{type: "danger", message: data.responseText}]) | ||||||
|                         }, |                         }, | ||||||
|                     }); |                     }); | ||||||
|                 } |                 } | ||||||
|             ); |             ); | ||||||
|         }); |         }); | ||||||
|  |  | ||||||
| } | } | ||||||
|  |  | ||||||
| function handleListServerResponse (data) { | function handleListServerResponse (data) { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Ozzie Isaacs
					Ozzie Isaacs