refactoring

deepsource-autofix-76c6eb20
Dan Gowans 2022-12-29 13:11:21 -05:00
parent 830053b820
commit cb3c2c4492
8 changed files with 692 additions and 719 deletions

View File

@ -88,7 +88,7 @@ declare const bulmaJS: BulmaJS;
"</div>" +
"</div>";
if (feeCategory.fees!.length === 0) {
if (feeCategory.fees.length === 0) {
feeCategoryContainerElement.insertAdjacentHTML(
"beforeend",
'<div class="panel-block is-block">' +
@ -100,7 +100,7 @@ declare const bulmaJS: BulmaJS;
"</div>"
);
} else {
for (const fee of feeCategory.fees!) {
for (const fee of feeCategory.fees) {
const panelBlockElement = document.createElement("div");
panelBlockElement.className = "panel-block is-block container--fee";
@ -524,7 +524,7 @@ declare const bulmaJS: BulmaJS;
for (const feeCategory of feeCategories) {
const optionElement = document.createElement("option");
optionElement.value = feeCategory.feeCategoryId!.toString();
optionElement.value = feeCategory.feeCategoryId.toString();
optionElement.textContent = feeCategory.feeCategory!;
if (feeCategory.feeCategoryId === feeCategoryId) {
@ -653,7 +653,7 @@ declare const bulmaJS: BulmaJS;
return currentFeeCategory.feeCategoryId === feeCategoryId;
})!;
const fee = feeCategory.fees!.find((currentFee) => {
const fee = feeCategory.fees.find((currentFee) => {
return currentFee.feeId === feeId;
})!;
@ -781,7 +781,7 @@ declare const bulmaJS: BulmaJS;
editModalElement = modalElement;
(modalElement.querySelector("#feeEdit--feeId") as HTMLInputElement).value =
fee.feeId!.toString();
fee.feeId.toString();
const feeCategoryElement = modalElement.querySelector(
"#feeEdit--feeCategoryId"
@ -789,7 +789,7 @@ declare const bulmaJS: BulmaJS;
for (const feeCategory of feeCategories) {
const optionElement = document.createElement("option");
optionElement.value = feeCategory.feeCategoryId!.toString();
optionElement.value = feeCategory.feeCategoryId.toString();
optionElement.textContent = feeCategory.feeCategory!;
if (feeCategory.feeCategoryId === feeCategoryId) {

View File

@ -344,7 +344,7 @@ declare const bulmaJS: BulmaJS;
modalElement.querySelector(
"#lotTypeFieldEdit--lotTypeFieldId"
) as HTMLInputElement
).value = lotTypeField.lotTypeFieldId!.toString();
).value = lotTypeField.lotTypeFieldId.toString();
(
modalElement.querySelector(
@ -494,7 +494,7 @@ declare const bulmaJS: BulmaJS;
panelBlockElement.classList.add("is-hidden");
}
panelBlockElement.dataset.lotTypeFieldId = lotTypeField.lotTypeFieldId!.toString();
panelBlockElement.dataset.lotTypeFieldId = lotTypeField.lotTypeFieldId.toString();
panelBlockElement.innerHTML =
'<div class="level is-mobile">' +

View File

@ -485,18 +485,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
"use strict";
/* eslint-disable @typescript-eslint/no-non-null-assertion, unicorn/prefer-module */
Object.defineProperty(exports, "__esModule", { value: true });
if (isCreate) {
const lotOccupantTypeIdElement = document.querySelector("#lotOccupancy--lotOccupantTypeId");
lotOccupantTypeIdElement.addEventListener("change", () => {
const occupantFields = formElement.querySelectorAll("[data-table='LotOccupancyOccupant']");
for (const occupantField of occupantFields) {
occupantField.disabled = lotOccupantTypeIdElement.value === "";
}
});
}
else {
let lotOccupancyOccupants = exports.lotOccupancyOccupants;
delete exports.lotOccupancyOccupants;
let lotOccupancyOccupants;
const openEditLotOccupancyOccupant = (clickEvent) => {
const lotOccupantIndex = Number.parseInt(clickEvent.currentTarget.closest("tr").dataset.lotOccupantIndex, 10);
const lotOccupancyOccupant = lotOccupancyOccupants.find((currentLotOccupancyOccupant) => {
@ -532,8 +521,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
const optionElement = document.createElement("option");
optionElement.value = lotOccupantType.lotOccupantTypeId.toString();
optionElement.textContent = lotOccupantType.lotOccupantType;
if (lotOccupantType.lotOccupantTypeId ===
lotOccupancyOccupant.lotOccupantTypeId) {
if (lotOccupantType.lotOccupantTypeId === lotOccupancyOccupant.lotOccupantTypeId) {
optionElement.selected = true;
lotOccupantTypeSelected = true;
}
@ -569,8 +557,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
});
};
const deleteLotOccupancyOccupant = (clickEvent) => {
const lotOccupantIndex = clickEvent.currentTarget.closest("tr")
.dataset.lotOccupantIndex;
const lotOccupantIndex = clickEvent.currentTarget.closest("tr").dataset
.lotOccupantIndex;
const doDelete = () => {
cityssm.postJSON(los.urlPrefix + "/lotOccupancies/doDeleteLotOccupancyOccupant", {
lotOccupancyId,
@ -591,9 +579,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
};
bulmaJS.confirm({
title: "Remove " + exports.aliases.occupant + "?",
message: "Are you sure you want to remove this " +
exports.aliases.occupant.toLowerCase() +
"?",
message: "Are you sure you want to remove this " + exports.aliases.occupant.toLowerCase() + "?",
okButton: {
text: "Yes, Remove " + exports.aliases.occupant,
callbackFunction: doDelete
@ -657,8 +643,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
"</td>") +
("<td>" +
(lotOccupancyOccupant.occupantPhoneNumber
? cityssm.escapeHTML(lotOccupancyOccupant.occupantPhoneNumber) +
"<br />"
? cityssm.escapeHTML(lotOccupancyOccupant.occupantPhoneNumber) + "<br />"
: "") +
(lotOccupancyOccupant.occupantEmailAddress
? cityssm.escapeHTML(lotOccupancyOccupant.occupantEmailAddress)
@ -684,6 +669,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
}
occupantsContainer.append(tableElement);
};
if (isCreate) {
const lotOccupantTypeIdElement = document.querySelector("#lotOccupancy--lotOccupantTypeId");
lotOccupantTypeIdElement.addEventListener("change", () => {
const occupantFields = formElement.querySelectorAll("[data-table='LotOccupancyOccupant']");
for (const occupantField of occupantFields) {
occupantField.disabled = lotOccupantTypeIdElement.value === "";
}
});
}
else {
lotOccupancyOccupants = exports.lotOccupancyOccupants;
delete exports.lotOccupancyOccupants;
document.querySelector("#button--addOccupant").addEventListener("click", () => {
let addCloseModalFunction;
let addFormElement;
@ -764,8 +761,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
cityssm.escapeHTML(occupant.occupantAddress1 || "") +
"<br />" +
(occupant.occupantAddress2
? cityssm.escapeHTML(occupant.occupantAddress2) +
"<br />"
? cityssm.escapeHTML(occupant.occupantAddress2) + "<br />"
: "") +
cityssm.escapeHTML(occupant.occupantCity || "") +
", " +

View File

@ -1,18 +1,7 @@
"use strict";
/* eslint-disable @typescript-eslint/no-non-null-assertion, unicorn/prefer-module */
Object.defineProperty(exports, "__esModule", { value: true });
if (isCreate) {
const lotOccupantTypeIdElement = document.querySelector("#lotOccupancy--lotOccupantTypeId");
lotOccupantTypeIdElement.addEventListener("change", () => {
const occupantFields = formElement.querySelectorAll("[data-table='LotOccupancyOccupant']");
for (const occupantField of occupantFields) {
occupantField.disabled = lotOccupantTypeIdElement.value === "";
}
});
}
else {
let lotOccupancyOccupants = exports.lotOccupancyOccupants;
delete exports.lotOccupancyOccupants;
let lotOccupancyOccupants;
const openEditLotOccupancyOccupant = (clickEvent) => {
const lotOccupantIndex = Number.parseInt(clickEvent.currentTarget.closest("tr").dataset.lotOccupantIndex, 10);
const lotOccupancyOccupant = lotOccupancyOccupants.find((currentLotOccupancyOccupant) => {
@ -48,8 +37,7 @@ else {
const optionElement = document.createElement("option");
optionElement.value = lotOccupantType.lotOccupantTypeId.toString();
optionElement.textContent = lotOccupantType.lotOccupantType;
if (lotOccupantType.lotOccupantTypeId ===
lotOccupancyOccupant.lotOccupantTypeId) {
if (lotOccupantType.lotOccupantTypeId === lotOccupancyOccupant.lotOccupantTypeId) {
optionElement.selected = true;
lotOccupantTypeSelected = true;
}
@ -85,8 +73,8 @@ else {
});
};
const deleteLotOccupancyOccupant = (clickEvent) => {
const lotOccupantIndex = clickEvent.currentTarget.closest("tr")
.dataset.lotOccupantIndex;
const lotOccupantIndex = clickEvent.currentTarget.closest("tr").dataset
.lotOccupantIndex;
const doDelete = () => {
cityssm.postJSON(los.urlPrefix + "/lotOccupancies/doDeleteLotOccupancyOccupant", {
lotOccupancyId,
@ -107,9 +95,7 @@ else {
};
bulmaJS.confirm({
title: "Remove " + exports.aliases.occupant + "?",
message: "Are you sure you want to remove this " +
exports.aliases.occupant.toLowerCase() +
"?",
message: "Are you sure you want to remove this " + exports.aliases.occupant.toLowerCase() + "?",
okButton: {
text: "Yes, Remove " + exports.aliases.occupant,
callbackFunction: doDelete
@ -173,8 +159,7 @@ else {
"</td>") +
("<td>" +
(lotOccupancyOccupant.occupantPhoneNumber
? cityssm.escapeHTML(lotOccupancyOccupant.occupantPhoneNumber) +
"<br />"
? cityssm.escapeHTML(lotOccupancyOccupant.occupantPhoneNumber) + "<br />"
: "") +
(lotOccupancyOccupant.occupantEmailAddress
? cityssm.escapeHTML(lotOccupancyOccupant.occupantEmailAddress)
@ -200,6 +185,18 @@ else {
}
occupantsContainer.append(tableElement);
};
if (isCreate) {
const lotOccupantTypeIdElement = document.querySelector("#lotOccupancy--lotOccupantTypeId");
lotOccupantTypeIdElement.addEventListener("change", () => {
const occupantFields = formElement.querySelectorAll("[data-table='LotOccupancyOccupant']");
for (const occupantField of occupantFields) {
occupantField.disabled = lotOccupantTypeIdElement.value === "";
}
});
}
else {
lotOccupancyOccupants = exports.lotOccupancyOccupants;
delete exports.lotOccupancyOccupants;
document.querySelector("#button--addOccupant").addEventListener("click", () => {
let addCloseModalFunction;
let addFormElement;
@ -280,8 +277,7 @@ else {
cityssm.escapeHTML(occupant.occupantAddress1 || "") +
"<br />" +
(occupant.occupantAddress2
? cityssm.escapeHTML(occupant.occupantAddress2) +
"<br />"
? cityssm.escapeHTML(occupant.occupantAddress2) + "<br />"
: "") +
cityssm.escapeHTML(occupant.occupantCity || "") +
", " +

View File

@ -16,25 +16,7 @@ declare const lotOccupancyId: string;
declare const isCreate: boolean;
declare const formElement: HTMLFormElement;
if (isCreate) {
const lotOccupantTypeIdElement = document.querySelector(
"#lotOccupancy--lotOccupantTypeId"
) as HTMLSelectElement;
lotOccupantTypeIdElement.addEventListener("change", () => {
const occupantFields = formElement.querySelectorAll(
"[data-table='LotOccupancyOccupant']"
) as NodeListOf<HTMLInputElement | HTMLTextAreaElement>;
for (const occupantField of occupantFields) {
occupantField.disabled = lotOccupantTypeIdElement.value === "";
}
});
} else {
let lotOccupancyOccupants: recordTypes.LotOccupancyOccupant[] =
exports.lotOccupancyOccupants;
delete exports.lotOccupancyOccupants;
let lotOccupancyOccupants: recordTypes.LotOccupancyOccupant[];
const openEditLotOccupancyOccupant = (clickEvent: Event) => {
const lotOccupantIndex = Number.parseInt(
@ -42,11 +24,9 @@ if (isCreate) {
10
);
const lotOccupancyOccupant = lotOccupancyOccupants.find(
(currentLotOccupancyOccupant) => {
const lotOccupancyOccupant = lotOccupancyOccupants.find((currentLotOccupancyOccupant) => {
return currentLotOccupancyOccupant.lotOccupantIndex === lotOccupantIndex;
}
)!;
})!;
let editFormElement: HTMLFormElement;
let editCloseModalFunction: () => void;
@ -103,10 +83,7 @@ if (isCreate) {
optionElement.value = lotOccupantType.lotOccupantTypeId.toString();
optionElement.textContent = lotOccupantType.lotOccupantType;
if (
lotOccupantType.lotOccupantTypeId ===
lotOccupancyOccupant.lotOccupantTypeId
) {
if (lotOccupantType.lotOccupantTypeId === lotOccupancyOccupant.lotOccupantTypeId) {
optionElement.selected = true;
lotOccupantTypeSelected = true;
}
@ -195,8 +172,8 @@ if (isCreate) {
};
const deleteLotOccupancyOccupant = (clickEvent: Event) => {
const lotOccupantIndex = (clickEvent.currentTarget as HTMLElement).closest("tr")!
.dataset.lotOccupantIndex;
const lotOccupantIndex = (clickEvent.currentTarget as HTMLElement).closest("tr")!.dataset
.lotOccupantIndex;
const doDelete = () => {
cityssm.postJSON(
@ -227,9 +204,7 @@ if (isCreate) {
bulmaJS.confirm({
title: "Remove " + exports.aliases.occupant + "?",
message:
"Are you sure you want to remove this " +
exports.aliases.occupant.toLowerCase() +
"?",
"Are you sure you want to remove this " + exports.aliases.occupant.toLowerCase() + "?",
okButton: {
text: "Yes, Remove " + exports.aliases.occupant,
callbackFunction: doDelete
@ -303,8 +278,7 @@ if (isCreate) {
"</td>") +
("<td>" +
(lotOccupancyOccupant.occupantPhoneNumber
? cityssm.escapeHTML(lotOccupancyOccupant.occupantPhoneNumber) +
"<br />"
? cityssm.escapeHTML(lotOccupancyOccupant.occupantPhoneNumber) + "<br />"
: "") +
(lotOccupancyOccupant.occupantEmailAddress
? cityssm.escapeHTML(lotOccupancyOccupant.occupantEmailAddress)
@ -325,13 +299,15 @@ if (isCreate) {
"</div>" +
"</td>");
(
tableRowElement.querySelector(".button--edit") as HTMLButtonElement
).addEventListener("click", openEditLotOccupancyOccupant);
(tableRowElement.querySelector(".button--edit") as HTMLButtonElement).addEventListener(
"click",
openEditLotOccupancyOccupant
);
(
tableRowElement.querySelector(".button--delete") as HTMLButtonElement
).addEventListener("click", deleteLotOccupancyOccupant);
(tableRowElement.querySelector(".button--delete") as HTMLButtonElement).addEventListener(
"click",
deleteLotOccupancyOccupant
);
tableElement.querySelector("tbody")!.append(tableRowElement);
}
@ -339,6 +315,24 @@ if (isCreate) {
occupantsContainer.append(tableElement);
};
if (isCreate) {
const lotOccupantTypeIdElement = document.querySelector(
"#lotOccupancy--lotOccupantTypeId"
) as HTMLSelectElement;
lotOccupantTypeIdElement.addEventListener("change", () => {
const occupantFields = formElement.querySelectorAll(
"[data-table='LotOccupancyOccupant']"
) as NodeListOf<HTMLInputElement | HTMLTextAreaElement>;
for (const occupantField of occupantFields) {
occupantField.disabled = lotOccupantTypeIdElement.value === "";
}
});
} else {
lotOccupancyOccupants = exports.lotOccupancyOccupants;
delete exports.lotOccupancyOccupants;
(document.querySelector("#button--addOccupant") as HTMLButtonElement).addEventListener(
"click",
() => {
@ -464,8 +458,7 @@ if (isCreate) {
cityssm.escapeHTML(occupant.occupantAddress1 || "") +
"<br />" +
(occupant.occupantAddress2
? cityssm.escapeHTML(occupant.occupantAddress2) +
"<br />"
? cityssm.escapeHTML(occupant.occupantAddress2) + "<br />"
: "") +
cityssm.escapeHTML(occupant.occupantCity || "") +
", " +

File diff suppressed because one or more lines are too long

View File

@ -32,7 +32,7 @@ export interface LotType extends Record {
lotTypeFields?: LotTypeField[];
}
export interface LotTypeField extends Record {
lotTypeFieldId?: number;
lotTypeFieldId: number;
lotTypeField?: string;
lotTypeId?: number;
lotType: LotType;
@ -78,7 +78,6 @@ export interface LotComment extends Record {
}
export interface LotField extends LotTypeField, Record {
lotId?: number;
lotTypeFieldId?: number;
lotFieldValue?: string;
}
export interface OccupancyType extends Record {
@ -106,13 +105,13 @@ export interface LotOccupantType extends Record {
orderNumber?: number;
}
export interface FeeCategory extends Record {
feeCategoryId?: number;
feeCategory?: string;
fees?: Fee[];
feeCategoryId: number;
feeCategory: string;
fees: Fee[];
orderNumber?: number;
}
export interface Fee extends Record {
feeId?: number;
feeId: number;
feeCategoryId?: number;
feeCategory?: string;
feeName?: string;
@ -132,11 +131,7 @@ export interface Fee extends Record {
}
export interface LotOccupancyFee extends Fee, Record {
lotOccupancyId?: number;
feeId?: number;
feeName?: string;
quantity?: number;
feeAmount?: number;
taxAmount?: number;
}
export interface LotOccupancyTransaction extends Record {
lotOccupancyId?: number;

View File

@ -44,7 +44,7 @@ export interface LotType extends Record {
}
export interface LotTypeField extends Record {
lotTypeFieldId?: number;
lotTypeFieldId: number;
lotTypeField?: string;
lotTypeId?: number;
@ -107,7 +107,6 @@ export interface LotComment extends Record {
export interface LotField extends LotTypeField, Record {
lotId?: number;
lotTypeFieldId?: number;
lotFieldValue?: string;
}
@ -139,14 +138,14 @@ export interface LotOccupantType extends Record {
}
export interface FeeCategory extends Record {
feeCategoryId?: number;
feeCategory?: string;
fees?: Fee[];
feeCategoryId: number;
feeCategory: string;
fees: Fee[];
orderNumber?: number;
}
export interface Fee extends Record {
feeId?: number;
feeId: number;
feeCategoryId?: number;
feeCategory?: string;
@ -176,13 +175,7 @@ export interface Fee extends Record {
export interface LotOccupancyFee extends Fee, Record {
lotOccupancyId?: number;
feeId?: number;
feeName?: string;
quantity?: number;
feeAmount?: number;
taxAmount?: number;
}
export interface LotOccupancyTransaction extends Record {