199 lines
5.0 KiB
JavaScript
199 lines
5.0 KiB
JavaScript
|
|
|
||
|
|
// ===================
|
||
|
|
// Setup HistoryCodes
|
||
|
|
// ===================
|
||
|
|
|
||
|
|
$(document).ready(function () {
|
||
|
|
|
||
|
|
var $application = $("#APPLICATION_MNEMONIC").val(), $sessionStorage = JSON.parse(sessionStorage.getItem($application) || "{}");
|
||
|
|
|
||
|
|
// -----------
|
||
|
|
// Find Button
|
||
|
|
// -----------
|
||
|
|
|
||
|
|
$(".btnFind").on("click", function () {
|
||
|
|
|
||
|
|
$sessionStorage.action = "HistoryCodes.setupHistoryCodes";
|
||
|
|
$sessionStorage.pagination = "first";
|
||
|
|
|
||
|
|
sessionStorage.setItem($application, JSON.stringify($sessionStorage));
|
||
|
|
|
||
|
|
formSubmit($sessionStorage);
|
||
|
|
|
||
|
|
});
|
||
|
|
|
||
|
|
$("#find_historycode").on("keyup", function (e) {
|
||
|
|
if (e.key === "Enter") {
|
||
|
|
$(".btnFind").trigger("click");
|
||
|
|
}
|
||
|
|
});
|
||
|
|
|
||
|
|
// -----------------
|
||
|
|
// Clear Find Button
|
||
|
|
// -----------------
|
||
|
|
|
||
|
|
$(".btnClearFind").on("click", function () {
|
||
|
|
|
||
|
|
$("#find_historycode").val("").trigger("change");
|
||
|
|
|
||
|
|
$sessionStorage.action = "HistoryCodes.setupHistoryCodes";
|
||
|
|
$sessionStorage.pagination = "first";
|
||
|
|
|
||
|
|
sessionStorage.setItem($application, JSON.stringify($sessionStorage));
|
||
|
|
|
||
|
|
formSubmit($sessionStorage);
|
||
|
|
|
||
|
|
});
|
||
|
|
|
||
|
|
// ------------------
|
||
|
|
// Pagination Buttons
|
||
|
|
// ------------------
|
||
|
|
|
||
|
|
$(".btnPagination").on("click", function () {
|
||
|
|
|
||
|
|
$sessionStorage.action = "HistoryCodes.setupHistoryCodes";
|
||
|
|
$sessionStorage.pagination = $(this).data("pagination");
|
||
|
|
|
||
|
|
sessionStorage.setItem($application, JSON.stringify($sessionStorage));
|
||
|
|
|
||
|
|
formSubmit($sessionStorage);
|
||
|
|
|
||
|
|
delete $sessionStorage.pagination;
|
||
|
|
|
||
|
|
sessionStorage.setItem($application, JSON.stringify($sessionStorage));
|
||
|
|
|
||
|
|
});
|
||
|
|
|
||
|
|
// ----------
|
||
|
|
// Add Button
|
||
|
|
// ----------
|
||
|
|
|
||
|
|
$(".btnAdd").on("click", function () {
|
||
|
|
|
||
|
|
$sessionStorage.action = "HistoryCodes.addHistoryCode";
|
||
|
|
$sessionStorage.addHistoryCode = "HistoryCodes.setupHistoryCodes";
|
||
|
|
|
||
|
|
sessionStorage.setItem($application, JSON.stringify($sessionStorage));
|
||
|
|
|
||
|
|
formSubmit($sessionStorage);
|
||
|
|
|
||
|
|
});
|
||
|
|
|
||
|
|
// -----------
|
||
|
|
// Done Button
|
||
|
|
// -----------
|
||
|
|
|
||
|
|
$(".btnDone").on("click", function () {
|
||
|
|
|
||
|
|
formSubmit({action: ""});
|
||
|
|
|
||
|
|
});
|
||
|
|
|
||
|
|
// -----------------
|
||
|
|
// Edit History Code
|
||
|
|
// -----------------
|
||
|
|
|
||
|
|
$("#historycodes-table tbody").on("click touch", "tr", function (e) {
|
||
|
|
|
||
|
|
e.preventDefault();
|
||
|
|
|
||
|
|
$sessionStorage.action = "HistoryCodes.editHistoryCode";
|
||
|
|
$sessionStorage.historycode_serial = $(e.target).closest("tr").data("historycode-serial");
|
||
|
|
$sessionStorage.editHistoryCode = "HistoryCodes.setupHistoryCodes";
|
||
|
|
$sessionStorage.deleteHistoryCode = "HistoryCodes.setupHistoryCodes";
|
||
|
|
|
||
|
|
sessionStorage.setItem($application, JSON.stringify($sessionStorage));
|
||
|
|
|
||
|
|
formSubmit($sessionStorage);
|
||
|
|
|
||
|
|
});
|
||
|
|
|
||
|
|
// -------------------
|
||
|
|
// Save Changed Inputs
|
||
|
|
// -------------------
|
||
|
|
|
||
|
|
$(".autosave").on("change", function (e) {
|
||
|
|
|
||
|
|
switch (e.target.type) {
|
||
|
|
|
||
|
|
case "text" :
|
||
|
|
$sessionStorage[e.target.name] = $(this).val();
|
||
|
|
break;
|
||
|
|
case "radio" :
|
||
|
|
$sessionStorage[e.target.name] = $(this).val();
|
||
|
|
break;
|
||
|
|
case "checkbox" :
|
||
|
|
$sessionStorage[e.target.name] = $(this).prop("checked");
|
||
|
|
break;
|
||
|
|
case "select-one" :
|
||
|
|
$sessionStorage[e.target.name] = $(this).val();
|
||
|
|
break;
|
||
|
|
case "hidden" :
|
||
|
|
$sessionStorage[e.target.name] = $(this).val();
|
||
|
|
break;
|
||
|
|
|
||
|
|
default :
|
||
|
|
$sessionStorage[e.target.name] = $(this).val();
|
||
|
|
break;
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
sessionStorage.setItem($application, JSON.stringify($sessionStorage));
|
||
|
|
|
||
|
|
});
|
||
|
|
|
||
|
|
// ----------------
|
||
|
|
// Initalize Inputs
|
||
|
|
// ----------------
|
||
|
|
|
||
|
|
$.each($sessionStorage, function (name, value) {
|
||
|
|
|
||
|
|
var $input = $(":input").filter("[name=" + name + "]");
|
||
|
|
|
||
|
|
if ($input.length > 0) {
|
||
|
|
|
||
|
|
switch ($input.prop("type")) {
|
||
|
|
|
||
|
|
case "text" :
|
||
|
|
$input.val(value);
|
||
|
|
break;
|
||
|
|
case "radio" :
|
||
|
|
$input.filter("[value=" + value + "]").prop("checked", true);
|
||
|
|
break;
|
||
|
|
case "checkbox" :
|
||
|
|
$input.prop("checked", value);
|
||
|
|
break;
|
||
|
|
case "select-one" :
|
||
|
|
$input.val(value);
|
||
|
|
break;
|
||
|
|
case "hidden" :
|
||
|
|
$input.val(value);
|
||
|
|
break;
|
||
|
|
|
||
|
|
default :
|
||
|
|
$input.val(value);
|
||
|
|
break;
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
});
|
||
|
|
|
||
|
|
// ------------------
|
||
|
|
// Save preset Inputs
|
||
|
|
// ------------------
|
||
|
|
|
||
|
|
$("input[type=radio]:checked").trigger("change");
|
||
|
|
|
||
|
|
// -----------------
|
||
|
|
// Per Page Dropdown
|
||
|
|
// -----------------
|
||
|
|
|
||
|
|
$("#historycodes_per_page").on("change", function () {
|
||
|
|
|
||
|
|
$(".btnFind").trigger("click");
|
||
|
|
|
||
|
|
});
|
||
|
|
|
||
|
|
});
|