generated from jric11/baseProject
Chat's updates for security, db and workflow
Security and workflow regressions / regression (push) Has been cancelled
Security and workflow regressions / regression (push) Has been cancelled
This commit is contained in:
+15
-283
@@ -1,283 +1,15 @@
|
||||
|
||||
// ============
|
||||
// User Summary
|
||||
// ============
|
||||
|
||||
$(document).ready(function () {
|
||||
|
||||
var $application = $("#APPLICATION_MNEMONIC").val(), $sessionStorage = JSON.parse(sessionStorage.getItem($application) || "{}");
|
||||
|
||||
var default_tab = "Subscriptions";
|
||||
|
||||
var user_role = $("#USER_ROLE").val();
|
||||
|
||||
//
|
||||
// --------------
|
||||
// Select Picker.
|
||||
// --------------
|
||||
|
||||
$(".search-dropdown").selectpicker({noneSelectedText: "",
|
||||
style: "",
|
||||
styleBase: "form-select form-select-sm",
|
||||
iconBase: "bi",
|
||||
virtualScroll: true,
|
||||
size: 10,
|
||||
selectOnTab: true,
|
||||
containter: "body",
|
||||
liveSearch: true});
|
||||
|
||||
// -----------
|
||||
// Input Masks
|
||||
// -----------
|
||||
|
||||
$(".date-mask").inputmask({alias: "datetime",
|
||||
inputFormat: "mm/dd/yyyy",
|
||||
placeholder: "MM/DD/YYYY",
|
||||
showMaskOnHover: false});
|
||||
|
||||
$(".numeric-mask").inputmask("9{0,9}", {showMaskOnHover: false});
|
||||
|
||||
$(".numeric-2-mask").inputmask({alias: "numeric",
|
||||
showMaskOnHover: false,
|
||||
placeholder: "0",
|
||||
groupSeparator: ",",
|
||||
allowMinus: false,
|
||||
digitsOptional: false,
|
||||
digits: 2});
|
||||
|
||||
// ------------
|
||||
// Date Pickers
|
||||
// ------------
|
||||
|
||||
$("#user_completed").datepicker({format: "mm-dd-yyyy",
|
||||
container: "div.user_completed",
|
||||
keyboardNavigation: false,
|
||||
showOnFocus: false,
|
||||
autoclose: true,
|
||||
endDate: "0d",
|
||||
orientation: "left bottom",
|
||||
todayBtn: "linked",
|
||||
todayHighlight: true});
|
||||
|
||||
// Disable standard Drag/Drop processing.
|
||||
|
||||
$("html").on("dragenter dragover dragleave drop", function (e) {
|
||||
|
||||
e.preventDefault();
|
||||
|
||||
});
|
||||
|
||||
// ---------------------------
|
||||
// Set and Show the Active Tab
|
||||
// --------------------------
|
||||
|
||||
$sessionStorage.userSummary_tab = $sessionStorage.userSummary_tab || default_tab;
|
||||
|
||||
sessionStorage.setItem($application, JSON.stringify($sessionStorage));
|
||||
|
||||
$("#tab-" + ($sessionStorage.userSummary_tab || default_tab)).tab("show");
|
||||
|
||||
// --------------------
|
||||
// Capture a Tab Change
|
||||
// --------------------
|
||||
|
||||
$(".nav-tabs a[data-bs-toggle='tab']").on("shown.bs.tab", function (e) {
|
||||
|
||||
$sessionStorage.userSummary_tab = $(e.target).attr("data-tab");
|
||||
|
||||
sessionStorage.setItem($application, JSON.stringify($sessionStorage));
|
||||
|
||||
});
|
||||
|
||||
// ----------------------
|
||||
// Active Status Dropdown
|
||||
// ----------------------
|
||||
|
||||
$("#user_active").on("change", function () {
|
||||
|
||||
formPost({action: "Users.updateActiveStatus", user_serial: $sessionStorage.user_serial, user_active: $(this).val()});
|
||||
|
||||
location.reload();
|
||||
});
|
||||
|
||||
// --------------------
|
||||
// Reset Users Password
|
||||
// ---------------------
|
||||
|
||||
$(".btnResetPassword").on("click", function () {
|
||||
|
||||
formPost({action: "Users.resetPassword", user_serial: $sessionStorage.user_serial});
|
||||
|
||||
$sessionStorage.toast = "Passsword Reset";
|
||||
location.reload();
|
||||
|
||||
});
|
||||
|
||||
// ==============
|
||||
// Action Buttons
|
||||
// ==============
|
||||
|
||||
// -----------
|
||||
// Done Button
|
||||
// -----------
|
||||
|
||||
$(".btnDone").on("click", function () {
|
||||
|
||||
$sessionStorage.action = $sessionStorage.userSummary || "";
|
||||
|
||||
formSubmit($sessionStorage);
|
||||
|
||||
});
|
||||
|
||||
// -----------
|
||||
// Edit Button
|
||||
// -----------
|
||||
|
||||
$(".btnEdit").on("click", function () {
|
||||
|
||||
if (user_role === "Guest") {
|
||||
return false;
|
||||
}
|
||||
|
||||
$sessionStorage.action = "Users.editUser";
|
||||
$sessionStorage.editUser = "Users.userSummary";
|
||||
$sessionStorage.deleteUser = "Users.setupUsers";
|
||||
|
||||
sessionStorage.setItem($application, JSON.stringify($sessionStorage));
|
||||
|
||||
formSubmit($sessionStorage);
|
||||
|
||||
});
|
||||
|
||||
// ------------
|
||||
// Print Button
|
||||
// ------------
|
||||
|
||||
$(".btnPrint").on("click", function (e) {
|
||||
|
||||
e.preventDefault();
|
||||
|
||||
window.open("", "PrintTab");
|
||||
|
||||
$("input[name = 'user_serial']", "#PrintUserSummaryForm").val($sessionStorage.user_serial);
|
||||
$("#PrintUserSummaryForm").submit();
|
||||
|
||||
});
|
||||
|
||||
// -------------
|
||||
// Delete Button
|
||||
// -------------
|
||||
|
||||
$(".btnDelete").on("click", function () {
|
||||
|
||||
$("#confirm-dialog").removeClass().addClass("modal confirm-delete-user")
|
||||
.find(".modal-title").html("Confirm Delete User").end()
|
||||
.find(".modal-body").html("Are you sure you wish to delete this User?").end()
|
||||
.modal("show");
|
||||
|
||||
});
|
||||
|
||||
$("body").on("click", ".confirm-delete-user .btnConfirmDialogConfirm", function () {
|
||||
|
||||
$.post("./", {action: "Users.deleteUser", user_serial: $sessionStorage.user_serial})
|
||||
|
||||
.done(function () {
|
||||
|
||||
$sessionStorage.action = $sessionStorage.deleteUser || "";
|
||||
$sessionStorage.toast = "User was Deleted";
|
||||
|
||||
sessionStorage.setItem($application, JSON.stringify($sessionStorage));
|
||||
|
||||
formSubmit($sessionStorage);
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
// =========
|
||||
// Notes Tab
|
||||
// =========
|
||||
|
||||
// ---------------
|
||||
// Add Note Button
|
||||
// ---------------
|
||||
|
||||
$(".btnAddNote").on("click", function () {
|
||||
|
||||
$sessionStorage.action = "Notes.addNote";
|
||||
$sessionStorage.note_type = "User";
|
||||
$sessionStorage.note_reference = $sessionStorage.user_serial;
|
||||
$sessionStorage.addNote = "Users.userSummary";
|
||||
|
||||
sessionStorage.setItem($application, JSON.stringify($sessionStorage));
|
||||
|
||||
formSubmit($sessionStorage);
|
||||
|
||||
});
|
||||
|
||||
// ---------
|
||||
// Edit Note
|
||||
// ---------
|
||||
|
||||
$("#notes-table tbody").on("click touch", "tr", function (e) {
|
||||
|
||||
e.preventDefault();
|
||||
|
||||
if (user_role === "Guest") {
|
||||
return false;
|
||||
}
|
||||
|
||||
$sessionStorage.action = "Notes.editNote";
|
||||
$sessionStorage.note_serial = $(this).data("note-serial");
|
||||
$sessionStorage.editNote = "Users.userSummary";
|
||||
$sessionStorage.deleteNote = "Users.userSummary";
|
||||
|
||||
sessionStorage.setItem($application, JSON.stringify($sessionStorage));
|
||||
|
||||
formSubmit($sessionStorage);
|
||||
|
||||
});
|
||||
// =================
|
||||
// Subscriptions Tab
|
||||
// =================
|
||||
|
||||
// -------------------------------
|
||||
// Add Subscription to User Button
|
||||
// -------------------------------
|
||||
|
||||
$(".btnAddSubscription").on("click", function () {
|
||||
|
||||
$sessionStorage.action = "Subscriptions.addSubscriptionToUser";
|
||||
$sessionStorage.user_reference = $sessionStorage.user_serial;
|
||||
$sessionStorage.addSubscriptionToUser = "Users.userSummary";
|
||||
|
||||
sessionStorage.setItem($application, JSON.stringify($sessionStorage));
|
||||
|
||||
formSubmit($sessionStorage);
|
||||
|
||||
});
|
||||
|
||||
// --------------------------------
|
||||
// Edit Subscription to User Button
|
||||
// --------------------------------
|
||||
|
||||
$("#usersubscriptions-table tbody").on("click touch", "tr", function (e) {
|
||||
|
||||
e.preventDefault();
|
||||
|
||||
if (user_role === "Guest") {
|
||||
return false;
|
||||
}
|
||||
|
||||
$sessionStorage.action = "Subscriptions.editUsersSubscription";
|
||||
$sessionStorage.usersubscription_serial = $(this).data("usersubscription-serial");
|
||||
$sessionStorage.editUsersSubscription = "Users.userSummary";
|
||||
$sessionStorage.deleteUsersSubscription = "Users.userSummary";
|
||||
|
||||
sessionStorage.setItem($application, JSON.stringify($sessionStorage));
|
||||
|
||||
formSubmit($sessionStorage);
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
$(function(){
|
||||
const id=$('#summary_user_serial').val(), application=$('#APPLICATION_MNEMONIC').val();
|
||||
function summaryReturn(action,extra={}){
|
||||
const state={action:action,user_serial:id,userSummary:'Users.setupUsers',addNote:'Users.userSummary',editNote:'Users.userSummary',deleteNote:'Users.userSummary',editUser:'Users.userSummary',deleteUser:'Users.setupUsers',...extra};
|
||||
sessionStorage.setItem(application,JSON.stringify(state));formSubmit(state);
|
||||
}
|
||||
$('.summary-edit').on('click',()=>summaryReturn('Users.editUser'));
|
||||
$('.summary-back').on('click',()=>formSubmit({action:'Users.setupUsers'}));
|
||||
$('.summary-add-note').on('click',()=>summaryReturn('Notes.addNote',{note_type:'User',note_reference:id}));
|
||||
$('.summary-edit-note').on('click',function(){summaryReturn('Notes.editNote',{note_serial:$(this).data('note')});});
|
||||
$('.summary-invite').on('click',async function(){
|
||||
const button=$(this);button.prop('disabled',true);
|
||||
try{const result=await formPost({action:'Users.resetPassword',user_serial:id});showRequestMessage(result.message||'Password setup link sent.');}catch(error){}finally{button.prop('disabled',false);}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user