96 lines
2.5 KiB
JavaScript
96 lines
2.5 KiB
JavaScript
|
|
// =============
|
|
// Add Political Party
|
|
// =============
|
|
|
|
$(document).ready(function () {
|
|
|
|
var $application = $("#APPLICATION_MNEMONIC").val(), $sessionStorage = JSON.parse(sessionStorage.getItem($application) || "{}");
|
|
|
|
// -----------
|
|
// Input Masks
|
|
// -----------
|
|
|
|
$("#politicalparty_code").inputmask({
|
|
regex: "[A-Za-z]{0,3}"
|
|
});
|
|
|
|
// -----------
|
|
// Save Button
|
|
// -----------
|
|
|
|
$(".btnSave").on("click", function (e) {
|
|
e.preventDefault();
|
|
$("#editPoliticalParty").submit();
|
|
});
|
|
|
|
// --------------
|
|
// Cancel Button.
|
|
// --------------
|
|
|
|
$(".btnCancel").on("click", function () {
|
|
formSubmit({action: $sessionStorage.addPoliticalParty});
|
|
});
|
|
|
|
// -------------
|
|
// Delete Button
|
|
// -------------
|
|
|
|
$(".btnDelete").on("click", function () {
|
|
|
|
$("#confirm-dialog").removeClass().addClass("modal confirm-delete-race-code")
|
|
.find(".modal-title").html("Confirm Delete this Political Party").end()
|
|
.find(".modal-body").html("Are you sure you wish to delete this Political Party?").end()
|
|
.modal("show");
|
|
|
|
});
|
|
|
|
$("body").on("click", ".confirm-delete-race-code .btnConfirmDialogConfirm", function () {
|
|
|
|
$.post("./", {action: "PoliticalParties.deletePoliticalParty", politicalparty_serial: $sessionStorage.politicalparty_serial})
|
|
.done(function () {
|
|
formSubmit({action: $sessionStorage.deletePoliticalParty});
|
|
});
|
|
|
|
});
|
|
|
|
|
|
// ---------------
|
|
// Validate Inputs
|
|
// ---------------
|
|
|
|
$("#editPoliticalParty").submit(function (e) {
|
|
|
|
var politicalparty_code = $("#politicalparty_code"), politicalparty_name = $("#politicalparty_name");
|
|
|
|
clearInputErrors();
|
|
|
|
if (isBlank(politicalparty_code)) {
|
|
createInputError(politicalparty_code, "Code is required");
|
|
return false;
|
|
}
|
|
|
|
if (isBlank(politicalparty_name)) {
|
|
createInputError(politicalparty_name, "Name is required");
|
|
return false;
|
|
}
|
|
|
|
|
|
e.preventDefault();
|
|
|
|
$.post("./", $(this).serialize())
|
|
|
|
.done(function () {
|
|
|
|
$sessionStorage.action = $sessionStorage.editPoliticalParty || "";
|
|
$sessionStorage.toast = "Political Party updated";
|
|
|
|
sessionStorage.setItem($application, JSON.stringify($sessionStorage));
|
|
|
|
formSubmit($sessionStorage);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}); |