125 lines
3.2 KiB
JavaScript
125 lines
3.2 KiB
JavaScript
|
|
|
||
|
|
// =============
|
||
|
|
// Voter Summary
|
||
|
|
// =============
|
||
|
|
|
||
|
|
$(document).ready(function () {
|
||
|
|
|
||
|
|
var $application = $("#APPLICATION_MNEMONIC").val(), $sessionStorage = JSON.parse(sessionStorage.getItem($application) || "{}");
|
||
|
|
|
||
|
|
var default_tab = "Subscriptions";
|
||
|
|
|
||
|
|
// --------------
|
||
|
|
// 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});
|
||
|
|
|
||
|
|
// ---------------------------
|
||
|
|
// Set and Show the Active Tab
|
||
|
|
// --------------------------
|
||
|
|
|
||
|
|
$sessionStorage.voterSummary_tab = $sessionStorage.voterSummary_tab || default_tab;
|
||
|
|
|
||
|
|
sessionStorage.setItem($application, JSON.stringify($sessionStorage));
|
||
|
|
|
||
|
|
$("#tab-" + ($sessionStorage.voterSummary_tab || default_tab)).tab("show");
|
||
|
|
|
||
|
|
// --------------------
|
||
|
|
// Capture a Tab Change
|
||
|
|
// --------------------
|
||
|
|
|
||
|
|
$(".nav-tabs a[data-bs-toggle='tab']").on("shown.bs.tab", function (e) {
|
||
|
|
|
||
|
|
$sessionStorage.voterSummary_tab = $(e.target).attr("data-tab");
|
||
|
|
|
||
|
|
sessionStorage.setItem($application, JSON.stringify($sessionStorage));
|
||
|
|
|
||
|
|
});
|
||
|
|
|
||
|
|
// ==============
|
||
|
|
// Action Buttons
|
||
|
|
// ==============
|
||
|
|
|
||
|
|
// -----------
|
||
|
|
// Done Button
|
||
|
|
// -----------
|
||
|
|
|
||
|
|
$(".btnDone").on("click", function () {
|
||
|
|
|
||
|
|
$sessionStorage.action = $sessionStorage.voterSummary || "";
|
||
|
|
|
||
|
|
formSubmit($sessionStorage);
|
||
|
|
|
||
|
|
});
|
||
|
|
|
||
|
|
// -----------
|
||
|
|
// Edit Button
|
||
|
|
// -----------
|
||
|
|
|
||
|
|
$(".btnEdit").on("click", function () {
|
||
|
|
|
||
|
|
$sessionStorage.action = "Voters.editVoter";
|
||
|
|
$sessionStorage.editVoter = "Voters.voterSummary";
|
||
|
|
$sessionStorage.deleteVoter = "Voters.setupVoters";
|
||
|
|
|
||
|
|
sessionStorage.setItem($application, JSON.stringify($sessionStorage));
|
||
|
|
|
||
|
|
formSubmit($sessionStorage);
|
||
|
|
|
||
|
|
});
|
||
|
|
|
||
|
|
// ------------
|
||
|
|
// Print Button
|
||
|
|
// ------------
|
||
|
|
|
||
|
|
$(".btnPrint").on("click", function (e) {
|
||
|
|
|
||
|
|
e.preventDefault();
|
||
|
|
|
||
|
|
window.open("", "PrintTab");
|
||
|
|
|
||
|
|
$("input[name = 'voter_serial']", "#PrintVoterSummaryForm").val($sessionStorage.voter_serial);
|
||
|
|
$("#PrintVoterSummaryForm").submit();
|
||
|
|
|
||
|
|
});
|
||
|
|
|
||
|
|
// -------------
|
||
|
|
// Delete Button
|
||
|
|
// -------------
|
||
|
|
|
||
|
|
$(".btnDelete").on("click", function () {
|
||
|
|
|
||
|
|
$("#confirm-dialog").removeClass().addClass("modal confirm-delete-voter")
|
||
|
|
.find(".modal-title").html("Confirm Delete Voter").end()
|
||
|
|
.find(".modal-body").html("Are you sure you wish to delete this Voter?").end()
|
||
|
|
.modal("show");
|
||
|
|
|
||
|
|
});
|
||
|
|
|
||
|
|
$("body").on("click", ".confirm-delete-voter .btnConfirmDialogConfirm", function () {
|
||
|
|
|
||
|
|
$.post("./", {action: "Voters.deleteVoter", voter_serial: $sessionStorage.voter_serial})
|
||
|
|
|
||
|
|
.done(function () {
|
||
|
|
|
||
|
|
$sessionStorage.action = $sessionStorage.deleteVoter || "";
|
||
|
|
$sessionStorage.toast = "Voter was Deleted";
|
||
|
|
|
||
|
|
sessionStorage.setItem($application, JSON.stringify($sessionStorage));
|
||
|
|
|
||
|
|
formSubmit($sessionStorage);
|
||
|
|
|
||
|
|
});
|
||
|
|
|
||
|
|
});
|
||
|
|
|
||
|
|
});
|