code cleanup

deepsource-autofix-76c6eb20
Dan Gowans 2024-06-25 10:35:15 -04:00
parent 2247857716
commit d55d76ba03
4 changed files with 202 additions and 203 deletions

View File

@ -896,14 +896,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
if (!isCreate) { if (!isCreate) {
"use strict"; "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 */
var _a; var _a;
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
let lotOccupancyComments = exports.lotOccupancyComments; let lotOccupancyComments = exports.lotOccupancyComments;
delete exports.lotOccupancyComments; delete exports.lotOccupancyComments;
function openEditLotOccupancyComment(clickEvent) { function openEditLotOccupancyComment(clickEvent) {
const lotOccupancyCommentId = Number.parseInt(clickEvent.currentTarget.closest('tr').dataset var _a, _b;
.lotOccupancyCommentId, 10); const lotOccupancyCommentId = Number.parseInt((_b = (_a = clickEvent.currentTarget.closest('tr')) === null || _a === void 0 ? void 0 : _a.dataset.lotOccupancyCommentId) !== null && _b !== void 0 ? _b : '', 10);
const lotOccupancyComment = lotOccupancyComments.find((currentLotOccupancyComment) => { const lotOccupancyComment = lotOccupancyComments.find((currentLotOccupancyComment) => {
return (currentLotOccupancyComment.lotOccupancyCommentId === return (currentLotOccupancyComment.lotOccupancyCommentId ===
lotOccupancyCommentId); lotOccupancyCommentId);
@ -912,17 +913,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
let editCloseModalFunction; let editCloseModalFunction;
function editComment(submitEvent) { function editComment(submitEvent) {
submitEvent.preventDefault(); submitEvent.preventDefault();
cityssm.postJSON(los.urlPrefix + '/lotOccupancies/doUpdateLotOccupancyComment', editFormElement, (responseJSON) => { cityssm.postJSON(`${los.urlPrefix}/lotOccupancies/doUpdateLotOccupancyComment`, editFormElement, (rawResponseJSON) => {
var _a; var _a, _b;
const responseJSON = rawResponseJSON;
if (responseJSON.success) { if (responseJSON.success) {
lotOccupancyComments = responseJSON.lotOccupancyComments; lotOccupancyComments = (_a = responseJSON.lotOccupancyComments) !== null && _a !== void 0 ? _a : [];
editCloseModalFunction(); editCloseModalFunction();
renderLotOccupancyComments(); renderLotOccupancyComments();
} }
else { else {
bulmaJS.alert({ bulmaJS.alert({
title: 'Error Updating Comment', title: 'Error Updating Comment',
message: (_a = responseJSON.errorMessage) !== null && _a !== void 0 ? _a : '', message: (_b = responseJSON.errorMessage) !== null && _b !== void 0 ? _b : '',
contextualColorName: 'danger' contextualColorName: 'danger'
}); });
} }
@ -930,19 +932,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
} }
cityssm.openHtmlModal('lotOccupancy-editComment', { cityssm.openHtmlModal('lotOccupancy-editComment', {
onshow(modalElement) { onshow(modalElement) {
var _a, _b, _c, _d;
los.populateAliases(modalElement); los.populateAliases(modalElement);
modalElement.querySelector('#lotOccupancyCommentEdit--lotOccupancyId').value = lotOccupancyId; modalElement.querySelector('#lotOccupancyCommentEdit--lotOccupancyId').value = lotOccupancyId;
modalElement.querySelector('#lotOccupancyCommentEdit--lotOccupancyCommentId').value = lotOccupancyCommentId.toString(); modalElement.querySelector('#lotOccupancyCommentEdit--lotOccupancyCommentId').value = lotOccupancyCommentId.toString();
modalElement.querySelector('#lotOccupancyCommentEdit--lotOccupancyComment').value = lotOccupancyComment.lotOccupancyComment; modalElement.querySelector('#lotOccupancyCommentEdit--lotOccupancyComment').value = (_a = lotOccupancyComment.lotOccupancyComment) !== null && _a !== void 0 ? _a : '';
const lotOccupancyCommentDateStringElement = modalElement.querySelector('#lotOccupancyCommentEdit--lotOccupancyCommentDateString'); const lotOccupancyCommentDateStringElement = modalElement.querySelector('#lotOccupancyCommentEdit--lotOccupancyCommentDateString');
lotOccupancyCommentDateStringElement.value = lotOccupancyCommentDateStringElement.value =
lotOccupancyComment.lotOccupancyCommentDateString; (_b = lotOccupancyComment.lotOccupancyCommentDateString) !== null && _b !== void 0 ? _b : '';
const currentDateString = cityssm.dateToString(new Date()); const currentDateString = cityssm.dateToString(new Date());
lotOccupancyCommentDateStringElement.max = lotOccupancyCommentDateStringElement.max =
lotOccupancyComment.lotOccupancyCommentDateString <= currentDateString lotOccupancyComment.lotOccupancyCommentDateString <= currentDateString
? currentDateString ? currentDateString
: lotOccupancyComment.lotOccupancyCommentDateString; : (_c = lotOccupancyComment.lotOccupancyCommentDateString) !== null && _c !== void 0 ? _c : '';
modalElement.querySelector('#lotOccupancyCommentEdit--lotOccupancyCommentTimeString').value = lotOccupancyComment.lotOccupancyCommentTimeString; modalElement.querySelector('#lotOccupancyCommentEdit--lotOccupancyCommentTimeString').value = (_d = lotOccupancyComment.lotOccupancyCommentTimeString) !== null && _d !== void 0 ? _d : '';
}, },
onshown(modalElement, closeModalFunction) { onshown(modalElement, closeModalFunction) {
bulmaJS.toggleHtmlClipped(); bulmaJS.toggleHtmlClipped();
@ -958,14 +961,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
}); });
} }
function deleteLotOccupancyComment(clickEvent) { function deleteLotOccupancyComment(clickEvent) {
const lotOccupancyCommentId = Number.parseInt(clickEvent.currentTarget.closest('tr').dataset var _a, _b;
.lotOccupancyCommentId, 10); const lotOccupancyCommentId = Number.parseInt((_b = (_a = clickEvent.currentTarget.closest('tr')) === null || _a === void 0 ? void 0 : _a.dataset.lotOccupancyCommentId) !== null && _b !== void 0 ? _b : '', 10);
function doDelete() { function doDelete() {
cityssm.postJSON(los.urlPrefix + '/lotOccupancies/doDeleteLotOccupancyComment', { cityssm.postJSON(`${los.urlPrefix}/lotOccupancies/doDeleteLotOccupancyComment`, {
lotOccupancyId, lotOccupancyId,
lotOccupancyCommentId lotOccupancyCommentId
}, (responseJSON) => { }, (rawResponseJSON) => {
var _a; var _a;
const responseJSON = rawResponseJSON;
if (responseJSON.success) { if (responseJSON.success) {
lotOccupancyComments = responseJSON.lotOccupancyComments; lotOccupancyComments = responseJSON.lotOccupancyComments;
renderLotOccupancyComments(); renderLotOccupancyComments();
@ -990,60 +994,51 @@ Object.defineProperty(exports, "__esModule", { value: true });
}); });
} }
function renderLotOccupancyComments() { function renderLotOccupancyComments() {
var _a, _b, _c; var _a, _b, _c, _d, _e, _f, _g, _h;
const containerElement = document.querySelector('#container--lotOccupancyComments'); const containerElement = document.querySelector('#container--lotOccupancyComments');
if (lotOccupancyComments.length === 0) { if (lotOccupancyComments.length === 0) {
containerElement.innerHTML = containerElement.innerHTML = `<div class="message is-info">
'<div class="message is-info">' + <p class="message-body">There are no comments associated with this record.</p>
'<p class="message-body">There are no comments associated with this record.</p>' + </div>`;
'</div>';
return; return;
} }
const tableElement = document.createElement('table'); const tableElement = document.createElement('table');
tableElement.className = 'table is-fullwidth is-striped is-hoverable'; tableElement.className = 'table is-fullwidth is-striped is-hoverable';
tableElement.innerHTML = tableElement.innerHTML = `<thead><tr>
'<thead><tr>' + <th>Commentor</th>
'<th>Commentor</th>' + <th>Comment Date</th>
'<th>Comment Date</th>' + <th>Comment</th>
'<th>Comment</th>' + <th class="is-hidden-print"><span class="is-sr-only">Options</span></th>
'<th class="is-hidden-print"><span class="is-sr-only">Options</span></th>' + </tr></thead>
'</tr></thead>' + <tbody></tbody>`;
'<tbody></tbody>';
for (const lotOccupancyComment of lotOccupancyComments) { for (const lotOccupancyComment of lotOccupancyComments) {
const tableRowElement = document.createElement('tr'); const tableRowElement = document.createElement('tr');
tableRowElement.dataset.lotOccupancyCommentId = tableRowElement.dataset.lotOccupancyCommentId =
lotOccupancyComment.lotOccupancyCommentId.toString(); (_a = lotOccupancyComment.lotOccupancyCommentId) === null || _a === void 0 ? void 0 : _a.toString();
tableRowElement.innerHTML = tableRowElement.innerHTML = `<td>${cityssm.escapeHTML((_b = lotOccupancyComment.recordCreate_userName) !== null && _b !== void 0 ? _b : '')}</td>
'<td>' + <td>
cityssm.escapeHTML((_a = lotOccupancyComment.recordCreate_userName) !== null && _a !== void 0 ? _a : '') + ${cityssm.escapeHTML((_c = lotOccupancyComment.lotOccupancyCommentDateString) !== null && _c !== void 0 ? _c : '')}
'</td>' + ${cityssm.escapeHTML(lotOccupancyComment.lotOccupancyCommentTime === 0
'<td>' +
((_b = lotOccupancyComment.lotOccupancyCommentDateString) !== null && _b !== void 0 ? _b : '') +
(lotOccupancyComment.lotOccupancyCommentTime === 0
? '' ? ''
: ' ' + lotOccupancyComment.lotOccupancyCommentTimePeriodString) + : (_d = lotOccupancyComment.lotOccupancyCommentTimePeriodString) !== null && _d !== void 0 ? _d : '')}
'</td>' + </td>
'<td>' + <td>${cityssm.escapeHTML((_e = lotOccupancyComment.lotOccupancyComment) !== null && _e !== void 0 ? _e : '')}</td>
cityssm.escapeHTML((_c = lotOccupancyComment.lotOccupancyComment) !== null && _c !== void 0 ? _c : '') + <td class="is-hidden-print">
'</td>' + <div class="buttons are-small is-justify-content-end">
('<td class="is-hidden-print">' + <button class="button is-primary button--edit" type="button">
'<div class="buttons are-small is-justify-content-end">' + <span class="icon is-small"><i class="fas fa-pencil-alt" aria-hidden="true"></i></span>
('<button class="button is-primary button--edit" type="button">' + <span>Edit</span>
'<span class="icon is-small"><i class="fas fa-pencil-alt" aria-hidden="true"></i></span>' + </button>
' <span>Edit</span>' + <button class="button is-light is-danger button--delete" data-tooltip="Delete Comment" type="button" aria-label="Delete">
'</button>') + <i class="fas fa-trash" aria-hidden="true"></i>
('<button class="button is-light is-danger button--delete" data-tooltip="Delete Comment" type="button" aria-label="Delete">' + </button>
'<i class="fas fa-trash" aria-hidden="true"></i>' + </div>
'</button>') + </td>`;
'</div>' + (_f = tableRowElement
'</td>'); .querySelector('.button--edit')) === null || _f === void 0 ? void 0 : _f.addEventListener('click', openEditLotOccupancyComment);
tableRowElement (_g = tableRowElement
.querySelector('.button--edit') .querySelector('.button--delete')) === null || _g === void 0 ? void 0 : _g.addEventListener('click', deleteLotOccupancyComment);
.addEventListener('click', openEditLotOccupancyComment); (_h = tableElement.querySelector('tbody')) === null || _h === void 0 ? void 0 : _h.append(tableRowElement);
tableRowElement
.querySelector('.button--delete')
.addEventListener('click', deleteLotOccupancyComment);
tableElement.querySelector('tbody').append(tableRowElement);
} }
containerElement.innerHTML = ''; containerElement.innerHTML = '';
containerElement.append(tableElement); containerElement.append(tableElement);
@ -1053,8 +1048,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
let addCloseModalFunction; let addCloseModalFunction;
function addComment(submitEvent) { function addComment(submitEvent) {
submitEvent.preventDefault(); submitEvent.preventDefault();
cityssm.postJSON(los.urlPrefix + '/lotOccupancies/doAddLotOccupancyComment', addFormElement, (responseJSON) => { cityssm.postJSON(`${los.urlPrefix}/lotOccupancies/doAddLotOccupancyComment`, addFormElement, (rawResponseJSON) => {
var _a; var _a;
const responseJSON = rawResponseJSON;
if (responseJSON.success) { if (responseJSON.success) {
lotOccupancyComments = responseJSON.lotOccupancyComments; lotOccupancyComments = responseJSON.lotOccupancyComments;
addCloseModalFunction(); addCloseModalFunction();

View File

@ -1,12 +1,13 @@
"use strict"; "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 */
var _a; var _a;
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
let lotOccupancyComments = exports.lotOccupancyComments; let lotOccupancyComments = exports.lotOccupancyComments;
delete exports.lotOccupancyComments; delete exports.lotOccupancyComments;
function openEditLotOccupancyComment(clickEvent) { function openEditLotOccupancyComment(clickEvent) {
const lotOccupancyCommentId = Number.parseInt(clickEvent.currentTarget.closest('tr').dataset var _a, _b;
.lotOccupancyCommentId, 10); const lotOccupancyCommentId = Number.parseInt((_b = (_a = clickEvent.currentTarget.closest('tr')) === null || _a === void 0 ? void 0 : _a.dataset.lotOccupancyCommentId) !== null && _b !== void 0 ? _b : '', 10);
const lotOccupancyComment = lotOccupancyComments.find((currentLotOccupancyComment) => { const lotOccupancyComment = lotOccupancyComments.find((currentLotOccupancyComment) => {
return (currentLotOccupancyComment.lotOccupancyCommentId === return (currentLotOccupancyComment.lotOccupancyCommentId ===
lotOccupancyCommentId); lotOccupancyCommentId);
@ -15,17 +16,18 @@ function openEditLotOccupancyComment(clickEvent) {
let editCloseModalFunction; let editCloseModalFunction;
function editComment(submitEvent) { function editComment(submitEvent) {
submitEvent.preventDefault(); submitEvent.preventDefault();
cityssm.postJSON(los.urlPrefix + '/lotOccupancies/doUpdateLotOccupancyComment', editFormElement, (responseJSON) => { cityssm.postJSON(`${los.urlPrefix}/lotOccupancies/doUpdateLotOccupancyComment`, editFormElement, (rawResponseJSON) => {
var _a; var _a, _b;
const responseJSON = rawResponseJSON;
if (responseJSON.success) { if (responseJSON.success) {
lotOccupancyComments = responseJSON.lotOccupancyComments; lotOccupancyComments = (_a = responseJSON.lotOccupancyComments) !== null && _a !== void 0 ? _a : [];
editCloseModalFunction(); editCloseModalFunction();
renderLotOccupancyComments(); renderLotOccupancyComments();
} }
else { else {
bulmaJS.alert({ bulmaJS.alert({
title: 'Error Updating Comment', title: 'Error Updating Comment',
message: (_a = responseJSON.errorMessage) !== null && _a !== void 0 ? _a : '', message: (_b = responseJSON.errorMessage) !== null && _b !== void 0 ? _b : '',
contextualColorName: 'danger' contextualColorName: 'danger'
}); });
} }
@ -33,19 +35,20 @@ function openEditLotOccupancyComment(clickEvent) {
} }
cityssm.openHtmlModal('lotOccupancy-editComment', { cityssm.openHtmlModal('lotOccupancy-editComment', {
onshow(modalElement) { onshow(modalElement) {
var _a, _b, _c, _d;
los.populateAliases(modalElement); los.populateAliases(modalElement);
modalElement.querySelector('#lotOccupancyCommentEdit--lotOccupancyId').value = lotOccupancyId; modalElement.querySelector('#lotOccupancyCommentEdit--lotOccupancyId').value = lotOccupancyId;
modalElement.querySelector('#lotOccupancyCommentEdit--lotOccupancyCommentId').value = lotOccupancyCommentId.toString(); modalElement.querySelector('#lotOccupancyCommentEdit--lotOccupancyCommentId').value = lotOccupancyCommentId.toString();
modalElement.querySelector('#lotOccupancyCommentEdit--lotOccupancyComment').value = lotOccupancyComment.lotOccupancyComment; modalElement.querySelector('#lotOccupancyCommentEdit--lotOccupancyComment').value = (_a = lotOccupancyComment.lotOccupancyComment) !== null && _a !== void 0 ? _a : '';
const lotOccupancyCommentDateStringElement = modalElement.querySelector('#lotOccupancyCommentEdit--lotOccupancyCommentDateString'); const lotOccupancyCommentDateStringElement = modalElement.querySelector('#lotOccupancyCommentEdit--lotOccupancyCommentDateString');
lotOccupancyCommentDateStringElement.value = lotOccupancyCommentDateStringElement.value =
lotOccupancyComment.lotOccupancyCommentDateString; (_b = lotOccupancyComment.lotOccupancyCommentDateString) !== null && _b !== void 0 ? _b : '';
const currentDateString = cityssm.dateToString(new Date()); const currentDateString = cityssm.dateToString(new Date());
lotOccupancyCommentDateStringElement.max = lotOccupancyCommentDateStringElement.max =
lotOccupancyComment.lotOccupancyCommentDateString <= currentDateString lotOccupancyComment.lotOccupancyCommentDateString <= currentDateString
? currentDateString ? currentDateString
: lotOccupancyComment.lotOccupancyCommentDateString; : (_c = lotOccupancyComment.lotOccupancyCommentDateString) !== null && _c !== void 0 ? _c : '';
modalElement.querySelector('#lotOccupancyCommentEdit--lotOccupancyCommentTimeString').value = lotOccupancyComment.lotOccupancyCommentTimeString; modalElement.querySelector('#lotOccupancyCommentEdit--lotOccupancyCommentTimeString').value = (_d = lotOccupancyComment.lotOccupancyCommentTimeString) !== null && _d !== void 0 ? _d : '';
}, },
onshown(modalElement, closeModalFunction) { onshown(modalElement, closeModalFunction) {
bulmaJS.toggleHtmlClipped(); bulmaJS.toggleHtmlClipped();
@ -61,14 +64,15 @@ function openEditLotOccupancyComment(clickEvent) {
}); });
} }
function deleteLotOccupancyComment(clickEvent) { function deleteLotOccupancyComment(clickEvent) {
const lotOccupancyCommentId = Number.parseInt(clickEvent.currentTarget.closest('tr').dataset var _a, _b;
.lotOccupancyCommentId, 10); const lotOccupancyCommentId = Number.parseInt((_b = (_a = clickEvent.currentTarget.closest('tr')) === null || _a === void 0 ? void 0 : _a.dataset.lotOccupancyCommentId) !== null && _b !== void 0 ? _b : '', 10);
function doDelete() { function doDelete() {
cityssm.postJSON(los.urlPrefix + '/lotOccupancies/doDeleteLotOccupancyComment', { cityssm.postJSON(`${los.urlPrefix}/lotOccupancies/doDeleteLotOccupancyComment`, {
lotOccupancyId, lotOccupancyId,
lotOccupancyCommentId lotOccupancyCommentId
}, (responseJSON) => { }, (rawResponseJSON) => {
var _a; var _a;
const responseJSON = rawResponseJSON;
if (responseJSON.success) { if (responseJSON.success) {
lotOccupancyComments = responseJSON.lotOccupancyComments; lotOccupancyComments = responseJSON.lotOccupancyComments;
renderLotOccupancyComments(); renderLotOccupancyComments();
@ -93,60 +97,51 @@ function deleteLotOccupancyComment(clickEvent) {
}); });
} }
function renderLotOccupancyComments() { function renderLotOccupancyComments() {
var _a, _b, _c; var _a, _b, _c, _d, _e, _f, _g, _h;
const containerElement = document.querySelector('#container--lotOccupancyComments'); const containerElement = document.querySelector('#container--lotOccupancyComments');
if (lotOccupancyComments.length === 0) { if (lotOccupancyComments.length === 0) {
containerElement.innerHTML = containerElement.innerHTML = `<div class="message is-info">
'<div class="message is-info">' + <p class="message-body">There are no comments associated with this record.</p>
'<p class="message-body">There are no comments associated with this record.</p>' + </div>`;
'</div>';
return; return;
} }
const tableElement = document.createElement('table'); const tableElement = document.createElement('table');
tableElement.className = 'table is-fullwidth is-striped is-hoverable'; tableElement.className = 'table is-fullwidth is-striped is-hoverable';
tableElement.innerHTML = tableElement.innerHTML = `<thead><tr>
'<thead><tr>' + <th>Commentor</th>
'<th>Commentor</th>' + <th>Comment Date</th>
'<th>Comment Date</th>' + <th>Comment</th>
'<th>Comment</th>' + <th class="is-hidden-print"><span class="is-sr-only">Options</span></th>
'<th class="is-hidden-print"><span class="is-sr-only">Options</span></th>' + </tr></thead>
'</tr></thead>' + <tbody></tbody>`;
'<tbody></tbody>';
for (const lotOccupancyComment of lotOccupancyComments) { for (const lotOccupancyComment of lotOccupancyComments) {
const tableRowElement = document.createElement('tr'); const tableRowElement = document.createElement('tr');
tableRowElement.dataset.lotOccupancyCommentId = tableRowElement.dataset.lotOccupancyCommentId =
lotOccupancyComment.lotOccupancyCommentId.toString(); (_a = lotOccupancyComment.lotOccupancyCommentId) === null || _a === void 0 ? void 0 : _a.toString();
tableRowElement.innerHTML = tableRowElement.innerHTML = `<td>${cityssm.escapeHTML((_b = lotOccupancyComment.recordCreate_userName) !== null && _b !== void 0 ? _b : '')}</td>
'<td>' + <td>
cityssm.escapeHTML((_a = lotOccupancyComment.recordCreate_userName) !== null && _a !== void 0 ? _a : '') + ${cityssm.escapeHTML((_c = lotOccupancyComment.lotOccupancyCommentDateString) !== null && _c !== void 0 ? _c : '')}
'</td>' + ${cityssm.escapeHTML(lotOccupancyComment.lotOccupancyCommentTime === 0
'<td>' +
((_b = lotOccupancyComment.lotOccupancyCommentDateString) !== null && _b !== void 0 ? _b : '') +
(lotOccupancyComment.lotOccupancyCommentTime === 0
? '' ? ''
: ' ' + lotOccupancyComment.lotOccupancyCommentTimePeriodString) + : (_d = lotOccupancyComment.lotOccupancyCommentTimePeriodString) !== null && _d !== void 0 ? _d : '')}
'</td>' + </td>
'<td>' + <td>${cityssm.escapeHTML((_e = lotOccupancyComment.lotOccupancyComment) !== null && _e !== void 0 ? _e : '')}</td>
cityssm.escapeHTML((_c = lotOccupancyComment.lotOccupancyComment) !== null && _c !== void 0 ? _c : '') + <td class="is-hidden-print">
'</td>' + <div class="buttons are-small is-justify-content-end">
('<td class="is-hidden-print">' + <button class="button is-primary button--edit" type="button">
'<div class="buttons are-small is-justify-content-end">' + <span class="icon is-small"><i class="fas fa-pencil-alt" aria-hidden="true"></i></span>
('<button class="button is-primary button--edit" type="button">' + <span>Edit</span>
'<span class="icon is-small"><i class="fas fa-pencil-alt" aria-hidden="true"></i></span>' + </button>
' <span>Edit</span>' + <button class="button is-light is-danger button--delete" data-tooltip="Delete Comment" type="button" aria-label="Delete">
'</button>') + <i class="fas fa-trash" aria-hidden="true"></i>
('<button class="button is-light is-danger button--delete" data-tooltip="Delete Comment" type="button" aria-label="Delete">' + </button>
'<i class="fas fa-trash" aria-hidden="true"></i>' + </div>
'</button>') + </td>`;
'</div>' + (_f = tableRowElement
'</td>'); .querySelector('.button--edit')) === null || _f === void 0 ? void 0 : _f.addEventListener('click', openEditLotOccupancyComment);
tableRowElement (_g = tableRowElement
.querySelector('.button--edit') .querySelector('.button--delete')) === null || _g === void 0 ? void 0 : _g.addEventListener('click', deleteLotOccupancyComment);
.addEventListener('click', openEditLotOccupancyComment); (_h = tableElement.querySelector('tbody')) === null || _h === void 0 ? void 0 : _h.append(tableRowElement);
tableRowElement
.querySelector('.button--delete')
.addEventListener('click', deleteLotOccupancyComment);
tableElement.querySelector('tbody').append(tableRowElement);
} }
containerElement.innerHTML = ''; containerElement.innerHTML = '';
containerElement.append(tableElement); containerElement.append(tableElement);
@ -156,8 +151,9 @@ function renderLotOccupancyComments() {
let addCloseModalFunction; let addCloseModalFunction;
function addComment(submitEvent) { function addComment(submitEvent) {
submitEvent.preventDefault(); submitEvent.preventDefault();
cityssm.postJSON(los.urlPrefix + '/lotOccupancies/doAddLotOccupancyComment', addFormElement, (responseJSON) => { cityssm.postJSON(`${los.urlPrefix}/lotOccupancies/doAddLotOccupancyComment`, addFormElement, (rawResponseJSON) => {
var _a; var _a;
const responseJSON = rawResponseJSON;
if (responseJSON.success) { if (responseJSON.success) {
lotOccupancyComments = responseJSON.lotOccupancyComments; lotOccupancyComments = responseJSON.lotOccupancyComments;
addCloseModalFunction(); addCloseModalFunction();

View File

@ -1,11 +1,11 @@
/* 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 { BulmaJS } from '@cityssm/bulma-js/types.js'
import type * as recordTypes from '../../types/recordTypes' import type { cityssmGlobal } from '@cityssm/bulma-webapp-js/src/types.js'
import type { cityssmGlobal } from '@cityssm/bulma-webapp-js/src/types' import type * as globalTypes from '../../types/globalTypes.js'
import type * as recordTypes from '../../types/recordTypes.js'
import type { BulmaJS } from '@cityssm/bulma-js/types'
declare const cityssm: cityssmGlobal declare const cityssm: cityssmGlobal
declare const bulmaJS: BulmaJS declare const bulmaJS: BulmaJS
@ -14,14 +14,16 @@ declare const los: globalTypes.LOS
declare const lotOccupancyId: string declare const lotOccupancyId: string
let lotOccupancyComments: recordTypes.LotOccupancyComment[] = declare const exports: Record<string, unknown>
exports.lotOccupancyComments
let lotOccupancyComments =
exports.lotOccupancyComments as recordTypes.LotOccupancyComment[]
delete exports.lotOccupancyComments delete exports.lotOccupancyComments
function openEditLotOccupancyComment(clickEvent: Event): void { function openEditLotOccupancyComment(clickEvent: Event): void {
const lotOccupancyCommentId = Number.parseInt( const lotOccupancyCommentId = Number.parseInt(
(clickEvent.currentTarget as HTMLElement).closest('tr')!.dataset (clickEvent.currentTarget as HTMLElement).closest('tr')?.dataset
.lotOccupancyCommentId!, .lotOccupancyCommentId ?? '',
10 10
) )
@ -41,15 +43,17 @@ function openEditLotOccupancyComment(clickEvent: Event): void {
submitEvent.preventDefault() submitEvent.preventDefault()
cityssm.postJSON( cityssm.postJSON(
los.urlPrefix + '/lotOccupancies/doUpdateLotOccupancyComment', `${los.urlPrefix}/lotOccupancies/doUpdateLotOccupancyComment`,
editFormElement, editFormElement,
(responseJSON: { (rawResponseJSON) => {
const responseJSON = rawResponseJSON as {
success: boolean success: boolean
errorMessage?: string errorMessage?: string
lotOccupancyComments?: recordTypes.LotOccupancyComment[] lotOccupancyComments?: recordTypes.LotOccupancyComment[]
}) => { }
if (responseJSON.success) { if (responseJSON.success) {
lotOccupancyComments = responseJSON.lotOccupancyComments! lotOccupancyComments = responseJSON.lotOccupancyComments ?? []
editCloseModalFunction() editCloseModalFunction()
renderLotOccupancyComments() renderLotOccupancyComments()
} else { } else {
@ -80,26 +84,26 @@ function openEditLotOccupancyComment(clickEvent: Event): void {
modalElement.querySelector( modalElement.querySelector(
'#lotOccupancyCommentEdit--lotOccupancyComment' '#lotOccupancyCommentEdit--lotOccupancyComment'
) as HTMLInputElement ) as HTMLInputElement
).value = lotOccupancyComment.lotOccupancyComment! ).value = lotOccupancyComment.lotOccupancyComment ?? ''
const lotOccupancyCommentDateStringElement = modalElement.querySelector( const lotOccupancyCommentDateStringElement = modalElement.querySelector(
'#lotOccupancyCommentEdit--lotOccupancyCommentDateString' '#lotOccupancyCommentEdit--lotOccupancyCommentDateString'
) as HTMLInputElement ) as HTMLInputElement
lotOccupancyCommentDateStringElement.value = lotOccupancyCommentDateStringElement.value =
lotOccupancyComment.lotOccupancyCommentDateString! lotOccupancyComment.lotOccupancyCommentDateString ?? ''
const currentDateString = cityssm.dateToString(new Date()) const currentDateString = cityssm.dateToString(new Date())
lotOccupancyCommentDateStringElement.max = lotOccupancyCommentDateStringElement.max =
lotOccupancyComment.lotOccupancyCommentDateString! <= currentDateString lotOccupancyComment.lotOccupancyCommentDateString! <= currentDateString
? currentDateString ? currentDateString
: lotOccupancyComment.lotOccupancyCommentDateString! : lotOccupancyComment.lotOccupancyCommentDateString ?? ''
;( ;(
modalElement.querySelector( modalElement.querySelector(
'#lotOccupancyCommentEdit--lotOccupancyCommentTimeString' '#lotOccupancyCommentEdit--lotOccupancyCommentTimeString'
) as HTMLInputElement ) as HTMLInputElement
).value = lotOccupancyComment.lotOccupancyCommentTimeString! ).value = lotOccupancyComment.lotOccupancyCommentTimeString ?? ''
}, },
onshown(modalElement, closeModalFunction) { onshown(modalElement, closeModalFunction) {
bulmaJS.toggleHtmlClipped() bulmaJS.toggleHtmlClipped()
@ -111,7 +115,8 @@ function openEditLotOccupancyComment(clickEvent: Event): void {
) as HTMLTextAreaElement ) as HTMLTextAreaElement
).focus() ).focus()
editFormElement = modalElement.querySelector('form')! editFormElement = modalElement.querySelector('form') as HTMLFormElement
editFormElement.addEventListener('submit', editComment) editFormElement.addEventListener('submit', editComment)
editCloseModalFunction = closeModalFunction editCloseModalFunction = closeModalFunction
@ -124,23 +129,25 @@ function openEditLotOccupancyComment(clickEvent: Event): void {
function deleteLotOccupancyComment(clickEvent: Event): void { function deleteLotOccupancyComment(clickEvent: Event): void {
const lotOccupancyCommentId = Number.parseInt( const lotOccupancyCommentId = Number.parseInt(
(clickEvent.currentTarget as HTMLElement).closest('tr')!.dataset (clickEvent.currentTarget as HTMLElement).closest('tr')?.dataset
.lotOccupancyCommentId!, .lotOccupancyCommentId ?? '',
10 10
) )
function doDelete(): void { function doDelete(): void {
cityssm.postJSON( cityssm.postJSON(
los.urlPrefix + '/lotOccupancies/doDeleteLotOccupancyComment', `${los.urlPrefix}/lotOccupancies/doDeleteLotOccupancyComment`,
{ {
lotOccupancyId, lotOccupancyId,
lotOccupancyCommentId lotOccupancyCommentId
}, },
(responseJSON: { (rawResponseJSON) => {
const responseJSON = rawResponseJSON as {
success: boolean success: boolean
errorMessage?: string errorMessage?: string
lotOccupancyComments: recordTypes.LotOccupancyComment[] lotOccupancyComments: recordTypes.LotOccupancyComment[]
}) => { }
if (responseJSON.success) { if (responseJSON.success) {
lotOccupancyComments = responseJSON.lotOccupancyComments lotOccupancyComments = responseJSON.lotOccupancyComments
renderLotOccupancyComments() renderLotOccupancyComments()
@ -172,63 +179,60 @@ function renderLotOccupancyComments(): void {
) as HTMLElement ) as HTMLElement
if (lotOccupancyComments.length === 0) { if (lotOccupancyComments.length === 0) {
containerElement.innerHTML = containerElement.innerHTML = `<div class="message is-info">
'<div class="message is-info">' + <p class="message-body">There are no comments associated with this record.</p>
'<p class="message-body">There are no comments associated with this record.</p>' + </div>`
'</div>'
return return
} }
const tableElement = document.createElement('table') const tableElement = document.createElement('table')
tableElement.className = 'table is-fullwidth is-striped is-hoverable' tableElement.className = 'table is-fullwidth is-striped is-hoverable'
tableElement.innerHTML = tableElement.innerHTML = `<thead><tr>
'<thead><tr>' + <th>Commentor</th>
'<th>Commentor</th>' + <th>Comment Date</th>
'<th>Comment Date</th>' + <th>Comment</th>
'<th>Comment</th>' + <th class="is-hidden-print"><span class="is-sr-only">Options</span></th>
'<th class="is-hidden-print"><span class="is-sr-only">Options</span></th>' + </tr></thead>
'</tr></thead>' + <tbody></tbody>`
'<tbody></tbody>'
for (const lotOccupancyComment of lotOccupancyComments) { for (const lotOccupancyComment of lotOccupancyComments) {
const tableRowElement = document.createElement('tr') const tableRowElement = document.createElement('tr')
tableRowElement.dataset.lotOccupancyCommentId = tableRowElement.dataset.lotOccupancyCommentId =
lotOccupancyComment.lotOccupancyCommentId!.toString() lotOccupancyComment.lotOccupancyCommentId?.toString()
tableRowElement.innerHTML = tableRowElement.innerHTML = `<td>${cityssm.escapeHTML(lotOccupancyComment.recordCreate_userName ?? '')}</td>
'<td>' + <td>
cityssm.escapeHTML(lotOccupancyComment.recordCreate_userName ?? '') + ${cityssm.escapeHTML(
'</td>' + lotOccupancyComment.lotOccupancyCommentDateString ?? ''
'<td>' + )}
(lotOccupancyComment.lotOccupancyCommentDateString ?? '') + ${cityssm.escapeHTML(
(lotOccupancyComment.lotOccupancyCommentTime === 0 lotOccupancyComment.lotOccupancyCommentTime === 0
? '' ? ''
: ' ' + lotOccupancyComment.lotOccupancyCommentTimePeriodString!) + : lotOccupancyComment.lotOccupancyCommentTimePeriodString ?? ''
'</td>' + )}
'<td>' + </td>
cityssm.escapeHTML(lotOccupancyComment.lotOccupancyComment ?? '') + <td>${cityssm.escapeHTML(lotOccupancyComment.lotOccupancyComment ?? '')}</td>
'</td>' + <td class="is-hidden-print">
('<td class="is-hidden-print">' + <div class="buttons are-small is-justify-content-end">
'<div class="buttons are-small is-justify-content-end">' + <button class="button is-primary button--edit" type="button">
('<button class="button is-primary button--edit" type="button">' + <span class="icon is-small"><i class="fas fa-pencil-alt" aria-hidden="true"></i></span>
'<span class="icon is-small"><i class="fas fa-pencil-alt" aria-hidden="true"></i></span>' + <span>Edit</span>
' <span>Edit</span>' + </button>
'</button>') + <button class="button is-light is-danger button--delete" data-tooltip="Delete Comment" type="button" aria-label="Delete">
('<button class="button is-light is-danger button--delete" data-tooltip="Delete Comment" type="button" aria-label="Delete">' + <i class="fas fa-trash" aria-hidden="true"></i>
'<i class="fas fa-trash" aria-hidden="true"></i>' + </button>
'</button>') + </div>
'</div>' + </td>`
'</td>')
tableRowElement tableRowElement
.querySelector('.button--edit')! .querySelector('.button--edit')
.addEventListener('click', openEditLotOccupancyComment) ?.addEventListener('click', openEditLotOccupancyComment)
tableRowElement tableRowElement
.querySelector('.button--delete')! .querySelector('.button--delete')
.addEventListener('click', deleteLotOccupancyComment) ?.addEventListener('click', deleteLotOccupancyComment)
tableElement.querySelector('tbody')!.append(tableRowElement) tableElement.querySelector('tbody')?.append(tableRowElement)
} }
containerElement.innerHTML = '' containerElement.innerHTML = ''
@ -243,15 +247,17 @@ document.querySelector('#button--addComment')?.addEventListener('click', () => {
submitEvent.preventDefault() submitEvent.preventDefault()
cityssm.postJSON( cityssm.postJSON(
los.urlPrefix + '/lotOccupancies/doAddLotOccupancyComment', `${los.urlPrefix}/lotOccupancies/doAddLotOccupancyComment`,
addFormElement, addFormElement,
(responseJSON: { (rawResponseJSON) => {
const responseJSON = rawResponseJSON as {
success: boolean success: boolean
errorMessage?: string errorMessage?: string
lotOccupancyComments?: recordTypes.LotOccupancyComment[] lotOccupancyComments: recordTypes.LotOccupancyComment[]
}) => { }
if (responseJSON.success) { if (responseJSON.success) {
lotOccupancyComments = responseJSON.lotOccupancyComments! lotOccupancyComments = responseJSON.lotOccupancyComments
addCloseModalFunction() addCloseModalFunction()
renderLotOccupancyComments() renderLotOccupancyComments()
} else { } else {
@ -282,7 +288,8 @@ document.querySelector('#button--addComment')?.addEventListener('click', () => {
) as HTMLTextAreaElement ) as HTMLTextAreaElement
).focus() ).focus()
addFormElement = modalElement.querySelector('form')! addFormElement = modalElement.querySelector('form') as HTMLFormElement
addFormElement.addEventListener('submit', addComment) addFormElement.addEventListener('submit', addComment)
addCloseModalFunction = closeModalFunction addCloseModalFunction = closeModalFunction

File diff suppressed because one or more lines are too long