609 lines
31 KiB
JavaScript
609 lines
31 KiB
JavaScript
"use strict";
|
|
// 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, _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>
|
|
</div>`;
|
|
return;
|
|
}
|
|
feeCategoriesContainerElement.innerHTML = '';
|
|
for (const feeCategory of feeCategories) {
|
|
const feeCategoryContainerElement = document.createElement('section');
|
|
feeCategoryContainerElement.className = 'panel container--feeCategory';
|
|
feeCategoryContainerElement.dataset.feeCategoryId =
|
|
feeCategory.feeCategoryId.toString();
|
|
// 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">
|
|
<p class="message-body">
|
|
There are no fees in the
|
|
"${cityssm.escapeHTML((_b = feeCategory.feeCategory) !== null && _b !== void 0 ? _b : '')}"
|
|
category.
|
|
</p>
|
|
</div>
|
|
</div>`);
|
|
(_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 = ((_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((_e = fee.feeName) !== null && _e !== void 0 ? _e : '')}</a><br />
|
|
<small>
|
|
${cityssm
|
|
.escapeHTML((_f = fee.feeDescription) !== null && _f !== void 0 ? _f : '')
|
|
.replaceAll('\n', '<br />')}
|
|
</small>
|
|
</p>
|
|
${hasTagsBlock
|
|
? `<p class="tags">
|
|
${((_g = fee.isRequired) !== null && _g !== void 0 ? _g : false)
|
|
? '<span class="tag is-warning">Required</span>'
|
|
: ''}
|
|
${((_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((_j = fee.occupancyType) !== null && _j !== void 0 ? _j : '')}</span>
|
|
</span>`}
|
|
${((_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((_l = fee.lotType) !== null && _l !== void 0 ? _l : '')}</span>
|
|
</span>`}
|
|
</p>`
|
|
: ''}
|
|
</div>
|
|
<div class="column">
|
|
<div class="columns is-mobile">
|
|
<div class="column has-text-centered">
|
|
${fee.feeFunction
|
|
? `${cityssm.escapeHTML(fee.feeFunction)}<br />
|
|
<small>Fee Function</small>`
|
|
: `$${((_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()}%`
|
|
: `$${((_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((_p = fee.quantityUnit) !== null && _p !== void 0 ? _p : '')}<br />
|
|
<small>Quantity</small>`
|
|
: ''}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="column is-narrow">
|
|
${los.getMoveUpDownButtonFieldHTML('button--moveFeeUp', 'button--moveFeeDown')}
|
|
</div>
|
|
</div>`;
|
|
(_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);
|
|
}
|
|
(_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);
|
|
}
|
|
}
|
|
/*
|
|
* Fee Categories
|
|
*/
|
|
(_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) => {
|
|
var _a;
|
|
const responseJSON = rawResponseJSON;
|
|
if (responseJSON.success) {
|
|
feeCategories = responseJSON.feeCategories;
|
|
addCloseModalFunction();
|
|
renderFeeCategories();
|
|
}
|
|
else {
|
|
bulmaJS.alert({
|
|
title: 'Error Creating Fee Category',
|
|
message: (_a = responseJSON.errorMessage) !== null && _a !== void 0 ? _a : '',
|
|
contextualColorName: 'danger'
|
|
});
|
|
}
|
|
});
|
|
}
|
|
cityssm.openHtmlModal('adminFees-addFeeCategory', {
|
|
onshown(modalElement, closeModalFunction) {
|
|
var _a;
|
|
bulmaJS.toggleHtmlClipped();
|
|
modalElement.querySelector('#feeCategoryAdd--feeCategory').focus();
|
|
addCloseModalFunction = closeModalFunction;
|
|
(_a = modalElement
|
|
.querySelector('form')) === null || _a === void 0 ? void 0 : _a.addEventListener('submit', doAddFeeCategory);
|
|
},
|
|
onremoved() {
|
|
bulmaJS.toggleHtmlClipped();
|
|
document.querySelector('#button--addFeeCategory').focus();
|
|
}
|
|
});
|
|
});
|
|
function openEditFeeCategory(clickEvent) {
|
|
var _a;
|
|
const feeCategoryId = Number.parseInt((_a = clickEvent.currentTarget.closest('.container--feeCategory').dataset.feeCategoryId) !== null && _a !== void 0 ? _a : '', 10);
|
|
const feeCategory = feeCategories.find((currentFeeCategory) => {
|
|
return currentFeeCategory.feeCategoryId === feeCategoryId;
|
|
});
|
|
let editCloseModalFunction;
|
|
function doUpdateFeeCategory(submitEvent) {
|
|
submitEvent.preventDefault();
|
|
cityssm.postJSON(`${los.urlPrefix}/admin/doUpdateFeeCategory`, submitEvent.currentTarget, (rawResponseJSON) => {
|
|
var _a;
|
|
const responseJSON = rawResponseJSON;
|
|
if (responseJSON.success) {
|
|
feeCategories = responseJSON.feeCategories;
|
|
editCloseModalFunction();
|
|
renderFeeCategories();
|
|
}
|
|
else {
|
|
bulmaJS.alert({
|
|
title: 'Error Updating Fee Category',
|
|
message: (_a = responseJSON.errorMessage) !== null && _a !== void 0 ? _a : '',
|
|
contextualColorName: 'danger'
|
|
});
|
|
}
|
|
});
|
|
}
|
|
cityssm.openHtmlModal('adminFees-editFeeCategory', {
|
|
onshow(modalElement) {
|
|
;
|
|
modalElement.querySelector('#feeCategoryEdit--feeCategoryId').value = feeCategory.feeCategoryId.toString();
|
|
modalElement.querySelector('#feeCategoryEdit--feeCategory').value = feeCategory.feeCategory;
|
|
},
|
|
onshown(modalElement, closeModalFunction) {
|
|
var _a;
|
|
bulmaJS.toggleHtmlClipped();
|
|
editCloseModalFunction = closeModalFunction;
|
|
(_a = modalElement
|
|
.querySelector('form')) === null || _a === void 0 ? void 0 : _a.addEventListener('submit', doUpdateFeeCategory);
|
|
modalElement.querySelector('#feeCategoryEdit--feeCategory').focus();
|
|
},
|
|
onremoved: () => {
|
|
bulmaJS.toggleHtmlClipped();
|
|
}
|
|
});
|
|
}
|
|
function confirmDeleteFeeCategory(clickEvent) {
|
|
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`, {
|
|
feeCategoryId
|
|
}, (rawResponseJSON) => {
|
|
var _a;
|
|
const responseJSON = rawResponseJSON;
|
|
if (responseJSON.success) {
|
|
feeCategories = responseJSON.feeCategories;
|
|
renderFeeCategories();
|
|
}
|
|
else {
|
|
bulmaJS.alert({
|
|
title: 'Error Updating Fee Category',
|
|
message: (_a = responseJSON.errorMessage) !== null && _a !== void 0 ? _a : '',
|
|
contextualColorName: 'danger'
|
|
});
|
|
}
|
|
});
|
|
}
|
|
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: doDelete
|
|
}
|
|
});
|
|
}
|
|
function moveFeeCategory(clickEvent) {
|
|
var _a;
|
|
const buttonElement = clickEvent.currentTarget;
|
|
const feeCategoryId = (_a = buttonElement.closest('.container--feeCategory').dataset
|
|
.feeCategoryId) !== null && _a !== void 0 ? _a : '';
|
|
cityssm.postJSON(`${los.urlPrefix}/admin/${buttonElement.dataset.direction === 'up'
|
|
? 'doMoveFeeCategoryUp'
|
|
: 'doMoveFeeCategoryDown'}`, {
|
|
feeCategoryId,
|
|
moveToEnd: clickEvent.shiftKey ? '1' : '0'
|
|
}, (rawResponseJSON) => {
|
|
var _a;
|
|
const responseJSON = rawResponseJSON;
|
|
if (responseJSON.success) {
|
|
feeCategories = responseJSON.feeCategories;
|
|
renderFeeCategories();
|
|
}
|
|
else {
|
|
bulmaJS.alert({
|
|
title: 'Error Moving Fee Category',
|
|
message: (_a = responseJSON.errorMessage) !== null && _a !== void 0 ? _a : '',
|
|
contextualColorName: 'danger'
|
|
});
|
|
}
|
|
});
|
|
}
|
|
/*
|
|
* Fees
|
|
*/
|
|
function openAddFee(clickEvent) {
|
|
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) => {
|
|
var _a;
|
|
const responseJSON = rawResponseJSON;
|
|
if (responseJSON.success) {
|
|
feeCategories = responseJSON.feeCategories;
|
|
addCloseModalFunction();
|
|
renderFeeCategories();
|
|
}
|
|
else {
|
|
bulmaJS.alert({
|
|
title: 'Error Adding Fee',
|
|
message: (_a = responseJSON.errorMessage) !== null && _a !== void 0 ? _a : '',
|
|
contextualColorName: 'danger'
|
|
});
|
|
}
|
|
});
|
|
}
|
|
cityssm.openHtmlModal('adminFees-addFee', {
|
|
onshow(modalElement) {
|
|
const feeCategoryElement = modalElement.querySelector('#feeAdd--feeCategoryId');
|
|
for (const feeCategory of feeCategories) {
|
|
const optionElement = document.createElement('option');
|
|
optionElement.value = feeCategory.feeCategoryId.toString();
|
|
optionElement.textContent = feeCategory.feeCategory;
|
|
if (feeCategory.feeCategoryId === feeCategoryId) {
|
|
optionElement.selected = true;
|
|
}
|
|
feeCategoryElement.append(optionElement);
|
|
}
|
|
const occupancyTypeElement = modalElement.querySelector('#feeAdd--occupancyTypeId');
|
|
for (const occupancyType of exports.occupancyTypes) {
|
|
const optionElement = document.createElement('option');
|
|
optionElement.value = occupancyType.occupancyTypeId.toString();
|
|
optionElement.textContent = occupancyType.occupancyType;
|
|
occupancyTypeElement.append(optionElement);
|
|
}
|
|
const lotTypeElement = modalElement.querySelector('#feeAdd--lotTypeId');
|
|
for (const lotType of exports.lotTypes) {
|
|
const optionElement = document.createElement('option');
|
|
optionElement.value = lotType.lotTypeId.toString();
|
|
optionElement.textContent = lotType.lotType;
|
|
lotTypeElement.append(optionElement);
|
|
}
|
|
;
|
|
modalElement.querySelector('#feeAdd--taxPercentage').value = exports.taxPercentageDefault.toString();
|
|
los.populateAliases(modalElement);
|
|
},
|
|
onshown(modalElement, closeModalFunction) {
|
|
var _a, _b, _c;
|
|
bulmaJS.toggleHtmlClipped();
|
|
addCloseModalFunction = closeModalFunction;
|
|
(_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 === '') {
|
|
(_a = feeFunctionElement
|
|
.closest('.select')) === null || _a === void 0 ? void 0 : _a.classList.remove('is-success');
|
|
feeAmountElement.classList.add('is-success');
|
|
feeAmountElement.disabled = false;
|
|
}
|
|
else {
|
|
(_b = feeFunctionElement.closest('.select')) === null || _b === void 0 ? void 0 : _b.classList.add('is-success');
|
|
feeAmountElement.classList.remove('is-success');
|
|
feeAmountElement.disabled = true;
|
|
}
|
|
});
|
|
(_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 === '') {
|
|
taxPercentageElement.classList.remove('is-success');
|
|
taxAmountElement.classList.add('is-success');
|
|
taxAmountElement.disabled = false;
|
|
}
|
|
else {
|
|
taxPercentageElement.classList.add('is-success');
|
|
taxAmountElement.classList.remove('is-success');
|
|
taxAmountElement.disabled = true;
|
|
}
|
|
});
|
|
(_c = modalElement
|
|
.querySelector('#feeAdd--includeQuantity')) === null || _c === void 0 ? void 0 : _c.addEventListener('change', () => {
|
|
;
|
|
modalElement.querySelector('#feeAdd--quantityUnit').disabled =
|
|
modalElement.querySelector('#feeAdd--includeQuantity').value === '';
|
|
});
|
|
},
|
|
onremoved() {
|
|
bulmaJS.toggleHtmlClipped();
|
|
}
|
|
});
|
|
}
|
|
function openEditFee(clickEvent) {
|
|
var _a, _b;
|
|
clickEvent.preventDefault();
|
|
const feeContainerElement = clickEvent.currentTarget.closest('.container--fee');
|
|
const feeId = Number.parseInt((_a = feeContainerElement.dataset.feeId) !== null && _a !== void 0 ? _a : '', 10);
|
|
const feeCategoryId = Number.parseInt((_b = feeContainerElement.closest('.container--feeCategory')
|
|
.dataset.feeCategoryId) !== null && _b !== void 0 ? _b : '');
|
|
const feeCategory = feeCategories.find((currentFeeCategory) => {
|
|
return currentFeeCategory.feeCategoryId === feeCategoryId;
|
|
});
|
|
const fee = feeCategory.fees.find((currentFee) => {
|
|
return currentFee.feeId === feeId;
|
|
});
|
|
let editCloseModalFunction;
|
|
let editModalElement;
|
|
function doUpdateFee(submitEvent) {
|
|
submitEvent.preventDefault();
|
|
cityssm.postJSON(`${los.urlPrefix}/admin/doUpdateFee`, submitEvent.currentTarget, (rawResponseJSON) => {
|
|
var _a;
|
|
const responseJSON = rawResponseJSON;
|
|
if (responseJSON.success) {
|
|
feeCategories = responseJSON.feeCategories;
|
|
editCloseModalFunction();
|
|
renderFeeCategories();
|
|
}
|
|
else {
|
|
bulmaJS.alert({
|
|
title: 'Error Updating Fee',
|
|
message: (_a = responseJSON.errorMessage) !== null && _a !== void 0 ? _a : '',
|
|
contextualColorName: 'danger'
|
|
});
|
|
}
|
|
});
|
|
}
|
|
function confirmDeleteFee(clickEvent) {
|
|
clickEvent.preventDefault();
|
|
function doDelete() {
|
|
cityssm.postJSON(`${los.urlPrefix}/admin/doDeleteFee`, {
|
|
feeId
|
|
}, (rawResponseJSON) => {
|
|
var _a;
|
|
const responseJSON = rawResponseJSON;
|
|
if (responseJSON.success) {
|
|
feeCategories = responseJSON.feeCategories;
|
|
editCloseModalFunction();
|
|
renderFeeCategories();
|
|
}
|
|
else {
|
|
bulmaJS.alert({
|
|
title: 'Error Deleting Fee',
|
|
message: (_a = responseJSON.errorMessage) !== null && _a !== void 0 ? _a : '',
|
|
contextualColorName: 'danger'
|
|
});
|
|
}
|
|
});
|
|
}
|
|
bulmaJS.confirm({
|
|
title: 'Delete Fee?',
|
|
message: 'Are you sure you want to delete this fee?',
|
|
contextualColorName: 'warning',
|
|
okButton: {
|
|
text: 'Yes, Delete the Fee',
|
|
callbackFunction: doDelete
|
|
}
|
|
});
|
|
}
|
|
function toggleFeeFields() {
|
|
var _a, _b;
|
|
const feeAmountElement = editModalElement.querySelector('#feeEdit--feeAmount');
|
|
const feeFunctionElement = editModalElement.querySelector('#feeEdit--feeFunction');
|
|
if (feeFunctionElement.value === '') {
|
|
(_a = feeFunctionElement.closest('.select')) === null || _a === void 0 ? void 0 : _a.classList.remove('is-success');
|
|
feeAmountElement.classList.add('is-success');
|
|
feeAmountElement.disabled = false;
|
|
}
|
|
else {
|
|
(_b = feeFunctionElement.closest('.select')) === null || _b === void 0 ? void 0 : _b.classList.add('is-success');
|
|
feeAmountElement.classList.remove('is-success');
|
|
feeAmountElement.disabled = true;
|
|
}
|
|
}
|
|
function toggleTaxFields() {
|
|
const taxAmountElement = editModalElement.querySelector('#feeEdit--taxAmount');
|
|
const taxPercentageElement = editModalElement.querySelector('#feeEdit--taxPercentage');
|
|
if (taxPercentageElement.value === '') {
|
|
taxPercentageElement.classList.remove('is-success');
|
|
taxAmountElement.classList.add('is-success');
|
|
taxAmountElement.disabled = false;
|
|
}
|
|
else {
|
|
taxPercentageElement.classList.add('is-success');
|
|
taxAmountElement.classList.remove('is-success');
|
|
taxAmountElement.disabled = true;
|
|
}
|
|
}
|
|
function toggleQuantityFields() {
|
|
const includeQuanitityValue = editModalElement.querySelector('#feeEdit--includeQuantity').value;
|
|
editModalElement.querySelector('#feeEdit--quantityUnit').disabled = includeQuanitityValue === '';
|
|
}
|
|
cityssm.openHtmlModal('adminFees-editFee', {
|
|
onshow(modalElement) {
|
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
editModalElement = modalElement;
|
|
modalElement.querySelector('#feeEdit--feeId').value = fee.feeId.toString();
|
|
const feeCategoryElement = modalElement.querySelector('#feeEdit--feeCategoryId');
|
|
for (const feeCategory of feeCategories) {
|
|
const optionElement = document.createElement('option');
|
|
optionElement.value = feeCategory.feeCategoryId.toString();
|
|
optionElement.textContent = feeCategory.feeCategory;
|
|
if (feeCategory.feeCategoryId === feeCategoryId) {
|
|
optionElement.selected = true;
|
|
}
|
|
feeCategoryElement.append(optionElement);
|
|
}
|
|
;
|
|
modalElement.querySelector('#feeEdit--feeName').value = (_a = fee.feeName) !== null && _a !== void 0 ? _a : '';
|
|
modalElement.querySelector('#feeEdit--feeAccount').value = (_b = fee.feeAccount) !== null && _b !== void 0 ? _b : '';
|
|
modalElement.querySelector('#feeEdit--feeDescription').value = (_c = fee.feeDescription) !== null && _c !== void 0 ? _c : '';
|
|
const occupancyTypeElement = modalElement.querySelector('#feeEdit--occupancyTypeId');
|
|
for (const occupancyType of exports.occupancyTypes) {
|
|
const optionElement = document.createElement('option');
|
|
optionElement.value = occupancyType.occupancyTypeId.toString();
|
|
optionElement.textContent = occupancyType.occupancyType;
|
|
if (occupancyType.occupancyTypeId === fee.occupancyTypeId) {
|
|
optionElement.selected = true;
|
|
}
|
|
occupancyTypeElement.append(optionElement);
|
|
}
|
|
const lotTypeElement = modalElement.querySelector('#feeEdit--lotTypeId');
|
|
for (const lotType of exports.lotTypes) {
|
|
const optionElement = document.createElement('option');
|
|
optionElement.value = lotType.lotTypeId.toString();
|
|
optionElement.textContent = lotType.lotType;
|
|
if (lotType.lotTypeId === fee.lotTypeId) {
|
|
optionElement.selected = true;
|
|
}
|
|
lotTypeElement.append(optionElement);
|
|
}
|
|
;
|
|
modalElement.querySelector('#feeEdit--feeAmount').value = fee.feeAmount ? fee.feeAmount.toFixed(2) : '';
|
|
(_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');
|
|
taxPercentageElement.value = fee.taxPercentage
|
|
? fee.taxPercentage.toString()
|
|
: '';
|
|
taxPercentageElement.addEventListener('keyup', toggleTaxFields);
|
|
toggleTaxFields();
|
|
const includeQuantityElement = modalElement.querySelector('#feeEdit--includeQuantity');
|
|
if ((_e = fee.includeQuantity) !== null && _e !== void 0 ? _e : false) {
|
|
includeQuantityElement.value = '1';
|
|
}
|
|
includeQuantityElement.addEventListener('change', toggleQuantityFields);
|
|
modalElement.querySelector('#feeEdit--quantityUnit').value = (_f = fee.quantityUnit) !== null && _f !== void 0 ? _f : '';
|
|
toggleQuantityFields();
|
|
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;
|
|
(_a = modalElement
|
|
.querySelector('form')) === null || _a === void 0 ? void 0 : _a.addEventListener('submit', doUpdateFee);
|
|
bulmaJS.init(modalElement);
|
|
(_b = modalElement
|
|
.querySelector('.button--deleteFee')) === null || _b === void 0 ? void 0 : _b.addEventListener('click', confirmDeleteFee);
|
|
},
|
|
onremoved() {
|
|
bulmaJS.toggleHtmlClipped();
|
|
}
|
|
});
|
|
}
|
|
function moveFee(clickEvent) {
|
|
var _a;
|
|
const buttonElement = clickEvent.currentTarget;
|
|
const feeContainerElement = buttonElement.closest('.container--fee');
|
|
const feeId = (_a = feeContainerElement.dataset.feeId) !== null && _a !== void 0 ? _a : '';
|
|
cityssm.postJSON(`${los.urlPrefix}/admin/${buttonElement.dataset.direction === 'up'
|
|
? 'doMoveFeeUp'
|
|
: 'doMoveFeeDown'}`, {
|
|
feeId,
|
|
moveToEnd: clickEvent.shiftKey ? '1' : '0'
|
|
}, (rawResponseJSON) => {
|
|
var _a;
|
|
const responseJSON = rawResponseJSON;
|
|
if (responseJSON.success) {
|
|
feeCategories = responseJSON.feeCategories;
|
|
renderFeeCategories();
|
|
}
|
|
else {
|
|
bulmaJS.alert({
|
|
title: 'Error Moving Fee',
|
|
message: (_a = responseJSON.errorMessage) !== null && _a !== void 0 ? _a : '',
|
|
contextualColorName: 'danger'
|
|
});
|
|
}
|
|
});
|
|
}
|
|
/*
|
|
* Initialize
|
|
*/
|
|
renderFeeCategories();
|
|
})();
|