code cleanup

deepsource-autofix-76c6eb20
Dan Gowans 2024-06-25 11:36:42 -04:00
parent d8e833a954
commit f2bbcf0890
6 changed files with 223 additions and 219 deletions

View File

@ -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) {

View File

@ -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<string, unknown>
;(() => {
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

View File

@ -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 = `<div class="message is-warning">
<p class="message-body">There are no available fees.</p>
@ -20,42 +22,40 @@ Object.defineProperty(exports, "__esModule", { value: true });
feeCategoryContainerElement.className = 'panel container--feeCategory';
feeCategoryContainerElement.dataset.feeCategoryId =
feeCategory.feeCategoryId.toString();
feeCategoryContainerElement.innerHTML =
'<div class="panel-heading">' +
'<div class="columns">' +
('<div class="column">' +
'<h2 class="title is-4">' +
cityssm.escapeHTML((_a = feeCategory.feeCategory) !== null && _a !== void 0 ? _a : '') +
'</h2>' +
'</div>') +
('<div class="column is-narrow">' +
'<div class="field is-grouped is-justify-content-end">' +
(feeCategory.fees.length === 0
? '<div class="control">' +
'<button class="button is-small is-danger button--deleteFeeCategory" type="button">' +
'<span class="icon is-small"><i class="fas fa-trash" aria-hidden="true"></i></span>' +
'<span>Delete Category</span>' +
'</button>' +
'</div>'
: '') +
('<div class="control">' +
'<button class="button is-small is-primary button--editFeeCategory" type="button">' +
'<span class="icon is-small"><i class="fas fa-pencil-alt" aria-hidden="true"></i></span>' +
'<span>Edit Category</span>' +
'</button>' +
'</div>') +
('<div class="control">' +
'<button class="button is-small is-success button--addFee" data-cy="addFee" type="button">' +
'<span class="icon is-small"><i class="fas fa-plus" aria-hidden="true"></i></span>' +
'<span>Add Fee</span>' +
'</button>' +
'</div>') +
('<div class="control">' +
los.getMoveUpDownButtonFieldHTML('button--moveFeeCategoryUp', 'button--moveFeeCategoryDown') +
'</div>') +
'</div>') +
'</div>' +
'</div>';
// eslint-disable-next-line no-unsanitized/property
feeCategoryContainerElement.innerHTML = `<div class="panel-heading">
<div class="columns">
<div class="column">
<h2 class="title is-4">${cityssm.escapeHTML((_a = feeCategory.feeCategory) !== null && _a !== void 0 ? _a : '')}</h2>
</div>
<div class="column is-narrow">
<div class="field is-grouped is-justify-content-end">
${feeCategory.fees.length === 0
? `<div class="control">
<button class="button is-small is-danger button--deleteFeeCategory" type="button">
<span class="icon is-small"><i class="fas fa-trash" aria-hidden="true"></i></span>
<span>Delete Category</span>
</button>
</div>`
: ''}
<div class="control">
<button class="button is-small is-primary button--editFeeCategory" type="button">
<span class="icon is-small"><i class="fas fa-pencil-alt" aria-hidden="true"></i></span>
<span>Edit Category</span>
</button>
</div>
<div class="control">
<button class="button is-small is-success button--addFee" data-cy="addFee" type="button">
<span class="icon is-small"><i class="fas fa-plus" aria-hidden="true"></i></span>
<span>Add Fee</span>
</button>
</div>
<div class="control">
${los.getMoveUpDownButtonFieldHTML('button--moveFeeCategoryUp', 'button--moveFeeCategoryDown')}
</div>
</div>
</div>
</div>`;
if (feeCategory.fees.length === 0) {
feeCategoryContainerElement.insertAdjacentHTML('beforeend', `<div class="panel-block is-block">
<div class="message is-info">
@ -66,53 +66,53 @@ Object.defineProperty(exports, "__esModule", { value: true });
</p>
</div>
</div>`);
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 =
'<div class="columns">' +
('<div class="column is-half">' +
'<p>' +
'<a class="has-text-weight-bold" href="#">' +
cityssm.escapeHTML((_d = fee.feeName) !== null && _d !== void 0 ? _d : '') +
cityssm.escapeHTML((_e = fee.feeName) !== null && _e !== void 0 ? _e : '') +
'</a><br />' +
'<small>' +
cityssm
.escapeHTML((_e = fee.feeDescription) !== null && _e !== void 0 ? _e : '')
.replace(/\n/g, '<br />') +
.escapeHTML((_f = fee.feeDescription) !== null && _f !== void 0 ? _f : '')
.replaceAll('\n', '<br />') +
'</small>' +
'</p>' +
(hasTagsBlock
? '<p class="tags">' +
(((_f = fee.isRequired) !== null && _f !== void 0 ? _f : false)
(((_g = fee.isRequired) !== null && _g !== void 0 ? _g : false)
? '<span class="tag is-warning">Required</span>'
: '') +
(((_g = fee.occupancyTypeId) !== null && _g !== void 0 ? _g : -1) === -1
(((_h = fee.occupancyTypeId) !== null && _h !== void 0 ? _h : -1) === -1
? ''
: ' <span class="tag has-tooltip-bottom" data-tooltip="' +
los.escapedAliases.Occupancy +
' Type Filter">' +
'<span class="icon is-small"><i class="fas fa-filter" aria-hidden="true"></i></span> ' +
'<span>' +
cityssm.escapeHTML((_h = fee.occupancyType) !== null && _h !== void 0 ? _h : '') +
cityssm.escapeHTML((_j = fee.occupancyType) !== null && _j !== void 0 ? _j : '') +
'</span>' +
'</span>') +
(((_j = fee.lotTypeId) !== null && _j !== void 0 ? _j : -1) === -1
(((_k = fee.lotTypeId) !== null && _k !== void 0 ? _k : -1) === -1
? ''
: ' <span class="tag has-tooltip-bottom" data-tooltip="' +
los.escapedAliases.Lot +
' Type Filter">' +
'<span class="icon is-small"><i class="fas fa-filter" aria-hidden="true"></i></span> ' +
'<span>' +
cityssm.escapeHTML((_k = fee.lotType) !== null && _k !== void 0 ? _k : '') +
cityssm.escapeHTML((_l = fee.lotType) !== null && _l !== void 0 ? _l : '') +
'</span>' +
'</span>') +
'</p>'
@ -126,19 +126,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
'<br />' +
'<small>Fee Function</small>'
: '$' +
((_l = fee.feeAmount) !== null && _l !== void 0 ? _l : 0).toFixed(2) +
((_m = fee.feeAmount) !== null && _m !== void 0 ? _m : 0).toFixed(2) +
'<br />' +
'<small>Fee</small>') +
'</div>') +
('<div class="column has-text-centered">' +
(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)) +
'<br /><small>Tax</small>' +
'</div>') +
('<div class="column has-text-centered">' +
(fee.includeQuantity
? cityssm.escapeHTML((_o = fee.quantityUnit) !== null && _o !== void 0 ? _o : '') +
? cityssm.escapeHTML((_p = fee.quantityUnit) !== null && _p !== void 0 ? _p : '') +
'<br />' +
'<small>Quantity</small>'
: '') +
@ -150,19 +150,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
'</div>' +
'</div>') +
'</div>';
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'

View File

@ -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<string, unknown>
;(() => {
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 =
'<div class="panel-heading">' +
'<div class="columns">' +
('<div class="column">' +
'<h2 class="title is-4">' +
cityssm.escapeHTML(feeCategory.feeCategory ?? '') +
'</h2>' +
'</div>') +
('<div class="column is-narrow">' +
'<div class="field is-grouped is-justify-content-end">' +
(feeCategory.fees.length === 0
? '<div class="control">' +
'<button class="button is-small is-danger button--deleteFeeCategory" type="button">' +
'<span class="icon is-small"><i class="fas fa-trash" aria-hidden="true"></i></span>' +
'<span>Delete Category</span>' +
'</button>' +
'</div>'
: '') +
('<div class="control">' +
'<button class="button is-small is-primary button--editFeeCategory" type="button">' +
'<span class="icon is-small"><i class="fas fa-pencil-alt" aria-hidden="true"></i></span>' +
'<span>Edit Category</span>' +
'</button>' +
'</div>') +
('<div class="control">' +
'<button class="button is-small is-success button--addFee" data-cy="addFee" type="button">' +
'<span class="icon is-small"><i class="fas fa-plus" aria-hidden="true"></i></span>' +
'<span>Add Fee</span>' +
'</button>' +
'</div>') +
('<div class="control">' +
los.getMoveUpDownButtonFieldHTML(
'button--moveFeeCategoryUp',
'button--moveFeeCategoryDown'
) +
'</div>') +
'</div>') +
'</div>' +
'</div>'
// eslint-disable-next-line no-unsanitized/property
feeCategoryContainerElement.innerHTML = `<div class="panel-heading">
<div class="columns">
<div class="column">
<h2 class="title is-4">${cityssm.escapeHTML(feeCategory.feeCategory ?? '')}</h2>
</div>
<div class="column is-narrow">
<div class="field is-grouped is-justify-content-end">
${
feeCategory.fees.length === 0
? `<div class="control">
<button class="button is-small is-danger button--deleteFeeCategory" type="button">
<span class="icon is-small"><i class="fas fa-trash" aria-hidden="true"></i></span>
<span>Delete Category</span>
</button>
</div>`
: ''
}
<div class="control">
<button class="button is-small is-primary button--editFeeCategory" type="button">
<span class="icon is-small"><i class="fas fa-pencil-alt" aria-hidden="true"></i></span>
<span>Edit Category</span>
</button>
</div>
<div class="control">
<button class="button is-small is-success button--addFee" data-cy="addFee" type="button">
<span class="icon is-small"><i class="fas fa-plus" aria-hidden="true"></i></span>
<span>Add Fee</span>
</button>
</div>
<div class="control">
${los.getMoveUpDownButtonFieldHTML(
'button--moveFeeCategoryUp',
'button--moveFeeCategoryDown'
)}
</div>
</div>
</div>
</div>`
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 =
'<div class="columns">' +
('<div class="column is-half">' +
@ -128,7 +131,7 @@ declare const bulmaJS: BulmaJS
'<small>' +
cityssm
.escapeHTML(fee.feeDescription ?? '')
.replace(/\n/g, '<br />') +
.replaceAll('\n', '<br />') +
'</small>' +
'</p>' +
(hasTagsBlock
@ -196,8 +199,8 @@ declare const bulmaJS: BulmaJS
'</div>'
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({

View File

@ -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 <strong>${t.fileName}</strong><br />\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}})})})();
"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 <strong>${t.fileName}</strong><br />\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}})})})();

File diff suppressed because one or more lines are too long