"use strict";
/* eslint-disable @typescript-eslint/no-non-null-assertion, unicorn/prefer-module */
Object.defineProperty(exports, "__esModule", { value: true });
let lotOccupantTypes = exports.lotOccupantTypes;
delete exports.lotOccupantTypes;
const updateLotOccupantType = (submitEvent) => {
submitEvent.preventDefault();
cityssm.postJSON(los.urlPrefix + "/admin/doUpdateLotOccupantType", submitEvent.currentTarget, (responseJSON) => {
if (responseJSON.success) {
lotOccupantTypes = responseJSON.lotOccupantTypes;
bulmaJS.alert({
message: exports.aliases.lot +
" " +
exports.aliases.occupant +
" Type Updated Successfully",
contextualColorName: "success"
});
}
else {
bulmaJS.alert({
title: "Error Updating " +
exports.aliases.lot +
" " +
exports.aliases.occupant +
" Type",
message: responseJSON.errorMessage || "",
contextualColorName: "danger"
});
}
});
};
const deleteLotOccupantType = (clickEvent) => {
const tableRowElement = clickEvent.currentTarget.closest("tr");
const lotOccupantTypeId = tableRowElement.dataset.lotOccupantTypeId;
const doDelete = () => {
cityssm.postJSON(los.urlPrefix + "/admin/doDeleteLotOccupantType", {
lotOccupantTypeId
}, (responseJSON) => {
if (responseJSON.success) {
lotOccupantTypes = responseJSON.lotOccupantTypes;
if (lotOccupantTypes.length === 0) {
renderLotOccupantTypes();
}
else {
tableRowElement.remove();
}
bulmaJS.alert({
message: exports.aliases.lot +
" " +
exports.aliases.occupant +
" Type Deleted Successfully",
contextualColorName: "success"
});
}
else {
bulmaJS.alert({
title: "Error Deleting " +
exports.aliases.lot +
" " +
exports.aliases.occupant +
" Type",
message: responseJSON.errorMessage || "",
contextualColorName: "danger"
});
}
});
};
bulmaJS.confirm({
title: "Delete " + exports.aliases.lot + " " + exports.aliases.occupant + " Type",
message: "Are you sure you want to delete this " +
exports.aliases.lot.toLowerCase() +
" " +
exports.aliases.occupant.toLowerCase() +
" type?
" +
"Note that no " +
exports.aliases.lot.toLowerCase() +
" " +
exports.aliases.occupancy.toLowerCase() +
" will be removed.",
messageIsHtml: true,
contextualColorName: "warning",
okButton: {
text: "Yes, Delete " + exports.aliases.lot + " " + exports.aliases.occupant + " Type",
callbackFunction: doDelete
}
});
};
const moveLotOccupantTypeUp = (clickEvent) => {
const tableRowElement = clickEvent.currentTarget.closest("tr");
const lotOccupantTypeId = tableRowElement.dataset.lotOccupantTypeId;
cityssm.postJSON(los.urlPrefix + "/admin/doMoveLotOccupantTypeUp", {
lotOccupantTypeId,
moveToTop: clickEvent.shiftKey ? "1" : "0"
}, (responseJSON) => {
if (responseJSON.success) {
lotOccupantTypes = responseJSON.lotOccupantTypes;
renderLotOccupantTypes();
}
else {
bulmaJS.alert({
title: "Error Moving " +
exports.aliases.lot +
" " +
exports.aliases.occupant +
" Type",
message: responseJSON.errorMessage || "",
contextualColorName: "danger"
});
}
});
};
const moveLotOccupantTypeDown = (clickEvent) => {
const tableRowElement = clickEvent.currentTarget.closest("tr");
const lotOccupantTypeId = tableRowElement.dataset.lotOccupantTypeId;
cityssm.postJSON(los.urlPrefix + "/admin/doMoveLotOccupantTypeDown", {
lotOccupantTypeId,
moveToBottom: clickEvent.shiftKey ? "1" : "0"
}, (responseJSON) => {
if (responseJSON.success) {
lotOccupantTypes = responseJSON.lotOccupantTypes;
renderLotOccupantTypes();
}
else {
bulmaJS.alert({
title: "Error Moving " +
exports.aliases.lot +
" " +
exports.aliases.occupant +
" Type",
message: responseJSON.errorMessage || "",
contextualColorName: "danger"
});
}
});
};
const renderLotOccupantTypes = () => {
const containerElement = document.querySelector("#container--lotOccupantTypes");
if (lotOccupantTypes.length === 0) {
containerElement.innerHTML =
"