From cb3c2c4492bcd901151dcd47d091bf0a2ce1668e Mon Sep 17 00:00:00 2001 From: Dan Gowans Date: Thu, 29 Dec 2022 13:11:21 -0500 Subject: [PATCH] refactoring --- public-typescript/adminFees.ts | 12 +- public-typescript/adminLotTypes.ts | 4 +- public-typescript/lotOccupancyEdit.js | 376 ++++++----- .../lotOccupancyEditOccupants.js | 376 ++++++----- .../lotOccupancyEditOccupants.ts | 609 +++++++++--------- public/javascripts/lotOccupancyEdit.min.js | 2 +- types/recordTypes.d.ts | 15 +- types/recordTypes.ts | 17 +- 8 files changed, 692 insertions(+), 719 deletions(-) diff --git a/public-typescript/adminFees.ts b/public-typescript/adminFees.ts index aa52bd85..5ad76e68 100644 --- a/public-typescript/adminFees.ts +++ b/public-typescript/adminFees.ts @@ -88,7 +88,7 @@ declare const bulmaJS: BulmaJS; "" + ""; - if (feeCategory.fees!.length === 0) { + if (feeCategory.fees.length === 0) { feeCategoryContainerElement.insertAdjacentHTML( "beforeend", '
' + @@ -100,7 +100,7 @@ declare const bulmaJS: BulmaJS; "
" ); } 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) { diff --git a/public-typescript/adminLotTypes.ts b/public-typescript/adminLotTypes.ts index 29b795b8..bfad4d40 100644 --- a/public-typescript/adminLotTypes.ts +++ b/public-typescript/adminLotTypes.ts @@ -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 = '
' + diff --git a/public-typescript/lotOccupancyEdit.js b/public-typescript/lotOccupancyEdit.js index 76295423..b0978dc6 100644 --- a/public-typescript/lotOccupancyEdit.js +++ b/public-typescript/lotOccupancyEdit.js @@ -485,6 +485,190 @@ 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 }); + let lotOccupancyOccupants; + const openEditLotOccupancyOccupant = (clickEvent) => { + const lotOccupantIndex = Number.parseInt(clickEvent.currentTarget.closest("tr").dataset.lotOccupantIndex, 10); + const lotOccupancyOccupant = lotOccupancyOccupants.find((currentLotOccupancyOccupant) => { + return currentLotOccupancyOccupant.lotOccupantIndex === lotOccupantIndex; + }); + let editFormElement; + let editCloseModalFunction; + const editOccupant = (submitEvent) => { + submitEvent.preventDefault(); + cityssm.postJSON(los.urlPrefix + "/lotOccupancies/doUpdateLotOccupancyOccupant", editFormElement, (responseJSON) => { + if (responseJSON.success) { + lotOccupancyOccupants = responseJSON.lotOccupancyOccupants; + editCloseModalFunction(); + renderLotOccupancyOccupants(); + } + else { + bulmaJS.alert({ + title: "Error Updating " + exports.aliases.occupant, + message: responseJSON.errorMessage || "", + contextualColorName: "danger" + }); + } + }); + }; + cityssm.openHtmlModal("lotOccupancy-editOccupant", { + onshow: (modalElement) => { + los.populateAliases(modalElement); + modalElement.querySelector("#lotOccupancyOccupantEdit--lotOccupancyId").value = lotOccupancyId; + modalElement.querySelector("#lotOccupancyOccupantEdit--lotOccupantIndex").value = lotOccupantIndex.toString(); + const lotOccupantTypeSelectElement = modalElement.querySelector("#lotOccupancyOccupantEdit--lotOccupantTypeId"); + let lotOccupantTypeSelected = false; + for (const lotOccupantType of exports.lotOccupantTypes) { + const optionElement = document.createElement("option"); + optionElement.value = lotOccupantType.lotOccupantTypeId.toString(); + optionElement.textContent = lotOccupantType.lotOccupantType; + if (lotOccupantType.lotOccupantTypeId === lotOccupancyOccupant.lotOccupantTypeId) { + optionElement.selected = true; + lotOccupantTypeSelected = true; + } + lotOccupantTypeSelectElement.append(optionElement); + } + if (!lotOccupantTypeSelected) { + const optionElement = document.createElement("option"); + optionElement.value = lotOccupancyOccupant.lotOccupantTypeId.toString(); + optionElement.textContent = lotOccupancyOccupant.lotOccupantType; + optionElement.selected = true; + lotOccupantTypeSelectElement.append(optionElement); + } + modalElement.querySelector("#lotOccupancyOccupantEdit--occupantName").value = lotOccupancyOccupant.occupantName; + modalElement.querySelector("#lotOccupancyOccupantEdit--occupantAddress1").value = lotOccupancyOccupant.occupantAddress1; + modalElement.querySelector("#lotOccupancyOccupantEdit--occupantAddress2").value = lotOccupancyOccupant.occupantAddress2; + modalElement.querySelector("#lotOccupancyOccupantEdit--occupantCity").value = lotOccupancyOccupant.occupantCity; + modalElement.querySelector("#lotOccupancyOccupantEdit--occupantProvince").value = lotOccupancyOccupant.occupantProvince; + modalElement.querySelector("#lotOccupancyOccupantEdit--occupantPostalCode").value = lotOccupancyOccupant.occupantPostalCode; + modalElement.querySelector("#lotOccupancyOccupantEdit--occupantPhoneNumber").value = lotOccupancyOccupant.occupantPhoneNumber; + modalElement.querySelector("#lotOccupancyOccupantEdit--occupantEmailAddress").value = lotOccupancyOccupant.occupantEmailAddress; + modalElement.querySelector("#lotOccupancyOccupantEdit--occupantComment").value = lotOccupancyOccupant.occupantComment; + }, + onshown: (modalElement, closeModalFunction) => { + bulmaJS.toggleHtmlClipped(); + modalElement.querySelector("#lotOccupancyOccupantEdit--lotOccupantTypeId").focus(); + editFormElement = modalElement.querySelector("form"); + editFormElement.addEventListener("submit", editOccupant); + editCloseModalFunction = closeModalFunction; + }, + onremoved: () => { + bulmaJS.toggleHtmlClipped(); + } + }); + }; + const deleteLotOccupancyOccupant = (clickEvent) => { + const lotOccupantIndex = clickEvent.currentTarget.closest("tr").dataset + .lotOccupantIndex; + const doDelete = () => { + cityssm.postJSON(los.urlPrefix + "/lotOccupancies/doDeleteLotOccupancyOccupant", { + lotOccupancyId, + lotOccupantIndex + }, (responseJSON) => { + if (responseJSON.success) { + lotOccupancyOccupants = responseJSON.lotOccupancyOccupants; + renderLotOccupancyOccupants(); + } + else { + bulmaJS.alert({ + title: "Error Removing " + exports.aliases.occupant, + message: responseJSON.errorMessage || "", + contextualColorName: "danger" + }); + } + }); + }; + bulmaJS.confirm({ + title: "Remove " + exports.aliases.occupant + "?", + message: "Are you sure you want to remove this " + exports.aliases.occupant.toLowerCase() + "?", + okButton: { + text: "Yes, Remove " + exports.aliases.occupant, + callbackFunction: doDelete + }, + contextualColorName: "warning" + }); + }; + const renderLotOccupancyOccupants = () => { + const occupantsContainer = document.querySelector("#container--lotOccupancyOccupants"); + cityssm.clearElement(occupantsContainer); + if (lotOccupancyOccupants.length === 0) { + occupantsContainer.innerHTML = + '
' + + '

There are no ' + + exports.aliases.occupants.toLowerCase() + + " associated with this record.

" + + "
"; + return; + } + const tableElement = document.createElement("table"); + tableElement.className = "table is-fullwidth is-striped is-hoverable"; + tableElement.innerHTML = + "" + + ("" + exports.aliases.occupant + "") + + "Address" + + "Other Contact" + + "Comment" + + 'Options' + + "" + + ""; + for (const lotOccupancyOccupant of lotOccupancyOccupants) { + const tableRowElement = document.createElement("tr"); + tableRowElement.dataset.lotOccupantIndex = + lotOccupancyOccupant.lotOccupantIndex.toString(); + tableRowElement.innerHTML = + "" + + cityssm.escapeHTML(lotOccupancyOccupant.occupantName || "(No Name)") + + "
" + + ('' + + '' + + ' ' + + cityssm.escapeHTML(lotOccupancyOccupant.lotOccupantType) + + "" + + "") + + "" + + ("" + + (lotOccupancyOccupant.occupantAddress1 + ? cityssm.escapeHTML(lotOccupancyOccupant.occupantAddress1) + "
" + : "") + + (lotOccupancyOccupant.occupantAddress2 + ? cityssm.escapeHTML(lotOccupancyOccupant.occupantAddress2) + "
" + : "") + + (lotOccupancyOccupant.occupantCity + ? cityssm.escapeHTML(lotOccupancyOccupant.occupantCity) + ", " + : "") + + cityssm.escapeHTML(lotOccupancyOccupant.occupantProvince || "") + + "
" + + cityssm.escapeHTML(lotOccupancyOccupant.occupantPostalCode || "") + + "") + + ("" + + (lotOccupancyOccupant.occupantPhoneNumber + ? cityssm.escapeHTML(lotOccupancyOccupant.occupantPhoneNumber) + "
" + : "") + + (lotOccupancyOccupant.occupantEmailAddress + ? cityssm.escapeHTML(lotOccupancyOccupant.occupantEmailAddress) + : "") + + "") + + ("" + cityssm.escapeHTML(lotOccupancyOccupant.occupantComment) + "") + + ('' + + '
' + + ('") + + ('") + + "
" + + ""); + tableRowElement.querySelector(".button--edit").addEventListener("click", openEditLotOccupancyOccupant); + tableRowElement.querySelector(".button--delete").addEventListener("click", deleteLotOccupancyOccupant); + tableElement.querySelector("tbody").append(tableRowElement); + } + occupantsContainer.append(tableElement); + }; if (isCreate) { const lotOccupantTypeIdElement = document.querySelector("#lotOccupancy--lotOccupantTypeId"); lotOccupantTypeIdElement.addEventListener("change", () => { @@ -495,195 +679,8 @@ Object.defineProperty(exports, "__esModule", { value: true }); }); } else { - let lotOccupancyOccupants = exports.lotOccupancyOccupants; + lotOccupancyOccupants = exports.lotOccupancyOccupants; delete exports.lotOccupancyOccupants; - const openEditLotOccupancyOccupant = (clickEvent) => { - const lotOccupantIndex = Number.parseInt(clickEvent.currentTarget.closest("tr").dataset.lotOccupantIndex, 10); - const lotOccupancyOccupant = lotOccupancyOccupants.find((currentLotOccupancyOccupant) => { - return currentLotOccupancyOccupant.lotOccupantIndex === lotOccupantIndex; - }); - let editFormElement; - let editCloseModalFunction; - const editOccupant = (submitEvent) => { - submitEvent.preventDefault(); - cityssm.postJSON(los.urlPrefix + "/lotOccupancies/doUpdateLotOccupancyOccupant", editFormElement, (responseJSON) => { - if (responseJSON.success) { - lotOccupancyOccupants = responseJSON.lotOccupancyOccupants; - editCloseModalFunction(); - renderLotOccupancyOccupants(); - } - else { - bulmaJS.alert({ - title: "Error Updating " + exports.aliases.occupant, - message: responseJSON.errorMessage || "", - contextualColorName: "danger" - }); - } - }); - }; - cityssm.openHtmlModal("lotOccupancy-editOccupant", { - onshow: (modalElement) => { - los.populateAliases(modalElement); - modalElement.querySelector("#lotOccupancyOccupantEdit--lotOccupancyId").value = lotOccupancyId; - modalElement.querySelector("#lotOccupancyOccupantEdit--lotOccupantIndex").value = lotOccupantIndex.toString(); - const lotOccupantTypeSelectElement = modalElement.querySelector("#lotOccupancyOccupantEdit--lotOccupantTypeId"); - let lotOccupantTypeSelected = false; - for (const lotOccupantType of exports.lotOccupantTypes) { - const optionElement = document.createElement("option"); - optionElement.value = lotOccupantType.lotOccupantTypeId.toString(); - optionElement.textContent = lotOccupantType.lotOccupantType; - if (lotOccupantType.lotOccupantTypeId === - lotOccupancyOccupant.lotOccupantTypeId) { - optionElement.selected = true; - lotOccupantTypeSelected = true; - } - lotOccupantTypeSelectElement.append(optionElement); - } - if (!lotOccupantTypeSelected) { - const optionElement = document.createElement("option"); - optionElement.value = lotOccupancyOccupant.lotOccupantTypeId.toString(); - optionElement.textContent = lotOccupancyOccupant.lotOccupantType; - optionElement.selected = true; - lotOccupantTypeSelectElement.append(optionElement); - } - modalElement.querySelector("#lotOccupancyOccupantEdit--occupantName").value = lotOccupancyOccupant.occupantName; - modalElement.querySelector("#lotOccupancyOccupantEdit--occupantAddress1").value = lotOccupancyOccupant.occupantAddress1; - modalElement.querySelector("#lotOccupancyOccupantEdit--occupantAddress2").value = lotOccupancyOccupant.occupantAddress2; - modalElement.querySelector("#lotOccupancyOccupantEdit--occupantCity").value = lotOccupancyOccupant.occupantCity; - modalElement.querySelector("#lotOccupancyOccupantEdit--occupantProvince").value = lotOccupancyOccupant.occupantProvince; - modalElement.querySelector("#lotOccupancyOccupantEdit--occupantPostalCode").value = lotOccupancyOccupant.occupantPostalCode; - modalElement.querySelector("#lotOccupancyOccupantEdit--occupantPhoneNumber").value = lotOccupancyOccupant.occupantPhoneNumber; - modalElement.querySelector("#lotOccupancyOccupantEdit--occupantEmailAddress").value = lotOccupancyOccupant.occupantEmailAddress; - modalElement.querySelector("#lotOccupancyOccupantEdit--occupantComment").value = lotOccupancyOccupant.occupantComment; - }, - onshown: (modalElement, closeModalFunction) => { - bulmaJS.toggleHtmlClipped(); - modalElement.querySelector("#lotOccupancyOccupantEdit--lotOccupantTypeId").focus(); - editFormElement = modalElement.querySelector("form"); - editFormElement.addEventListener("submit", editOccupant); - editCloseModalFunction = closeModalFunction; - }, - onremoved: () => { - bulmaJS.toggleHtmlClipped(); - } - }); - }; - const deleteLotOccupancyOccupant = (clickEvent) => { - const lotOccupantIndex = clickEvent.currentTarget.closest("tr") - .dataset.lotOccupantIndex; - const doDelete = () => { - cityssm.postJSON(los.urlPrefix + "/lotOccupancies/doDeleteLotOccupancyOccupant", { - lotOccupancyId, - lotOccupantIndex - }, (responseJSON) => { - if (responseJSON.success) { - lotOccupancyOccupants = responseJSON.lotOccupancyOccupants; - renderLotOccupancyOccupants(); - } - else { - bulmaJS.alert({ - title: "Error Removing " + exports.aliases.occupant, - message: responseJSON.errorMessage || "", - contextualColorName: "danger" - }); - } - }); - }; - bulmaJS.confirm({ - title: "Remove " + exports.aliases.occupant + "?", - message: "Are you sure you want to remove this " + - exports.aliases.occupant.toLowerCase() + - "?", - okButton: { - text: "Yes, Remove " + exports.aliases.occupant, - callbackFunction: doDelete - }, - contextualColorName: "warning" - }); - }; - const renderLotOccupancyOccupants = () => { - const occupantsContainer = document.querySelector("#container--lotOccupancyOccupants"); - cityssm.clearElement(occupantsContainer); - if (lotOccupancyOccupants.length === 0) { - occupantsContainer.innerHTML = - '
' + - '

There are no ' + - exports.aliases.occupants.toLowerCase() + - " associated with this record.

" + - "
"; - return; - } - const tableElement = document.createElement("table"); - tableElement.className = "table is-fullwidth is-striped is-hoverable"; - tableElement.innerHTML = - "" + - ("" + exports.aliases.occupant + "") + - "Address" + - "Other Contact" + - "Comment" + - 'Options' + - "" + - ""; - for (const lotOccupancyOccupant of lotOccupancyOccupants) { - const tableRowElement = document.createElement("tr"); - tableRowElement.dataset.lotOccupantIndex = - lotOccupancyOccupant.lotOccupantIndex.toString(); - tableRowElement.innerHTML = - "" + - cityssm.escapeHTML(lotOccupancyOccupant.occupantName || "(No Name)") + - "
" + - ('' + - '' + - ' ' + - cityssm.escapeHTML(lotOccupancyOccupant.lotOccupantType) + - "" + - "") + - "" + - ("" + - (lotOccupancyOccupant.occupantAddress1 - ? cityssm.escapeHTML(lotOccupancyOccupant.occupantAddress1) + "
" - : "") + - (lotOccupancyOccupant.occupantAddress2 - ? cityssm.escapeHTML(lotOccupancyOccupant.occupantAddress2) + "
" - : "") + - (lotOccupancyOccupant.occupantCity - ? cityssm.escapeHTML(lotOccupancyOccupant.occupantCity) + ", " - : "") + - cityssm.escapeHTML(lotOccupancyOccupant.occupantProvince || "") + - "
" + - cityssm.escapeHTML(lotOccupancyOccupant.occupantPostalCode || "") + - "") + - ("" + - (lotOccupancyOccupant.occupantPhoneNumber - ? cityssm.escapeHTML(lotOccupancyOccupant.occupantPhoneNumber) + - "
" - : "") + - (lotOccupancyOccupant.occupantEmailAddress - ? cityssm.escapeHTML(lotOccupancyOccupant.occupantEmailAddress) - : "") + - "") + - ("" + cityssm.escapeHTML(lotOccupancyOccupant.occupantComment) + "") + - ('' + - '
' + - ('") + - ('") + - "
" + - ""); - tableRowElement.querySelector(".button--edit").addEventListener("click", openEditLotOccupancyOccupant); - tableRowElement.querySelector(".button--delete").addEventListener("click", deleteLotOccupancyOccupant); - tableElement.querySelector("tbody").append(tableRowElement); - } - occupantsContainer.append(tableElement); - }; document.querySelector("#button--addOccupant").addEventListener("click", () => { let addCloseModalFunction; let addFormElement; @@ -764,8 +761,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); cityssm.escapeHTML(occupant.occupantAddress1 || "") + "
" + (occupant.occupantAddress2 - ? cityssm.escapeHTML(occupant.occupantAddress2) + - "
" + ? cityssm.escapeHTML(occupant.occupantAddress2) + "
" : "") + cityssm.escapeHTML(occupant.occupantCity || "") + ", " + diff --git a/public-typescript/lotOccupancyEdit/lotOccupancyEditOccupants.js b/public-typescript/lotOccupancyEdit/lotOccupancyEditOccupants.js index 64d1584e..7fab3717 100644 --- a/public-typescript/lotOccupancyEdit/lotOccupancyEditOccupants.js +++ b/public-typescript/lotOccupancyEdit/lotOccupancyEditOccupants.js @@ -1,6 +1,190 @@ "use strict"; /* eslint-disable @typescript-eslint/no-non-null-assertion, unicorn/prefer-module */ Object.defineProperty(exports, "__esModule", { value: true }); +let lotOccupancyOccupants; +const openEditLotOccupancyOccupant = (clickEvent) => { + const lotOccupantIndex = Number.parseInt(clickEvent.currentTarget.closest("tr").dataset.lotOccupantIndex, 10); + const lotOccupancyOccupant = lotOccupancyOccupants.find((currentLotOccupancyOccupant) => { + return currentLotOccupancyOccupant.lotOccupantIndex === lotOccupantIndex; + }); + let editFormElement; + let editCloseModalFunction; + const editOccupant = (submitEvent) => { + submitEvent.preventDefault(); + cityssm.postJSON(los.urlPrefix + "/lotOccupancies/doUpdateLotOccupancyOccupant", editFormElement, (responseJSON) => { + if (responseJSON.success) { + lotOccupancyOccupants = responseJSON.lotOccupancyOccupants; + editCloseModalFunction(); + renderLotOccupancyOccupants(); + } + else { + bulmaJS.alert({ + title: "Error Updating " + exports.aliases.occupant, + message: responseJSON.errorMessage || "", + contextualColorName: "danger" + }); + } + }); + }; + cityssm.openHtmlModal("lotOccupancy-editOccupant", { + onshow: (modalElement) => { + los.populateAliases(modalElement); + modalElement.querySelector("#lotOccupancyOccupantEdit--lotOccupancyId").value = lotOccupancyId; + modalElement.querySelector("#lotOccupancyOccupantEdit--lotOccupantIndex").value = lotOccupantIndex.toString(); + const lotOccupantTypeSelectElement = modalElement.querySelector("#lotOccupancyOccupantEdit--lotOccupantTypeId"); + let lotOccupantTypeSelected = false; + for (const lotOccupantType of exports.lotOccupantTypes) { + const optionElement = document.createElement("option"); + optionElement.value = lotOccupantType.lotOccupantTypeId.toString(); + optionElement.textContent = lotOccupantType.lotOccupantType; + if (lotOccupantType.lotOccupantTypeId === lotOccupancyOccupant.lotOccupantTypeId) { + optionElement.selected = true; + lotOccupantTypeSelected = true; + } + lotOccupantTypeSelectElement.append(optionElement); + } + if (!lotOccupantTypeSelected) { + const optionElement = document.createElement("option"); + optionElement.value = lotOccupancyOccupant.lotOccupantTypeId.toString(); + optionElement.textContent = lotOccupancyOccupant.lotOccupantType; + optionElement.selected = true; + lotOccupantTypeSelectElement.append(optionElement); + } + modalElement.querySelector("#lotOccupancyOccupantEdit--occupantName").value = lotOccupancyOccupant.occupantName; + modalElement.querySelector("#lotOccupancyOccupantEdit--occupantAddress1").value = lotOccupancyOccupant.occupantAddress1; + modalElement.querySelector("#lotOccupancyOccupantEdit--occupantAddress2").value = lotOccupancyOccupant.occupantAddress2; + modalElement.querySelector("#lotOccupancyOccupantEdit--occupantCity").value = lotOccupancyOccupant.occupantCity; + modalElement.querySelector("#lotOccupancyOccupantEdit--occupantProvince").value = lotOccupancyOccupant.occupantProvince; + modalElement.querySelector("#lotOccupancyOccupantEdit--occupantPostalCode").value = lotOccupancyOccupant.occupantPostalCode; + modalElement.querySelector("#lotOccupancyOccupantEdit--occupantPhoneNumber").value = lotOccupancyOccupant.occupantPhoneNumber; + modalElement.querySelector("#lotOccupancyOccupantEdit--occupantEmailAddress").value = lotOccupancyOccupant.occupantEmailAddress; + modalElement.querySelector("#lotOccupancyOccupantEdit--occupantComment").value = lotOccupancyOccupant.occupantComment; + }, + onshown: (modalElement, closeModalFunction) => { + bulmaJS.toggleHtmlClipped(); + modalElement.querySelector("#lotOccupancyOccupantEdit--lotOccupantTypeId").focus(); + editFormElement = modalElement.querySelector("form"); + editFormElement.addEventListener("submit", editOccupant); + editCloseModalFunction = closeModalFunction; + }, + onremoved: () => { + bulmaJS.toggleHtmlClipped(); + } + }); +}; +const deleteLotOccupancyOccupant = (clickEvent) => { + const lotOccupantIndex = clickEvent.currentTarget.closest("tr").dataset + .lotOccupantIndex; + const doDelete = () => { + cityssm.postJSON(los.urlPrefix + "/lotOccupancies/doDeleteLotOccupancyOccupant", { + lotOccupancyId, + lotOccupantIndex + }, (responseJSON) => { + if (responseJSON.success) { + lotOccupancyOccupants = responseJSON.lotOccupancyOccupants; + renderLotOccupancyOccupants(); + } + else { + bulmaJS.alert({ + title: "Error Removing " + exports.aliases.occupant, + message: responseJSON.errorMessage || "", + contextualColorName: "danger" + }); + } + }); + }; + bulmaJS.confirm({ + title: "Remove " + exports.aliases.occupant + "?", + message: "Are you sure you want to remove this " + exports.aliases.occupant.toLowerCase() + "?", + okButton: { + text: "Yes, Remove " + exports.aliases.occupant, + callbackFunction: doDelete + }, + contextualColorName: "warning" + }); +}; +const renderLotOccupancyOccupants = () => { + const occupantsContainer = document.querySelector("#container--lotOccupancyOccupants"); + cityssm.clearElement(occupantsContainer); + if (lotOccupancyOccupants.length === 0) { + occupantsContainer.innerHTML = + '
' + + '

There are no ' + + exports.aliases.occupants.toLowerCase() + + " associated with this record.

" + + "
"; + return; + } + const tableElement = document.createElement("table"); + tableElement.className = "table is-fullwidth is-striped is-hoverable"; + tableElement.innerHTML = + "" + + ("" + exports.aliases.occupant + "") + + "Address" + + "Other Contact" + + "Comment" + + 'Options' + + "" + + ""; + for (const lotOccupancyOccupant of lotOccupancyOccupants) { + const tableRowElement = document.createElement("tr"); + tableRowElement.dataset.lotOccupantIndex = + lotOccupancyOccupant.lotOccupantIndex.toString(); + tableRowElement.innerHTML = + "" + + cityssm.escapeHTML(lotOccupancyOccupant.occupantName || "(No Name)") + + "
" + + ('' + + '' + + ' ' + + cityssm.escapeHTML(lotOccupancyOccupant.lotOccupantType) + + "" + + "") + + "" + + ("" + + (lotOccupancyOccupant.occupantAddress1 + ? cityssm.escapeHTML(lotOccupancyOccupant.occupantAddress1) + "
" + : "") + + (lotOccupancyOccupant.occupantAddress2 + ? cityssm.escapeHTML(lotOccupancyOccupant.occupantAddress2) + "
" + : "") + + (lotOccupancyOccupant.occupantCity + ? cityssm.escapeHTML(lotOccupancyOccupant.occupantCity) + ", " + : "") + + cityssm.escapeHTML(lotOccupancyOccupant.occupantProvince || "") + + "
" + + cityssm.escapeHTML(lotOccupancyOccupant.occupantPostalCode || "") + + "") + + ("" + + (lotOccupancyOccupant.occupantPhoneNumber + ? cityssm.escapeHTML(lotOccupancyOccupant.occupantPhoneNumber) + "
" + : "") + + (lotOccupancyOccupant.occupantEmailAddress + ? cityssm.escapeHTML(lotOccupancyOccupant.occupantEmailAddress) + : "") + + "") + + ("" + cityssm.escapeHTML(lotOccupancyOccupant.occupantComment) + "") + + ('' + + '
' + + ('") + + ('") + + "
" + + ""); + tableRowElement.querySelector(".button--edit").addEventListener("click", openEditLotOccupancyOccupant); + tableRowElement.querySelector(".button--delete").addEventListener("click", deleteLotOccupancyOccupant); + tableElement.querySelector("tbody").append(tableRowElement); + } + occupantsContainer.append(tableElement); +}; if (isCreate) { const lotOccupantTypeIdElement = document.querySelector("#lotOccupancy--lotOccupantTypeId"); lotOccupantTypeIdElement.addEventListener("change", () => { @@ -11,195 +195,8 @@ if (isCreate) { }); } else { - let lotOccupancyOccupants = exports.lotOccupancyOccupants; + lotOccupancyOccupants = exports.lotOccupancyOccupants; delete exports.lotOccupancyOccupants; - const openEditLotOccupancyOccupant = (clickEvent) => { - const lotOccupantIndex = Number.parseInt(clickEvent.currentTarget.closest("tr").dataset.lotOccupantIndex, 10); - const lotOccupancyOccupant = lotOccupancyOccupants.find((currentLotOccupancyOccupant) => { - return currentLotOccupancyOccupant.lotOccupantIndex === lotOccupantIndex; - }); - let editFormElement; - let editCloseModalFunction; - const editOccupant = (submitEvent) => { - submitEvent.preventDefault(); - cityssm.postJSON(los.urlPrefix + "/lotOccupancies/doUpdateLotOccupancyOccupant", editFormElement, (responseJSON) => { - if (responseJSON.success) { - lotOccupancyOccupants = responseJSON.lotOccupancyOccupants; - editCloseModalFunction(); - renderLotOccupancyOccupants(); - } - else { - bulmaJS.alert({ - title: "Error Updating " + exports.aliases.occupant, - message: responseJSON.errorMessage || "", - contextualColorName: "danger" - }); - } - }); - }; - cityssm.openHtmlModal("lotOccupancy-editOccupant", { - onshow: (modalElement) => { - los.populateAliases(modalElement); - modalElement.querySelector("#lotOccupancyOccupantEdit--lotOccupancyId").value = lotOccupancyId; - modalElement.querySelector("#lotOccupancyOccupantEdit--lotOccupantIndex").value = lotOccupantIndex.toString(); - const lotOccupantTypeSelectElement = modalElement.querySelector("#lotOccupancyOccupantEdit--lotOccupantTypeId"); - let lotOccupantTypeSelected = false; - for (const lotOccupantType of exports.lotOccupantTypes) { - const optionElement = document.createElement("option"); - optionElement.value = lotOccupantType.lotOccupantTypeId.toString(); - optionElement.textContent = lotOccupantType.lotOccupantType; - if (lotOccupantType.lotOccupantTypeId === - lotOccupancyOccupant.lotOccupantTypeId) { - optionElement.selected = true; - lotOccupantTypeSelected = true; - } - lotOccupantTypeSelectElement.append(optionElement); - } - if (!lotOccupantTypeSelected) { - const optionElement = document.createElement("option"); - optionElement.value = lotOccupancyOccupant.lotOccupantTypeId.toString(); - optionElement.textContent = lotOccupancyOccupant.lotOccupantType; - optionElement.selected = true; - lotOccupantTypeSelectElement.append(optionElement); - } - modalElement.querySelector("#lotOccupancyOccupantEdit--occupantName").value = lotOccupancyOccupant.occupantName; - modalElement.querySelector("#lotOccupancyOccupantEdit--occupantAddress1").value = lotOccupancyOccupant.occupantAddress1; - modalElement.querySelector("#lotOccupancyOccupantEdit--occupantAddress2").value = lotOccupancyOccupant.occupantAddress2; - modalElement.querySelector("#lotOccupancyOccupantEdit--occupantCity").value = lotOccupancyOccupant.occupantCity; - modalElement.querySelector("#lotOccupancyOccupantEdit--occupantProvince").value = lotOccupancyOccupant.occupantProvince; - modalElement.querySelector("#lotOccupancyOccupantEdit--occupantPostalCode").value = lotOccupancyOccupant.occupantPostalCode; - modalElement.querySelector("#lotOccupancyOccupantEdit--occupantPhoneNumber").value = lotOccupancyOccupant.occupantPhoneNumber; - modalElement.querySelector("#lotOccupancyOccupantEdit--occupantEmailAddress").value = lotOccupancyOccupant.occupantEmailAddress; - modalElement.querySelector("#lotOccupancyOccupantEdit--occupantComment").value = lotOccupancyOccupant.occupantComment; - }, - onshown: (modalElement, closeModalFunction) => { - bulmaJS.toggleHtmlClipped(); - modalElement.querySelector("#lotOccupancyOccupantEdit--lotOccupantTypeId").focus(); - editFormElement = modalElement.querySelector("form"); - editFormElement.addEventListener("submit", editOccupant); - editCloseModalFunction = closeModalFunction; - }, - onremoved: () => { - bulmaJS.toggleHtmlClipped(); - } - }); - }; - const deleteLotOccupancyOccupant = (clickEvent) => { - const lotOccupantIndex = clickEvent.currentTarget.closest("tr") - .dataset.lotOccupantIndex; - const doDelete = () => { - cityssm.postJSON(los.urlPrefix + "/lotOccupancies/doDeleteLotOccupancyOccupant", { - lotOccupancyId, - lotOccupantIndex - }, (responseJSON) => { - if (responseJSON.success) { - lotOccupancyOccupants = responseJSON.lotOccupancyOccupants; - renderLotOccupancyOccupants(); - } - else { - bulmaJS.alert({ - title: "Error Removing " + exports.aliases.occupant, - message: responseJSON.errorMessage || "", - contextualColorName: "danger" - }); - } - }); - }; - bulmaJS.confirm({ - title: "Remove " + exports.aliases.occupant + "?", - message: "Are you sure you want to remove this " + - exports.aliases.occupant.toLowerCase() + - "?", - okButton: { - text: "Yes, Remove " + exports.aliases.occupant, - callbackFunction: doDelete - }, - contextualColorName: "warning" - }); - }; - const renderLotOccupancyOccupants = () => { - const occupantsContainer = document.querySelector("#container--lotOccupancyOccupants"); - cityssm.clearElement(occupantsContainer); - if (lotOccupancyOccupants.length === 0) { - occupantsContainer.innerHTML = - '
' + - '

There are no ' + - exports.aliases.occupants.toLowerCase() + - " associated with this record.

" + - "
"; - return; - } - const tableElement = document.createElement("table"); - tableElement.className = "table is-fullwidth is-striped is-hoverable"; - tableElement.innerHTML = - "" + - ("" + exports.aliases.occupant + "") + - "Address" + - "Other Contact" + - "Comment" + - 'Options' + - "" + - ""; - for (const lotOccupancyOccupant of lotOccupancyOccupants) { - const tableRowElement = document.createElement("tr"); - tableRowElement.dataset.lotOccupantIndex = - lotOccupancyOccupant.lotOccupantIndex.toString(); - tableRowElement.innerHTML = - "" + - cityssm.escapeHTML(lotOccupancyOccupant.occupantName || "(No Name)") + - "
" + - ('' + - '' + - ' ' + - cityssm.escapeHTML(lotOccupancyOccupant.lotOccupantType) + - "" + - "") + - "" + - ("" + - (lotOccupancyOccupant.occupantAddress1 - ? cityssm.escapeHTML(lotOccupancyOccupant.occupantAddress1) + "
" - : "") + - (lotOccupancyOccupant.occupantAddress2 - ? cityssm.escapeHTML(lotOccupancyOccupant.occupantAddress2) + "
" - : "") + - (lotOccupancyOccupant.occupantCity - ? cityssm.escapeHTML(lotOccupancyOccupant.occupantCity) + ", " - : "") + - cityssm.escapeHTML(lotOccupancyOccupant.occupantProvince || "") + - "
" + - cityssm.escapeHTML(lotOccupancyOccupant.occupantPostalCode || "") + - "") + - ("" + - (lotOccupancyOccupant.occupantPhoneNumber - ? cityssm.escapeHTML(lotOccupancyOccupant.occupantPhoneNumber) + - "
" - : "") + - (lotOccupancyOccupant.occupantEmailAddress - ? cityssm.escapeHTML(lotOccupancyOccupant.occupantEmailAddress) - : "") + - "") + - ("" + cityssm.escapeHTML(lotOccupancyOccupant.occupantComment) + "") + - ('' + - '
' + - ('") + - ('") + - "
" + - ""); - tableRowElement.querySelector(".button--edit").addEventListener("click", openEditLotOccupancyOccupant); - tableRowElement.querySelector(".button--delete").addEventListener("click", deleteLotOccupancyOccupant); - tableElement.querySelector("tbody").append(tableRowElement); - } - occupantsContainer.append(tableElement); - }; document.querySelector("#button--addOccupant").addEventListener("click", () => { let addCloseModalFunction; let addFormElement; @@ -280,8 +277,7 @@ else { cityssm.escapeHTML(occupant.occupantAddress1 || "") + "
" + (occupant.occupantAddress2 - ? cityssm.escapeHTML(occupant.occupantAddress2) + - "
" + ? cityssm.escapeHTML(occupant.occupantAddress2) + "
" : "") + cityssm.escapeHTML(occupant.occupantCity || "") + ", " + diff --git a/public-typescript/lotOccupancyEdit/lotOccupancyEditOccupants.ts b/public-typescript/lotOccupancyEdit/lotOccupancyEditOccupants.ts index da82f06c..8b42d97c 100644 --- a/public-typescript/lotOccupancyEdit/lotOccupancyEditOccupants.ts +++ b/public-typescript/lotOccupancyEdit/lotOccupancyEditOccupants.ts @@ -16,6 +16,305 @@ declare const lotOccupancyId: string; declare const isCreate: boolean; declare const formElement: HTMLFormElement; +let lotOccupancyOccupants: recordTypes.LotOccupancyOccupant[]; + +const openEditLotOccupancyOccupant = (clickEvent: Event) => { + const lotOccupantIndex = Number.parseInt( + (clickEvent.currentTarget as HTMLElement).closest("tr")!.dataset.lotOccupantIndex!, + 10 + ); + + const lotOccupancyOccupant = lotOccupancyOccupants.find((currentLotOccupancyOccupant) => { + return currentLotOccupancyOccupant.lotOccupantIndex === lotOccupantIndex; + })!; + + let editFormElement: HTMLFormElement; + let editCloseModalFunction: () => void; + + const editOccupant = (submitEvent: SubmitEvent) => { + submitEvent.preventDefault(); + + cityssm.postJSON( + los.urlPrefix + "/lotOccupancies/doUpdateLotOccupancyOccupant", + editFormElement, + (responseJSON: { + success: boolean; + errorMessage?: string; + lotOccupancyOccupants?: recordTypes.LotOccupancyOccupant[]; + }) => { + if (responseJSON.success) { + lotOccupancyOccupants = responseJSON.lotOccupancyOccupants!; + editCloseModalFunction(); + renderLotOccupancyOccupants(); + } else { + bulmaJS.alert({ + title: "Error Updating " + exports.aliases.occupant, + message: responseJSON.errorMessage || "", + contextualColorName: "danger" + }); + } + } + ); + }; + + cityssm.openHtmlModal("lotOccupancy-editOccupant", { + onshow: (modalElement) => { + los.populateAliases(modalElement); + + ( + modalElement.querySelector( + "#lotOccupancyOccupantEdit--lotOccupancyId" + ) as HTMLInputElement + ).value = lotOccupancyId; + ( + modalElement.querySelector( + "#lotOccupancyOccupantEdit--lotOccupantIndex" + ) as HTMLInputElement + ).value = lotOccupantIndex.toString(); + + const lotOccupantTypeSelectElement = modalElement.querySelector( + "#lotOccupancyOccupantEdit--lotOccupantTypeId" + ) as HTMLSelectElement; + + let lotOccupantTypeSelected = false; + + for (const lotOccupantType of exports.lotOccupantTypes as recordTypes.LotOccupantType[]) { + const optionElement = document.createElement("option"); + optionElement.value = lotOccupantType.lotOccupantTypeId.toString(); + optionElement.textContent = lotOccupantType.lotOccupantType; + + if (lotOccupantType.lotOccupantTypeId === lotOccupancyOccupant.lotOccupantTypeId) { + optionElement.selected = true; + lotOccupantTypeSelected = true; + } + + lotOccupantTypeSelectElement.append(optionElement); + } + + if (!lotOccupantTypeSelected) { + const optionElement = document.createElement("option"); + + optionElement.value = lotOccupancyOccupant.lotOccupantTypeId!.toString(); + optionElement.textContent = lotOccupancyOccupant.lotOccupantType as string; + optionElement.selected = true; + + lotOccupantTypeSelectElement.append(optionElement); + } + + ( + modalElement.querySelector( + "#lotOccupancyOccupantEdit--occupantName" + ) as HTMLInputElement + ).value = lotOccupancyOccupant.occupantName!; + ( + modalElement.querySelector( + "#lotOccupancyOccupantEdit--occupantAddress1" + ) as HTMLInputElement + ).value = lotOccupancyOccupant.occupantAddress1!; + ( + modalElement.querySelector( + "#lotOccupancyOccupantEdit--occupantAddress2" + ) as HTMLInputElement + ).value = lotOccupancyOccupant.occupantAddress2!; + ( + modalElement.querySelector( + "#lotOccupancyOccupantEdit--occupantCity" + ) as HTMLInputElement + ).value = lotOccupancyOccupant.occupantCity!; + ( + modalElement.querySelector( + "#lotOccupancyOccupantEdit--occupantProvince" + ) as HTMLInputElement + ).value = lotOccupancyOccupant.occupantProvince!; + + ( + modalElement.querySelector( + "#lotOccupancyOccupantEdit--occupantPostalCode" + ) as HTMLInputElement + ).value = lotOccupancyOccupant.occupantPostalCode!; + + ( + modalElement.querySelector( + "#lotOccupancyOccupantEdit--occupantPhoneNumber" + ) as HTMLInputElement + ).value = lotOccupancyOccupant.occupantPhoneNumber!; + + ( + modalElement.querySelector( + "#lotOccupancyOccupantEdit--occupantEmailAddress" + ) as HTMLInputElement + ).value = lotOccupancyOccupant.occupantEmailAddress!; + + ( + modalElement.querySelector( + "#lotOccupancyOccupantEdit--occupantComment" + ) as HTMLTextAreaElement + ).value = lotOccupancyOccupant.occupantComment!; + }, + onshown: (modalElement, closeModalFunction) => { + bulmaJS.toggleHtmlClipped(); + + ( + modalElement.querySelector( + "#lotOccupancyOccupantEdit--lotOccupantTypeId" + ) as HTMLInputElement + ).focus(); + + editFormElement = modalElement.querySelector("form")!; + editFormElement.addEventListener("submit", editOccupant); + + editCloseModalFunction = closeModalFunction; + }, + onremoved: () => { + bulmaJS.toggleHtmlClipped(); + } + }); +}; + +const deleteLotOccupancyOccupant = (clickEvent: Event) => { + const lotOccupantIndex = (clickEvent.currentTarget as HTMLElement).closest("tr")!.dataset + .lotOccupantIndex; + + const doDelete = () => { + cityssm.postJSON( + los.urlPrefix + "/lotOccupancies/doDeleteLotOccupancyOccupant", + { + lotOccupancyId, + lotOccupantIndex + }, + (responseJSON: { + success: boolean; + errorMessage?: string; + lotOccupancyOccupants: recordTypes.LotOccupancyOccupant[]; + }) => { + if (responseJSON.success) { + lotOccupancyOccupants = responseJSON.lotOccupancyOccupants; + renderLotOccupancyOccupants(); + } else { + bulmaJS.alert({ + title: "Error Removing " + exports.aliases.occupant, + message: responseJSON.errorMessage || "", + contextualColorName: "danger" + }); + } + } + ); + }; + + bulmaJS.confirm({ + title: "Remove " + exports.aliases.occupant + "?", + message: + "Are you sure you want to remove this " + exports.aliases.occupant.toLowerCase() + "?", + okButton: { + text: "Yes, Remove " + exports.aliases.occupant, + callbackFunction: doDelete + }, + contextualColorName: "warning" + }); +}; + +const renderLotOccupancyOccupants = () => { + const occupantsContainer = document.querySelector( + "#container--lotOccupancyOccupants" + ) as HTMLElement; + + cityssm.clearElement(occupantsContainer); + + if (lotOccupancyOccupants.length === 0) { + occupantsContainer.innerHTML = + '
' + + '

There are no ' + + exports.aliases.occupants.toLowerCase() + + " associated with this record.

" + + "
"; + + return; + } + + const tableElement = document.createElement("table"); + tableElement.className = "table is-fullwidth is-striped is-hoverable"; + + tableElement.innerHTML = + "" + + ("" + exports.aliases.occupant + "") + + "Address" + + "Other Contact" + + "Comment" + + 'Options' + + "" + + ""; + + for (const lotOccupancyOccupant of lotOccupancyOccupants) { + const tableRowElement = document.createElement("tr"); + tableRowElement.dataset.lotOccupantIndex = + lotOccupancyOccupant.lotOccupantIndex!.toString(); + + tableRowElement.innerHTML = + "" + + cityssm.escapeHTML(lotOccupancyOccupant.occupantName || "(No Name)") + + "
" + + ('' + + '' + + ' ' + + cityssm.escapeHTML(lotOccupancyOccupant.lotOccupantType!) + + "" + + "") + + "" + + ("" + + (lotOccupancyOccupant.occupantAddress1 + ? cityssm.escapeHTML(lotOccupancyOccupant.occupantAddress1) + "
" + : "") + + (lotOccupancyOccupant.occupantAddress2 + ? cityssm.escapeHTML(lotOccupancyOccupant.occupantAddress2) + "
" + : "") + + (lotOccupancyOccupant.occupantCity + ? cityssm.escapeHTML(lotOccupancyOccupant.occupantCity) + ", " + : "") + + cityssm.escapeHTML(lotOccupancyOccupant.occupantProvince || "") + + "
" + + cityssm.escapeHTML(lotOccupancyOccupant.occupantPostalCode || "") + + "") + + ("" + + (lotOccupancyOccupant.occupantPhoneNumber + ? cityssm.escapeHTML(lotOccupancyOccupant.occupantPhoneNumber) + "
" + : "") + + (lotOccupancyOccupant.occupantEmailAddress + ? cityssm.escapeHTML(lotOccupancyOccupant.occupantEmailAddress) + : "") + + "") + + ("" + cityssm.escapeHTML(lotOccupancyOccupant.occupantComment!) + "") + + ('' + + '
' + + ('") + + ('") + + "
" + + ""); + + (tableRowElement.querySelector(".button--edit") as HTMLButtonElement).addEventListener( + "click", + openEditLotOccupancyOccupant + ); + + (tableRowElement.querySelector(".button--delete") as HTMLButtonElement).addEventListener( + "click", + deleteLotOccupancyOccupant + ); + + tableElement.querySelector("tbody")!.append(tableRowElement); + } + + occupantsContainer.append(tableElement); +}; + if (isCreate) { const lotOccupantTypeIdElement = document.querySelector( "#lotOccupancy--lotOccupantTypeId" @@ -31,314 +330,9 @@ if (isCreate) { } }); } else { - let lotOccupancyOccupants: recordTypes.LotOccupancyOccupant[] = - exports.lotOccupancyOccupants; - + lotOccupancyOccupants = exports.lotOccupancyOccupants; delete exports.lotOccupancyOccupants; - const openEditLotOccupancyOccupant = (clickEvent: Event) => { - const lotOccupantIndex = Number.parseInt( - (clickEvent.currentTarget as HTMLElement).closest("tr")!.dataset.lotOccupantIndex!, - 10 - ); - - const lotOccupancyOccupant = lotOccupancyOccupants.find( - (currentLotOccupancyOccupant) => { - return currentLotOccupancyOccupant.lotOccupantIndex === lotOccupantIndex; - } - )!; - - let editFormElement: HTMLFormElement; - let editCloseModalFunction: () => void; - - const editOccupant = (submitEvent: SubmitEvent) => { - submitEvent.preventDefault(); - - cityssm.postJSON( - los.urlPrefix + "/lotOccupancies/doUpdateLotOccupancyOccupant", - editFormElement, - (responseJSON: { - success: boolean; - errorMessage?: string; - lotOccupancyOccupants?: recordTypes.LotOccupancyOccupant[]; - }) => { - if (responseJSON.success) { - lotOccupancyOccupants = responseJSON.lotOccupancyOccupants!; - editCloseModalFunction(); - renderLotOccupancyOccupants(); - } else { - bulmaJS.alert({ - title: "Error Updating " + exports.aliases.occupant, - message: responseJSON.errorMessage || "", - contextualColorName: "danger" - }); - } - } - ); - }; - - cityssm.openHtmlModal("lotOccupancy-editOccupant", { - onshow: (modalElement) => { - los.populateAliases(modalElement); - - ( - modalElement.querySelector( - "#lotOccupancyOccupantEdit--lotOccupancyId" - ) as HTMLInputElement - ).value = lotOccupancyId; - ( - modalElement.querySelector( - "#lotOccupancyOccupantEdit--lotOccupantIndex" - ) as HTMLInputElement - ).value = lotOccupantIndex.toString(); - - const lotOccupantTypeSelectElement = modalElement.querySelector( - "#lotOccupancyOccupantEdit--lotOccupantTypeId" - ) as HTMLSelectElement; - - let lotOccupantTypeSelected = false; - - for (const lotOccupantType of exports.lotOccupantTypes as recordTypes.LotOccupantType[]) { - const optionElement = document.createElement("option"); - optionElement.value = lotOccupantType.lotOccupantTypeId.toString(); - optionElement.textContent = lotOccupantType.lotOccupantType; - - if ( - lotOccupantType.lotOccupantTypeId === - lotOccupancyOccupant.lotOccupantTypeId - ) { - optionElement.selected = true; - lotOccupantTypeSelected = true; - } - - lotOccupantTypeSelectElement.append(optionElement); - } - - if (!lotOccupantTypeSelected) { - const optionElement = document.createElement("option"); - - optionElement.value = lotOccupancyOccupant.lotOccupantTypeId!.toString(); - optionElement.textContent = lotOccupancyOccupant.lotOccupantType as string; - optionElement.selected = true; - - lotOccupantTypeSelectElement.append(optionElement); - } - - ( - modalElement.querySelector( - "#lotOccupancyOccupantEdit--occupantName" - ) as HTMLInputElement - ).value = lotOccupancyOccupant.occupantName!; - ( - modalElement.querySelector( - "#lotOccupancyOccupantEdit--occupantAddress1" - ) as HTMLInputElement - ).value = lotOccupancyOccupant.occupantAddress1!; - ( - modalElement.querySelector( - "#lotOccupancyOccupantEdit--occupantAddress2" - ) as HTMLInputElement - ).value = lotOccupancyOccupant.occupantAddress2!; - ( - modalElement.querySelector( - "#lotOccupancyOccupantEdit--occupantCity" - ) as HTMLInputElement - ).value = lotOccupancyOccupant.occupantCity!; - ( - modalElement.querySelector( - "#lotOccupancyOccupantEdit--occupantProvince" - ) as HTMLInputElement - ).value = lotOccupancyOccupant.occupantProvince!; - - ( - modalElement.querySelector( - "#lotOccupancyOccupantEdit--occupantPostalCode" - ) as HTMLInputElement - ).value = lotOccupancyOccupant.occupantPostalCode!; - - ( - modalElement.querySelector( - "#lotOccupancyOccupantEdit--occupantPhoneNumber" - ) as HTMLInputElement - ).value = lotOccupancyOccupant.occupantPhoneNumber!; - - ( - modalElement.querySelector( - "#lotOccupancyOccupantEdit--occupantEmailAddress" - ) as HTMLInputElement - ).value = lotOccupancyOccupant.occupantEmailAddress!; - - ( - modalElement.querySelector( - "#lotOccupancyOccupantEdit--occupantComment" - ) as HTMLTextAreaElement - ).value = lotOccupancyOccupant.occupantComment!; - }, - onshown: (modalElement, closeModalFunction) => { - bulmaJS.toggleHtmlClipped(); - - ( - modalElement.querySelector( - "#lotOccupancyOccupantEdit--lotOccupantTypeId" - ) as HTMLInputElement - ).focus(); - - editFormElement = modalElement.querySelector("form")!; - editFormElement.addEventListener("submit", editOccupant); - - editCloseModalFunction = closeModalFunction; - }, - onremoved: () => { - bulmaJS.toggleHtmlClipped(); - } - }); - }; - - const deleteLotOccupancyOccupant = (clickEvent: Event) => { - const lotOccupantIndex = (clickEvent.currentTarget as HTMLElement).closest("tr")! - .dataset.lotOccupantIndex; - - const doDelete = () => { - cityssm.postJSON( - los.urlPrefix + "/lotOccupancies/doDeleteLotOccupancyOccupant", - { - lotOccupancyId, - lotOccupantIndex - }, - (responseJSON: { - success: boolean; - errorMessage?: string; - lotOccupancyOccupants: recordTypes.LotOccupancyOccupant[]; - }) => { - if (responseJSON.success) { - lotOccupancyOccupants = responseJSON.lotOccupancyOccupants; - renderLotOccupancyOccupants(); - } else { - bulmaJS.alert({ - title: "Error Removing " + exports.aliases.occupant, - message: responseJSON.errorMessage || "", - contextualColorName: "danger" - }); - } - } - ); - }; - - bulmaJS.confirm({ - title: "Remove " + exports.aliases.occupant + "?", - message: - "Are you sure you want to remove this " + - exports.aliases.occupant.toLowerCase() + - "?", - okButton: { - text: "Yes, Remove " + exports.aliases.occupant, - callbackFunction: doDelete - }, - contextualColorName: "warning" - }); - }; - - const renderLotOccupancyOccupants = () => { - const occupantsContainer = document.querySelector( - "#container--lotOccupancyOccupants" - ) as HTMLElement; - - cityssm.clearElement(occupantsContainer); - - if (lotOccupancyOccupants.length === 0) { - occupantsContainer.innerHTML = - '
' + - '

There are no ' + - exports.aliases.occupants.toLowerCase() + - " associated with this record.

" + - "
"; - - return; - } - - const tableElement = document.createElement("table"); - tableElement.className = "table is-fullwidth is-striped is-hoverable"; - - tableElement.innerHTML = - "" + - ("" + exports.aliases.occupant + "") + - "Address" + - "Other Contact" + - "Comment" + - 'Options' + - "" + - ""; - - for (const lotOccupancyOccupant of lotOccupancyOccupants) { - const tableRowElement = document.createElement("tr"); - tableRowElement.dataset.lotOccupantIndex = - lotOccupancyOccupant.lotOccupantIndex!.toString(); - - tableRowElement.innerHTML = - "" + - cityssm.escapeHTML(lotOccupancyOccupant.occupantName || "(No Name)") + - "
" + - ('' + - '' + - ' ' + - cityssm.escapeHTML(lotOccupancyOccupant.lotOccupantType!) + - "" + - "") + - "" + - ("" + - (lotOccupancyOccupant.occupantAddress1 - ? cityssm.escapeHTML(lotOccupancyOccupant.occupantAddress1) + "
" - : "") + - (lotOccupancyOccupant.occupantAddress2 - ? cityssm.escapeHTML(lotOccupancyOccupant.occupantAddress2) + "
" - : "") + - (lotOccupancyOccupant.occupantCity - ? cityssm.escapeHTML(lotOccupancyOccupant.occupantCity) + ", " - : "") + - cityssm.escapeHTML(lotOccupancyOccupant.occupantProvince || "") + - "
" + - cityssm.escapeHTML(lotOccupancyOccupant.occupantPostalCode || "") + - "") + - ("" + - (lotOccupancyOccupant.occupantPhoneNumber - ? cityssm.escapeHTML(lotOccupancyOccupant.occupantPhoneNumber) + - "
" - : "") + - (lotOccupancyOccupant.occupantEmailAddress - ? cityssm.escapeHTML(lotOccupancyOccupant.occupantEmailAddress) - : "") + - "") + - ("" + cityssm.escapeHTML(lotOccupancyOccupant.occupantComment!) + "") + - ('' + - '
' + - ('") + - ('") + - "
" + - ""); - - ( - tableRowElement.querySelector(".button--edit") as HTMLButtonElement - ).addEventListener("click", openEditLotOccupancyOccupant); - - ( - tableRowElement.querySelector(".button--delete") as HTMLButtonElement - ).addEventListener("click", deleteLotOccupancyOccupant); - - tableElement.querySelector("tbody")!.append(tableRowElement); - } - - occupantsContainer.append(tableElement); - }; - (document.querySelector("#button--addOccupant") as HTMLButtonElement).addEventListener( "click", () => { @@ -464,8 +458,7 @@ if (isCreate) { cityssm.escapeHTML(occupant.occupantAddress1 || "") + "
" + (occupant.occupantAddress2 - ? cityssm.escapeHTML(occupant.occupantAddress2) + - "
" + ? cityssm.escapeHTML(occupant.occupantAddress2) + "
" : "") + cityssm.escapeHTML(occupant.occupantCity || "") + ", " + diff --git a/public/javascripts/lotOccupancyEdit.min.js b/public/javascripts/lotOccupancyEdit.min.js index f31c3176..e8e97ff2 100644 --- a/public/javascripts/lotOccupancyEdit.min.js +++ b/public/javascripts/lotOccupancyEdit.min.js @@ -1 +1 @@ -"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),(()=>{var e,t,c;const a=exports.los,o=document.querySelector("#lotOccupancy--lotOccupancyId").value,n=""===o;let s=!1,l=n;const r=()=>{s||(s=!0,cityssm.enableNavBlocker())},i=document.querySelector("#form--lotOccupancy");i.addEventListener("submit",e=>{e.preventDefault(),cityssm.postJSON(a.urlPrefix+"/lotOccupancies/"+(n?"doCreateLotOccupancy":"doUpdateLotOccupancy"),i,e=>{e.success?(s=!1,cityssm.disableNavBlocker(),n||l?window.location.href=a.urlPrefix+"/lotOccupancies/"+e.lotOccupancyId+"/edit?t="+Date.now():bulmaJS.alert({message:exports.aliases.occupancy+" Updated Successfully",contextualColorName:"success"})):bulmaJS.alert({title:"Error Saving "+exports.aliases.occupancy,message:e.errorMessage||"",contextualColorName:"danger"})})});const u=i.querySelectorAll("input, select");for(const e of u)e.addEventListener("change",r);if(!n){const n=()=>{cityssm.postJSON(a.urlPrefix+"/lotOccupancies/doCopyLotOccupancy",{lotOccupancyId:o},e=>{var t;e.success?(cityssm.disableNavBlocker(),window.location.href=a.urlPrefix+"/lotOccupancies/"+(null===(t=e.lotOccupancyId)||void 0===t?void 0:t.toString())+"/edit"):bulmaJS.alert({title:"Error Copying Record",message:e.errorMessage||"",contextualColorName:"danger"})})};null===(e=document.querySelector("#button--copyLotOccupancy"))||void 0===e||e.addEventListener("click",e=>{e.preventDefault(),s?bulmaJS.alert({title:"Unsaved Changes",message:"Please save all unsaved changes before continuing.",contextualColorName:"warning"}):bulmaJS.confirm({title:"Copy "+exports.aliases.occupancy+" Record as New",message:"Are you sure you want to copy this record to a new record?",contextualColorName:"info",okButton:{text:"Yes, Copy",callbackFunction:n}})}),null===(t=document.querySelector("#button--deleteLotOccupancy"))||void 0===t||t.addEventListener("click",e=>{e.preventDefault();bulmaJS.confirm({title:"Delete "+exports.aliases.occupancy+" Record",message:"Are you sure you want to delete this record?",contextualColorName:"warning",okButton:{text:"Yes, Delete",callbackFunction:()=>{cityssm.postJSON(a.urlPrefix+"/lotOccupancies/doDeleteLotOccupancy",{lotOccupancyId:o},e=>{e.success?(cityssm.disableNavBlocker(),window.location.href=a.urlPrefix+"/lotOccupancies?t="+Date.now()):bulmaJS.alert({title:"Error Deleting Record",message:e.errorMessage||"",contextualColorName:"danger"})})}}})}),null===(c=document.querySelector("#button--createWorkOrder"))||void 0===c||c.addEventListener("click",e=>{let t;e.preventDefault();const c=e=>{e.preventDefault(),cityssm.postJSON(a.urlPrefix+"/workOrders/doCreateWorkOrder",e.currentTarget,e=>{e.success?(t(),bulmaJS.confirm({title:"Work Order Created Successfully",message:"Would you like to open the work order now?",contextualColorName:"success",okButton:{text:"Yes, Open the Work Order",callbackFunction:()=>{window.location.href=a.urlPrefix+"/workOrders/"+e.workOrderId+"/edit"}}})):bulmaJS.alert({title:"Error Creating Work Order",message:e.errorMessage,contextualColorName:"danger"})})};cityssm.openHtmlModal("lotOccupancy-createWorkOrder",{onshow:e=>{e.querySelector("#workOrderCreate--lotOccupancyId").value=o,e.querySelector("#workOrderCreate--workOrderOpenDateString").value=cityssm.dateToString(new Date);const t=e.querySelector("#workOrderCreate--workOrderTypeId"),c=exports.workOrderTypes;1===c.length&&(t.innerHTML="");for(const e of c){const c=document.createElement("option");c.value=e.workOrderTypeId.toString(),c.textContent=e.workOrderType,t.append(c)}},onshown:(e,a)=>{var o;t=a,null===(o=e.querySelector("form"))||void 0===o||o.addEventListener("submit",c)}})})}const d=document.querySelector("#lotOccupancy--occupancyTypeId");if(n){const e=document.querySelector("#container--lotOccupancyFields");d.addEventListener("change",()=>{""!==d.value?cityssm.postJSON(a.urlPrefix+"/lotOccupancies/doGetOccupancyTypeFields",{occupancyTypeId:d.value},t=>{if(0===t.occupancyTypeFields.length)return void(e.innerHTML='

There are no additional fields for this '+exports.aliases.occupancy.toLowerCase()+" type.

");e.innerHTML="";let c="";for(const a of t.occupancyTypeFields){c+=","+a.occupancyTypeFieldId;const t="lotOccupancyFieldValue_"+a.occupancyTypeFieldId,o="lotOccupancy--"+t,n=document.createElement("div");if(n.className="field",n.innerHTML='
',n.querySelector("label").textContent=a.occupancyTypeField,""===a.occupancyTypeFieldValues){const e=document.createElement("input");e.className="input",e.id=o,e.name=t,e.type="text",e.required=a.isRequired,e.minLength=a.minimumLength,e.maxLength=a.maximumLength,a.pattern&&""!==a.pattern&&(e.pattern=a.pattern),n.querySelector(".control").append(e)}else{n.querySelector(".control").innerHTML='
';const e=n.querySelector("select");e.required=a.isRequired;const c=a.occupancyTypeFieldValues.split("\n");for(const t of c){const c=document.createElement("option");c.value=t,c.textContent=t,e.append(c)}}e.append(n)}e.insertAdjacentHTML("beforeend",'')}):e.innerHTML='

Select the '+exports.aliases.occupancy.toLowerCase()+" type to load the available fields.

"})}else{const e=d.value;d.addEventListener("change",()=>{d.value!==e&&bulmaJS.confirm({title:"Confirm Change",message:"Are you sure you want to change the "+exports.aliases.occupancy.toLowerCase()+" type?\nThis change affects the additional fields associated with this record, and may also affect the available fees.",contextualColorName:"warning",okButton:{text:"Yes, Keep the Change",callbackFunction:()=>{l=!0}},cancelButton:{text:"Revert the Change",callbackFunction:()=>{d.value=e}}})})}const p=document.querySelector("#lotOccupancy--lotName");if(p.addEventListener("click",e=>{const t=e.currentTarget.value;let c,o,n,s;const l=(e,t)=>{document.querySelector("#lotOccupancy--lotId").value=e.toString(),document.querySelector("#lotOccupancy--lotName").value=t,r(),c()},i=e=>{e.preventDefault();const t=e.currentTarget;l(t.dataset.lotId,t.dataset.lotName)},u=()=>{s.innerHTML='


Searching...

',cityssm.postJSON(a.urlPrefix+"/lots/doSearchLots",n,e=>{if(0===e.count)return void(s.innerHTML='

No results.

');const t=document.createElement("div");t.className="panel";for(const c of e.lots){const e=document.createElement("a");e.className="panel-block is-block",e.href="#",e.dataset.lotId=c.lotId.toString(),e.dataset.lotName=c.lotName,e.innerHTML='
'+cityssm.escapeHTML(c.lotName||"")+'
'+cityssm.escapeHTML(c.mapName||"")+'
'+cityssm.escapeHTML(c.lotStatus)+'
'+(c.lotOccupancyCount>0?"Currently Occupied":"")+"
",e.addEventListener("click",i),t.append(e)}s.innerHTML="",s.append(t)})},d=e=>{e.preventDefault();const t=o.querySelector("#lotCreate--lotName").value;cityssm.postJSON(a.urlPrefix+"/lots/doCreateLot",e.currentTarget,e=>{e.success?l(e.lotId,t):bulmaJS.alert({title:"Error Creating "+exports.aliases.lot,message:e.errorMessage||"",contextualColorName:"danger"})})};cityssm.openHtmlModal("lotOccupancy-selectLot",{onshow:e=>{a.populateAliases(e)},onshown:(e,a)=>{bulmaJS.toggleHtmlClipped(),o=e,c=a,bulmaJS.init(e);const l=e.querySelector("#lotSelect--lotName");""!==document.querySelector("#lotOccupancy--lotId").value&&(l.value=t),l.focus(),l.addEventListener("change",u);const r=e.querySelector("#lotSelect--occupancyStatus");if(r.addEventListener("change",u),""!==t&&(r.value=""),n=e.querySelector("#form--lotSelect"),s=e.querySelector("#resultsContainer--lotSelect"),n.addEventListener("submit",e=>{e.preventDefault()}),u(),exports.lotNamePattern){const t=exports.lotNamePattern;e.querySelector("#lotCreate--lotName").pattern=t.source}const i=e.querySelector("#lotCreate--lotTypeId");for(const e of exports.lotTypes){const t=document.createElement("option");t.value=e.lotTypeId.toString(),t.textContent=e.lotType,i.append(t)}const p=e.querySelector("#lotCreate--lotStatusId");for(const e of exports.lotStatuses){const t=document.createElement("option");t.value=e.lotStatusId.toString(),t.textContent=e.lotStatus,p.append(t)}const m=e.querySelector("#lotCreate--mapId");for(const e of exports.maps){const t=document.createElement("option");t.value=e.mapId.toString(),t.textContent=e.mapName||"(No Name)",m.append(t)}e.querySelector("#form--lotCreate").addEventListener("submit",d)},onremoved:()=>{bulmaJS.toggleHtmlClipped()}})}),document.querySelector(".is-lot-view-button").addEventListener("click",()=>{const e=document.querySelector("#lotOccupancy--lotId").value;e?window.open(a.urlPrefix+"/lots/"+e):bulmaJS.alert({message:"No "+exports.aliases.lot.toLowerCase()+" selected.",contextualColorName:"info"})}),document.querySelector(".is-clear-lot-button").addEventListener("click",()=>{p.disabled?bulmaJS.alert({message:"You need to unlock the field before clearing it.",contextualColorName:"info"}):(p.value="(No "+exports.aliases.lot+")",document.querySelector("#lotOccupancy--lotId").value="",r())}),a.initializeDatePickers(i),document.querySelector("#lotOccupancy--occupancyStartDateString").addEventListener("change",()=>{const e=document.querySelector("#lotOccupancy--occupancyEndDateString").bulmaCalendar.datePicker;e.min=document.querySelector("#lotOccupancy--occupancyStartDateString").value,e.refresh()}),a.initializeUnlockFieldButtons(i),Object.defineProperty(exports,"__esModule",{value:!0}),n){const e=document.querySelector("#lotOccupancy--lotOccupantTypeId");e.addEventListener("change",()=>{const t=i.querySelectorAll("[data-table='LotOccupancyOccupant']");for(const c of t)c.disabled=""===e.value})}else{let e=exports.lotOccupancyOccupants;delete exports.lotOccupancyOccupants;const t=t=>{const c=Number.parseInt(t.currentTarget.closest("tr").dataset.lotOccupantIndex,10),s=e.find(e=>e.lotOccupantIndex===c);let l,r;const i=t=>{t.preventDefault(),cityssm.postJSON(a.urlPrefix+"/lotOccupancies/doUpdateLotOccupancyOccupant",l,t=>{t.success?(e=t.lotOccupancyOccupants,r(),n()):bulmaJS.alert({title:"Error Updating "+exports.aliases.occupant,message:t.errorMessage||"",contextualColorName:"danger"})})};cityssm.openHtmlModal("lotOccupancy-editOccupant",{onshow:e=>{a.populateAliases(e),e.querySelector("#lotOccupancyOccupantEdit--lotOccupancyId").value=o,e.querySelector("#lotOccupancyOccupantEdit--lotOccupantIndex").value=c.toString();const t=e.querySelector("#lotOccupancyOccupantEdit--lotOccupantTypeId");let n=!1;for(const e of exports.lotOccupantTypes){const c=document.createElement("option");c.value=e.lotOccupantTypeId.toString(),c.textContent=e.lotOccupantType,e.lotOccupantTypeId===s.lotOccupantTypeId&&(c.selected=!0,n=!0),t.append(c)}if(!n){const e=document.createElement("option");e.value=s.lotOccupantTypeId.toString(),e.textContent=s.lotOccupantType,e.selected=!0,t.append(e)}e.querySelector("#lotOccupancyOccupantEdit--occupantName").value=s.occupantName,e.querySelector("#lotOccupancyOccupantEdit--occupantAddress1").value=s.occupantAddress1,e.querySelector("#lotOccupancyOccupantEdit--occupantAddress2").value=s.occupantAddress2,e.querySelector("#lotOccupancyOccupantEdit--occupantCity").value=s.occupantCity,e.querySelector("#lotOccupancyOccupantEdit--occupantProvince").value=s.occupantProvince,e.querySelector("#lotOccupancyOccupantEdit--occupantPostalCode").value=s.occupantPostalCode,e.querySelector("#lotOccupancyOccupantEdit--occupantPhoneNumber").value=s.occupantPhoneNumber,e.querySelector("#lotOccupancyOccupantEdit--occupantEmailAddress").value=s.occupantEmailAddress,e.querySelector("#lotOccupancyOccupantEdit--occupantComment").value=s.occupantComment},onshown:(e,t)=>{bulmaJS.toggleHtmlClipped(),e.querySelector("#lotOccupancyOccupantEdit--lotOccupantTypeId").focus(),(l=e.querySelector("form")).addEventListener("submit",i),r=t},onremoved:()=>{bulmaJS.toggleHtmlClipped()}})},c=t=>{const c=t.currentTarget.closest("tr").dataset.lotOccupantIndex;bulmaJS.confirm({title:"Remove "+exports.aliases.occupant+"?",message:"Are you sure you want to remove this "+exports.aliases.occupant.toLowerCase()+"?",okButton:{text:"Yes, Remove "+exports.aliases.occupant,callbackFunction:()=>{cityssm.postJSON(a.urlPrefix+"/lotOccupancies/doDeleteLotOccupancyOccupant",{lotOccupancyId:o,lotOccupantIndex:c},t=>{t.success?(e=t.lotOccupancyOccupants,n()):bulmaJS.alert({title:"Error Removing "+exports.aliases.occupant,message:t.errorMessage||"",contextualColorName:"danger"})})}},contextualColorName:"warning"})},n=()=>{const a=document.querySelector("#container--lotOccupancyOccupants");if(cityssm.clearElement(a),0===e.length)return void(a.innerHTML='

There are no '+exports.aliases.occupants.toLowerCase()+" associated with this record.

");const o=document.createElement("table");o.className="table is-fullwidth is-striped is-hoverable",o.innerHTML=""+exports.aliases.occupant+'AddressOther ContactCommentOptions';for(const a of e){const e=document.createElement("tr");e.dataset.lotOccupantIndex=a.lotOccupantIndex.toString(),e.innerHTML=""+cityssm.escapeHTML(a.occupantName||"(No Name)")+'
'+cityssm.escapeHTML(a.lotOccupantType)+""+(a.occupantAddress1?cityssm.escapeHTML(a.occupantAddress1)+"
":"")+(a.occupantAddress2?cityssm.escapeHTML(a.occupantAddress2)+"
":"")+(a.occupantCity?cityssm.escapeHTML(a.occupantCity)+", ":"")+cityssm.escapeHTML(a.occupantProvince||"")+"
"+cityssm.escapeHTML(a.occupantPostalCode||"")+""+(a.occupantPhoneNumber?cityssm.escapeHTML(a.occupantPhoneNumber)+"
":"")+(a.occupantEmailAddress?cityssm.escapeHTML(a.occupantEmailAddress):"")+""+cityssm.escapeHTML(a.occupantComment)+'
',e.querySelector(".button--edit").addEventListener("click",t),e.querySelector(".button--delete").addEventListener("click",c),o.querySelector("tbody").append(e)}a.append(o)};document.querySelector("#button--addOccupant").addEventListener("click",()=>{let t,c,s,l;const r=c=>{cityssm.postJSON(a.urlPrefix+"/lotOccupancies/doAddLotOccupancyOccupant",c,c=>{c.success?(e=c.lotOccupancyOccupants,t(),n()):bulmaJS.alert({title:"Error Adding "+exports.aliases.occupant,message:c.errorMessage||"",contextualColorName:"danger"})})},i=e=>{e.preventDefault(),r(c)};let u=[];const d=e=>{e.preventDefault();const t=e.currentTarget,c=u[Number.parseInt(t.dataset.index,10)],a=t.closest(".modal").querySelector("#lotOccupancyOccupantCopy--lotOccupantTypeId").value;""===a?bulmaJS.alert({title:"No "+exports.aliases.occupant+" Type Selected",message:"Select a type to apply to the newly added "+exports.aliases.occupant.toLowerCase()+".",contextualColorName:"warning"}):(c.lotOccupantTypeId=Number.parseInt(a,10),c.lotOccupancyId=Number.parseInt(o,10),r(c))},p=e=>{e.preventDefault(),""!==s.querySelector("#lotOccupancyOccupantCopy--searchFilter").value?(l.innerHTML='

Searching...
',cityssm.postJSON(a.urlPrefix+"/lotOccupancies/doSearchPastOccupants",s,e=>{u=e.occupants;const t=document.createElement("div");t.className="panel";for(const[e,c]of u.entries()){const a=document.createElement("a");a.className="panel-block is-block",a.dataset.index=e.toString(),a.innerHTML=""+cityssm.escapeHTML(c.occupantName||"")+'
'+cityssm.escapeHTML(c.occupantAddress1||"")+"
"+(c.occupantAddress2?cityssm.escapeHTML(c.occupantAddress2)+"
":"")+cityssm.escapeHTML(c.occupantCity||"")+", "+cityssm.escapeHTML(c.occupantProvince||"")+"
"+cityssm.escapeHTML(c.occupantPostalCode||"")+'
'+(c.occupantPhoneNumber?cityssm.escapeHTML(c.occupantPhoneNumber)+"
":"")+cityssm.escapeHTML(c.occupantEmailAddress||"")+"
",a.addEventListener("click",d),t.append(a)}l.innerHTML="",l.append(t)})):l.innerHTML='

Enter a partial name or address in the search field above.

'};cityssm.openHtmlModal("lotOccupancy-addOccupant",{onshow:e=>{a.populateAliases(e),e.querySelector("#lotOccupancyOccupantAdd--lotOccupancyId").value=o;const t=e.querySelector("#lotOccupancyOccupantAdd--lotOccupantTypeId"),c=e.querySelector("#lotOccupancyOccupantCopy--lotOccupantTypeId");for(const e of exports.lotOccupantTypes){const a=document.createElement("option");a.value=e.lotOccupantTypeId.toString(),a.textContent=e.lotOccupantType,t.append(a),c.append(a.cloneNode(!0))}e.querySelector("#lotOccupancyOccupantAdd--occupantCity").value=exports.occupantCityDefault,e.querySelector("#lotOccupancyOccupantAdd--occupantProvince").value=exports.occupantProvinceDefault},onshown:(e,a)=>{bulmaJS.toggleHtmlClipped(),bulmaJS.init(e),e.querySelector("#lotOccupancyOccupantAdd--lotOccupantTypeId").focus(),(c=e.querySelector("#form--lotOccupancyOccupantAdd")).addEventListener("submit",i),l=e.querySelector("#lotOccupancyOccupantCopy--searchResults"),(s=e.querySelector("#form--lotOccupancyOccupantCopy")).addEventListener("submit",e=>{e.preventDefault()}),e.querySelector("#lotOccupancyOccupantCopy--searchFilter").addEventListener("change",p),t=a},onremoved:()=>{bulmaJS.toggleHtmlClipped()}})}),n()}if(!n){Object.defineProperty(exports,"__esModule",{value:!0});let e=exports.lotOccupancyComments;delete exports.lotOccupancyComments;const t=t=>{const c=Number.parseInt(t.currentTarget.closest("tr").dataset.lotOccupancyCommentId,10),s=e.find(e=>e.lotOccupancyCommentId===c);let l,r;const i=t=>{t.preventDefault(),cityssm.postJSON(a.urlPrefix+"/lotOccupancies/doUpdateLotOccupancyComment",l,t=>{t.success?(e=t.lotOccupancyComments,r(),n()):bulmaJS.alert({title:"Error Updating Comment",message:t.errorMessage||"",contextualColorName:"danger"})})};cityssm.openHtmlModal("lotOccupancy-editComment",{onshow:e=>{a.populateAliases(e),e.querySelector("#lotOccupancyCommentEdit--lotOccupancyId").value=o,e.querySelector("#lotOccupancyCommentEdit--lotOccupancyCommentId").value=c.toString(),e.querySelector("#lotOccupancyCommentEdit--lotOccupancyComment").value=s.lotOccupancyComment;const t=e.querySelector("#lotOccupancyCommentEdit--lotOccupancyCommentDateString");t.value=s.lotOccupancyCommentDateString;const n=cityssm.dateToString(new Date);t.max=s.lotOccupancyCommentDateString<=n?n:s.lotOccupancyCommentDateString,e.querySelector("#lotOccupancyCommentEdit--lotOccupancyCommentTimeString").value=s.lotOccupancyCommentTimeString},onshown:(e,t)=>{bulmaJS.toggleHtmlClipped(),a.initializeDatePickers(e),e.querySelector("#lotOccupancyCommentEdit--lotOccupancyComment").focus(),(l=e.querySelector("form")).addEventListener("submit",i),r=t},onremoved:()=>{bulmaJS.toggleHtmlClipped()}})},c=t=>{const c=Number.parseInt(t.currentTarget.closest("tr").dataset.lotOccupancyCommentId,10);bulmaJS.confirm({title:"Remove Comment?",message:"Are you sure you want to remove this comment?",okButton:{text:"Yes, Remove Comment",callbackFunction:()=>{cityssm.postJSON(a.urlPrefix+"/lotOccupancies/doDeleteLotOccupancyComment",{lotOccupancyId:o,lotOccupancyCommentId:c},t=>{t.success?(e=t.lotOccupancyComments,n()):bulmaJS.alert({title:"Error Removing Comment",message:t.errorMessage||"",contextualColorName:"danger"})})}},contextualColorName:"warning"})},n=()=>{const a=document.querySelector("#container--lotOccupancyComments");if(0===e.length)return void(a.innerHTML='

There are no comments associated with this record.

');const o=document.createElement("table");o.className="table is-fullwidth is-striped is-hoverable",o.innerHTML='CommentorComment DateCommentOptions';for(const a of e){const e=document.createElement("tr");e.dataset.lotOccupancyCommentId=a.lotOccupancyCommentId.toString(),e.innerHTML=""+cityssm.escapeHTML(a.recordCreate_userName||"")+""+a.lotOccupancyCommentDateString+(0===a.lotOccupancyCommentTime?"":" "+a.lotOccupancyCommentTimeString)+""+cityssm.escapeHTML(a.lotOccupancyComment||"")+'
',e.querySelector(".button--edit").addEventListener("click",t),e.querySelector(".button--delete").addEventListener("click",c),o.querySelector("tbody").append(e)}a.innerHTML="",a.append(o)};document.querySelector("#button--addComment").addEventListener("click",()=>{let t,c;const s=o=>{o.preventDefault(),cityssm.postJSON(a.urlPrefix+"/lotOccupancies/doAddLotOccupancyComment",t,t=>{t.success?(e=t.lotOccupancyComments,c(),n()):bulmaJS.alert({title:"Error Adding Comment",message:t.errorMessage||"",contextualColorName:"danger"})})};cityssm.openHtmlModal("lotOccupancy-addComment",{onshow:e=>{a.populateAliases(e),e.querySelector("#lotOccupancyCommentAdd--lotOccupancyId").value=o},onshown:(e,a)=>{bulmaJS.toggleHtmlClipped(),e.querySelector("#lotOccupancyCommentAdd--lotOccupancyComment").focus(),(t=e.querySelector("form")).addEventListener("submit",s),c=a},onremoved:()=>{bulmaJS.toggleHtmlClipped()}})}),n(),Object.defineProperty(exports,"__esModule",{value:!0});let l=exports.lotOccupancyFees;delete exports.lotOccupancyFees;const r=document.querySelector("#container--lotOccupancyFees"),i=()=>{let e=0;for(const t of l)e+=(t.feeAmount+t.taxAmount)*t.quantity;return e},u=e=>{const t=e.currentTarget.closest(".container--lotOccupancyFee").dataset.feeId;bulmaJS.confirm({title:"Delete Fee",message:"Are you sure you want to delete this fee?",contextualColorName:"warning",okButton:{text:"Yes, Delete Fee",callbackFunction:()=>{cityssm.postJSON(a.urlPrefix+"/lotOccupancies/doDeleteLotOccupancyFee",{lotOccupancyId:o,feeId:t},e=>{e.success?(l=e.lotOccupancyFees,d()):bulmaJS.alert({title:"Error Deleting Fee",message:e.errorMessage||"",contextualColorName:"danger"})})}}})},d=()=>{if(0===l.length)return r.innerHTML='

There are no fees associated with this record.

',void g();r.innerHTML='
FeeUnit Cost×QuantityequalsTotalOptions
Subtotal
Tax
Grand Total
';let e=0,t=0;for(const c of l){const a=document.createElement("tr");a.className="container--lotOccupancyFee",a.dataset.feeId=c.feeId.toString(),a.dataset.includeQuantity=c.includeQuantity?"1":"0",a.innerHTML=''+cityssm.escapeHTML(c.feeName||"")+""+(1===c.quantity?"":'$'+c.feeAmount.toFixed(2)+'×'+c.quantity+"=")+'$'+(c.feeAmount*c.quantity).toFixed(2)+'',a.querySelector("button").addEventListener("click",u),r.querySelector("tbody").append(a),e+=c.feeAmount*c.quantity,t+=c.taxAmount*c.quantity}r.querySelector("#lotOccupancyFees--feeAmountTotal").textContent="$"+e.toFixed(2),r.querySelector("#lotOccupancyFees--taxAmountTotal").textContent="$"+t.toFixed(2),r.querySelector("#lotOccupancyFees--grandTotal").textContent="$"+(e+t).toFixed(2),g()};document.querySelector("#button--addFee").addEventListener("click",()=>{if(s)return void bulmaJS.alert({message:"Please save all unsaved changes before adding fees.",contextualColorName:"warning"});let e,t,c;const n=(e,t=1)=>{cityssm.postJSON(a.urlPrefix+"/lotOccupancies/doAddLotOccupancyFee",{lotOccupancyId:o,feeId:e,quantity:t},e=>{e.success?(l=e.lotOccupancyFees,d(),u()):bulmaJS.alert({title:"Error Adding Fee",message:e.errorMessage||"",contextualColorName:"danger"})})},i=t=>{t.preventDefault();const c=Number.parseInt(t.currentTarget.dataset.feeId,10),a=Number.parseInt(t.currentTarget.closest(".container--feeCategory").dataset.feeCategoryId,10),o=e.find(e=>e.feeCategoryId===a).fees.find(e=>e.feeId===c);o.includeQuantity?(e=>{let t,c;const a=a=>{a.preventDefault(),n(e.feeId,t.value),c()};cityssm.openHtmlModal("lotOccupancy-setFeeQuantity",{onshow:t=>{t.querySelector("#lotOccupancyFeeQuantity--quantityUnit").textContent=e.quantityUnit},onshown:(e,o)=>{c=o,t=e.querySelector("#lotOccupancyFeeQuantity--quantity"),e.querySelector("form").addEventListener("submit",a)}})})(o):n(c)},u=()=>{const a=t.value.trim().toLowerCase().split(" ");c.innerHTML="";for(const t of e){const e=document.createElement("div");e.className="container--feeCategory",e.dataset.feeCategoryId=t.feeCategoryId.toString(),e.innerHTML='

'+cityssm.escapeHTML(t.feeCategory||"")+'

';let o=!1;for(const c of t.fees){if(r.querySelector(".container--lotOccupancyFee[data-fee-id='"+c.feeId+"'][data-include-quantity='0']"))continue;let t=!0;for(const e of a)if(!c.feeName.toLowerCase().includes(e)){t=!1;break}if(!t)continue;o=!0;const n=document.createElement("a");n.className="panel-block is-block container--fee",n.dataset.feeId=c.feeId.toString(),n.href="#",n.innerHTML=""+cityssm.escapeHTML(c.feeName||"")+"
"+cityssm.escapeHTML(c.feeDescription||"").replace(/\n/g,"
")+"
",n.addEventListener("click",i),e.querySelector(".panel").append(n)}o&&c.append(e)}};cityssm.openHtmlModal("lotOccupancy-addFee",{onshow:n=>{t=n.querySelector("#feeSelect--feeName"),c=n.querySelector("#resultsContainer--feeSelect"),cityssm.postJSON(a.urlPrefix+"/lotOccupancies/doGetFees",{lotOccupancyId:o},c=>{e=c.feeCategories,t.disabled=!1,t.addEventListener("keyup",u),t.focus(),u()})},onshown:()=>{bulmaJS.toggleHtmlClipped()},onhidden:()=>{d()},onremoved:()=>{bulmaJS.toggleHtmlClipped()}})});let p=exports.lotOccupancyTransactions;delete exports.lotOccupancyTransactions;const m=document.querySelector("#container--lotOccupancyTransactions"),y=()=>{let e=0;for(const t of p)e+=t.transactionAmount;return e},O=e=>{const t=e.currentTarget.closest(".container--lotOccupancyTransaction").dataset.transactionIndex;bulmaJS.confirm({title:"Delete Trasnaction",message:"Are you sure you want to delete this transaction?",contextualColorName:"warning",okButton:{text:"Yes, Delete Transaction",callbackFunction:()=>{cityssm.postJSON(a.urlPrefix+"/lotOccupancies/doDeleteLotOccupancyTransaction",{lotOccupancyId:o,transactionIndex:t},e=>{e.success?(p=e.lotOccupancyTransactions,g()):bulmaJS.alert({title:"Error Deleting Transaction",message:e.errorMessage||"",contextualColorName:"danger"})})}}})},g=()=>{if(0===p.length)return void(m.innerHTML='

There are no transactions associated with this record.

');m.innerHTML='
Date'+cityssm.escapeHTML(exports.aliases.externalReceiptNumber)+'AmountOptions
Transaction Total
';let e=0;for(const t of p){e+=t.transactionAmount;const c=document.createElement("tr");c.className="container--lotOccupancyTransaction",c.dataset.transactionIndex=t.transactionIndex.toString(),c.innerHTML=""+t.transactionDateString+""+cityssm.escapeHTML(t.externalReceiptNumber||"")+"
"+cityssm.escapeHTML(t.transactionNote||"")+'$'+t.transactionAmount.toFixed(2)+'',c.querySelector("button").addEventListener("click",O),m.querySelector("tbody").append(c)}m.querySelector("#lotOccupancyTransactions--grandTotal").textContent="$"+e.toFixed(2);const t=i();t>e&&m.insertAdjacentHTML("afterbegin",'
Outstanding Balance
$'+(t-e).toFixed(2)+"
")};document.querySelector("#button--addTransaction").addEventListener("click",()=>{let e;const t=t=>{t.preventDefault(),cityssm.postJSON(a.urlPrefix+"/lotOccupancies/doAddLotOccupancyTransaction",t.currentTarget,t=>{t.success?(p=t.lotOccupancyTransactions,e(),g()):bulmaJS.confirm({title:"Error Adding Transaction",message:t.errorMessage||"",contextualColorName:"danger"})})};cityssm.openHtmlModal("lotOccupancy-addTransaction",{onshow:e=>{a.populateAliases(e),e.querySelector("#lotOccupancyTransactionAdd--lotOccupancyId").value=o.toString();const t=i(),c=y(),n=e.querySelector("#lotOccupancyTransactionAdd--transactionAmount");n.min=(-1*c).toFixed(2),n.max=Math.max(t-c,0).toFixed(2),n.value=Math.max(t-c,0).toFixed(2)},onshown:(c,a)=>{bulmaJS.toggleHtmlClipped(),e=a,c.querySelector("form").addEventListener("submit",t)},onremoved:()=>{bulmaJS.toggleHtmlClipped()}})}),d()}})(); \ No newline at end of file +"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),(()=>{var e,t,c;const a=exports.los,o=document.querySelector("#lotOccupancy--lotOccupancyId").value,n=""===o;let s=!1,l=n;const r=()=>{s||(s=!0,cityssm.enableNavBlocker())},i=document.querySelector("#form--lotOccupancy");i.addEventListener("submit",e=>{e.preventDefault(),cityssm.postJSON(a.urlPrefix+"/lotOccupancies/"+(n?"doCreateLotOccupancy":"doUpdateLotOccupancy"),i,e=>{e.success?(s=!1,cityssm.disableNavBlocker(),n||l?window.location.href=a.urlPrefix+"/lotOccupancies/"+e.lotOccupancyId+"/edit?t="+Date.now():bulmaJS.alert({message:exports.aliases.occupancy+" Updated Successfully",contextualColorName:"success"})):bulmaJS.alert({title:"Error Saving "+exports.aliases.occupancy,message:e.errorMessage||"",contextualColorName:"danger"})})});const u=i.querySelectorAll("input, select");for(const e of u)e.addEventListener("change",r);if(!n){const n=()=>{cityssm.postJSON(a.urlPrefix+"/lotOccupancies/doCopyLotOccupancy",{lotOccupancyId:o},e=>{var t;e.success?(cityssm.disableNavBlocker(),window.location.href=a.urlPrefix+"/lotOccupancies/"+(null===(t=e.lotOccupancyId)||void 0===t?void 0:t.toString())+"/edit"):bulmaJS.alert({title:"Error Copying Record",message:e.errorMessage||"",contextualColorName:"danger"})})};null===(e=document.querySelector("#button--copyLotOccupancy"))||void 0===e||e.addEventListener("click",e=>{e.preventDefault(),s?bulmaJS.alert({title:"Unsaved Changes",message:"Please save all unsaved changes before continuing.",contextualColorName:"warning"}):bulmaJS.confirm({title:"Copy "+exports.aliases.occupancy+" Record as New",message:"Are you sure you want to copy this record to a new record?",contextualColorName:"info",okButton:{text:"Yes, Copy",callbackFunction:n}})}),null===(t=document.querySelector("#button--deleteLotOccupancy"))||void 0===t||t.addEventListener("click",e=>{e.preventDefault();bulmaJS.confirm({title:"Delete "+exports.aliases.occupancy+" Record",message:"Are you sure you want to delete this record?",contextualColorName:"warning",okButton:{text:"Yes, Delete",callbackFunction:()=>{cityssm.postJSON(a.urlPrefix+"/lotOccupancies/doDeleteLotOccupancy",{lotOccupancyId:o},e=>{e.success?(cityssm.disableNavBlocker(),window.location.href=a.urlPrefix+"/lotOccupancies?t="+Date.now()):bulmaJS.alert({title:"Error Deleting Record",message:e.errorMessage||"",contextualColorName:"danger"})})}}})}),null===(c=document.querySelector("#button--createWorkOrder"))||void 0===c||c.addEventListener("click",e=>{let t;e.preventDefault();const c=e=>{e.preventDefault(),cityssm.postJSON(a.urlPrefix+"/workOrders/doCreateWorkOrder",e.currentTarget,e=>{e.success?(t(),bulmaJS.confirm({title:"Work Order Created Successfully",message:"Would you like to open the work order now?",contextualColorName:"success",okButton:{text:"Yes, Open the Work Order",callbackFunction:()=>{window.location.href=a.urlPrefix+"/workOrders/"+e.workOrderId+"/edit"}}})):bulmaJS.alert({title:"Error Creating Work Order",message:e.errorMessage,contextualColorName:"danger"})})};cityssm.openHtmlModal("lotOccupancy-createWorkOrder",{onshow:e=>{e.querySelector("#workOrderCreate--lotOccupancyId").value=o,e.querySelector("#workOrderCreate--workOrderOpenDateString").value=cityssm.dateToString(new Date);const t=e.querySelector("#workOrderCreate--workOrderTypeId"),c=exports.workOrderTypes;1===c.length&&(t.innerHTML="");for(const e of c){const c=document.createElement("option");c.value=e.workOrderTypeId.toString(),c.textContent=e.workOrderType,t.append(c)}},onshown:(e,a)=>{var o;t=a,null===(o=e.querySelector("form"))||void 0===o||o.addEventListener("submit",c)}})})}const d=document.querySelector("#lotOccupancy--occupancyTypeId");if(n){const e=document.querySelector("#container--lotOccupancyFields");d.addEventListener("change",()=>{""!==d.value?cityssm.postJSON(a.urlPrefix+"/lotOccupancies/doGetOccupancyTypeFields",{occupancyTypeId:d.value},t=>{if(0===t.occupancyTypeFields.length)return void(e.innerHTML='

There are no additional fields for this '+exports.aliases.occupancy.toLowerCase()+" type.

");e.innerHTML="";let c="";for(const a of t.occupancyTypeFields){c+=","+a.occupancyTypeFieldId;const t="lotOccupancyFieldValue_"+a.occupancyTypeFieldId,o="lotOccupancy--"+t,n=document.createElement("div");if(n.className="field",n.innerHTML='
',n.querySelector("label").textContent=a.occupancyTypeField,""===a.occupancyTypeFieldValues){const e=document.createElement("input");e.className="input",e.id=o,e.name=t,e.type="text",e.required=a.isRequired,e.minLength=a.minimumLength,e.maxLength=a.maximumLength,a.pattern&&""!==a.pattern&&(e.pattern=a.pattern),n.querySelector(".control").append(e)}else{n.querySelector(".control").innerHTML='
';const e=n.querySelector("select");e.required=a.isRequired;const c=a.occupancyTypeFieldValues.split("\n");for(const t of c){const c=document.createElement("option");c.value=t,c.textContent=t,e.append(c)}}e.append(n)}e.insertAdjacentHTML("beforeend",'')}):e.innerHTML='

Select the '+exports.aliases.occupancy.toLowerCase()+" type to load the available fields.

"})}else{const e=d.value;d.addEventListener("change",()=>{d.value!==e&&bulmaJS.confirm({title:"Confirm Change",message:"Are you sure you want to change the "+exports.aliases.occupancy.toLowerCase()+" type?\nThis change affects the additional fields associated with this record, and may also affect the available fees.",contextualColorName:"warning",okButton:{text:"Yes, Keep the Change",callbackFunction:()=>{l=!0}},cancelButton:{text:"Revert the Change",callbackFunction:()=>{d.value=e}}})})}const p=document.querySelector("#lotOccupancy--lotName");let m;p.addEventListener("click",e=>{const t=e.currentTarget.value;let c,o,n,s;const l=(e,t)=>{document.querySelector("#lotOccupancy--lotId").value=e.toString(),document.querySelector("#lotOccupancy--lotName").value=t,r(),c()},i=e=>{e.preventDefault();const t=e.currentTarget;l(t.dataset.lotId,t.dataset.lotName)},u=()=>{s.innerHTML='


Searching...

',cityssm.postJSON(a.urlPrefix+"/lots/doSearchLots",n,e=>{if(0===e.count)return void(s.innerHTML='

No results.

');const t=document.createElement("div");t.className="panel";for(const c of e.lots){const e=document.createElement("a");e.className="panel-block is-block",e.href="#",e.dataset.lotId=c.lotId.toString(),e.dataset.lotName=c.lotName,e.innerHTML='
'+cityssm.escapeHTML(c.lotName||"")+'
'+cityssm.escapeHTML(c.mapName||"")+'
'+cityssm.escapeHTML(c.lotStatus)+'
'+(c.lotOccupancyCount>0?"Currently Occupied":"")+"
",e.addEventListener("click",i),t.append(e)}s.innerHTML="",s.append(t)})},d=e=>{e.preventDefault();const t=o.querySelector("#lotCreate--lotName").value;cityssm.postJSON(a.urlPrefix+"/lots/doCreateLot",e.currentTarget,e=>{e.success?l(e.lotId,t):bulmaJS.alert({title:"Error Creating "+exports.aliases.lot,message:e.errorMessage||"",contextualColorName:"danger"})})};cityssm.openHtmlModal("lotOccupancy-selectLot",{onshow:e=>{a.populateAliases(e)},onshown:(e,a)=>{bulmaJS.toggleHtmlClipped(),o=e,c=a,bulmaJS.init(e);const l=e.querySelector("#lotSelect--lotName");""!==document.querySelector("#lotOccupancy--lotId").value&&(l.value=t),l.focus(),l.addEventListener("change",u);const r=e.querySelector("#lotSelect--occupancyStatus");if(r.addEventListener("change",u),""!==t&&(r.value=""),n=e.querySelector("#form--lotSelect"),s=e.querySelector("#resultsContainer--lotSelect"),n.addEventListener("submit",e=>{e.preventDefault()}),u(),exports.lotNamePattern){const t=exports.lotNamePattern;e.querySelector("#lotCreate--lotName").pattern=t.source}const i=e.querySelector("#lotCreate--lotTypeId");for(const e of exports.lotTypes){const t=document.createElement("option");t.value=e.lotTypeId.toString(),t.textContent=e.lotType,i.append(t)}const p=e.querySelector("#lotCreate--lotStatusId");for(const e of exports.lotStatuses){const t=document.createElement("option");t.value=e.lotStatusId.toString(),t.textContent=e.lotStatus,p.append(t)}const m=e.querySelector("#lotCreate--mapId");for(const e of exports.maps){const t=document.createElement("option");t.value=e.mapId.toString(),t.textContent=e.mapName||"(No Name)",m.append(t)}e.querySelector("#form--lotCreate").addEventListener("submit",d)},onremoved:()=>{bulmaJS.toggleHtmlClipped()}})}),document.querySelector(".is-lot-view-button").addEventListener("click",()=>{const e=document.querySelector("#lotOccupancy--lotId").value;e?window.open(a.urlPrefix+"/lots/"+e):bulmaJS.alert({message:"No "+exports.aliases.lot.toLowerCase()+" selected.",contextualColorName:"info"})}),document.querySelector(".is-clear-lot-button").addEventListener("click",()=>{p.disabled?bulmaJS.alert({message:"You need to unlock the field before clearing it.",contextualColorName:"info"}):(p.value="(No "+exports.aliases.lot+")",document.querySelector("#lotOccupancy--lotId").value="",r())}),a.initializeDatePickers(i),document.querySelector("#lotOccupancy--occupancyStartDateString").addEventListener("change",()=>{const e=document.querySelector("#lotOccupancy--occupancyEndDateString").bulmaCalendar.datePicker;e.min=document.querySelector("#lotOccupancy--occupancyStartDateString").value,e.refresh()}),a.initializeUnlockFieldButtons(i),Object.defineProperty(exports,"__esModule",{value:!0});const y=e=>{const t=Number.parseInt(e.currentTarget.closest("tr").dataset.lotOccupantIndex,10),c=m.find(e=>e.lotOccupantIndex===t);let n,s;const l=e=>{e.preventDefault(),cityssm.postJSON(a.urlPrefix+"/lotOccupancies/doUpdateLotOccupancyOccupant",n,e=>{e.success?(m=e.lotOccupancyOccupants,s(),g()):bulmaJS.alert({title:"Error Updating "+exports.aliases.occupant,message:e.errorMessage||"",contextualColorName:"danger"})})};cityssm.openHtmlModal("lotOccupancy-editOccupant",{onshow:e=>{a.populateAliases(e),e.querySelector("#lotOccupancyOccupantEdit--lotOccupancyId").value=o,e.querySelector("#lotOccupancyOccupantEdit--lotOccupantIndex").value=t.toString();const n=e.querySelector("#lotOccupancyOccupantEdit--lotOccupantTypeId");let s=!1;for(const e of exports.lotOccupantTypes){const t=document.createElement("option");t.value=e.lotOccupantTypeId.toString(),t.textContent=e.lotOccupantType,e.lotOccupantTypeId===c.lotOccupantTypeId&&(t.selected=!0,s=!0),n.append(t)}if(!s){const e=document.createElement("option");e.value=c.lotOccupantTypeId.toString(),e.textContent=c.lotOccupantType,e.selected=!0,n.append(e)}e.querySelector("#lotOccupancyOccupantEdit--occupantName").value=c.occupantName,e.querySelector("#lotOccupancyOccupantEdit--occupantAddress1").value=c.occupantAddress1,e.querySelector("#lotOccupancyOccupantEdit--occupantAddress2").value=c.occupantAddress2,e.querySelector("#lotOccupancyOccupantEdit--occupantCity").value=c.occupantCity,e.querySelector("#lotOccupancyOccupantEdit--occupantProvince").value=c.occupantProvince,e.querySelector("#lotOccupancyOccupantEdit--occupantPostalCode").value=c.occupantPostalCode,e.querySelector("#lotOccupancyOccupantEdit--occupantPhoneNumber").value=c.occupantPhoneNumber,e.querySelector("#lotOccupancyOccupantEdit--occupantEmailAddress").value=c.occupantEmailAddress,e.querySelector("#lotOccupancyOccupantEdit--occupantComment").value=c.occupantComment},onshown:(e,t)=>{bulmaJS.toggleHtmlClipped(),e.querySelector("#lotOccupancyOccupantEdit--lotOccupantTypeId").focus(),(n=e.querySelector("form")).addEventListener("submit",l),s=t},onremoved:()=>{bulmaJS.toggleHtmlClipped()}})},O=e=>{const t=e.currentTarget.closest("tr").dataset.lotOccupantIndex;bulmaJS.confirm({title:"Remove "+exports.aliases.occupant+"?",message:"Are you sure you want to remove this "+exports.aliases.occupant.toLowerCase()+"?",okButton:{text:"Yes, Remove "+exports.aliases.occupant,callbackFunction:()=>{cityssm.postJSON(a.urlPrefix+"/lotOccupancies/doDeleteLotOccupancyOccupant",{lotOccupancyId:o,lotOccupantIndex:t},e=>{e.success?(m=e.lotOccupancyOccupants,g()):bulmaJS.alert({title:"Error Removing "+exports.aliases.occupant,message:e.errorMessage||"",contextualColorName:"danger"})})}},contextualColorName:"warning"})},g=()=>{const e=document.querySelector("#container--lotOccupancyOccupants");if(cityssm.clearElement(e),0===m.length)return void(e.innerHTML='

There are no '+exports.aliases.occupants.toLowerCase()+" associated with this record.

");const t=document.createElement("table");t.className="table is-fullwidth is-striped is-hoverable",t.innerHTML=""+exports.aliases.occupant+'AddressOther ContactCommentOptions';for(const e of m){const c=document.createElement("tr");c.dataset.lotOccupantIndex=e.lotOccupantIndex.toString(),c.innerHTML=""+cityssm.escapeHTML(e.occupantName||"(No Name)")+'
'+cityssm.escapeHTML(e.lotOccupantType)+""+(e.occupantAddress1?cityssm.escapeHTML(e.occupantAddress1)+"
":"")+(e.occupantAddress2?cityssm.escapeHTML(e.occupantAddress2)+"
":"")+(e.occupantCity?cityssm.escapeHTML(e.occupantCity)+", ":"")+cityssm.escapeHTML(e.occupantProvince||"")+"
"+cityssm.escapeHTML(e.occupantPostalCode||"")+""+(e.occupantPhoneNumber?cityssm.escapeHTML(e.occupantPhoneNumber)+"
":"")+(e.occupantEmailAddress?cityssm.escapeHTML(e.occupantEmailAddress):"")+""+cityssm.escapeHTML(e.occupantComment)+'
',c.querySelector(".button--edit").addEventListener("click",y),c.querySelector(".button--delete").addEventListener("click",O),t.querySelector("tbody").append(c)}e.append(t)};if(n){const e=document.querySelector("#lotOccupancy--lotOccupantTypeId");e.addEventListener("change",()=>{const t=i.querySelectorAll("[data-table='LotOccupancyOccupant']");for(const c of t)c.disabled=""===e.value})}else m=exports.lotOccupancyOccupants,delete exports.lotOccupancyOccupants,document.querySelector("#button--addOccupant").addEventListener("click",()=>{let e,t,c,n;const s=t=>{cityssm.postJSON(a.urlPrefix+"/lotOccupancies/doAddLotOccupancyOccupant",t,t=>{t.success?(m=t.lotOccupancyOccupants,e(),g()):bulmaJS.alert({title:"Error Adding "+exports.aliases.occupant,message:t.errorMessage||"",contextualColorName:"danger"})})},l=e=>{e.preventDefault(),s(t)};let r=[];const i=e=>{e.preventDefault();const t=e.currentTarget,c=r[Number.parseInt(t.dataset.index,10)],a=t.closest(".modal").querySelector("#lotOccupancyOccupantCopy--lotOccupantTypeId").value;""===a?bulmaJS.alert({title:"No "+exports.aliases.occupant+" Type Selected",message:"Select a type to apply to the newly added "+exports.aliases.occupant.toLowerCase()+".",contextualColorName:"warning"}):(c.lotOccupantTypeId=Number.parseInt(a,10),c.lotOccupancyId=Number.parseInt(o,10),s(c))},u=e=>{e.preventDefault(),""!==c.querySelector("#lotOccupancyOccupantCopy--searchFilter").value?(n.innerHTML='

Searching...
',cityssm.postJSON(a.urlPrefix+"/lotOccupancies/doSearchPastOccupants",c,e=>{r=e.occupants;const t=document.createElement("div");t.className="panel";for(const[e,c]of r.entries()){const a=document.createElement("a");a.className="panel-block is-block",a.dataset.index=e.toString(),a.innerHTML=""+cityssm.escapeHTML(c.occupantName||"")+'
'+cityssm.escapeHTML(c.occupantAddress1||"")+"
"+(c.occupantAddress2?cityssm.escapeHTML(c.occupantAddress2)+"
":"")+cityssm.escapeHTML(c.occupantCity||"")+", "+cityssm.escapeHTML(c.occupantProvince||"")+"
"+cityssm.escapeHTML(c.occupantPostalCode||"")+'
'+(c.occupantPhoneNumber?cityssm.escapeHTML(c.occupantPhoneNumber)+"
":"")+cityssm.escapeHTML(c.occupantEmailAddress||"")+"
",a.addEventListener("click",i),t.append(a)}n.innerHTML="",n.append(t)})):n.innerHTML='

Enter a partial name or address in the search field above.

'};cityssm.openHtmlModal("lotOccupancy-addOccupant",{onshow:e=>{a.populateAliases(e),e.querySelector("#lotOccupancyOccupantAdd--lotOccupancyId").value=o;const t=e.querySelector("#lotOccupancyOccupantAdd--lotOccupantTypeId"),c=e.querySelector("#lotOccupancyOccupantCopy--lotOccupantTypeId");for(const e of exports.lotOccupantTypes){const a=document.createElement("option");a.value=e.lotOccupantTypeId.toString(),a.textContent=e.lotOccupantType,t.append(a),c.append(a.cloneNode(!0))}e.querySelector("#lotOccupancyOccupantAdd--occupantCity").value=exports.occupantCityDefault,e.querySelector("#lotOccupancyOccupantAdd--occupantProvince").value=exports.occupantProvinceDefault},onshown:(a,o)=>{bulmaJS.toggleHtmlClipped(),bulmaJS.init(a),a.querySelector("#lotOccupancyOccupantAdd--lotOccupantTypeId").focus(),(t=a.querySelector("#form--lotOccupancyOccupantAdd")).addEventListener("submit",l),n=a.querySelector("#lotOccupancyOccupantCopy--searchResults"),(c=a.querySelector("#form--lotOccupancyOccupantCopy")).addEventListener("submit",e=>{e.preventDefault()}),a.querySelector("#lotOccupancyOccupantCopy--searchFilter").addEventListener("change",u),e=o},onremoved:()=>{bulmaJS.toggleHtmlClipped()}})}),g();if(!n){Object.defineProperty(exports,"__esModule",{value:!0});let e=exports.lotOccupancyComments;delete exports.lotOccupancyComments;const t=t=>{const c=Number.parseInt(t.currentTarget.closest("tr").dataset.lotOccupancyCommentId,10),s=e.find(e=>e.lotOccupancyCommentId===c);let l,r;const i=t=>{t.preventDefault(),cityssm.postJSON(a.urlPrefix+"/lotOccupancies/doUpdateLotOccupancyComment",l,t=>{t.success?(e=t.lotOccupancyComments,r(),n()):bulmaJS.alert({title:"Error Updating Comment",message:t.errorMessage||"",contextualColorName:"danger"})})};cityssm.openHtmlModal("lotOccupancy-editComment",{onshow:e=>{a.populateAliases(e),e.querySelector("#lotOccupancyCommentEdit--lotOccupancyId").value=o,e.querySelector("#lotOccupancyCommentEdit--lotOccupancyCommentId").value=c.toString(),e.querySelector("#lotOccupancyCommentEdit--lotOccupancyComment").value=s.lotOccupancyComment;const t=e.querySelector("#lotOccupancyCommentEdit--lotOccupancyCommentDateString");t.value=s.lotOccupancyCommentDateString;const n=cityssm.dateToString(new Date);t.max=s.lotOccupancyCommentDateString<=n?n:s.lotOccupancyCommentDateString,e.querySelector("#lotOccupancyCommentEdit--lotOccupancyCommentTimeString").value=s.lotOccupancyCommentTimeString},onshown:(e,t)=>{bulmaJS.toggleHtmlClipped(),a.initializeDatePickers(e),e.querySelector("#lotOccupancyCommentEdit--lotOccupancyComment").focus(),(l=e.querySelector("form")).addEventListener("submit",i),r=t},onremoved:()=>{bulmaJS.toggleHtmlClipped()}})},c=t=>{const c=Number.parseInt(t.currentTarget.closest("tr").dataset.lotOccupancyCommentId,10);bulmaJS.confirm({title:"Remove Comment?",message:"Are you sure you want to remove this comment?",okButton:{text:"Yes, Remove Comment",callbackFunction:()=>{cityssm.postJSON(a.urlPrefix+"/lotOccupancies/doDeleteLotOccupancyComment",{lotOccupancyId:o,lotOccupancyCommentId:c},t=>{t.success?(e=t.lotOccupancyComments,n()):bulmaJS.alert({title:"Error Removing Comment",message:t.errorMessage||"",contextualColorName:"danger"})})}},contextualColorName:"warning"})},n=()=>{const a=document.querySelector("#container--lotOccupancyComments");if(0===e.length)return void(a.innerHTML='

There are no comments associated with this record.

');const o=document.createElement("table");o.className="table is-fullwidth is-striped is-hoverable",o.innerHTML='CommentorComment DateCommentOptions';for(const a of e){const e=document.createElement("tr");e.dataset.lotOccupancyCommentId=a.lotOccupancyCommentId.toString(),e.innerHTML=""+cityssm.escapeHTML(a.recordCreate_userName||"")+""+a.lotOccupancyCommentDateString+(0===a.lotOccupancyCommentTime?"":" "+a.lotOccupancyCommentTimeString)+""+cityssm.escapeHTML(a.lotOccupancyComment||"")+'
',e.querySelector(".button--edit").addEventListener("click",t),e.querySelector(".button--delete").addEventListener("click",c),o.querySelector("tbody").append(e)}a.innerHTML="",a.append(o)};document.querySelector("#button--addComment").addEventListener("click",()=>{let t,c;const s=o=>{o.preventDefault(),cityssm.postJSON(a.urlPrefix+"/lotOccupancies/doAddLotOccupancyComment",t,t=>{t.success?(e=t.lotOccupancyComments,c(),n()):bulmaJS.alert({title:"Error Adding Comment",message:t.errorMessage||"",contextualColorName:"danger"})})};cityssm.openHtmlModal("lotOccupancy-addComment",{onshow:e=>{a.populateAliases(e),e.querySelector("#lotOccupancyCommentAdd--lotOccupancyId").value=o},onshown:(e,a)=>{bulmaJS.toggleHtmlClipped(),e.querySelector("#lotOccupancyCommentAdd--lotOccupancyComment").focus(),(t=e.querySelector("form")).addEventListener("submit",s),c=a},onremoved:()=>{bulmaJS.toggleHtmlClipped()}})}),n(),Object.defineProperty(exports,"__esModule",{value:!0});let l=exports.lotOccupancyFees;delete exports.lotOccupancyFees;const r=document.querySelector("#container--lotOccupancyFees"),i=()=>{let e=0;for(const t of l)e+=(t.feeAmount+t.taxAmount)*t.quantity;return e},u=e=>{const t=e.currentTarget.closest(".container--lotOccupancyFee").dataset.feeId;bulmaJS.confirm({title:"Delete Fee",message:"Are you sure you want to delete this fee?",contextualColorName:"warning",okButton:{text:"Yes, Delete Fee",callbackFunction:()=>{cityssm.postJSON(a.urlPrefix+"/lotOccupancies/doDeleteLotOccupancyFee",{lotOccupancyId:o,feeId:t},e=>{e.success?(l=e.lotOccupancyFees,d()):bulmaJS.alert({title:"Error Deleting Fee",message:e.errorMessage||"",contextualColorName:"danger"})})}}})},d=()=>{if(0===l.length)return r.innerHTML='

There are no fees associated with this record.

',void g();r.innerHTML='
FeeUnit Cost×QuantityequalsTotalOptions
Subtotal
Tax
Grand Total
';let e=0,t=0;for(const c of l){const a=document.createElement("tr");a.className="container--lotOccupancyFee",a.dataset.feeId=c.feeId.toString(),a.dataset.includeQuantity=c.includeQuantity?"1":"0",a.innerHTML=''+cityssm.escapeHTML(c.feeName||"")+""+(1===c.quantity?"":'$'+c.feeAmount.toFixed(2)+'×'+c.quantity+"=")+'$'+(c.feeAmount*c.quantity).toFixed(2)+'',a.querySelector("button").addEventListener("click",u),r.querySelector("tbody").append(a),e+=c.feeAmount*c.quantity,t+=c.taxAmount*c.quantity}r.querySelector("#lotOccupancyFees--feeAmountTotal").textContent="$"+e.toFixed(2),r.querySelector("#lotOccupancyFees--taxAmountTotal").textContent="$"+t.toFixed(2),r.querySelector("#lotOccupancyFees--grandTotal").textContent="$"+(e+t).toFixed(2),g()};document.querySelector("#button--addFee").addEventListener("click",()=>{if(s)return void bulmaJS.alert({message:"Please save all unsaved changes before adding fees.",contextualColorName:"warning"});let e,t,c;const n=(e,t=1)=>{cityssm.postJSON(a.urlPrefix+"/lotOccupancies/doAddLotOccupancyFee",{lotOccupancyId:o,feeId:e,quantity:t},e=>{e.success?(l=e.lotOccupancyFees,d(),u()):bulmaJS.alert({title:"Error Adding Fee",message:e.errorMessage||"",contextualColorName:"danger"})})},i=t=>{t.preventDefault();const c=Number.parseInt(t.currentTarget.dataset.feeId,10),a=Number.parseInt(t.currentTarget.closest(".container--feeCategory").dataset.feeCategoryId,10),o=e.find(e=>e.feeCategoryId===a).fees.find(e=>e.feeId===c);o.includeQuantity?(e=>{let t,c;const a=a=>{a.preventDefault(),n(e.feeId,t.value),c()};cityssm.openHtmlModal("lotOccupancy-setFeeQuantity",{onshow:t=>{t.querySelector("#lotOccupancyFeeQuantity--quantityUnit").textContent=e.quantityUnit},onshown:(e,o)=>{c=o,t=e.querySelector("#lotOccupancyFeeQuantity--quantity"),e.querySelector("form").addEventListener("submit",a)}})})(o):n(c)},u=()=>{const a=t.value.trim().toLowerCase().split(" ");c.innerHTML="";for(const t of e){const e=document.createElement("div");e.className="container--feeCategory",e.dataset.feeCategoryId=t.feeCategoryId.toString(),e.innerHTML='

'+cityssm.escapeHTML(t.feeCategory||"")+'

';let o=!1;for(const c of t.fees){if(r.querySelector(".container--lotOccupancyFee[data-fee-id='"+c.feeId+"'][data-include-quantity='0']"))continue;let t=!0;for(const e of a)if(!c.feeName.toLowerCase().includes(e)){t=!1;break}if(!t)continue;o=!0;const n=document.createElement("a");n.className="panel-block is-block container--fee",n.dataset.feeId=c.feeId.toString(),n.href="#",n.innerHTML=""+cityssm.escapeHTML(c.feeName||"")+"
"+cityssm.escapeHTML(c.feeDescription||"").replace(/\n/g,"
")+"
",n.addEventListener("click",i),e.querySelector(".panel").append(n)}o&&c.append(e)}};cityssm.openHtmlModal("lotOccupancy-addFee",{onshow:n=>{t=n.querySelector("#feeSelect--feeName"),c=n.querySelector("#resultsContainer--feeSelect"),cityssm.postJSON(a.urlPrefix+"/lotOccupancies/doGetFees",{lotOccupancyId:o},c=>{e=c.feeCategories,t.disabled=!1,t.addEventListener("keyup",u),t.focus(),u()})},onshown:()=>{bulmaJS.toggleHtmlClipped()},onhidden:()=>{d()},onremoved:()=>{bulmaJS.toggleHtmlClipped()}})});let p=exports.lotOccupancyTransactions;delete exports.lotOccupancyTransactions;const m=document.querySelector("#container--lotOccupancyTransactions"),y=()=>{let e=0;for(const t of p)e+=t.transactionAmount;return e},O=e=>{const t=e.currentTarget.closest(".container--lotOccupancyTransaction").dataset.transactionIndex;bulmaJS.confirm({title:"Delete Trasnaction",message:"Are you sure you want to delete this transaction?",contextualColorName:"warning",okButton:{text:"Yes, Delete Transaction",callbackFunction:()=>{cityssm.postJSON(a.urlPrefix+"/lotOccupancies/doDeleteLotOccupancyTransaction",{lotOccupancyId:o,transactionIndex:t},e=>{e.success?(p=e.lotOccupancyTransactions,g()):bulmaJS.alert({title:"Error Deleting Transaction",message:e.errorMessage||"",contextualColorName:"danger"})})}}})},g=()=>{if(0===p.length)return void(m.innerHTML='

There are no transactions associated with this record.

');m.innerHTML='
Date'+cityssm.escapeHTML(exports.aliases.externalReceiptNumber)+'AmountOptions
Transaction Total
';let e=0;for(const t of p){e+=t.transactionAmount;const c=document.createElement("tr");c.className="container--lotOccupancyTransaction",c.dataset.transactionIndex=t.transactionIndex.toString(),c.innerHTML=""+t.transactionDateString+""+cityssm.escapeHTML(t.externalReceiptNumber||"")+"
"+cityssm.escapeHTML(t.transactionNote||"")+'$'+t.transactionAmount.toFixed(2)+'',c.querySelector("button").addEventListener("click",O),m.querySelector("tbody").append(c)}m.querySelector("#lotOccupancyTransactions--grandTotal").textContent="$"+e.toFixed(2);const t=i();t>e&&m.insertAdjacentHTML("afterbegin",'
Outstanding Balance
$'+(t-e).toFixed(2)+"
")};document.querySelector("#button--addTransaction").addEventListener("click",()=>{let e;const t=t=>{t.preventDefault(),cityssm.postJSON(a.urlPrefix+"/lotOccupancies/doAddLotOccupancyTransaction",t.currentTarget,t=>{t.success?(p=t.lotOccupancyTransactions,e(),g()):bulmaJS.confirm({title:"Error Adding Transaction",message:t.errorMessage||"",contextualColorName:"danger"})})};cityssm.openHtmlModal("lotOccupancy-addTransaction",{onshow:e=>{a.populateAliases(e),e.querySelector("#lotOccupancyTransactionAdd--lotOccupancyId").value=o.toString();const t=i(),c=y(),n=e.querySelector("#lotOccupancyTransactionAdd--transactionAmount");n.min=(-1*c).toFixed(2),n.max=Math.max(t-c,0).toFixed(2),n.value=Math.max(t-c,0).toFixed(2)},onshown:(c,a)=>{bulmaJS.toggleHtmlClipped(),e=a,c.querySelector("form").addEventListener("submit",t)},onremoved:()=>{bulmaJS.toggleHtmlClipped()}})}),d()}})(); \ No newline at end of file diff --git a/types/recordTypes.d.ts b/types/recordTypes.d.ts index 3d903fe9..7c231215 100644 --- a/types/recordTypes.d.ts +++ b/types/recordTypes.d.ts @@ -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; diff --git a/types/recordTypes.ts b/types/recordTypes.ts index 33b7006d..fcb30f78 100644 --- a/types/recordTypes.ts +++ b/types/recordTypes.ts @@ -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 {