From 19232ff1b6e981ab52f8253b76f6a3e58ab0dc69 Mon Sep 17 00:00:00 2001 From: Dan Gowans Date: Tue, 24 Jan 2023 13:18:01 -0500 Subject: [PATCH] remove unneeded else --- public-typescript/adminFees.js | 166 ++++++++++++------------ public-typescript/adminFees.ts | 190 ++++++++++++++-------------- public/javascripts/adminFees.min.js | 2 +- 3 files changed, 184 insertions(+), 174 deletions(-) diff --git a/public-typescript/adminFees.js b/public-typescript/adminFees.js index e7e7c861..330df52d 100644 --- a/public-typescript/adminFees.js +++ b/public-typescript/adminFees.js @@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); let feeCategories = exports.feeCategories; delete exports.feeCategories; function renderFeeCategories() { - var _a, _b, _c, _d, _e, _f, _g, _h, _j; + var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l; if (feeCategories.length === 0) { feeCategoriesContainerElement.innerHTML = `

There are no available fees.

@@ -70,88 +70,92 @@ Object.defineProperty(exports, "__esModule", { value: true }); .querySelector('.button--deleteFeeCategory') .addEventListener('click', confirmDeleteFeeCategory); } - else { - for (const fee of feeCategory.fees) { - const panelBlockElement = document.createElement('div'); - panelBlockElement.className = 'panel-block is-block container--fee'; - panelBlockElement.dataset.feeId = fee.feeId.toString(); - const hasTagsBlock = ((_c = fee.isRequired) !== null && _c !== void 0 ? _c : false) || - fee.occupancyTypeId !== undefined || - fee.lotTypeId !== undefined; - panelBlockElement.innerHTML = - '
' + - ('
' + - '

' + - '' + - cityssm.escapeHTML((_d = fee.feeName) !== null && _d !== void 0 ? _d : '') + - '
' + - '' + - cityssm - .escapeHTML((_e = fee.feeDescription) !== null && _e !== void 0 ? _e : '') - .replace(/\n/g, '
') + - '
' + - '

' + - (hasTagsBlock - ? '

' + - (((_f = fee.isRequired) !== null && _f !== void 0 ? _f : false) - ? 'Required' - : '') + - (fee.occupancyTypeId === undefined - ? '' - : ' ' + - cityssm.escapeHTML((_g = fee.occupancyType) !== null && _g !== void 0 ? _g : '') + - '') + - (fee.lotTypeId === undefined - ? '' - : ' ' + - cityssm.escapeHTML((_h = fee.lotType) !== null && _h !== void 0 ? _h : '') + - '') + - '

' + for (const fee of feeCategory.fees) { + const panelBlockElement = document.createElement('div'); + panelBlockElement.className = 'panel-block is-block container--fee'; + panelBlockElement.dataset.feeId = fee.feeId.toString(); + const hasTagsBlock = ((_c = fee.isRequired) !== null && _c !== void 0 ? _c : false) || + fee.occupancyTypeId !== undefined || + fee.lotTypeId !== undefined; + panelBlockElement.innerHTML = + '
' + + ('
' + + '

' + + '' + + cityssm.escapeHTML((_d = fee.feeName) !== null && _d !== void 0 ? _d : '') + + '
' + + '' + + cityssm + .escapeHTML((_e = fee.feeDescription) !== null && _e !== void 0 ? _e : '') + .replace(/\n/g, '
') + + '
' + + '

' + + (hasTagsBlock + ? '

' + + (((_f = fee.isRequired) !== null && _f !== void 0 ? _f : false) + ? 'Required' + : '') + + (((_g = fee.occupancyTypeId) !== null && _g !== void 0 ? _g : -1) === -1 + ? '' + : ' ' + + ' ' + + '' + + cityssm.escapeHTML((_h = fee.occupancyType) !== null && _h !== void 0 ? _h : '') + + '' + + '') + + (((_j = fee.lotTypeId) !== null && _j !== void 0 ? _j : -1) === -1 + ? '' + : ' ' + + ' ' + + '' + + cityssm.escapeHTML((_k = fee.lotType) !== null && _k !== void 0 ? _k : '') + + '' + + '') + + '

' + : '') + + '
') + + ('
' + + '
' + + ('
' + + (fee.feeFunction + ? cityssm.escapeHTML(fee.feeFunction) + + '
' + + 'Fee Function' + : '$' + + fee.feeAmount.toFixed(2) + + '
' + + 'Fee') + + '
') + + ('
' + + (fee.taxPercentage + ? fee.taxPercentage + '%' + : '$' + fee.taxAmount.toFixed(2)) + + '
Tax' + + '
') + + ('
' + + (fee.includeQuantity + ? cityssm.escapeHTML((_l = fee.quantityUnit) !== null && _l !== void 0 ? _l : '') + + '
' + + 'Quantity' : '') + '
') + - ('
' + - '
' + - ('
' + - (fee.feeFunction - ? cityssm.escapeHTML(fee.feeFunction) + - '
' + - 'Fee Function' - : '$' + - fee.feeAmount.toFixed(2) + - '
' + - 'Fee') + - '
') + - ('
' + - (fee.taxPercentage - ? fee.taxPercentage + '%' - : '$' + fee.taxAmount.toFixed(2)) + - '
Tax' + - '
') + - ('
' + - (fee.includeQuantity - ? cityssm.escapeHTML((_j = fee.quantityUnit) !== null && _j !== void 0 ? _j : '') + - '
' + - 'Quantity' - : '') + - '
') + - '
' + - '
') + - ('
' + - los.getMoveUpDownButtonFieldHTML('button--moveFeeUp', 'button--moveFeeDown') + - '
' + - '
') + - '
'; - panelBlockElement - .querySelector('a') - .addEventListener('click', openEditFee); - panelBlockElement.querySelector('.button--moveFeeUp').addEventListener('click', moveFee); - panelBlockElement.querySelector('.button--moveFeeDown').addEventListener('click', moveFee); - feeCategoryContainerElement.append(panelBlockElement); - } + '
' + + '
') + + ('
' + + los.getMoveUpDownButtonFieldHTML('button--moveFeeUp', 'button--moveFeeDown') + + '
' + + '
') + + '
'; + panelBlockElement + .querySelector('a') + .addEventListener('click', openEditFee); + panelBlockElement.querySelector('.button--moveFeeUp').addEventListener('click', moveFee); + panelBlockElement.querySelector('.button--moveFeeDown').addEventListener('click', moveFee); + feeCategoryContainerElement.append(panelBlockElement); } feeCategoryContainerElement .querySelector('.button--editFeeCategory') diff --git a/public-typescript/adminFees.ts b/public-typescript/adminFees.ts index a627d1ca..21476d61 100644 --- a/public-typescript/adminFees.ts +++ b/public-typescript/adminFees.ts @@ -95,105 +95,111 @@ declare const bulmaJS: BulmaJS feeCategoryContainerElement .querySelector('.button--deleteFeeCategory')! .addEventListener('click', confirmDeleteFeeCategory) - } else { - for (const fee of feeCategory.fees) { - const panelBlockElement = document.createElement('div') + } - panelBlockElement.className = 'panel-block is-block container--fee' - panelBlockElement.dataset.feeId = fee.feeId.toString() + for (const fee of feeCategory.fees) { + const panelBlockElement = document.createElement('div') - const hasTagsBlock = - (fee.isRequired ?? false) || - fee.occupancyTypeId !== undefined || - fee.lotTypeId !== undefined + panelBlockElement.className = 'panel-block is-block container--fee' + panelBlockElement.dataset.feeId = fee.feeId.toString() - panelBlockElement.innerHTML = - '
' + - ('
' + - '

' + - '' + - cityssm.escapeHTML(fee.feeName ?? '') + - '
' + - '' + - cityssm - .escapeHTML(fee.feeDescription ?? '') - .replace(/\n/g, '
') + - '
' + - '

' + - (hasTagsBlock - ? '

' + - (fee.isRequired ?? false - ? 'Required' - : '') + - (fee.occupancyTypeId === undefined - ? '' - : ' ' + - cityssm.escapeHTML(fee.occupancyType ?? '') + - '') + - (fee.lotTypeId === undefined - ? '' - : ' ' + - cityssm.escapeHTML(fee.lotType ?? '') + - '') + - '

' + const hasTagsBlock = + (fee.isRequired ?? false) || + fee.occupancyTypeId !== undefined || + fee.lotTypeId !== undefined + + panelBlockElement.innerHTML = + '
' + + ('
' + + '

' + + '' + + cityssm.escapeHTML(fee.feeName ?? '') + + '
' + + '' + + cityssm + .escapeHTML(fee.feeDescription ?? '') + .replace(/\n/g, '
') + + '
' + + '

' + + (hasTagsBlock + ? '

' + + (fee.isRequired ?? false + ? 'Required' + : '') + + ((fee.occupancyTypeId ?? -1) === -1 + ? '' + : ' ' + + ' ' + + '' + + cityssm.escapeHTML(fee.occupancyType ?? '') + + '' + + '') + + ((fee.lotTypeId ?? -1) === -1 + ? '' + : ' ' + + ' ' + + '' + + cityssm.escapeHTML(fee.lotType ?? '') + + '' + + '') + + '

' + : '') + + '
') + + ('
' + + '
' + + ('
' + + (fee.feeFunction + ? cityssm.escapeHTML(fee.feeFunction) + + '
' + + 'Fee Function' + : '$' + + fee.feeAmount!.toFixed(2) + + '
' + + 'Fee') + + '
') + + ('
' + + (fee.taxPercentage + ? fee.taxPercentage + '%' + : '$' + fee.taxAmount!.toFixed(2)) + + '
Tax' + + '
') + + ('
' + + (fee.includeQuantity + ? cityssm.escapeHTML(fee.quantityUnit ?? '') + + '
' + + 'Quantity' : '') + '
') + - ('
' + - '
' + - ('
' + - (fee.feeFunction - ? cityssm.escapeHTML(fee.feeFunction) + - '
' + - 'Fee Function' - : '$' + - fee.feeAmount!.toFixed(2) + - '
' + - 'Fee') + - '
') + - ('
' + - (fee.taxPercentage - ? fee.taxPercentage + '%' - : '$' + fee.taxAmount!.toFixed(2)) + - '
Tax' + - '
') + - ('
' + - (fee.includeQuantity - ? cityssm.escapeHTML(fee.quantityUnit ?? '') + - '
' + - 'Quantity' - : '') + - '
') + - '
' + - '
') + - ('
' + - los.getMoveUpDownButtonFieldHTML( - 'button--moveFeeUp', - 'button--moveFeeDown' - ) + - '
' + - '
') + - '
' + '
' + + '
') + + ('
' + + los.getMoveUpDownButtonFieldHTML( + 'button--moveFeeUp', + 'button--moveFeeDown' + ) + + '
' + + '
') + + '' - panelBlockElement - .querySelector('a')! - .addEventListener('click', openEditFee) - ;( - panelBlockElement.querySelector( - '.button--moveFeeUp' - ) as HTMLButtonElement - ).addEventListener('click', moveFee) - ;( - panelBlockElement.querySelector( - '.button--moveFeeDown' - ) as HTMLButtonElement - ).addEventListener('click', moveFee) + panelBlockElement + .querySelector('a')! + .addEventListener('click', openEditFee) + ;( + panelBlockElement.querySelector( + '.button--moveFeeUp' + ) as HTMLButtonElement + ).addEventListener('click', moveFee) + ;( + panelBlockElement.querySelector( + '.button--moveFeeDown' + ) as HTMLButtonElement + ).addEventListener('click', moveFee) - feeCategoryContainerElement.append(panelBlockElement) - } + feeCategoryContainerElement.append(panelBlockElement) } feeCategoryContainerElement diff --git a/public/javascripts/adminFees.min.js b/public/javascripts/adminFees.min.js index 8844bf92..fc7a5b89 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 o=exports.feeCategories;function s(){var s,d,u,y,f,m,p,g,v;if(0!==o.length){t.innerHTML="";for(const C of o){const o=document.createElement("section");if(o.className="panel container--feeCategory",o.dataset.feeCategoryId=C.feeCategoryId.toString(),o.innerHTML='

'+cityssm.escapeHTML(null!==(s=C.feeCategory)&&void 0!==s?s:"")+'

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

\n There are no fees in the\n "${cityssm.escapeHTML(null!==(d=C.feeCategory)&&void 0!==d?d:"")}"\n category.\n

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

'+cityssm.escapeHTML(null!==(y=t.feeName)&&void 0!==y?y:"")+"
"+cityssm.escapeHTML(null!==(f=t.feeDescription)&&void 0!==f?f:"").replace(/\n/g,"
")+"

"+(a?'

'+(null!==(m=t.isRequired)&&void 0!==m&&m?'Required':"")+(void 0===t.occupancyTypeId?"":' '+cityssm.escapeHTML(null!==(p=t.occupancyType)&&void 0!==p?p:"")+"")+(void 0===t.lotTypeId?"":' '+cityssm.escapeHTML(null!==(g=t.lotType)&&void 0!==g?g:"")+"")+"

":"")+'
'+(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(null!==(v=t.quantityUnit)&&void 0!==v?v:"")+"
Quantity":"")+'
'+e.getMoveUpDownButtonFieldHTML("button--moveFeeUp","button--moveFeeDown")+"
",s.querySelector("a").addEventListener("click",c),s.querySelector(".button--moveFeeUp").addEventListener("click",i),s.querySelector(".button--moveFeeDown").addEventListener("click",i),o.append(s)}o.querySelector(".button--editFeeCategory").addEventListener("click",a),o.querySelector(".button--addFee").addEventListener("click",l),o.querySelector(".button--moveFeeCategoryUp").addEventListener("click",r),o.querySelector(".button--moveFeeCategoryDown").addEventListener("click",r),t.append(o)}}else t.innerHTML='
\n

There are no available fees.

\n
'}function a(t){const a=Number.parseInt(t.currentTarget.closest(".container--feeCategory").dataset.feeCategoryId,10),n=o.find(e=>e.feeCategoryId===a);let r;function l(t){t.preventDefault(),cityssm.postJSON(e.urlPrefix+"/admin/doUpdateFeeCategory",t.currentTarget,e=>{var t;e.success?(o=e.feeCategories,r(),s()):bulmaJS.alert({title:"Error Updating Fee Category",message:null!==(t=e.errorMessage)&&void 0!==t?t:"",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",l),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=>{var t;e.success?(o=e.feeCategories,s()):bulmaJS.alert({title:"Error Updating Fee Category",message:null!==(t=e.errorMessage)&&void 0!==t?t:"",contextualColorName:"danger"})})}}})}function r(t){const a=t.currentTarget,n=a.closest(".container--feeCategory").dataset.feeCategoryId;cityssm.postJSON(e.urlPrefix+"/admin/"+("up"===a.dataset.direction?"doMoveFeeCategoryUp":"doMoveFeeCategoryDown"),{feeCategoryId:n,moveToEnd:t.shiftKey?"1":"0"},e=>{var t;e.success?(o=e.feeCategories,s()):bulmaJS.alert({title:"Error Moving Fee Category",message:null!==(t=e.errorMessage)&&void 0!==t?t:"",contextualColorName:"danger"})})}function l(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=>{var t;e.success?(o=e.feeCategories,n(),s()):bulmaJS.alert({title:"Error Adding Fee",message:null!==(t=e.errorMessage)&&void 0!==t?t:"",contextualColorName:"danger"})})}cityssm.openHtmlModal("adminFees-addFee",{onshow(t){const s=t.querySelector("#feeAdd--feeCategoryId");for(const e of o){const t=document.createElement("option");t.value=e.feeCategoryId.toString(),t.textContent=e.feeCategory,e.feeCategoryId===a&&(t.selected=!0),s.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"),o=e.querySelector("#feeAdd--feeFunction");""===o.value?(o.closest(".select").classList.remove("is-success"),t.classList.add("is-success"),t.disabled=!1):(o.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"),o=e.querySelector("#feeAdd--taxPercentage");""===o.value?(o.classList.remove("is-success"),t.classList.add("is-success"),t.disabled=!1):(o.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 c(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),l=o.find(e=>e.feeCategoryId===r).fees.find(e=>e.feeId===n);let c,i;function d(t){t.preventDefault(),cityssm.postJSON(e.urlPrefix+"/admin/doUpdateFee",t.currentTarget,e=>{var t;e.success?(o=e.feeCategories,c(),s()):bulmaJS.alert({title:"Error Updating Fee",message:null!==(t=e.errorMessage)&&void 0!==t?t:"",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:function(){cityssm.postJSON(e.urlPrefix+"/admin/doDeleteFee",{feeId:n},e=>{var t;e.success?(o=e.feeCategories,c(),s()):bulmaJS.alert({title:"Error Deleting Fee",message:null!==(t=e.errorMessage)&&void 0!==t?t:"",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(){const e=i.querySelector("#feeEdit--includeQuantity").value;i.querySelector("#feeEdit--quantityUnit").disabled=""===e}cityssm.openHtmlModal("adminFees-editFee",{onshow(t){var s,a,n;i=t,t.querySelector("#feeEdit--feeId").value=l.feeId.toString();const c=t.querySelector("#feeEdit--feeCategoryId");for(const e of o){const t=document.createElement("option");t.value=e.feeCategoryId.toString(),t.textContent=e.feeCategory,e.feeCategoryId===r&&(t.selected=!0),c.append(t)}t.querySelector("#feeEdit--feeName").value=l.feeName,t.querySelector("#feeEdit--feeDescription").value=l.feeDescription;const d=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===l.occupancyTypeId&&(t.selected=!0),d.append(t)}const u=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===l.lotTypeId&&(t.selected=!0),u.append(t)}t.querySelector("#feeEdit--feeAmount").value=l.feeAmount?l.feeAmount.toFixed(2):"",t.querySelector("#feeEdit--feeFunction").addEventListener("change",y),y(),t.querySelector("#feeEdit--taxAmount").value=l.taxAmount?l.taxAmount.toFixed(2):"";const p=t.querySelector("#feeEdit--taxPercentage");p.value=l.taxPercentage?l.taxPercentage.toString():"",p.addEventListener("keyup",f),f();const g=t.querySelector("#feeEdit--includeQuantity");null!==(s=l.includeQuantity)&&void 0!==s&&s&&(g.value="1"),g.addEventListener("change",m),t.querySelector("#feeEdit--quantityUnit").value=null!==(a=l.quantityUnit)&&void 0!==a?a:"",m(),null!==(n=l.isRequired)&&void 0!==n&&n&&(t.querySelector("#feeEdit--isRequired").value="1"),e.populateAliases(t)},onshown(e,t){bulmaJS.toggleHtmlClipped(),c=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").dataset.feeId;cityssm.postJSON(e.urlPrefix+"/admin/"+("up"===a.dataset.direction?"doMoveFeeUp":"doMoveFeeDown"),{feeId:n,moveToEnd:t.shiftKey?"1":"0"},e=>{var t;e.success?(o=e.feeCategories,s()):bulmaJS.alert({title:"Error Moving Fee",message:null!==(t=e.errorMessage)&&void 0!==t?t:"",contextualColorName:"danger"})})}delete exports.feeCategories,document.querySelector("#button--addFeeCategory").addEventListener("click",()=>{let t;function a(a){a.preventDefault(),cityssm.postJSON(e.urlPrefix+"/admin/doAddFeeCategory",a.currentTarget,e=>{var a;e.success?(o=e.feeCategories,t(),s()):bulmaJS.alert({title:"Error Creating Fee Category",message:null!==(a=e.errorMessage)&&void 0!==a?a:"",contextualColorName:"danger"})})}cityssm.openHtmlModal("adminFees-addFeeCategory",{onshown(e,o){bulmaJS.toggleHtmlClipped(),e.querySelector("#feeCategoryAdd--feeCategory").focus(),t=o,e.querySelector("form").addEventListener("submit",a)},onremoved(){bulmaJS.toggleHtmlClipped(),document.querySelector("#button--addFeeCategory").focus()}})}),s()})(); \ 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(){var o,d,u,y,f,p,m,g,v,C,S;if(0!==s.length){t.innerHTML="";for(const b of s){const s=document.createElement("section");s.className="panel container--feeCategory",s.dataset.feeCategoryId=b.feeCategoryId.toString(),s.innerHTML='

'+cityssm.escapeHTML(null!==(o=b.feeCategory)&&void 0!==o?o:"")+'

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

\n There are no fees in the\n "${cityssm.escapeHTML(null!==(d=b.feeCategory)&&void 0!==d?d:"")}"\n category.\n

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

'+cityssm.escapeHTML(null!==(y=t.feeName)&&void 0!==y?y:"")+"
"+cityssm.escapeHTML(null!==(f=t.feeDescription)&&void 0!==f?f:"").replace(/\n/g,"
")+"

"+(a?'

'+(null!==(p=t.isRequired)&&void 0!==p&&p?'Required':"")+(-1===(null!==(m=t.occupancyTypeId)&&void 0!==m?m:-1)?"":' '+cityssm.escapeHTML(null!==(g=t.occupancyType)&&void 0!==g?g:"")+"")+(-1===(null!==(v=t.lotTypeId)&&void 0!==v?v:-1)?"":' '+cityssm.escapeHTML(null!==(C=t.lotType)&&void 0!==C?C:"")+"")+"

":"")+'
'+(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(null!==(S=t.quantityUnit)&&void 0!==S?S:"")+"
Quantity":"")+'
'+e.getMoveUpDownButtonFieldHTML("button--moveFeeUp","button--moveFeeDown")+"
",o.querySelector("a").addEventListener("click",c),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",l),s.querySelector(".button--moveFeeCategoryUp").addEventListener("click",r),s.querySelector(".button--moveFeeCategoryDown").addEventListener("click",r),t.append(s)}}else t.innerHTML='
\n

There are no available fees.

\n
'}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 l(t){t.preventDefault(),cityssm.postJSON(e.urlPrefix+"/admin/doUpdateFeeCategory",t.currentTarget,e=>{var t;e.success?(s=e.feeCategories,r(),o()):bulmaJS.alert({title:"Error Updating Fee Category",message:null!==(t=e.errorMessage)&&void 0!==t?t:"",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",l),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=>{var t;e.success?(s=e.feeCategories,o()):bulmaJS.alert({title:"Error Updating Fee Category",message:null!==(t=e.errorMessage)&&void 0!==t?t:"",contextualColorName:"danger"})})}}})}function r(t){const a=t.currentTarget,n=a.closest(".container--feeCategory").dataset.feeCategoryId;cityssm.postJSON(e.urlPrefix+"/admin/"+("up"===a.dataset.direction?"doMoveFeeCategoryUp":"doMoveFeeCategoryDown"),{feeCategoryId:n,moveToEnd:t.shiftKey?"1":"0"},e=>{var t;e.success?(s=e.feeCategories,o()):bulmaJS.alert({title:"Error Moving Fee Category",message:null!==(t=e.errorMessage)&&void 0!==t?t:"",contextualColorName:"danger"})})}function l(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=>{var t;e.success?(s=e.feeCategories,n(),o()):bulmaJS.alert({title:"Error Adding Fee",message:null!==(t=e.errorMessage)&&void 0!==t?t:"",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 c(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),l=s.find(e=>e.feeCategoryId===r).fees.find(e=>e.feeId===n);let c,i;function d(t){t.preventDefault(),cityssm.postJSON(e.urlPrefix+"/admin/doUpdateFee",t.currentTarget,e=>{var t;e.success?(s=e.feeCategories,c(),o()):bulmaJS.alert({title:"Error Updating Fee",message:null!==(t=e.errorMessage)&&void 0!==t?t:"",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:function(){cityssm.postJSON(e.urlPrefix+"/admin/doDeleteFee",{feeId:n},e=>{var t;e.success?(s=e.feeCategories,c(),o()):bulmaJS.alert({title:"Error Deleting Fee",message:null!==(t=e.errorMessage)&&void 0!==t?t:"",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 p(){const e=i.querySelector("#feeEdit--includeQuantity").value;i.querySelector("#feeEdit--quantityUnit").disabled=""===e}cityssm.openHtmlModal("adminFees-editFee",{onshow(t){var o,a,n;i=t,t.querySelector("#feeEdit--feeId").value=l.feeId.toString();const c=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),c.append(t)}t.querySelector("#feeEdit--feeName").value=l.feeName,t.querySelector("#feeEdit--feeDescription").value=l.feeDescription;const d=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===l.occupancyTypeId&&(t.selected=!0),d.append(t)}const u=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===l.lotTypeId&&(t.selected=!0),u.append(t)}t.querySelector("#feeEdit--feeAmount").value=l.feeAmount?l.feeAmount.toFixed(2):"",t.querySelector("#feeEdit--feeFunction").addEventListener("change",y),y(),t.querySelector("#feeEdit--taxAmount").value=l.taxAmount?l.taxAmount.toFixed(2):"";const m=t.querySelector("#feeEdit--taxPercentage");m.value=l.taxPercentage?l.taxPercentage.toString():"",m.addEventListener("keyup",f),f();const g=t.querySelector("#feeEdit--includeQuantity");null!==(o=l.includeQuantity)&&void 0!==o&&o&&(g.value="1"),g.addEventListener("change",p),t.querySelector("#feeEdit--quantityUnit").value=null!==(a=l.quantityUnit)&&void 0!==a?a:"",p(),null!==(n=l.isRequired)&&void 0!==n&&n&&(t.querySelector("#feeEdit--isRequired").value="1"),e.populateAliases(t)},onshown(e,t){bulmaJS.toggleHtmlClipped(),c=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").dataset.feeId;cityssm.postJSON(e.urlPrefix+"/admin/"+("up"===a.dataset.direction?"doMoveFeeUp":"doMoveFeeDown"),{feeId:n,moveToEnd:t.shiftKey?"1":"0"},e=>{var t;e.success?(s=e.feeCategories,o()):bulmaJS.alert({title:"Error Moving Fee",message:null!==(t=e.errorMessage)&&void 0!==t?t:"",contextualColorName:"danger"})})}delete exports.feeCategories,document.querySelector("#button--addFeeCategory").addEventListener("click",()=>{let t;function a(a){a.preventDefault(),cityssm.postJSON(e.urlPrefix+"/admin/doAddFeeCategory",a.currentTarget,e=>{var a;e.success?(s=e.feeCategories,t(),o()):bulmaJS.alert({title:"Error Creating Fee Category",message:null!==(a=e.errorMessage)&&void 0!==a?a:"",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(),document.querySelector("#button--addFeeCategory").focus()}})}),o()})(); \ No newline at end of file