From 35dbc09d8285c67a4b646d1ef6ff691204f1909d Mon Sep 17 00:00:00 2001 From: Dan Gowans Date: Wed, 4 Jan 2023 14:20:16 -0500 Subject: [PATCH] reduce move duplication --- handlers/admin-post/doMoveFeeCategoryDown.js | 2 +- handlers/admin-post/doMoveFeeCategoryDown.ts | 2 +- handlers/admin-post/doMoveFeeCategoryUp.js | 2 +- handlers/admin-post/doMoveFeeCategoryUp.ts | 2 +- handlers/admin-post/doMoveFeeDown.js | 2 +- handlers/admin-post/doMoveFeeDown.ts | 2 +- handlers/admin-post/doMoveFeeUp.js | 2 +- handlers/admin-post/doMoveFeeUp.ts | 2 +- public-typescript/adminFees.js | 72 ++++--------- public-typescript/adminFees.ts | 108 ++++--------------- public-typescript/main.js | 4 +- public-typescript/main.ts | 4 +- public/javascripts/adminFees.min.js | 2 +- public/javascripts/main.min.js | 2 +- 14 files changed, 58 insertions(+), 150 deletions(-) diff --git a/handlers/admin-post/doMoveFeeCategoryDown.js b/handlers/admin-post/doMoveFeeCategoryDown.js index 44474bd2..c9a598ea 100644 --- a/handlers/admin-post/doMoveFeeCategoryDown.js +++ b/handlers/admin-post/doMoveFeeCategoryDown.js @@ -1,7 +1,7 @@ import { moveFeeCategoryDown, moveFeeCategoryDownToBottom } from "../../helpers/lotOccupancyDB/moveFeeCategoryDown.js"; import { getFeeCategories } from "../../helpers/lotOccupancyDB/getFeeCategories.js"; export const handler = async (request, response) => { - const success = request.body.moveToBottom === "1" + const success = request.body.moveToEnd === "1" ? moveFeeCategoryDownToBottom(request.body.feeCategoryId) : moveFeeCategoryDown(request.body.feeCategoryId); const feeCategories = getFeeCategories({}, { diff --git a/handlers/admin-post/doMoveFeeCategoryDown.ts b/handlers/admin-post/doMoveFeeCategoryDown.ts index 5b0e9ffa..ab27c684 100644 --- a/handlers/admin-post/doMoveFeeCategoryDown.ts +++ b/handlers/admin-post/doMoveFeeCategoryDown.ts @@ -9,7 +9,7 @@ import { getFeeCategories } from "../../helpers/lotOccupancyDB/getFeeCategories. export const handler: RequestHandler = async (request, response) => { const success = - request.body.moveToBottom === "1" + request.body.moveToEnd === "1" ? moveFeeCategoryDownToBottom(request.body.feeCategoryId) : moveFeeCategoryDown(request.body.feeCategoryId); diff --git a/handlers/admin-post/doMoveFeeCategoryUp.js b/handlers/admin-post/doMoveFeeCategoryUp.js index 0c1b3675..c450599e 100644 --- a/handlers/admin-post/doMoveFeeCategoryUp.js +++ b/handlers/admin-post/doMoveFeeCategoryUp.js @@ -1,7 +1,7 @@ import { moveFeeCategoryUp, moveFeeCategoryUpToTop } from "../../helpers/lotOccupancyDB/moveFeeCategoryUp.js"; import { getFeeCategories } from "../../helpers/lotOccupancyDB/getFeeCategories.js"; export const handler = async (request, response) => { - const success = request.body.moveToTop === "1" + const success = request.body.moveToEnd === "1" ? moveFeeCategoryUpToTop(request.body.feeCategoryId) : moveFeeCategoryUp(request.body.feeCategoryId); const feeCategories = getFeeCategories({}, { diff --git a/handlers/admin-post/doMoveFeeCategoryUp.ts b/handlers/admin-post/doMoveFeeCategoryUp.ts index 256337f2..67f21849 100644 --- a/handlers/admin-post/doMoveFeeCategoryUp.ts +++ b/handlers/admin-post/doMoveFeeCategoryUp.ts @@ -9,7 +9,7 @@ import { getFeeCategories } from "../../helpers/lotOccupancyDB/getFeeCategories. export const handler: RequestHandler = async (request, response) => { const success = - request.body.moveToTop === "1" + request.body.moveToEnd === "1" ? moveFeeCategoryUpToTop(request.body.feeCategoryId) : moveFeeCategoryUp(request.body.feeCategoryId); diff --git a/handlers/admin-post/doMoveFeeDown.js b/handlers/admin-post/doMoveFeeDown.js index 0308accd..29f4c482 100644 --- a/handlers/admin-post/doMoveFeeDown.js +++ b/handlers/admin-post/doMoveFeeDown.js @@ -1,7 +1,7 @@ import { moveFeeDown, moveFeeDownToBottom } from "../../helpers/lotOccupancyDB/moveFeeDown.js"; import { getFeeCategories } from "../../helpers/lotOccupancyDB/getFeeCategories.js"; export const handler = async (request, response) => { - const success = request.body.moveToBottom === "1" + const success = request.body.moveToEnd === "1" ? moveFeeDownToBottom(request.body.feeId) : moveFeeDown(request.body.feeId); const feeCategories = getFeeCategories({}, { diff --git a/handlers/admin-post/doMoveFeeDown.ts b/handlers/admin-post/doMoveFeeDown.ts index 5434e859..4a550fdf 100644 --- a/handlers/admin-post/doMoveFeeDown.ts +++ b/handlers/admin-post/doMoveFeeDown.ts @@ -6,7 +6,7 @@ import { getFeeCategories } from "../../helpers/lotOccupancyDB/getFeeCategories. export const handler: RequestHandler = async (request, response) => { const success = - request.body.moveToBottom === "1" + request.body.moveToEnd === "1" ? moveFeeDownToBottom(request.body.feeId) : moveFeeDown(request.body.feeId); diff --git a/handlers/admin-post/doMoveFeeUp.js b/handlers/admin-post/doMoveFeeUp.js index b98ffc48..fb911669 100644 --- a/handlers/admin-post/doMoveFeeUp.js +++ b/handlers/admin-post/doMoveFeeUp.js @@ -1,7 +1,7 @@ import { moveFeeUp, moveFeeUpToTop } from "../../helpers/lotOccupancyDB/moveFeeUp.js"; import { getFeeCategories } from "../../helpers/lotOccupancyDB/getFeeCategories.js"; export const handler = async (request, response) => { - const success = request.body.moveToTop === "1" + const success = request.body.moveToEnd === "1" ? moveFeeUpToTop(request.body.feeId) : moveFeeUp(request.body.feeId); const feeCategories = getFeeCategories({}, { diff --git a/handlers/admin-post/doMoveFeeUp.ts b/handlers/admin-post/doMoveFeeUp.ts index 8bf92f8b..8071b415 100644 --- a/handlers/admin-post/doMoveFeeUp.ts +++ b/handlers/admin-post/doMoveFeeUp.ts @@ -6,7 +6,7 @@ import { getFeeCategories } from "../../helpers/lotOccupancyDB/getFeeCategories. export const handler: RequestHandler = async (request, response) => { const success = - request.body.moveToTop === "1" + request.body.moveToEnd === "1" ? moveFeeUpToTop(request.body.feeId) : moveFeeUp(request.body.feeId); diff --git a/public-typescript/adminFees.js b/public-typescript/adminFees.js index 9c2cefd2..736a03a6 100644 --- a/public-typescript/adminFees.js +++ b/public-typescript/adminFees.js @@ -142,8 +142,8 @@ Object.defineProperty(exports, "__esModule", { value: true }); "") + ""; panelBlockElement.querySelector("a").addEventListener("click", openEditFee); - panelBlockElement.querySelector(".button--moveFeeUp").addEventListener("click", moveFeeUp); - panelBlockElement.querySelector(".button--moveFeeDown").addEventListener("click", moveFeeDown); + panelBlockElement.querySelector(".button--moveFeeUp").addEventListener("click", moveFee); + panelBlockElement.querySelector(".button--moveFeeDown").addEventListener("click", moveFee); feeCategoryContainerElement.append(panelBlockElement); } } @@ -153,8 +153,8 @@ Object.defineProperty(exports, "__esModule", { value: true }); feeCategoryContainerElement .querySelector(".button--addFee") .addEventListener("click", openAddFee); - feeCategoryContainerElement.querySelector(".button--moveFeeCategoryUp").addEventListener("click", moveFeeCategoryUp); - feeCategoryContainerElement.querySelector(".button--moveFeeCategoryDown").addEventListener("click", moveFeeCategoryDown); + feeCategoryContainerElement.querySelector(".button--moveFeeCategoryUp").addEventListener("click", moveFeeCategory); + feeCategoryContainerElement.querySelector(".button--moveFeeCategoryDown").addEventListener("click", moveFeeCategory); feeCategoriesContainerElement.append(feeCategoryContainerElement); } } @@ -260,30 +260,17 @@ Object.defineProperty(exports, "__esModule", { value: true }); } }); } - function moveFeeCategoryUp(clickEvent) { - const feeCategoryId = Number.parseInt(clickEvent.currentTarget.closest(".container--feeCategory").dataset.feeCategoryId, 10); - cityssm.postJSON(los.urlPrefix + "/admin/doMoveFeeCategoryUp", { + function moveFeeCategory(clickEvent) { + const buttonElement = clickEvent.currentTarget; + const feeCategoryId = Number.parseInt(buttonElement.closest(".container--feeCategory").dataset + .feeCategoryId, 10); + cityssm.postJSON(los.urlPrefix + + "/admin/" + + (buttonElement.dataset.direction === "up" + ? "doMoveFeeCategoryUp" + : "doMoveFeeCategoryDown"), { feeCategoryId, - moveToTop: clickEvent.shiftKey ? "1" : "0" - }, (responseJSON) => { - if (responseJSON.success) { - feeCategories = responseJSON.feeCategories; - renderFeeCategories(); - } - else { - bulmaJS.alert({ - title: "Error Moving Fee Category", - message: responseJSON.errorMessage || "", - contextualColorName: "danger" - }); - } - }); - } - function moveFeeCategoryDown(clickEvent) { - const feeCategoryId = Number.parseInt(clickEvent.currentTarget.closest(".container--feeCategory").dataset.feeCategoryId, 10); - cityssm.postJSON(los.urlPrefix + "/admin/doMoveFeeCategoryDown", { - feeCategoryId, - moveToBottom: clickEvent.shiftKey ? "1" : "0" + moveToEnd: clickEvent.shiftKey ? "1" : "0" }, (responseJSON) => { if (responseJSON.success) { feeCategories = responseJSON.feeCategories; @@ -562,32 +549,15 @@ Object.defineProperty(exports, "__esModule", { value: true }); } }); } - function moveFeeUp(clickEvent) { - const feeContainerElement = clickEvent.currentTarget.closest(".container--fee"); + function moveFee(clickEvent) { + const buttonElement = clickEvent.currentTarget; + const feeContainerElement = buttonElement.closest(".container--fee"); const feeId = Number.parseInt(feeContainerElement.dataset.feeId, 10); - cityssm.postJSON(los.urlPrefix + "/admin/doMoveFeeUp", { + cityssm.postJSON(los.urlPrefix + + "/admin/" + + (buttonElement.dataset.direction === "up" ? "doMoveFeeUp" : "doMoveFeeDown"), { feeId, - moveToTop: clickEvent.shiftKey ? "1" : "0" - }, (responseJSON) => { - if (responseJSON.success) { - feeCategories = responseJSON.feeCategories; - renderFeeCategories(); - } - else { - bulmaJS.alert({ - title: "Error Moving Fee", - message: responseJSON.errorMessage || "", - contextualColorName: "danger" - }); - } - }); - } - function moveFeeDown(clickEvent) { - const feeContainerElement = clickEvent.currentTarget.closest(".container--fee"); - const feeId = Number.parseInt(feeContainerElement.dataset.feeId, 10); - cityssm.postJSON(los.urlPrefix + "/admin/doMoveFeeDown", { - feeId, - moveToBottom: clickEvent.shiftKey ? "1" : "0" + moveToEnd: clickEvent.shiftKey ? "1" : "0" }, (responseJSON) => { if (responseJSON.success) { feeCategories = responseJSON.feeCategories; diff --git a/public-typescript/adminFees.ts b/public-typescript/adminFees.ts index f2c3413b..7664afed 100644 --- a/public-typescript/adminFees.ts +++ b/public-typescript/adminFees.ts @@ -179,11 +179,11 @@ declare const bulmaJS: BulmaJS; ( panelBlockElement.querySelector(".button--moveFeeUp") as HTMLButtonElement - ).addEventListener("click", moveFeeUp); + ).addEventListener("click", moveFee); ( panelBlockElement.querySelector(".button--moveFeeDown") as HTMLButtonElement - ).addEventListener("click", moveFeeDown); + ).addEventListener("click", moveFee); feeCategoryContainerElement.append(panelBlockElement); } @@ -201,13 +201,13 @@ declare const bulmaJS: BulmaJS; feeCategoryContainerElement.querySelector( ".button--moveFeeCategoryUp" ) as HTMLButtonElement - ).addEventListener("click", moveFeeCategoryUp); + ).addEventListener("click", moveFeeCategory); ( feeCategoryContainerElement.querySelector( ".button--moveFeeCategoryDown" ) as HTMLButtonElement - ).addEventListener("click", moveFeeCategoryDown); + ).addEventListener("click", moveFeeCategory); feeCategoriesContainerElement.append(feeCategoryContainerElement); } @@ -378,56 +378,24 @@ declare const bulmaJS: BulmaJS; }); } - function moveFeeCategoryUp(clickEvent: MouseEvent): void { + function moveFeeCategory(clickEvent: MouseEvent): void { + const buttonElement = clickEvent.currentTarget as HTMLButtonElement; + const feeCategoryId = Number.parseInt( - ( - (clickEvent.currentTarget as HTMLElement).closest( - ".container--feeCategory" - ) as HTMLElement - ).dataset.feeCategoryId!, + (buttonElement.closest(".container--feeCategory") as HTMLElement).dataset + .feeCategoryId!, 10 ); cityssm.postJSON( - los.urlPrefix + "/admin/doMoveFeeCategoryUp", + los.urlPrefix + + "/admin/" + + (buttonElement.dataset.direction === "up" + ? "doMoveFeeCategoryUp" + : "doMoveFeeCategoryDown"), { feeCategoryId, - moveToTop: clickEvent.shiftKey ? "1" : "0" - }, - (responseJSON: { - success: boolean; - errorMessage?: string; - feeCategories?: recordTypes.FeeCategory[]; - }) => { - if (responseJSON.success) { - feeCategories = responseJSON.feeCategories!; - renderFeeCategories(); - } else { - bulmaJS.alert({ - title: "Error Moving Fee Category", - message: responseJSON.errorMessage || "", - contextualColorName: "danger" - }); - } - } - ); - } - - function moveFeeCategoryDown(clickEvent: MouseEvent): void { - const feeCategoryId = Number.parseInt( - ( - (clickEvent.currentTarget as HTMLElement).closest( - ".container--feeCategory" - ) as HTMLElement - ).dataset.feeCategoryId!, - 10 - ); - - cityssm.postJSON( - los.urlPrefix + "/admin/doMoveFeeCategoryDown", - { - feeCategoryId, - moveToBottom: clickEvent.shiftKey ? "1" : "0" + moveToEnd: clickEvent.shiftKey ? "1" : "0" }, (responseJSON: { success: boolean; @@ -874,50 +842,20 @@ declare const bulmaJS: BulmaJS; }); } - function moveFeeUp(clickEvent: MouseEvent): void { - const feeContainerElement = (clickEvent.currentTarget as HTMLElement).closest( - ".container--fee" - ) as HTMLElement; + function moveFee(clickEvent: MouseEvent): void { + const buttonElement = clickEvent.currentTarget as HTMLButtonElement; + + const feeContainerElement = buttonElement.closest(".container--fee") as HTMLElement; const feeId = Number.parseInt(feeContainerElement.dataset.feeId!, 10); cityssm.postJSON( - los.urlPrefix + "/admin/doMoveFeeUp", + los.urlPrefix + + "/admin/" + + (buttonElement.dataset.direction === "up" ? "doMoveFeeUp" : "doMoveFeeDown"), { feeId, - moveToTop: clickEvent.shiftKey ? "1" : "0" - }, - (responseJSON: { - success: boolean; - errorMessage?: string; - feeCategories?: recordTypes.FeeCategory[]; - }) => { - if (responseJSON.success) { - feeCategories = responseJSON.feeCategories!; - renderFeeCategories(); - } else { - bulmaJS.alert({ - title: "Error Moving Fee", - message: responseJSON.errorMessage || "", - contextualColorName: "danger" - }); - } - } - ); - } - - function moveFeeDown(clickEvent: MouseEvent): void { - const feeContainerElement = (clickEvent.currentTarget as HTMLElement).closest( - ".container--fee" - ) as HTMLElement; - - const feeId = Number.parseInt(feeContainerElement.dataset.feeId!, 10); - - cityssm.postJSON( - los.urlPrefix + "/admin/doMoveFeeDown", - { - feeId, - moveToBottom: clickEvent.shiftKey ? "1" : "0" + moveToEnd: clickEvent.shiftKey ? "1" : "0" }, (responseJSON: { success: boolean; diff --git a/public-typescript/main.js b/public-typescript/main.js index 83611db5..17729670 100644 --- a/public-typescript/main.js +++ b/public-typescript/main.js @@ -293,14 +293,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
diff --git a/public-typescript/main.ts b/public-typescript/main.ts index 0f61627a..43caa9ad 100644 --- a/public-typescript/main.ts +++ b/public-typescript/main.ts @@ -376,14 +376,14 @@ declare const bulmaJS: BulmaJS;
diff --git a/public/javascripts/adminFees.min.js b/public/javascripts/adminFees.min.js index 5ab75c1d..fadee81a 100644 --- a/public/javascripts/adminFees.min.js +++ b/public/javascripts/adminFees.min.js @@ -1 +1 @@ -"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),(()=>{const e=exports.los,t=document.querySelector("#container--feeCategories");let s=exports.feeCategories;function o(){if(0!==s.length){t.innerHTML="";for(const o of s){const s=document.createElement("section");if(s.className="panel container--feeCategory",s.dataset.feeCategoryId=o.feeCategoryId.toString(),s.innerHTML='

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

'+(0===o.fees.length?'
':"")+'
'+e.getMoveUpDownButtonFieldHTML("button--moveFeeCategoryUp","button--moveFeeCategoryDown")+"
",0===o.fees.length)s.insertAdjacentHTML("beforeend",`
\n
\n

\n There are no fees in the\n "${cityssm.escapeHTML(o.feeCategory||"")}"\n category.\n

\n
\n
`),s.querySelector(".button--deleteFeeCategory").addEventListener("click",r);else for(const t of o.fees){const o=document.createElement("div");o.className="panel-block is-block container--fee",o.dataset.feeId=t.feeId.toString();const a=t.isRequired||t.occupancyTypeId||t.lotTypeId;o.innerHTML='

'+cityssm.escapeHTML(t.feeName||"")+"
"+cityssm.escapeHTML(t.feeDescription||"").replace(/\n/g,"
")+"

"+(a?'

'+(t.isRequired?'Required':"")+(t.occupancyTypeId?' '+cityssm.escapeHTML(t.occupancyType||"")+"":"")+(t.lotTypeId?' '+cityssm.escapeHTML(t.lotType||"")+"":"")+"

":"")+'
'+(t.feeFunction?cityssm.escapeHTML(t.feeFunction)+"
Fee Function":"$"+t.feeAmount.toFixed(2)+"
Fee")+'
'+(t.taxPercentage?t.taxPercentage+"%":"$"+t.taxAmount.toFixed(2))+'
Tax
'+(t.includeQuantity?cityssm.escapeHTML(t.quantityUnit||"")+"
Quantity":"")+'
'+e.getMoveUpDownButtonFieldHTML("button--moveFeeUp","button--moveFeeDown")+"
",o.querySelector("a").addEventListener("click",i),o.querySelector(".button--moveFeeUp").addEventListener("click",d),o.querySelector(".button--moveFeeDown").addEventListener("click",u),s.append(o)}s.querySelector(".button--editFeeCategory").addEventListener("click",a),s.querySelector(".button--addFee").addEventListener("click",l),s.querySelector(".button--moveFeeCategoryUp").addEventListener("click",n),s.querySelector(".button--moveFeeCategoryDown").addEventListener("click",c),t.append(s)}}else t.innerHTML='

There are no available fees.

'}function a(t){const a=Number.parseInt(t.currentTarget.closest(".container--feeCategory").dataset.feeCategoryId,10),r=s.find(e=>e.feeCategoryId===a);let n;function c(t){t.preventDefault(),cityssm.postJSON(e.urlPrefix+"/admin/doUpdateFeeCategory",t.currentTarget,e=>{e.success?(s=e.feeCategories,n(),o()):bulmaJS.alert({title:"Error Updating Fee Category",message:e.errorMessage||"",contextualColorName:"danger"})})}cityssm.openHtmlModal("adminFees-editFeeCategory",{onshow(e){e.querySelector("#feeCategoryEdit--feeCategoryId").value=r.feeCategoryId.toString(),e.querySelector("#feeCategoryEdit--feeCategory").value=r.feeCategory},onshown(e,t){bulmaJS.toggleHtmlClipped(),n=t,e.querySelector("form").addEventListener("submit",c),e.querySelector("#feeCategoryEdit--feeCategory").focus()},onremoved:()=>{bulmaJS.toggleHtmlClipped()}})}function r(t){const a=Number.parseInt(t.currentTarget.closest(".container--feeCategory").dataset.feeCategoryId,10);bulmaJS.confirm({title:"Delete Fee Category?",message:"Are you sure you want to delete this fee category?",contextualColorName:"warning",okButton:{text:"Yes, Delete the Fee Category",callbackFunction:function(){cityssm.postJSON(e.urlPrefix+"/admin/doDeleteFeeCategory",{feeCategoryId:a},e=>{e.success?(s=e.feeCategories,o()):bulmaJS.alert({title:"Error Updating Fee Category",message:e.errorMessage||"",contextualColorName:"danger"})})}}})}function n(t){const a=Number.parseInt(t.currentTarget.closest(".container--feeCategory").dataset.feeCategoryId,10);cityssm.postJSON(e.urlPrefix+"/admin/doMoveFeeCategoryUp",{feeCategoryId:a,moveToTop:t.shiftKey?"1":"0"},e=>{e.success?(s=e.feeCategories,o()):bulmaJS.alert({title:"Error Moving Fee Category",message:e.errorMessage||"",contextualColorName:"danger"})})}function c(t){const a=Number.parseInt(t.currentTarget.closest(".container--feeCategory").dataset.feeCategoryId,10);cityssm.postJSON(e.urlPrefix+"/admin/doMoveFeeCategoryDown",{feeCategoryId:a,moveToBottom:t.shiftKey?"1":"0"},e=>{e.success?(s=e.feeCategories,o()):bulmaJS.alert({title:"Error Moving Fee Category",message:e.errorMessage||"",contextualColorName:"danger"})})}function l(t){const a=Number.parseInt(t.currentTarget.closest(".container--feeCategory").dataset.feeCategoryId,10);let r;function n(t){t.preventDefault(),cityssm.postJSON(e.urlPrefix+"/admin/doAddFee",t.currentTarget,e=>{e.success?(s=e.feeCategories,r(),o()):bulmaJS.alert({title:"Error Adding Fee",message:e.errorMessage||"",contextualColorName:"danger"})})}cityssm.openHtmlModal("adminFees-addFee",{onshow(t){const o=t.querySelector("#feeAdd--feeCategoryId");for(const e of s){const t=document.createElement("option");t.value=e.feeCategoryId.toString(),t.textContent=e.feeCategory,e.feeCategoryId===a&&(t.selected=!0),o.append(t)}const r=t.querySelector("#feeAdd--occupancyTypeId");for(const e of exports.occupancyTypes){const t=document.createElement("option");t.value=e.occupancyTypeId.toString(),t.textContent=e.occupancyType,r.append(t)}const n=t.querySelector("#feeAdd--lotTypeId");for(const e of exports.lotTypes){const t=document.createElement("option");t.value=e.lotTypeId.toString(),t.textContent=e.lotType,n.append(t)}t.querySelector("#feeAdd--taxPercentage").value=exports.taxPercentageDefault.toString(),e.populateAliases(t)},onshown(e,t){bulmaJS.toggleHtmlClipped(),r=t,e.querySelector("form").addEventListener("submit",n),e.querySelector("#feeAdd--feeName").focus(),e.querySelector("#feeAdd--feeFunction").addEventListener("change",()=>{const t=e.querySelector("#feeAdd--feeAmount"),s=e.querySelector("#feeAdd--feeFunction");""===s.value?(s.closest(".select").classList.remove("is-success"),t.classList.add("is-success"),t.disabled=!1):(s.closest(".select").classList.add("is-success"),t.classList.remove("is-success"),t.disabled=!0)}),e.querySelector("#feeAdd--taxPercentage").addEventListener("keyup",()=>{const t=e.querySelector("#feeAdd--taxAmount"),s=e.querySelector("#feeAdd--taxPercentage");""===s.value?(s.classList.remove("is-success"),t.classList.add("is-success"),t.disabled=!1):(s.classList.add("is-success"),t.classList.remove("is-success"),t.disabled=!0)}),e.querySelector("#feeAdd--includeQuantity").addEventListener("change",()=>{e.querySelector("#feeAdd--quantityUnit").disabled=""===e.querySelector("#feeAdd--includeQuantity").value})},onremoved(){bulmaJS.toggleHtmlClipped()}})}function i(t){t.preventDefault();const a=t.currentTarget.closest(".container--fee"),r=Number.parseInt(a.dataset.feeId,10),n=Number.parseInt(a.closest(".container--feeCategory").dataset.feeCategoryId),c=s.find(e=>e.feeCategoryId===n).fees.find(e=>e.feeId===r);let l,i;function d(t){t.preventDefault(),cityssm.postJSON(e.urlPrefix+"/admin/doUpdateFee",t.currentTarget,e=>{e.success?(s=e.feeCategories,l(),o()):bulmaJS.alert({title:"Error Updating Fee",message:e.errorMessage||"",contextualColorName:"danger"})})}function u(t){t.preventDefault();bulmaJS.confirm({title:"Delete Fee?",message:"Are you sure you want to delete this fee?",contextualColorName:"warning",okButton:{text:"Yes, Delete the Fee",callbackFunction:()=>{cityssm.postJSON(e.urlPrefix+"/admin/doDeleteFee",{feeId:r},e=>{e.success?(s=e.feeCategories,l(),o()):bulmaJS.alert({title:"Error Deleting Fee",message:e.errorMessage||"",contextualColorName:"danger"})})}}})}function y(){const e=i.querySelector("#feeEdit--feeAmount"),t=i.querySelector("#feeEdit--feeFunction");""===t.value?(t.closest(".select").classList.remove("is-success"),e.classList.add("is-success"),e.disabled=!1):(t.closest(".select").classList.add("is-success"),e.classList.remove("is-success"),e.disabled=!0)}function m(){const e=i.querySelector("#feeEdit--taxAmount"),t=i.querySelector("#feeEdit--taxPercentage");""===t.value?(t.classList.remove("is-success"),e.classList.add("is-success"),e.disabled=!1):(t.classList.add("is-success"),e.classList.remove("is-success"),e.disabled=!0)}function f(){i.querySelector("#feeEdit--quantityUnit").disabled=""===i.querySelector("#feeEdit--includeQuantity").value}cityssm.openHtmlModal("adminFees-editFee",{onshow(t){i=t,t.querySelector("#feeEdit--feeId").value=c.feeId.toString();const o=t.querySelector("#feeEdit--feeCategoryId");for(const e of s){const t=document.createElement("option");t.value=e.feeCategoryId.toString(),t.textContent=e.feeCategory,e.feeCategoryId===n&&(t.selected=!0),o.append(t)}t.querySelector("#feeEdit--feeName").value=c.feeName,t.querySelector("#feeEdit--feeDescription").value=c.feeDescription;const a=t.querySelector("#feeEdit--occupancyTypeId");for(const e of exports.occupancyTypes){const t=document.createElement("option");t.value=e.occupancyTypeId.toString(),t.textContent=e.occupancyType,e.occupancyTypeId===c.occupancyTypeId&&(t.selected=!0),a.append(t)}const r=t.querySelector("#feeEdit--lotTypeId");for(const e of exports.lotTypes){const t=document.createElement("option");t.value=e.lotTypeId.toString(),t.textContent=e.lotType,e.lotTypeId===c.lotTypeId&&(t.selected=!0),r.append(t)}t.querySelector("#feeEdit--feeAmount").value=c.feeAmount?c.feeAmount.toFixed(2):"",t.querySelector("#feeEdit--feeFunction").addEventListener("change",y),y(),t.querySelector("#feeEdit--taxAmount").value=c.taxAmount?c.taxAmount.toFixed(2):"";const l=t.querySelector("#feeEdit--taxPercentage");l.value=c.taxPercentage?c.taxPercentage.toString():"",l.addEventListener("keyup",m),m();const d=t.querySelector("#feeEdit--includeQuantity");c.includeQuantity&&(d.value="1"),d.addEventListener("change",f),t.querySelector("#feeEdit--quantityUnit").value=c.quantityUnit||"",f(),c.isRequired&&(t.querySelector("#feeEdit--isRequired").value="1"),e.populateAliases(t)},onshown(e,t){bulmaJS.toggleHtmlClipped(),l=t,e.querySelector("form").addEventListener("submit",d),bulmaJS.init(e),e.querySelector(".button--deleteFee").addEventListener("click",u)},onremoved:()=>{bulmaJS.toggleHtmlClipped()}})}function d(t){const a=t.currentTarget.closest(".container--fee"),r=Number.parseInt(a.dataset.feeId,10);cityssm.postJSON(e.urlPrefix+"/admin/doMoveFeeUp",{feeId:r,moveToTop:t.shiftKey?"1":"0"},e=>{e.success?(s=e.feeCategories,o()):bulmaJS.alert({title:"Error Moving Fee",message:e.errorMessage||"",contextualColorName:"danger"})})}function u(t){const a=t.currentTarget.closest(".container--fee"),r=Number.parseInt(a.dataset.feeId,10);cityssm.postJSON(e.urlPrefix+"/admin/doMoveFeeDown",{feeId:r,moveToBottom:t.shiftKey?"1":"0"},e=>{e.success?(s=e.feeCategories,o()):bulmaJS.alert({title:"Error Moving Fee",message:e.errorMessage||"",contextualColorName:"danger"})})}delete exports.feeCategories,document.querySelector("#button--addFeeCategory").addEventListener("click",()=>{let t;const a=a=>{a.preventDefault(),cityssm.postJSON(e.urlPrefix+"/admin/doAddFeeCategory",a.currentTarget,e=>{e.success?(s=e.feeCategories,t(),o()):bulmaJS.alert({title:"Error Creating Fee Category",message:e.errorMessage||"",contextualColorName:"danger"})})};cityssm.openHtmlModal("adminFees-addFeeCategory",{onshown:(e,s)=>{bulmaJS.toggleHtmlClipped(),e.querySelector("#feeCategoryAdd--feeCategory").focus(),t=s,e.querySelector("form").addEventListener("submit",a)},onremoved:()=>{bulmaJS.toggleHtmlClipped()}})}),o()})(); \ No newline at end of file +"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),(()=>{const e=exports.los,t=document.querySelector("#container--feeCategories");let s=exports.feeCategories;function o(){if(0!==s.length){t.innerHTML="";for(const o of s){const s=document.createElement("section");if(s.className="panel container--feeCategory",s.dataset.feeCategoryId=o.feeCategoryId.toString(),s.innerHTML='

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

'+(0===o.fees.length?'
':"")+'
'+e.getMoveUpDownButtonFieldHTML("button--moveFeeCategoryUp","button--moveFeeCategoryDown")+"
",0===o.fees.length)s.insertAdjacentHTML("beforeend",`
\n
\n

\n There are no fees in the\n "${cityssm.escapeHTML(o.feeCategory||"")}"\n category.\n

\n
\n
`),s.querySelector(".button--deleteFeeCategory").addEventListener("click",n);else for(const t of o.fees){const o=document.createElement("div");o.className="panel-block is-block container--fee",o.dataset.feeId=t.feeId.toString();const a=t.isRequired||t.occupancyTypeId||t.lotTypeId;o.innerHTML='

'+cityssm.escapeHTML(t.feeName||"")+"
"+cityssm.escapeHTML(t.feeDescription||"").replace(/\n/g,"
")+"

"+(a?'

'+(t.isRequired?'Required':"")+(t.occupancyTypeId?' '+cityssm.escapeHTML(t.occupancyType||"")+"":"")+(t.lotTypeId?' '+cityssm.escapeHTML(t.lotType||"")+"":"")+"

":"")+'
'+(t.feeFunction?cityssm.escapeHTML(t.feeFunction)+"
Fee Function":"$"+t.feeAmount.toFixed(2)+"
Fee")+'
'+(t.taxPercentage?t.taxPercentage+"%":"$"+t.taxAmount.toFixed(2))+'
Tax
'+(t.includeQuantity?cityssm.escapeHTML(t.quantityUnit||"")+"
Quantity":"")+'
'+e.getMoveUpDownButtonFieldHTML("button--moveFeeUp","button--moveFeeDown")+"
",o.querySelector("a").addEventListener("click",l),o.querySelector(".button--moveFeeUp").addEventListener("click",i),o.querySelector(".button--moveFeeDown").addEventListener("click",i),s.append(o)}s.querySelector(".button--editFeeCategory").addEventListener("click",a),s.querySelector(".button--addFee").addEventListener("click",c),s.querySelector(".button--moveFeeCategoryUp").addEventListener("click",r),s.querySelector(".button--moveFeeCategoryDown").addEventListener("click",r),t.append(s)}}else t.innerHTML='

There are no available fees.

'}function a(t){const a=Number.parseInt(t.currentTarget.closest(".container--feeCategory").dataset.feeCategoryId,10),n=s.find(e=>e.feeCategoryId===a);let r;function c(t){t.preventDefault(),cityssm.postJSON(e.urlPrefix+"/admin/doUpdateFeeCategory",t.currentTarget,e=>{e.success?(s=e.feeCategories,r(),o()):bulmaJS.alert({title:"Error Updating Fee Category",message:e.errorMessage||"",contextualColorName:"danger"})})}cityssm.openHtmlModal("adminFees-editFeeCategory",{onshow(e){e.querySelector("#feeCategoryEdit--feeCategoryId").value=n.feeCategoryId.toString(),e.querySelector("#feeCategoryEdit--feeCategory").value=n.feeCategory},onshown(e,t){bulmaJS.toggleHtmlClipped(),r=t,e.querySelector("form").addEventListener("submit",c),e.querySelector("#feeCategoryEdit--feeCategory").focus()},onremoved:()=>{bulmaJS.toggleHtmlClipped()}})}function n(t){const a=Number.parseInt(t.currentTarget.closest(".container--feeCategory").dataset.feeCategoryId,10);bulmaJS.confirm({title:"Delete Fee Category?",message:"Are you sure you want to delete this fee category?",contextualColorName:"warning",okButton:{text:"Yes, Delete the Fee Category",callbackFunction:function(){cityssm.postJSON(e.urlPrefix+"/admin/doDeleteFeeCategory",{feeCategoryId:a},e=>{e.success?(s=e.feeCategories,o()):bulmaJS.alert({title:"Error Updating Fee Category",message:e.errorMessage||"",contextualColorName:"danger"})})}}})}function r(t){const a=t.currentTarget,n=Number.parseInt(a.closest(".container--feeCategory").dataset.feeCategoryId,10);cityssm.postJSON(e.urlPrefix+"/admin/"+("up"===a.dataset.direction?"doMoveFeeCategoryUp":"doMoveFeeCategoryDown"),{feeCategoryId:n,moveToEnd:t.shiftKey?"1":"0"},e=>{e.success?(s=e.feeCategories,o()):bulmaJS.alert({title:"Error Moving Fee Category",message:e.errorMessage||"",contextualColorName:"danger"})})}function c(t){const a=Number.parseInt(t.currentTarget.closest(".container--feeCategory").dataset.feeCategoryId,10);let n;function r(t){t.preventDefault(),cityssm.postJSON(e.urlPrefix+"/admin/doAddFee",t.currentTarget,e=>{e.success?(s=e.feeCategories,n(),o()):bulmaJS.alert({title:"Error Adding Fee",message:e.errorMessage||"",contextualColorName:"danger"})})}cityssm.openHtmlModal("adminFees-addFee",{onshow(t){const o=t.querySelector("#feeAdd--feeCategoryId");for(const e of s){const t=document.createElement("option");t.value=e.feeCategoryId.toString(),t.textContent=e.feeCategory,e.feeCategoryId===a&&(t.selected=!0),o.append(t)}const n=t.querySelector("#feeAdd--occupancyTypeId");for(const e of exports.occupancyTypes){const t=document.createElement("option");t.value=e.occupancyTypeId.toString(),t.textContent=e.occupancyType,n.append(t)}const r=t.querySelector("#feeAdd--lotTypeId");for(const e of exports.lotTypes){const t=document.createElement("option");t.value=e.lotTypeId.toString(),t.textContent=e.lotType,r.append(t)}t.querySelector("#feeAdd--taxPercentage").value=exports.taxPercentageDefault.toString(),e.populateAliases(t)},onshown(e,t){bulmaJS.toggleHtmlClipped(),n=t,e.querySelector("form").addEventListener("submit",r),e.querySelector("#feeAdd--feeName").focus(),e.querySelector("#feeAdd--feeFunction").addEventListener("change",()=>{const t=e.querySelector("#feeAdd--feeAmount"),s=e.querySelector("#feeAdd--feeFunction");""===s.value?(s.closest(".select").classList.remove("is-success"),t.classList.add("is-success"),t.disabled=!1):(s.closest(".select").classList.add("is-success"),t.classList.remove("is-success"),t.disabled=!0)}),e.querySelector("#feeAdd--taxPercentage").addEventListener("keyup",()=>{const t=e.querySelector("#feeAdd--taxAmount"),s=e.querySelector("#feeAdd--taxPercentage");""===s.value?(s.classList.remove("is-success"),t.classList.add("is-success"),t.disabled=!1):(s.classList.add("is-success"),t.classList.remove("is-success"),t.disabled=!0)}),e.querySelector("#feeAdd--includeQuantity").addEventListener("change",()=>{e.querySelector("#feeAdd--quantityUnit").disabled=""===e.querySelector("#feeAdd--includeQuantity").value})},onremoved(){bulmaJS.toggleHtmlClipped()}})}function l(t){t.preventDefault();const a=t.currentTarget.closest(".container--fee"),n=Number.parseInt(a.dataset.feeId,10),r=Number.parseInt(a.closest(".container--feeCategory").dataset.feeCategoryId),c=s.find(e=>e.feeCategoryId===r).fees.find(e=>e.feeId===n);let l,i;function d(t){t.preventDefault(),cityssm.postJSON(e.urlPrefix+"/admin/doUpdateFee",t.currentTarget,e=>{e.success?(s=e.feeCategories,l(),o()):bulmaJS.alert({title:"Error Updating Fee",message:e.errorMessage||"",contextualColorName:"danger"})})}function u(t){t.preventDefault();bulmaJS.confirm({title:"Delete Fee?",message:"Are you sure you want to delete this fee?",contextualColorName:"warning",okButton:{text:"Yes, Delete the Fee",callbackFunction:()=>{cityssm.postJSON(e.urlPrefix+"/admin/doDeleteFee",{feeId:n},e=>{e.success?(s=e.feeCategories,l(),o()):bulmaJS.alert({title:"Error Deleting Fee",message:e.errorMessage||"",contextualColorName:"danger"})})}}})}function y(){const e=i.querySelector("#feeEdit--feeAmount"),t=i.querySelector("#feeEdit--feeFunction");""===t.value?(t.closest(".select").classList.remove("is-success"),e.classList.add("is-success"),e.disabled=!1):(t.closest(".select").classList.add("is-success"),e.classList.remove("is-success"),e.disabled=!0)}function f(){const e=i.querySelector("#feeEdit--taxAmount"),t=i.querySelector("#feeEdit--taxPercentage");""===t.value?(t.classList.remove("is-success"),e.classList.add("is-success"),e.disabled=!1):(t.classList.add("is-success"),e.classList.remove("is-success"),e.disabled=!0)}function m(){i.querySelector("#feeEdit--quantityUnit").disabled=""===i.querySelector("#feeEdit--includeQuantity").value}cityssm.openHtmlModal("adminFees-editFee",{onshow(t){i=t,t.querySelector("#feeEdit--feeId").value=c.feeId.toString();const o=t.querySelector("#feeEdit--feeCategoryId");for(const e of s){const t=document.createElement("option");t.value=e.feeCategoryId.toString(),t.textContent=e.feeCategory,e.feeCategoryId===r&&(t.selected=!0),o.append(t)}t.querySelector("#feeEdit--feeName").value=c.feeName,t.querySelector("#feeEdit--feeDescription").value=c.feeDescription;const a=t.querySelector("#feeEdit--occupancyTypeId");for(const e of exports.occupancyTypes){const t=document.createElement("option");t.value=e.occupancyTypeId.toString(),t.textContent=e.occupancyType,e.occupancyTypeId===c.occupancyTypeId&&(t.selected=!0),a.append(t)}const n=t.querySelector("#feeEdit--lotTypeId");for(const e of exports.lotTypes){const t=document.createElement("option");t.value=e.lotTypeId.toString(),t.textContent=e.lotType,e.lotTypeId===c.lotTypeId&&(t.selected=!0),n.append(t)}t.querySelector("#feeEdit--feeAmount").value=c.feeAmount?c.feeAmount.toFixed(2):"",t.querySelector("#feeEdit--feeFunction").addEventListener("change",y),y(),t.querySelector("#feeEdit--taxAmount").value=c.taxAmount?c.taxAmount.toFixed(2):"";const l=t.querySelector("#feeEdit--taxPercentage");l.value=c.taxPercentage?c.taxPercentage.toString():"",l.addEventListener("keyup",f),f();const d=t.querySelector("#feeEdit--includeQuantity");c.includeQuantity&&(d.value="1"),d.addEventListener("change",m),t.querySelector("#feeEdit--quantityUnit").value=c.quantityUnit||"",m(),c.isRequired&&(t.querySelector("#feeEdit--isRequired").value="1"),e.populateAliases(t)},onshown(e,t){bulmaJS.toggleHtmlClipped(),l=t,e.querySelector("form").addEventListener("submit",d),bulmaJS.init(e),e.querySelector(".button--deleteFee").addEventListener("click",u)},onremoved:()=>{bulmaJS.toggleHtmlClipped()}})}function i(t){const a=t.currentTarget,n=a.closest(".container--fee"),r=Number.parseInt(n.dataset.feeId,10);cityssm.postJSON(e.urlPrefix+"/admin/"+("up"===a.dataset.direction?"doMoveFeeUp":"doMoveFeeDown"),{feeId:r,moveToEnd:t.shiftKey?"1":"0"},e=>{e.success?(s=e.feeCategories,o()):bulmaJS.alert({title:"Error Moving Fee",message:e.errorMessage||"",contextualColorName:"danger"})})}delete exports.feeCategories,document.querySelector("#button--addFeeCategory").addEventListener("click",()=>{let t;const a=a=>{a.preventDefault(),cityssm.postJSON(e.urlPrefix+"/admin/doAddFeeCategory",a.currentTarget,e=>{e.success?(s=e.feeCategories,t(),o()):bulmaJS.alert({title:"Error Creating Fee Category",message:e.errorMessage||"",contextualColorName:"danger"})})};cityssm.openHtmlModal("adminFees-addFeeCategory",{onshown:(e,s)=>{bulmaJS.toggleHtmlClipped(),e.querySelector("#feeCategoryAdd--feeCategory").focus(),t=s,e.querySelector("form").addEventListener("submit",a)},onremoved:()=>{bulmaJS.toggleHtmlClipped()}})}),o()})(); \ No newline at end of file diff --git a/public/javascripts/main.min.js b/public/javascripts/main.min.js index 8d8c1993..9df6b7cb 100644 --- a/public/javascripts/main.min.js +++ b/public/javascripts/main.min.js @@ -1 +1 @@ -"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),(()=>{let e=!1;function t(){return e}function s(e){const t=e.currentTarget.closest(".field").querySelector("input, select");if(t.classList.remove("is-readonly"),"INPUT"===t.tagName)t.readOnly=!1,t.disabled=!1;else{const e=t.querySelectorAll("option");for(const t of e)t.disabled=!1}t.focus()}const a={type:"date",dateFormat:"yyyy-MM-dd",showFooter:!1,color:"info",displayMode:"dialog"};const o=Object.freeze({Map:cityssm.escapeHTML(exports.aliases.map),map:cityssm.escapeHTML(exports.aliases.map.toLowerCase()),Maps:cityssm.escapeHTML(exports.aliases.maps),maps:cityssm.escapeHTML(exports.aliases.maps.toLowerCase()),Lot:cityssm.escapeHTML(exports.aliases.lot),lot:cityssm.escapeHTML(exports.aliases.lot.toLowerCase()),Lots:cityssm.escapeHTML(exports.aliases.lots),lots:cityssm.escapeHTML(exports.aliases.lots.toLowerCase()),Occupancy:cityssm.escapeHTML(exports.aliases.occupancy),occupancy:cityssm.escapeHTML(exports.aliases.occupancy.toLowerCase()),Occupancies:cityssm.escapeHTML(exports.aliases.occupancies),occupancies:cityssm.escapeHTML(exports.aliases.occupancies.toLowerCase()),Occupant:cityssm.escapeHTML(exports.aliases.occupant),occupant:cityssm.escapeHTML(exports.aliases.occupant.toLowerCase()),Occupants:cityssm.escapeHTML(exports.aliases.occupants),occupants:cityssm.escapeHTML(exports.aliases.occupants.toLowerCase()),ExternalReceiptNumber:cityssm.escapeHTML(exports.aliases.externalReceiptNumber),externalReceiptNumber:cityssm.escapeHTML(exports.aliases.externalReceiptNumber.toLowerCase()),OccupancyStartDate:cityssm.escapeHTML(exports.aliases.occupancyStartDate),occupancyStartDate:cityssm.escapeHTML(exports.aliases.occupancyStartDate.toLowerCase()),WorkOrderOpenDate:cityssm.escapeHTML(exports.aliases.workOrderOpenDate),workOrderOpenDate:cityssm.escapeHTML(exports.aliases.workOrderOpenDate.toLowerCase()),WorkOrderCloseDate:cityssm.escapeHTML(exports.aliases.workOrderCloseDate),workOrderCloseDate:cityssm.escapeHTML(exports.aliases.workOrderCloseDate.toLowerCase())}),c=["red","green","orange","blue","pink","yellow","purple"],i=["bright","light","dark"];const n={urlPrefix:document.querySelector("main").dataset.urlPrefix,apiKey:document.querySelector("main").dataset.apiKey,highlightMap:function(e,t,s){let a,o=t;for(;!(a=e.querySelector("#"+o))&&o.includes("-");)o=o.slice(0,Math.max(0,o.lastIndexOf("-")));if(a){a.style.fill="",a.classList.add("highlight","is-"+s);const e=a.querySelectorAll("path");for(const t of e)t.style.fill=""}},initializeUnlockFieldButtons:function(e){const t=e.querySelectorAll(".is-unlock-field-button");for(const e of t)e.addEventListener("click",s)},initializeDatePickers:function(e){const t=e.querySelectorAll("input[type='date']");for(const s of t){const t=Object.assign({},a);s.required&&(t.showClearButton=!1),s.min&&(t.minDate=cityssm.dateStringToDate(s.min)),s.max&&(t.maxDate=cityssm.dateStringToDate(s.max));const o=exports.bulmaCalendar.attach(s,t)[0];o.on("save",()=>{s.value=o.value(),s.dispatchEvent(new Event("change"))}),o.on("show",()=>{document.querySelector("html").classList.add("is-clipped")}),o.on("hide",()=>{bulmaJS.toggleHtmlClipped()});const c=e.querySelector("#"+o._id),i=c.querySelectorAll(".datepicker-nav button.is-text");for(const e of i)e.classList.add("is-"+a.color),e.classList.remove("is-text");const n=c.querySelector(".datetimepicker-clear-button");n&&(s.required?n.remove():(n.dataset.tooltip="Clear",n.ariaLabel="Clear",n.innerHTML=''));const r=document.querySelector("label[for='"+s.id+"']");r&&(c.querySelector(".datetimepicker-dummy-input").ariaLabel=r.textContent)}},populateAliases:function(e){const t=e.querySelectorAll(".alias");for(const e of t)switch(e.dataset.alias){case"Map":e.textContent=exports.aliases.map;break;case"Lot":e.textContent=exports.aliases.lot;break;case"lot":e.textContent=exports.aliases.lot.toLowerCase();break;case"Occupancy":e.textContent=exports.aliases.occupancy;break;case"occupancy":e.textContent=exports.aliases.occupancy.toLowerCase();break;case"Occupant":e.textContent=exports.aliases.occupant;break;case"occupant":e.textContent=exports.aliases.occupant.toLowerCase();break;case"ExternalReceiptNumber":e.textContent=exports.aliases.externalReceiptNumber}},escapedAliases:o,getRandomColor:function(e){let t=e;return t.length<2&&(t+="a1"),exports.randomColor({seed:t+t,hue:c[t.codePointAt(t.length-1)%c.length],luminosity:i[t.codePointAt(t.length-2)%i.length]})},setUnsavedChanges:function(){t()||(e=!0,cityssm.enableNavBlocker())},clearUnsavedChanges:function(){e=!1,cityssm.disableNavBlocker()},hasUnsavedChanges:t,getMoveUpDownButtonFieldHTML:function(e,t,s=!0){return`
\n
\n \n \n \n
\n
\n \n \n \n
\n
`},getLoadingParagraphHTML:function(e="Loading..."){return`

\n
\n ${cityssm.escapeHTML(e)}\n

`},getSearchResultsPagerHTML:function(e,t,s){return'
Displaying '+(t+1).toString()+" to "+Math.min(s,e+t)+" of "+s+'
'+(t>0?'
':"")+(e+t
':"")+"
"}};exports.los=n})(); \ No newline at end of file +"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),(()=>{let e=!1;function t(){return e}function s(e){const t=e.currentTarget.closest(".field").querySelector("input, select");if(t.classList.remove("is-readonly"),"INPUT"===t.tagName)t.readOnly=!1,t.disabled=!1;else{const e=t.querySelectorAll("option");for(const t of e)t.disabled=!1}t.focus()}const a={type:"date",dateFormat:"yyyy-MM-dd",showFooter:!1,color:"info",displayMode:"dialog"};const o=Object.freeze({Map:cityssm.escapeHTML(exports.aliases.map),map:cityssm.escapeHTML(exports.aliases.map.toLowerCase()),Maps:cityssm.escapeHTML(exports.aliases.maps),maps:cityssm.escapeHTML(exports.aliases.maps.toLowerCase()),Lot:cityssm.escapeHTML(exports.aliases.lot),lot:cityssm.escapeHTML(exports.aliases.lot.toLowerCase()),Lots:cityssm.escapeHTML(exports.aliases.lots),lots:cityssm.escapeHTML(exports.aliases.lots.toLowerCase()),Occupancy:cityssm.escapeHTML(exports.aliases.occupancy),occupancy:cityssm.escapeHTML(exports.aliases.occupancy.toLowerCase()),Occupancies:cityssm.escapeHTML(exports.aliases.occupancies),occupancies:cityssm.escapeHTML(exports.aliases.occupancies.toLowerCase()),Occupant:cityssm.escapeHTML(exports.aliases.occupant),occupant:cityssm.escapeHTML(exports.aliases.occupant.toLowerCase()),Occupants:cityssm.escapeHTML(exports.aliases.occupants),occupants:cityssm.escapeHTML(exports.aliases.occupants.toLowerCase()),ExternalReceiptNumber:cityssm.escapeHTML(exports.aliases.externalReceiptNumber),externalReceiptNumber:cityssm.escapeHTML(exports.aliases.externalReceiptNumber.toLowerCase()),OccupancyStartDate:cityssm.escapeHTML(exports.aliases.occupancyStartDate),occupancyStartDate:cityssm.escapeHTML(exports.aliases.occupancyStartDate.toLowerCase()),WorkOrderOpenDate:cityssm.escapeHTML(exports.aliases.workOrderOpenDate),workOrderOpenDate:cityssm.escapeHTML(exports.aliases.workOrderOpenDate.toLowerCase()),WorkOrderCloseDate:cityssm.escapeHTML(exports.aliases.workOrderCloseDate),workOrderCloseDate:cityssm.escapeHTML(exports.aliases.workOrderCloseDate.toLowerCase())}),c=["red","green","orange","blue","pink","yellow","purple"],i=["bright","light","dark"];const n={urlPrefix:document.querySelector("main").dataset.urlPrefix,apiKey:document.querySelector("main").dataset.apiKey,highlightMap:function(e,t,s){let a,o=t;for(;!(a=e.querySelector("#"+o))&&o.includes("-");)o=o.slice(0,Math.max(0,o.lastIndexOf("-")));if(a){a.style.fill="",a.classList.add("highlight","is-"+s);const e=a.querySelectorAll("path");for(const t of e)t.style.fill=""}},initializeUnlockFieldButtons:function(e){const t=e.querySelectorAll(".is-unlock-field-button");for(const e of t)e.addEventListener("click",s)},initializeDatePickers:function(e){const t=e.querySelectorAll("input[type='date']");for(const s of t){const t=Object.assign({},a);s.required&&(t.showClearButton=!1),s.min&&(t.minDate=cityssm.dateStringToDate(s.min)),s.max&&(t.maxDate=cityssm.dateStringToDate(s.max));const o=exports.bulmaCalendar.attach(s,t)[0];o.on("save",()=>{s.value=o.value(),s.dispatchEvent(new Event("change"))}),o.on("show",()=>{document.querySelector("html").classList.add("is-clipped")}),o.on("hide",()=>{bulmaJS.toggleHtmlClipped()});const c=e.querySelector("#"+o._id),i=c.querySelectorAll(".datepicker-nav button.is-text");for(const e of i)e.classList.add("is-"+a.color),e.classList.remove("is-text");const n=c.querySelector(".datetimepicker-clear-button");n&&(s.required?n.remove():(n.dataset.tooltip="Clear",n.ariaLabel="Clear",n.innerHTML=''));const r=document.querySelector("label[for='"+s.id+"']");r&&(c.querySelector(".datetimepicker-dummy-input").ariaLabel=r.textContent)}},populateAliases:function(e){const t=e.querySelectorAll(".alias");for(const e of t)switch(e.dataset.alias){case"Map":e.textContent=exports.aliases.map;break;case"Lot":e.textContent=exports.aliases.lot;break;case"lot":e.textContent=exports.aliases.lot.toLowerCase();break;case"Occupancy":e.textContent=exports.aliases.occupancy;break;case"occupancy":e.textContent=exports.aliases.occupancy.toLowerCase();break;case"Occupant":e.textContent=exports.aliases.occupant;break;case"occupant":e.textContent=exports.aliases.occupant.toLowerCase();break;case"ExternalReceiptNumber":e.textContent=exports.aliases.externalReceiptNumber}},escapedAliases:o,getRandomColor:function(e){let t=e;return t.length<2&&(t+="a1"),exports.randomColor({seed:t+t,hue:c[t.codePointAt(t.length-1)%c.length],luminosity:i[t.codePointAt(t.length-2)%i.length]})},setUnsavedChanges:function(){t()||(e=!0,cityssm.enableNavBlocker())},clearUnsavedChanges:function(){e=!1,cityssm.disableNavBlocker()},hasUnsavedChanges:t,getMoveUpDownButtonFieldHTML:function(e,t,s=!0){return`
\n
\n \n \n \n
\n
\n \n \n \n
\n
`},getLoadingParagraphHTML:function(e="Loading..."){return`

\n
\n ${cityssm.escapeHTML(e)}\n

`},getSearchResultsPagerHTML:function(e,t,s){return'
Displaying '+(t+1).toString()+" to "+Math.min(s,e+t)+" of "+s+'
'+(t>0?'
':"")+(e+t
':"")+"
"}};exports.los=n})(); \ No newline at end of file