From f2bbcf0890ce5e9cd09a15fa6d4ee44b628f8236 Mon Sep 17 00:00:00 2001 From: Dan Gowans Date: Tue, 25 Jun 2024 11:36:42 -0400 Subject: [PATCH] code cleanup --- public-typescript/adminDatabase.js | 4 +- public-typescript/adminDatabase.ts | 13 +- public-typescript/adminFees.js | 220 ++++++++++++------------ public-typescript/adminFees.ts | 201 +++++++++++----------- public/javascripts/adminDatabase.min.js | 2 +- public/javascripts/adminFees.min.js | 2 +- 6 files changed, 223 insertions(+), 219 deletions(-) diff --git a/public-typescript/adminDatabase.js b/public-typescript/adminDatabase.js index 4b28a2d4..0aea13b1 100644 --- a/public-typescript/adminDatabase.js +++ b/public-typescript/adminDatabase.js @@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); var _a, _b; const los = exports.los; function doBackup() { - cityssm.postJSON(los.urlPrefix + '/admin/doBackupDatabase', {}, (rawResponseJSON) => { + cityssm.postJSON(`${los.urlPrefix}/admin/doBackupDatabase`, {}, (rawResponseJSON) => { var _a; const responseJSON = rawResponseJSON; if (responseJSON.success) { @@ -27,7 +27,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); }); } function doCleanup() { - cityssm.postJSON(los.urlPrefix + '/admin/doCleanupDatabase', {}, (rawResponseJSON) => { + cityssm.postJSON(`${los.urlPrefix}/admin/doCleanupDatabase`, {}, (rawResponseJSON) => { var _a; const responseJSON = rawResponseJSON; if (responseJSON.success) { diff --git a/public-typescript/adminDatabase.ts b/public-typescript/adminDatabase.ts index d3858bdc..df06b3a3 100644 --- a/public-typescript/adminDatabase.ts +++ b/public-typescript/adminDatabase.ts @@ -1,19 +1,20 @@ /* @typescript-eslint/no-non-null-assertion, unicorn/prefer-module */ -import type * as globalTypes from '../types/globalTypes' +import type { BulmaJS } from '@cityssm/bulma-js/types.js' +import type { cityssmGlobal } from '@cityssm/bulma-webapp-js/src/types.js' -import type { cityssmGlobal } from '@cityssm/bulma-webapp-js/src/types' - -import type { BulmaJS } from '@cityssm/bulma-js/types' +import type * as globalTypes from '../types/globalTypes.js' declare const cityssm: cityssmGlobal declare const bulmaJS: BulmaJS + +declare const exports: Record ;(() => { const los = exports.los as globalTypes.LOS function doBackup(): void { cityssm.postJSON( - los.urlPrefix + '/admin/doBackupDatabase', + `${los.urlPrefix}/admin/doBackupDatabase`, {}, (rawResponseJSON) => { const responseJSON = rawResponseJSON as @@ -47,7 +48,7 @@ declare const bulmaJS: BulmaJS function doCleanup(): void { cityssm.postJSON( - los.urlPrefix + '/admin/doCleanupDatabase', + `${los.urlPrefix}/admin/doCleanupDatabase`, {}, (rawResponseJSON) => { const responseJSON = rawResponseJSON as diff --git a/public-typescript/adminFees.js b/public-typescript/adminFees.js index 2feb6d42..bc7d7c0e 100644 --- a/public-typescript/adminFees.js +++ b/public-typescript/adminFees.js @@ -1,13 +1,15 @@ "use strict"; -/* eslint-disable @typescript-eslint/no-non-null-assertion, unicorn/prefer-module */ +// eslint-disable-next-line @eslint-community/eslint-comments/disable-enable-pair +/* eslint-disable unicorn/prefer-module */ Object.defineProperty(exports, "__esModule", { value: true }); (() => { + var _a; const los = exports.los; const feeCategoriesContainerElement = document.querySelector('#container--feeCategories'); let feeCategories = exports.feeCategories; delete exports.feeCategories; function renderFeeCategories() { - var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o; + var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s; if (feeCategories.length === 0) { feeCategoriesContainerElement.innerHTML = `

There are no available fees.

@@ -20,42 +22,40 @@ Object.defineProperty(exports, "__esModule", { value: true }); feeCategoryContainerElement.className = 'panel container--feeCategory'; feeCategoryContainerElement.dataset.feeCategoryId = feeCategory.feeCategoryId.toString(); - feeCategoryContainerElement.innerHTML = - '
' + - '
' + - ('
' + - '

' + - cityssm.escapeHTML((_a = feeCategory.feeCategory) !== null && _a !== void 0 ? _a : '') + - '

' + - '
') + - ('
' + - '
' + - (feeCategory.fees.length === 0 - ? '
' + - '' + - '
' - : '') + - ('
' + - '' + - '
') + - ('
' + - '' + - '
') + - ('
' + - los.getMoveUpDownButtonFieldHTML('button--moveFeeCategoryUp', 'button--moveFeeCategoryDown') + - '
') + - '
') + - '
' + - '
'; + // eslint-disable-next-line no-unsanitized/property + feeCategoryContainerElement.innerHTML = `
+
+
+

${cityssm.escapeHTML((_a = feeCategory.feeCategory) !== null && _a !== void 0 ? _a : '')}

+
+
+
+ ${feeCategory.fees.length === 0 + ? `
+ +
` + : ''} +
+ +
+
+ +
+
+ ${los.getMoveUpDownButtonFieldHTML('button--moveFeeCategoryUp', 'button--moveFeeCategoryDown')} +
+
+
+
`; if (feeCategory.fees.length === 0) { feeCategoryContainerElement.insertAdjacentHTML('beforeend', `
@@ -66,53 +66,53 @@ Object.defineProperty(exports, "__esModule", { value: true });

`); - feeCategoryContainerElement - .querySelector('.button--deleteFeeCategory') - .addEventListener('click', confirmDeleteFeeCategory); + (_c = feeCategoryContainerElement + .querySelector('.button--deleteFeeCategory')) === null || _c === void 0 ? void 0 : _c.addEventListener('click', confirmDeleteFeeCategory); } 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) || + const hasTagsBlock = ((_d = fee.isRequired) !== null && _d !== void 0 ? _d : false) || fee.occupancyTypeId !== undefined || fee.lotTypeId !== undefined; + // eslint-disable-next-line no-unsanitized/property panelBlockElement.innerHTML = '
' + ('
' + '

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

' + (hasTagsBlock ? '

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

' @@ -126,19 +126,19 @@ Object.defineProperty(exports, "__esModule", { value: true }); '
' + 'Fee Function' : '$' + - ((_l = fee.feeAmount) !== null && _l !== void 0 ? _l : 0).toFixed(2) + + ((_m = fee.feeAmount) !== null && _m !== void 0 ? _m : 0).toFixed(2) + '
' + 'Fee') + '
') + ('
' + (fee.taxPercentage ? fee.taxPercentage.toString() + '%' - : '$' + ((_m = fee.taxAmount) !== null && _m !== void 0 ? _m : 0).toFixed(2)) + + : '$' + ((_o = fee.taxAmount) !== null && _o !== void 0 ? _o : 0).toFixed(2)) + '
Tax' + '
') + ('
' + (fee.includeQuantity - ? cityssm.escapeHTML((_o = fee.quantityUnit) !== null && _o !== void 0 ? _o : '') + + ? cityssm.escapeHTML((_p = fee.quantityUnit) !== null && _p !== void 0 ? _p : '') + '
' + 'Quantity' : '') + @@ -150,19 +150,16 @@ Object.defineProperty(exports, "__esModule", { value: true }); '
' + '
') + '
'; - panelBlockElement - .querySelector('a') - .addEventListener('click', openEditFee); + (_q = panelBlockElement + .querySelector('a')) === null || _q === void 0 ? void 0 : _q.addEventListener('click', openEditFee); panelBlockElement.querySelector('.button--moveFeeUp').addEventListener('click', moveFee); panelBlockElement.querySelector('.button--moveFeeDown').addEventListener('click', moveFee); feeCategoryContainerElement.append(panelBlockElement); } - feeCategoryContainerElement - .querySelector('.button--editFeeCategory') - .addEventListener('click', openEditFeeCategory); - feeCategoryContainerElement - .querySelector('.button--addFee') - .addEventListener('click', openAddFee); + (_r = feeCategoryContainerElement + .querySelector('.button--editFeeCategory')) === null || _r === void 0 ? void 0 : _r.addEventListener('click', openEditFeeCategory); + (_s = feeCategoryContainerElement + .querySelector('.button--addFee')) === null || _s === void 0 ? void 0 : _s.addEventListener('click', openAddFee); feeCategoryContainerElement.querySelector('.button--moveFeeCategoryUp').addEventListener('click', moveFeeCategory); feeCategoryContainerElement.querySelector('.button--moveFeeCategoryDown').addEventListener('click', moveFeeCategory); feeCategoriesContainerElement.append(feeCategoryContainerElement); @@ -171,13 +168,12 @@ Object.defineProperty(exports, "__esModule", { value: true }); /* * Fee Categories */ - document - .querySelector('#button--addFeeCategory') - .addEventListener('click', () => { + (_a = document + .querySelector('#button--addFeeCategory')) === null || _a === void 0 ? void 0 : _a.addEventListener('click', () => { let addCloseModalFunction; function doAddFeeCategory(submitEvent) { submitEvent.preventDefault(); - cityssm.postJSON(los.urlPrefix + '/admin/doAddFeeCategory', submitEvent.currentTarget, (rawResponseJSON) => { + cityssm.postJSON(`${los.urlPrefix}/admin/doAddFeeCategory`, submitEvent.currentTarget, (rawResponseJSON) => { var _a; const responseJSON = rawResponseJSON; if (responseJSON.success) { @@ -196,12 +192,12 @@ Object.defineProperty(exports, "__esModule", { value: true }); } cityssm.openHtmlModal('adminFees-addFeeCategory', { onshown(modalElement, closeModalFunction) { + var _a; bulmaJS.toggleHtmlClipped(); modalElement.querySelector('#feeCategoryAdd--feeCategory').focus(); addCloseModalFunction = closeModalFunction; - modalElement - .querySelector('form') - .addEventListener('submit', doAddFeeCategory); + (_a = modalElement + .querySelector('form')) === null || _a === void 0 ? void 0 : _a.addEventListener('submit', doAddFeeCategory); }, onremoved() { bulmaJS.toggleHtmlClipped(); @@ -217,7 +213,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); let editCloseModalFunction; function doUpdateFeeCategory(submitEvent) { submitEvent.preventDefault(); - cityssm.postJSON(los.urlPrefix + '/admin/doUpdateFeeCategory', submitEvent.currentTarget, (rawResponseJSON) => { + cityssm.postJSON(`${los.urlPrefix}/admin/doUpdateFeeCategory`, submitEvent.currentTarget, (rawResponseJSON) => { var _a; const responseJSON = rawResponseJSON; if (responseJSON.success) { @@ -241,11 +237,11 @@ Object.defineProperty(exports, "__esModule", { value: true }); modalElement.querySelector('#feeCategoryEdit--feeCategory').value = feeCategory.feeCategory; }, onshown(modalElement, closeModalFunction) { + var _a; bulmaJS.toggleHtmlClipped(); editCloseModalFunction = closeModalFunction; - modalElement - .querySelector('form') - .addEventListener('submit', doUpdateFeeCategory); + (_a = modalElement + .querySelector('form')) === null || _a === void 0 ? void 0 : _a.addEventListener('submit', doUpdateFeeCategory); modalElement.querySelector('#feeCategoryEdit--feeCategory').focus(); }, onremoved: () => { @@ -254,9 +250,10 @@ Object.defineProperty(exports, "__esModule", { value: true }); }); } function confirmDeleteFeeCategory(clickEvent) { - const feeCategoryId = Number.parseInt(clickEvent.currentTarget.closest('.container--feeCategory').dataset.feeCategoryId, 10); + var _a; + const feeCategoryId = Number.parseInt((_a = clickEvent.currentTarget.closest('.container--feeCategory').dataset.feeCategoryId) !== null && _a !== void 0 ? _a : '', 10); function doDelete() { - cityssm.postJSON(los.urlPrefix + '/admin/doDeleteFeeCategory', { + cityssm.postJSON(`${los.urlPrefix}/admin/doDeleteFeeCategory`, { feeCategoryId }, (rawResponseJSON) => { var _a; @@ -285,8 +282,10 @@ Object.defineProperty(exports, "__esModule", { value: true }); }); } function moveFeeCategory(clickEvent) { + var _a; const buttonElement = clickEvent.currentTarget; - const feeCategoryId = buttonElement.closest('.container--feeCategory').dataset.feeCategoryId; + const feeCategoryId = (_a = buttonElement.closest('.container--feeCategory').dataset + .feeCategoryId) !== null && _a !== void 0 ? _a : ''; cityssm.postJSON(los.urlPrefix + '/admin/' + (buttonElement.dataset.direction === 'up' @@ -314,11 +313,12 @@ Object.defineProperty(exports, "__esModule", { value: true }); * Fees */ function openAddFee(clickEvent) { - const feeCategoryId = Number.parseInt(clickEvent.currentTarget.closest('.container--feeCategory').dataset.feeCategoryId, 10); + var _a; + const feeCategoryId = Number.parseInt((_a = clickEvent.currentTarget.closest('.container--feeCategory').dataset.feeCategoryId) !== null && _a !== void 0 ? _a : '', 10); let addCloseModalFunction; function doAddFee(submitEvent) { submitEvent.preventDefault(); - cityssm.postJSON(los.urlPrefix + '/admin/doAddFee', submitEvent.currentTarget, (rawResponseJSON) => { + cityssm.postJSON(`${los.urlPrefix}/admin/doAddFee`, submitEvent.currentTarget, (rawResponseJSON) => { var _a; const responseJSON = rawResponseJSON; if (responseJSON.success) { @@ -366,29 +366,29 @@ Object.defineProperty(exports, "__esModule", { value: true }); los.populateAliases(modalElement); }, onshown(modalElement, closeModalFunction) { + var _a, _b, _c; bulmaJS.toggleHtmlClipped(); addCloseModalFunction = closeModalFunction; - modalElement.querySelector('form').addEventListener('submit', doAddFee); + (_a = modalElement.querySelector('form')) === null || _a === void 0 ? void 0 : _a.addEventListener('submit', doAddFee); modalElement.querySelector('#feeAdd--feeName').focus(); modalElement.querySelector('#feeAdd--feeFunction').addEventListener('change', () => { + var _a, _b; const feeAmountElement = modalElement.querySelector('#feeAdd--feeAmount'); const feeFunctionElement = modalElement.querySelector('#feeAdd--feeFunction'); if (feeFunctionElement.value === '') { - feeFunctionElement - .closest('.select') - .classList.remove('is-success'); + (_a = feeFunctionElement + .closest('.select')) === null || _a === void 0 ? void 0 : _a.classList.remove('is-success'); feeAmountElement.classList.add('is-success'); feeAmountElement.disabled = false; } else { - feeFunctionElement.closest('.select').classList.add('is-success'); + (_b = feeFunctionElement.closest('.select')) === null || _b === void 0 ? void 0 : _b.classList.add('is-success'); feeAmountElement.classList.remove('is-success'); feeAmountElement.disabled = true; } }); - modalElement - .querySelector('#feeAdd--taxPercentage') - .addEventListener('keyup', () => { + (_b = modalElement + .querySelector('#feeAdd--taxPercentage')) === null || _b === void 0 ? void 0 : _b.addEventListener('keyup', () => { const taxAmountElement = modalElement.querySelector('#feeAdd--taxAmount'); const taxPercentageElement = modalElement.querySelector('#feeAdd--taxPercentage'); if (taxPercentageElement.value === '') { @@ -402,9 +402,8 @@ Object.defineProperty(exports, "__esModule", { value: true }); taxAmountElement.disabled = true; } }); - modalElement - .querySelector('#feeAdd--includeQuantity') - .addEventListener('change', () => { + (_c = modalElement + .querySelector('#feeAdd--includeQuantity')) === null || _c === void 0 ? void 0 : _c.addEventListener('change', () => { ; modalElement.querySelector('#feeAdd--quantityUnit').disabled = modalElement.querySelector('#feeAdd--includeQuantity').value === ''; @@ -416,11 +415,12 @@ Object.defineProperty(exports, "__esModule", { value: true }); }); } function openEditFee(clickEvent) { + var _a; clickEvent.preventDefault(); const feeContainerElement = clickEvent.currentTarget.closest('.container--fee'); const feeId = Number.parseInt(feeContainerElement.dataset.feeId, 10); - const feeCategoryId = Number.parseInt(feeContainerElement.closest('.container--feeCategory') - .dataset.feeCategoryId); + const feeCategoryId = Number.parseInt((_a = feeContainerElement.closest('.container--feeCategory') + .dataset.feeCategoryId) !== null && _a !== void 0 ? _a : ''); const feeCategory = feeCategories.find((currentFeeCategory) => { return currentFeeCategory.feeCategoryId === feeCategoryId; }); @@ -431,7 +431,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); let editModalElement; function doUpdateFee(submitEvent) { submitEvent.preventDefault(); - cityssm.postJSON(los.urlPrefix + '/admin/doUpdateFee', submitEvent.currentTarget, (rawResponseJSON) => { + cityssm.postJSON(`${los.urlPrefix}/admin/doUpdateFee`, submitEvent.currentTarget, (rawResponseJSON) => { var _a; const responseJSON = rawResponseJSON; if (responseJSON.success) { @@ -451,7 +451,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); function confirmDeleteFee(clickEvent) { clickEvent.preventDefault(); function doDelete() { - cityssm.postJSON(los.urlPrefix + '/admin/doDeleteFee', { + cityssm.postJSON(`${los.urlPrefix}/admin/doDeleteFee`, { feeId }, (rawResponseJSON) => { var _a; @@ -481,15 +481,16 @@ Object.defineProperty(exports, "__esModule", { value: true }); }); } function toggleFeeFields() { + var _a, _b; const feeAmountElement = editModalElement.querySelector('#feeEdit--feeAmount'); const feeFunctionElement = editModalElement.querySelector('#feeEdit--feeFunction'); if (feeFunctionElement.value === '') { - feeFunctionElement.closest('.select').classList.remove('is-success'); + (_a = feeFunctionElement.closest('.select')) === null || _a === void 0 ? void 0 : _a.classList.remove('is-success'); feeAmountElement.classList.add('is-success'); feeAmountElement.disabled = false; } else { - feeFunctionElement.closest('.select').classList.add('is-success'); + (_b = feeFunctionElement.closest('.select')) === null || _b === void 0 ? void 0 : _b.classList.add('is-success'); feeAmountElement.classList.remove('is-success'); feeAmountElement.disabled = true; } @@ -514,7 +515,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); } cityssm.openHtmlModal('adminFees-editFee', { onshow(modalElement) { - var _a, _b, _c, _d, _e, _f; + var _a, _b, _c, _d, _e, _f, _g; editModalElement = modalElement; modalElement.querySelector('#feeEdit--feeId').value = fee.feeId.toString(); const feeCategoryElement = modalElement.querySelector('#feeEdit--feeCategoryId'); @@ -553,9 +554,8 @@ Object.defineProperty(exports, "__esModule", { value: true }); } ; modalElement.querySelector('#feeEdit--feeAmount').value = fee.feeAmount ? fee.feeAmount.toFixed(2) : ''; - modalElement - .querySelector('#feeEdit--feeFunction') - .addEventListener('change', toggleFeeFields); + (_d = modalElement + .querySelector('#feeEdit--feeFunction')) === null || _d === void 0 ? void 0 : _d.addEventListener('change', toggleFeeFields); toggleFeeFields(); modalElement.querySelector('#feeEdit--taxAmount').value = fee.taxAmount ? fee.taxAmount.toFixed(2) : ''; const taxPercentageElement = modalElement.querySelector('#feeEdit--taxPercentage'); @@ -565,38 +565,38 @@ Object.defineProperty(exports, "__esModule", { value: true }); taxPercentageElement.addEventListener('keyup', toggleTaxFields); toggleTaxFields(); const includeQuantityElement = modalElement.querySelector('#feeEdit--includeQuantity'); - if ((_d = fee.includeQuantity) !== null && _d !== void 0 ? _d : false) { + if ((_e = fee.includeQuantity) !== null && _e !== void 0 ? _e : false) { includeQuantityElement.value = '1'; } includeQuantityElement.addEventListener('change', toggleQuantityFields); - modalElement.querySelector('#feeEdit--quantityUnit').value = (_e = fee.quantityUnit) !== null && _e !== void 0 ? _e : ''; + modalElement.querySelector('#feeEdit--quantityUnit').value = (_f = fee.quantityUnit) !== null && _f !== void 0 ? _f : ''; toggleQuantityFields(); - if ((_f = fee.isRequired) !== null && _f !== void 0 ? _f : false) { + if ((_g = fee.isRequired) !== null && _g !== void 0 ? _g : false) { ; modalElement.querySelector('#feeEdit--isRequired').value = '1'; } los.populateAliases(modalElement); }, onshown(modalElement, closeModalFunction) { + var _a, _b; bulmaJS.toggleHtmlClipped(); editCloseModalFunction = closeModalFunction; - modalElement - .querySelector('form') - .addEventListener('submit', doUpdateFee); + (_a = modalElement + .querySelector('form')) === null || _a === void 0 ? void 0 : _a.addEventListener('submit', doUpdateFee); bulmaJS.init(modalElement); - modalElement - .querySelector('.button--deleteFee') - .addEventListener('click', confirmDeleteFee); + (_b = modalElement + .querySelector('.button--deleteFee')) === null || _b === void 0 ? void 0 : _b.addEventListener('click', confirmDeleteFee); }, - onremoved: () => { + onremoved() { bulmaJS.toggleHtmlClipped(); } }); } function moveFee(clickEvent) { + var _a; const buttonElement = clickEvent.currentTarget; const feeContainerElement = buttonElement.closest('.container--fee'); - const feeId = feeContainerElement.dataset.feeId; + const feeId = (_a = feeContainerElement.dataset.feeId) !== null && _a !== void 0 ? _a : ''; cityssm.postJSON(los.urlPrefix + '/admin/' + (buttonElement.dataset.direction === 'up' diff --git a/public-typescript/adminFees.ts b/public-typescript/adminFees.ts index 1344aa11..0396d6d4 100644 --- a/public-typescript/adminFees.ts +++ b/public-typescript/adminFees.ts @@ -1,14 +1,16 @@ -/* eslint-disable @typescript-eslint/no-non-null-assertion, unicorn/prefer-module */ +// eslint-disable-next-line @eslint-community/eslint-comments/disable-enable-pair +/* eslint-disable unicorn/prefer-module */ -import type * as globalTypes from '../types/globalTypes' -import type * as recordTypes from '../types/recordTypes' +import type { BulmaJS } from '@cityssm/bulma-js/types.js' +import type { cityssmGlobal } from '@cityssm/bulma-webapp-js/src/types.js' -import type { cityssmGlobal } from '@cityssm/bulma-webapp-js/src/types' - -import type { BulmaJS } from '@cityssm/bulma-js/types' +import type * as globalTypes from '../types/globalTypes.js' +import type * as recordTypes from '../types/recordTypes.js' declare const cityssm: cityssmGlobal declare const bulmaJS: BulmaJS + +declare const exports: Record ;(() => { const los = exports.los as globalTypes.LOS @@ -16,7 +18,7 @@ declare const bulmaJS: BulmaJS '#container--feeCategories' ) as HTMLElement - let feeCategories: recordTypes.FeeCategory[] = exports.feeCategories + let feeCategories = exports.feeCategories as recordTypes.FeeCategory[] delete exports.feeCategories type ResponseJSON = @@ -48,45 +50,45 @@ declare const bulmaJS: BulmaJS feeCategoryContainerElement.dataset.feeCategoryId = feeCategory.feeCategoryId.toString() - feeCategoryContainerElement.innerHTML = - '
' + - '
' + - ('
' + - '

' + - cityssm.escapeHTML(feeCategory.feeCategory ?? '') + - '

' + - '
') + - ('
' + - '
' + - (feeCategory.fees.length === 0 - ? '
' + - '' + - '
' - : '') + - ('
' + - '' + - '
') + - ('
' + - '' + - '
') + - ('
' + - los.getMoveUpDownButtonFieldHTML( - 'button--moveFeeCategoryUp', - 'button--moveFeeCategoryDown' - ) + - '
') + - '
') + - '
' + - '
' + // eslint-disable-next-line no-unsanitized/property + feeCategoryContainerElement.innerHTML = `
+
+
+

${cityssm.escapeHTML(feeCategory.feeCategory ?? '')}

+
+
+
+ ${ + feeCategory.fees.length === 0 + ? `
+ +
` + : '' + } +
+ +
+
+ +
+
+ ${los.getMoveUpDownButtonFieldHTML( + 'button--moveFeeCategoryUp', + 'button--moveFeeCategoryDown' + )} +
+
+
+
` if (feeCategory.fees.length === 0) { feeCategoryContainerElement.insertAdjacentHTML( @@ -103,8 +105,8 @@ declare const bulmaJS: BulmaJS ) feeCategoryContainerElement - .querySelector('.button--deleteFeeCategory')! - .addEventListener('click', confirmDeleteFeeCategory) + .querySelector('.button--deleteFeeCategory') + ?.addEventListener('click', confirmDeleteFeeCategory) } for (const fee of feeCategory.fees) { @@ -118,6 +120,7 @@ declare const bulmaJS: BulmaJS fee.occupancyTypeId !== undefined || fee.lotTypeId !== undefined + // eslint-disable-next-line no-unsanitized/property panelBlockElement.innerHTML = '
' + ('
' + @@ -128,7 +131,7 @@ declare const bulmaJS: BulmaJS '' + cityssm .escapeHTML(fee.feeDescription ?? '') - .replace(/\n/g, '
') + + .replaceAll('\n', '
') + '
' + '

' + (hasTagsBlock @@ -196,8 +199,8 @@ declare const bulmaJS: BulmaJS '
' panelBlockElement - .querySelector('a')! - .addEventListener('click', openEditFee) + .querySelector('a') + ?.addEventListener('click', openEditFee) ;( panelBlockElement.querySelector( '.button--moveFeeUp' @@ -213,12 +216,12 @@ declare const bulmaJS: BulmaJS } feeCategoryContainerElement - .querySelector('.button--editFeeCategory')! - .addEventListener('click', openEditFeeCategory) + .querySelector('.button--editFeeCategory') + ?.addEventListener('click', openEditFeeCategory) feeCategoryContainerElement - .querySelector('.button--addFee')! - .addEventListener('click', openAddFee) + .querySelector('.button--addFee') + ?.addEventListener('click', openAddFee) ;( feeCategoryContainerElement.querySelector( '.button--moveFeeCategoryUp' @@ -239,15 +242,15 @@ declare const bulmaJS: BulmaJS */ document - .querySelector('#button--addFeeCategory')! - .addEventListener('click', () => { + .querySelector('#button--addFeeCategory') + ?.addEventListener('click', () => { let addCloseModalFunction: () => void function doAddFeeCategory(submitEvent: SubmitEvent): void { submitEvent.preventDefault() cityssm.postJSON( - los.urlPrefix + '/admin/doAddFeeCategory', + `${los.urlPrefix}/admin/doAddFeeCategory`, submitEvent.currentTarget, (rawResponseJSON) => { const responseJSON = rawResponseJSON as ResponseJSON @@ -278,8 +281,8 @@ declare const bulmaJS: BulmaJS addCloseModalFunction = closeModalFunction modalElement - .querySelector('form')! - .addEventListener('submit', doAddFeeCategory) + .querySelector('form') + ?.addEventListener('submit', doAddFeeCategory) }, onremoved() { bulmaJS.toggleHtmlClipped() @@ -312,7 +315,7 @@ declare const bulmaJS: BulmaJS submitEvent.preventDefault() cityssm.postJSON( - los.urlPrefix + '/admin/doUpdateFeeCategory', + `${los.urlPrefix}/admin/doUpdateFeeCategory`, submitEvent.currentTarget, (rawResponseJSON) => { const responseJSON = rawResponseJSON as ResponseJSON @@ -343,7 +346,7 @@ declare const bulmaJS: BulmaJS modalElement.querySelector( '#feeCategoryEdit--feeCategory' ) as HTMLInputElement - ).value = feeCategory.feeCategory! + ).value = feeCategory.feeCategory }, onshown(modalElement, closeModalFunction) { bulmaJS.toggleHtmlClipped() @@ -351,8 +354,8 @@ declare const bulmaJS: BulmaJS editCloseModalFunction = closeModalFunction modalElement - .querySelector('form')! - .addEventListener('submit', doUpdateFeeCategory) + .querySelector('form') + ?.addEventListener('submit', doUpdateFeeCategory) ;( modalElement.querySelector( '#feeCategoryEdit--feeCategory' @@ -371,13 +374,13 @@ declare const bulmaJS: BulmaJS (clickEvent.currentTarget as HTMLElement).closest( '.container--feeCategory' ) as HTMLElement - ).dataset.feeCategoryId!, + ).dataset.feeCategoryId ?? '', 10 ) function doDelete(): void { cityssm.postJSON( - los.urlPrefix + '/admin/doDeleteFeeCategory', + `${los.urlPrefix}/admin/doDeleteFeeCategory`, { feeCategoryId }, @@ -385,7 +388,7 @@ declare const bulmaJS: BulmaJS const responseJSON = rawResponseJSON as ResponseJSON if (responseJSON.success) { - feeCategories = responseJSON.feeCategories! + feeCategories = responseJSON.feeCategories renderFeeCategories() } else { bulmaJS.alert({ @@ -412,9 +415,9 @@ declare const bulmaJS: BulmaJS function moveFeeCategory(clickEvent: MouseEvent): void { const buttonElement = clickEvent.currentTarget as HTMLButtonElement - const feeCategoryId = ( - buttonElement.closest('.container--feeCategory') as HTMLElement - ).dataset.feeCategoryId! + const feeCategoryId = + (buttonElement.closest('.container--feeCategory') as HTMLElement).dataset + .feeCategoryId ?? '' cityssm.postJSON( los.urlPrefix + @@ -430,7 +433,7 @@ declare const bulmaJS: BulmaJS const responseJSON = rawResponseJSON as ResponseJSON if (responseJSON.success) { - feeCategories = responseJSON.feeCategories! + feeCategories = responseJSON.feeCategories renderFeeCategories() } else { bulmaJS.alert({ @@ -453,7 +456,7 @@ declare const bulmaJS: BulmaJS (clickEvent.currentTarget as HTMLElement).closest( '.container--feeCategory' ) as HTMLElement - ).dataset.feeCategoryId!, + ).dataset.feeCategoryId ?? '', 10 ) @@ -463,7 +466,7 @@ declare const bulmaJS: BulmaJS submitEvent.preventDefault() cityssm.postJSON( - los.urlPrefix + '/admin/doAddFee', + `${los.urlPrefix}/admin/doAddFee`, submitEvent.currentTarget, (rawResponseJSON) => { const responseJSON = rawResponseJSON as ResponseJSON @@ -492,7 +495,7 @@ declare const bulmaJS: BulmaJS for (const feeCategory of feeCategories) { const optionElement = document.createElement('option') optionElement.value = feeCategory.feeCategoryId.toString() - optionElement.textContent = feeCategory.feeCategory! + optionElement.textContent = feeCategory.feeCategory if (feeCategory.feeCategoryId === feeCategoryId) { optionElement.selected = true @@ -536,7 +539,7 @@ declare const bulmaJS: BulmaJS addCloseModalFunction = closeModalFunction - modalElement.querySelector('form')!.addEventListener('submit', doAddFee) + modalElement.querySelector('form')?.addEventListener('submit', doAddFee) ;( modalElement.querySelector('#feeAdd--feeName') as HTMLInputElement ).focus() @@ -553,13 +556,13 @@ declare const bulmaJS: BulmaJS if (feeFunctionElement.value === '') { feeFunctionElement - .closest('.select')! - .classList.remove('is-success') + .closest('.select') + ?.classList.remove('is-success') feeAmountElement.classList.add('is-success') feeAmountElement.disabled = false } else { - feeFunctionElement.closest('.select')!.classList.add('is-success') + feeFunctionElement.closest('.select')?.classList.add('is-success') feeAmountElement.classList.remove('is-success') feeAmountElement.disabled = true @@ -567,8 +570,8 @@ declare const bulmaJS: BulmaJS }) modalElement - .querySelector('#feeAdd--taxPercentage')! - .addEventListener('keyup', () => { + .querySelector('#feeAdd--taxPercentage') + ?.addEventListener('keyup', () => { const taxAmountElement = modalElement.querySelector( '#feeAdd--taxAmount' ) as HTMLInputElement @@ -591,8 +594,8 @@ declare const bulmaJS: BulmaJS }) modalElement - .querySelector('#feeAdd--includeQuantity')! - .addEventListener('change', () => { + .querySelector('#feeAdd--includeQuantity') + ?.addEventListener('change', () => { ;( modalElement.querySelector( '#feeAdd--quantityUnit' @@ -621,7 +624,7 @@ declare const bulmaJS: BulmaJS const feeId = Number.parseInt(feeContainerElement.dataset.feeId!, 10) const feeCategoryId = Number.parseInt( (feeContainerElement.closest('.container--feeCategory') as HTMLElement) - .dataset.feeCategoryId! + .dataset.feeCategoryId ?? '' ) const feeCategory = feeCategories.find((currentFeeCategory) => { @@ -639,13 +642,13 @@ declare const bulmaJS: BulmaJS submitEvent.preventDefault() cityssm.postJSON( - los.urlPrefix + '/admin/doUpdateFee', + `${los.urlPrefix}/admin/doUpdateFee`, submitEvent.currentTarget, (rawResponseJSON) => { const responseJSON = rawResponseJSON as ResponseJSON if (responseJSON.success) { - feeCategories = responseJSON.feeCategories! + feeCategories = responseJSON.feeCategories editCloseModalFunction() renderFeeCategories() } else { @@ -664,7 +667,7 @@ declare const bulmaJS: BulmaJS function doDelete(): void { cityssm.postJSON( - los.urlPrefix + '/admin/doDeleteFee', + `${los.urlPrefix}/admin/doDeleteFee`, { feeId }, @@ -672,7 +675,7 @@ declare const bulmaJS: BulmaJS const responseJSON = rawResponseJSON as ResponseJSON if (responseJSON.success) { - feeCategories = responseJSON.feeCategories! + feeCategories = responseJSON.feeCategories editCloseModalFunction() renderFeeCategories() } else { @@ -707,12 +710,12 @@ declare const bulmaJS: BulmaJS ) as HTMLSelectElement if (feeFunctionElement.value === '') { - feeFunctionElement.closest('.select')!.classList.remove('is-success') + feeFunctionElement.closest('.select')?.classList.remove('is-success') feeAmountElement.classList.add('is-success') feeAmountElement.disabled = false } else { - feeFunctionElement.closest('.select')!.classList.add('is-success') + feeFunctionElement.closest('.select')?.classList.add('is-success') feeAmountElement.classList.remove('is-success') feeAmountElement.disabled = true @@ -769,7 +772,7 @@ declare const bulmaJS: BulmaJS for (const feeCategory of feeCategories) { const optionElement = document.createElement('option') optionElement.value = feeCategory.feeCategoryId.toString() - optionElement.textContent = feeCategory.feeCategory! + optionElement.textContent = feeCategory.feeCategory if (feeCategory.feeCategoryId === feeCategoryId) { optionElement.selected = true @@ -827,8 +830,8 @@ declare const bulmaJS: BulmaJS ).value = fee.feeAmount ? fee.feeAmount.toFixed(2) : '' modalElement - .querySelector('#feeEdit--feeFunction')! - .addEventListener('change', toggleFeeFields) + .querySelector('#feeEdit--feeFunction') + ?.addEventListener('change', toggleFeeFields) toggleFeeFields() ;( @@ -878,16 +881,16 @@ declare const bulmaJS: BulmaJS editCloseModalFunction = closeModalFunction modalElement - .querySelector('form')! - .addEventListener('submit', doUpdateFee) + .querySelector('form') + ?.addEventListener('submit', doUpdateFee) bulmaJS.init(modalElement) modalElement - .querySelector('.button--deleteFee')! - .addEventListener('click', confirmDeleteFee) + .querySelector('.button--deleteFee') + ?.addEventListener('click', confirmDeleteFee) }, - onremoved: () => { + onremoved() { bulmaJS.toggleHtmlClipped() } }) @@ -900,7 +903,7 @@ declare const bulmaJS: BulmaJS '.container--fee' ) as HTMLElement - const feeId = feeContainerElement.dataset.feeId! + const feeId = feeContainerElement.dataset.feeId ?? '' cityssm.postJSON( los.urlPrefix + @@ -916,7 +919,7 @@ declare const bulmaJS: BulmaJS const responseJSON = rawResponseJSON as ResponseJSON if (responseJSON.success) { - feeCategories = responseJSON.feeCategories! + feeCategories = responseJSON.feeCategories renderFeeCategories() } else { bulmaJS.alert({ diff --git a/public/javascripts/adminDatabase.min.js b/public/javascripts/adminDatabase.min.js index f40e8f47..fe298c9e 100644 --- a/public/javascripts/adminDatabase.min.js +++ b/public/javascripts/adminDatabase.min.js @@ -1 +1 @@ -"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),(()=>{var e,a;const t=exports.los;function s(){cityssm.postJSON(t.urlPrefix+"/admin/doBackupDatabase",{},e=>{var a;const t=e;t.success?bulmaJS.alert({title:"Database Backed Up Successfully",message:`Backed up to ${t.fileName}
\n To request a copy of the backup, contact your application administrator.`,messageIsHtml:!0,contextualColorName:"success"}):bulmaJS.alert({title:"Error Backing Up Database",message:null!==(a=t.errorMessage)&&void 0!==a?a:"",contextualColorName:"danger"})})}function o(){cityssm.postJSON(t.urlPrefix+"/admin/doCleanupDatabase",{},e=>{var a;const t=e;t.success?bulmaJS.alert({title:"Database Cleaned Up Successfully",message:`${t.inactivatedRecordCount} records inactivated,\n ${t.purgedRecordCount} permanently deleted.`,contextualColorName:"success"}):bulmaJS.alert({title:"Error Cleaning Database",message:null!==(a=t.errorMessage)&&void 0!==a?a:"",contextualColorName:"danger"})})}null===(e=document.querySelector("#button--cleanupDatabase"))||void 0===e||e.addEventListener("click",()=>{bulmaJS.confirm({title:"Cleanup Database",message:"Are you sure you want to cleanup up the database?",okButton:{text:"Yes, Cleanup Database",callbackFunction:o}})}),null===(a=document.querySelector("#button--backupDatabase"))||void 0===a||a.addEventListener("click",()=>{bulmaJS.confirm({title:"Backup Database",message:"Are you sure you want to backup up the database?",okButton:{text:"Yes, Backup Database",callbackFunction:s}})})})(); \ No newline at end of file +"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),(()=>{var e,a;const t=exports.los;function s(){cityssm.postJSON(`${t.urlPrefix}/admin/doBackupDatabase`,{},e=>{var a;const t=e;t.success?bulmaJS.alert({title:"Database Backed Up Successfully",message:`Backed up to ${t.fileName}
\n To request a copy of the backup, contact your application administrator.`,messageIsHtml:!0,contextualColorName:"success"}):bulmaJS.alert({title:"Error Backing Up Database",message:null!==(a=t.errorMessage)&&void 0!==a?a:"",contextualColorName:"danger"})})}function o(){cityssm.postJSON(`${t.urlPrefix}/admin/doCleanupDatabase`,{},e=>{var a;const t=e;t.success?bulmaJS.alert({title:"Database Cleaned Up Successfully",message:`${t.inactivatedRecordCount} records inactivated,\n ${t.purgedRecordCount} permanently deleted.`,contextualColorName:"success"}):bulmaJS.alert({title:"Error Cleaning Database",message:null!==(a=t.errorMessage)&&void 0!==a?a:"",contextualColorName:"danger"})})}null===(e=document.querySelector("#button--cleanupDatabase"))||void 0===e||e.addEventListener("click",()=>{bulmaJS.confirm({title:"Cleanup Database",message:"Are you sure you want to cleanup up the database?",okButton:{text:"Yes, Cleanup Database",callbackFunction:o}})}),null===(a=document.querySelector("#button--backupDatabase"))||void 0===a||a.addEventListener("click",()=>{bulmaJS.confirm({title:"Backup Database",message:"Are you sure you want to backup up the database?",okButton:{text:"Yes, Backup Database",callbackFunction:s}})})})(); \ No newline at end of file diff --git a/public/javascripts/adminFees.min.js b/public/javascripts/adminFees.min.js index ac23ebbc..2ac9151c 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,p,m,g,v,C,S,b,F;if(0!==o.length){t.innerHTML="";for(const q of o){const o=document.createElement("section");o.className="panel container--feeCategory",o.dataset.feeCategoryId=q.feeCategoryId.toString(),o.innerHTML='

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

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

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

\n
\n
`),o.querySelector(".button--deleteFeeCategory").addEventListener("click",n));for(const t of q.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!==(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":"$"+(null!==(S=t.feeAmount)&&void 0!==S?S:0).toFixed(2)+"
Fee")+'
'+(t.taxPercentage?t.taxPercentage.toString()+"%":"$"+(null!==(b=t.taxAmount)&&void 0!==b?b:0).toFixed(2))+'
Tax
'+(t.includeQuantity?cityssm.escapeHTML(null!==(F=t.quantityUnit)&&void 0!==F?F:"")+"
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;const a=e;a.success?(o=a.feeCategories,r(),s()):bulmaJS.alert({title:"Error Updating Fee Category",message:null!==(t=a.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;const a=e;a.success?(o=a.feeCategories,s()):bulmaJS.alert({title:"Error Updating Fee Category",message:null!==(t=a.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;const a=e;a.success?(o=a.feeCategories,s()):bulmaJS.alert({title:"Error Moving Fee Category",message:null!==(t=a.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;const a=e;a.success?(o=a.feeCategories,n(),s()):bulmaJS.alert({title:"Error Adding Fee",message:null!==(t=a.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;const a=e;a.success?(o=a.feeCategories,c(),s()):bulmaJS.alert({title:"Error Updating Fee",message:null!==(t=a.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;const a=e;a.success?(o=a.feeCategories,c(),s()):bulmaJS.alert({title:"Error Deleting Fee",message:null!==(t=a.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 s,a,n,c,d,u;i=t,t.querySelector("#feeEdit--feeId").value=l.feeId.toString();const m=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),m.append(t)}t.querySelector("#feeEdit--feeName").value=null!==(s=l.feeName)&&void 0!==s?s:"",t.querySelector("#feeEdit--feeAccount").value=null!==(a=l.feeAccount)&&void 0!==a?a:"",t.querySelector("#feeEdit--feeDescription").value=null!==(n=l.feeDescription)&&void 0!==n?n:"";const g=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),g.append(t)}const v=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),v.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 C=t.querySelector("#feeEdit--taxPercentage");C.value=l.taxPercentage?l.taxPercentage.toString():"",C.addEventListener("keyup",f),f();const S=t.querySelector("#feeEdit--includeQuantity");null!==(c=l.includeQuantity)&&void 0!==c&&c&&(S.value="1"),S.addEventListener("change",p),t.querySelector("#feeEdit--quantityUnit").value=null!==(d=l.quantityUnit)&&void 0!==d?d:"",p(),null!==(u=l.isRequired)&&void 0!==u&&u&&(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;const a=e;a.success?(o=a.feeCategories,s()):bulmaJS.alert({title:"Error Moving Fee",message:null!==(t=a.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;const n=e;n.success?(o=n.feeCategories,t(),s()):bulmaJS.alert({title:"Error Creating Fee Category",message:null!==(a=n.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}),(()=>{var e;const t=exports.los,o=document.querySelector("#container--feeCategories");let s=exports.feeCategories;function n(){var e,n,u,y,f,p,v,m,g,C,S,b,F,q,E,x,T;if(0!==s.length){o.innerHTML="";for(const L of s){const s=document.createElement("section");s.className="panel container--feeCategory",s.dataset.feeCategoryId=L.feeCategoryId.toString(),s.innerHTML=`
\n
\n
\n

${cityssm.escapeHTML(null!==(e=L.feeCategory)&&void 0!==e?e:"")}

\n
\n
\n
\n ${0===L.fees.length?'
\n \n
':""}\n
\n \n
\n
\n \n
\n
\n ${t.getMoveUpDownButtonFieldHTML("button--moveFeeCategoryUp","button--moveFeeCategoryDown")}\n
\n
\n
\n
`,0===L.fees.length&&(s.insertAdjacentHTML("beforeend",`
\n
\n

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

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

'+cityssm.escapeHTML(null!==(f=e.feeName)&&void 0!==f?f:"")+"
"+cityssm.escapeHTML(null!==(p=e.feeDescription)&&void 0!==p?p:"").replaceAll("\n","
")+"

"+(n?'

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

":"")+'
'+(e.feeFunction?cityssm.escapeHTML(e.feeFunction)+"
Fee Function":"$"+(null!==(b=e.feeAmount)&&void 0!==b?b:0).toFixed(2)+"
Fee")+'
'+(e.taxPercentage?e.taxPercentage.toString()+"%":"$"+(null!==(F=e.taxAmount)&&void 0!==F?F:0).toFixed(2))+'
Tax
'+(e.includeQuantity?cityssm.escapeHTML(null!==(q=e.quantityUnit)&&void 0!==q?q:"")+"
Quantity":"")+'
'+t.getMoveUpDownButtonFieldHTML("button--moveFeeUp","button--moveFeeDown")+"
",null===(E=o.querySelector("a"))||void 0===E||E.addEventListener("click",c),o.querySelector(".button--moveFeeUp").addEventListener("click",d),o.querySelector(".button--moveFeeDown").addEventListener("click",d),s.append(o)}null===(x=s.querySelector(".button--editFeeCategory"))||void 0===x||x.addEventListener("click",a),null===(T=s.querySelector(".button--addFee"))||void 0===T||T.addEventListener("click",i),s.querySelector(".button--moveFeeCategoryUp").addEventListener("click",r),s.querySelector(".button--moveFeeCategoryDown").addEventListener("click",r),o.append(s)}}else o.innerHTML='
\n

There are no available fees.

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