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

View File

@ -1,12 +1,13 @@
"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;
Object.defineProperty(exports, "__esModule", { value: true });
let lotOccupancyComments = exports.lotOccupancyComments;
delete exports.lotOccupancyComments;
function openEditLotOccupancyComment(clickEvent) {
const lotOccupancyCommentId = Number.parseInt(clickEvent.currentTarget.closest('tr').dataset
.lotOccupancyCommentId, 10);
var _a, _b;
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) => {
return (currentLotOccupancyComment.lotOccupancyCommentId ===
lotOccupancyCommentId);
@ -15,17 +16,18 @@ function openEditLotOccupancyComment(clickEvent) {
let editCloseModalFunction;
function editComment(submitEvent) {
submitEvent.preventDefault();
cityssm.postJSON(los.urlPrefix + '/lotOccupancies/doUpdateLotOccupancyComment', editFormElement, (responseJSON) => {
var _a;
cityssm.postJSON(`${los.urlPrefix}/lotOccupancies/doUpdateLotOccupancyComment`, editFormElement, (rawResponseJSON) => {
var _a, _b;
const responseJSON = rawResponseJSON;
if (responseJSON.success) {
lotOccupancyComments = responseJSON.lotOccupancyComments;
lotOccupancyComments = (_a = responseJSON.lotOccupancyComments) !== null && _a !== void 0 ? _a : [];
editCloseModalFunction();
renderLotOccupancyComments();
}
else {
bulmaJS.alert({
title: 'Error Updating Comment',
message: (_a = responseJSON.errorMessage) !== null && _a !== void 0 ? _a : '',
message: (_b = responseJSON.errorMessage) !== null && _b !== void 0 ? _b : '',
contextualColorName: 'danger'
});
}
@ -33,19 +35,20 @@ function openEditLotOccupancyComment(clickEvent) {
}
cityssm.openHtmlModal('lotOccupancy-editComment', {
onshow(modalElement) {
var _a, _b, _c, _d;
los.populateAliases(modalElement);
modalElement.querySelector('#lotOccupancyCommentEdit--lotOccupancyId').value = lotOccupancyId;
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');
lotOccupancyCommentDateStringElement.value =
lotOccupancyComment.lotOccupancyCommentDateString;
(_b = lotOccupancyComment.lotOccupancyCommentDateString) !== null && _b !== void 0 ? _b : '';
const currentDateString = cityssm.dateToString(new Date());
lotOccupancyCommentDateStringElement.max =
lotOccupancyComment.lotOccupancyCommentDateString <= currentDateString
? currentDateString
: lotOccupancyComment.lotOccupancyCommentDateString;
modalElement.querySelector('#lotOccupancyCommentEdit--lotOccupancyCommentTimeString').value = lotOccupancyComment.lotOccupancyCommentTimeString;
: (_c = lotOccupancyComment.lotOccupancyCommentDateString) !== null && _c !== void 0 ? _c : '';
modalElement.querySelector('#lotOccupancyCommentEdit--lotOccupancyCommentTimeString').value = (_d = lotOccupancyComment.lotOccupancyCommentTimeString) !== null && _d !== void 0 ? _d : '';
},
onshown(modalElement, closeModalFunction) {
bulmaJS.toggleHtmlClipped();
@ -61,14 +64,15 @@ function openEditLotOccupancyComment(clickEvent) {
});
}
function deleteLotOccupancyComment(clickEvent) {
const lotOccupancyCommentId = Number.parseInt(clickEvent.currentTarget.closest('tr').dataset
.lotOccupancyCommentId, 10);
var _a, _b;
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() {
cityssm.postJSON(los.urlPrefix + '/lotOccupancies/doDeleteLotOccupancyComment', {
cityssm.postJSON(`${los.urlPrefix}/lotOccupancies/doDeleteLotOccupancyComment`, {
lotOccupancyId,
lotOccupancyCommentId
}, (responseJSON) => {
}, (rawResponseJSON) => {
var _a;
const responseJSON = rawResponseJSON;
if (responseJSON.success) {
lotOccupancyComments = responseJSON.lotOccupancyComments;
renderLotOccupancyComments();
@ -93,60 +97,51 @@ function deleteLotOccupancyComment(clickEvent) {
});
}
function renderLotOccupancyComments() {
var _a, _b, _c;
var _a, _b, _c, _d, _e, _f, _g, _h;
const containerElement = document.querySelector('#container--lotOccupancyComments');
if (lotOccupancyComments.length === 0) {
containerElement.innerHTML =
'<div class="message is-info">' +
'<p class="message-body">There are no comments associated with this record.</p>' +
'</div>';
containerElement.innerHTML = `<div class="message is-info">
<p class="message-body">There are no comments associated with this record.</p>
</div>`;
return;
}
const tableElement = document.createElement('table');
tableElement.className = 'table is-fullwidth is-striped is-hoverable';
tableElement.innerHTML =
'<thead><tr>' +
'<th>Commentor</th>' +
'<th>Comment Date</th>' +
'<th>Comment</th>' +
'<th class="is-hidden-print"><span class="is-sr-only">Options</span></th>' +
'</tr></thead>' +
'<tbody></tbody>';
tableElement.innerHTML = `<thead><tr>
<th>Commentor</th>
<th>Comment Date</th>
<th>Comment</th>
<th class="is-hidden-print"><span class="is-sr-only">Options</span></th>
</tr></thead>
<tbody></tbody>`;
for (const lotOccupancyComment of lotOccupancyComments) {
const tableRowElement = document.createElement('tr');
tableRowElement.dataset.lotOccupancyCommentId =
lotOccupancyComment.lotOccupancyCommentId.toString();
tableRowElement.innerHTML =
'<td>' +
cityssm.escapeHTML((_a = lotOccupancyComment.recordCreate_userName) !== null && _a !== void 0 ? _a : '') +
'</td>' +
'<td>' +
((_b = lotOccupancyComment.lotOccupancyCommentDateString) !== null && _b !== void 0 ? _b : '') +
(lotOccupancyComment.lotOccupancyCommentTime === 0
? ''
: ' ' + lotOccupancyComment.lotOccupancyCommentTimePeriodString) +
'</td>' +
'<td>' +
cityssm.escapeHTML((_c = lotOccupancyComment.lotOccupancyComment) !== null && _c !== void 0 ? _c : '') +
'</td>' +
('<td class="is-hidden-print">' +
'<div class="buttons are-small is-justify-content-end">' +
('<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>Edit</span>' +
'</button>') +
('<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>' +
'</button>') +
'</div>' +
'</td>');
tableRowElement
.querySelector('.button--edit')
.addEventListener('click', openEditLotOccupancyComment);
tableRowElement
.querySelector('.button--delete')
.addEventListener('click', deleteLotOccupancyComment);
tableElement.querySelector('tbody').append(tableRowElement);
(_a = lotOccupancyComment.lotOccupancyCommentId) === null || _a === void 0 ? void 0 : _a.toString();
tableRowElement.innerHTML = `<td>${cityssm.escapeHTML((_b = lotOccupancyComment.recordCreate_userName) !== null && _b !== void 0 ? _b : '')}</td>
<td>
${cityssm.escapeHTML((_c = lotOccupancyComment.lotOccupancyCommentDateString) !== null && _c !== void 0 ? _c : '')}
${cityssm.escapeHTML(lotOccupancyComment.lotOccupancyCommentTime === 0
? ''
: (_d = lotOccupancyComment.lotOccupancyCommentTimePeriodString) !== null && _d !== void 0 ? _d : '')}
</td>
<td>${cityssm.escapeHTML((_e = lotOccupancyComment.lotOccupancyComment) !== null && _e !== void 0 ? _e : '')}</td>
<td class="is-hidden-print">
<div class="buttons are-small is-justify-content-end">
<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>Edit</span>
</button>
<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>
</button>
</div>
</td>`;
(_f = tableRowElement
.querySelector('.button--edit')) === null || _f === void 0 ? void 0 : _f.addEventListener('click', openEditLotOccupancyComment);
(_g = tableRowElement
.querySelector('.button--delete')) === null || _g === void 0 ? void 0 : _g.addEventListener('click', deleteLotOccupancyComment);
(_h = tableElement.querySelector('tbody')) === null || _h === void 0 ? void 0 : _h.append(tableRowElement);
}
containerElement.innerHTML = '';
containerElement.append(tableElement);
@ -156,8 +151,9 @@ function renderLotOccupancyComments() {
let addCloseModalFunction;
function addComment(submitEvent) {
submitEvent.preventDefault();
cityssm.postJSON(los.urlPrefix + '/lotOccupancies/doAddLotOccupancyComment', addFormElement, (responseJSON) => {
cityssm.postJSON(`${los.urlPrefix}/lotOccupancies/doAddLotOccupancyComment`, addFormElement, (rawResponseJSON) => {
var _a;
const responseJSON = rawResponseJSON;
if (responseJSON.success) {
lotOccupancyComments = responseJSON.lotOccupancyComments;
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 * 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
@ -14,14 +14,16 @@ declare const los: globalTypes.LOS
declare const lotOccupancyId: string
let lotOccupancyComments: recordTypes.LotOccupancyComment[] =
exports.lotOccupancyComments
declare const exports: Record<string, unknown>
let lotOccupancyComments =
exports.lotOccupancyComments as recordTypes.LotOccupancyComment[]
delete exports.lotOccupancyComments
function openEditLotOccupancyComment(clickEvent: Event): void {
const lotOccupancyCommentId = Number.parseInt(
(clickEvent.currentTarget as HTMLElement).closest('tr')!.dataset
.lotOccupancyCommentId!,
(clickEvent.currentTarget as HTMLElement).closest('tr')?.dataset
.lotOccupancyCommentId ?? '',
10
)
@ -41,15 +43,17 @@ function openEditLotOccupancyComment(clickEvent: Event): void {
submitEvent.preventDefault()
cityssm.postJSON(
los.urlPrefix + '/lotOccupancies/doUpdateLotOccupancyComment',
`${los.urlPrefix}/lotOccupancies/doUpdateLotOccupancyComment`,
editFormElement,
(responseJSON: {
success: boolean
errorMessage?: string
lotOccupancyComments?: recordTypes.LotOccupancyComment[]
}) => {
(rawResponseJSON) => {
const responseJSON = rawResponseJSON as {
success: boolean
errorMessage?: string
lotOccupancyComments?: recordTypes.LotOccupancyComment[]
}
if (responseJSON.success) {
lotOccupancyComments = responseJSON.lotOccupancyComments!
lotOccupancyComments = responseJSON.lotOccupancyComments ?? []
editCloseModalFunction()
renderLotOccupancyComments()
} else {
@ -80,26 +84,26 @@ function openEditLotOccupancyComment(clickEvent: Event): void {
modalElement.querySelector(
'#lotOccupancyCommentEdit--lotOccupancyComment'
) as HTMLInputElement
).value = lotOccupancyComment.lotOccupancyComment!
).value = lotOccupancyComment.lotOccupancyComment ?? ''
const lotOccupancyCommentDateStringElement = modalElement.querySelector(
'#lotOccupancyCommentEdit--lotOccupancyCommentDateString'
) as HTMLInputElement
lotOccupancyCommentDateStringElement.value =
lotOccupancyComment.lotOccupancyCommentDateString!
lotOccupancyComment.lotOccupancyCommentDateString ?? ''
const currentDateString = cityssm.dateToString(new Date())
lotOccupancyCommentDateStringElement.max =
lotOccupancyComment.lotOccupancyCommentDateString! <= currentDateString
? currentDateString
: lotOccupancyComment.lotOccupancyCommentDateString!
: lotOccupancyComment.lotOccupancyCommentDateString ?? ''
;(
modalElement.querySelector(
'#lotOccupancyCommentEdit--lotOccupancyCommentTimeString'
) as HTMLInputElement
).value = lotOccupancyComment.lotOccupancyCommentTimeString!
).value = lotOccupancyComment.lotOccupancyCommentTimeString ?? ''
},
onshown(modalElement, closeModalFunction) {
bulmaJS.toggleHtmlClipped()
@ -111,7 +115,8 @@ function openEditLotOccupancyComment(clickEvent: Event): void {
) as HTMLTextAreaElement
).focus()
editFormElement = modalElement.querySelector('form')!
editFormElement = modalElement.querySelector('form') as HTMLFormElement
editFormElement.addEventListener('submit', editComment)
editCloseModalFunction = closeModalFunction
@ -124,23 +129,25 @@ function openEditLotOccupancyComment(clickEvent: Event): void {
function deleteLotOccupancyComment(clickEvent: Event): void {
const lotOccupancyCommentId = Number.parseInt(
(clickEvent.currentTarget as HTMLElement).closest('tr')!.dataset
.lotOccupancyCommentId!,
(clickEvent.currentTarget as HTMLElement).closest('tr')?.dataset
.lotOccupancyCommentId ?? '',
10
)
function doDelete(): void {
cityssm.postJSON(
los.urlPrefix + '/lotOccupancies/doDeleteLotOccupancyComment',
`${los.urlPrefix}/lotOccupancies/doDeleteLotOccupancyComment`,
{
lotOccupancyId,
lotOccupancyCommentId
},
(responseJSON: {
success: boolean
errorMessage?: string
lotOccupancyComments: recordTypes.LotOccupancyComment[]
}) => {
(rawResponseJSON) => {
const responseJSON = rawResponseJSON as {
success: boolean
errorMessage?: string
lotOccupancyComments: recordTypes.LotOccupancyComment[]
}
if (responseJSON.success) {
lotOccupancyComments = responseJSON.lotOccupancyComments
renderLotOccupancyComments()
@ -172,63 +179,60 @@ function renderLotOccupancyComments(): void {
) as HTMLElement
if (lotOccupancyComments.length === 0) {
containerElement.innerHTML =
'<div class="message is-info">' +
'<p class="message-body">There are no comments associated with this record.</p>' +
'</div>'
containerElement.innerHTML = `<div class="message is-info">
<p class="message-body">There are no comments associated with this record.</p>
</div>`
return
}
const tableElement = document.createElement('table')
tableElement.className = 'table is-fullwidth is-striped is-hoverable'
tableElement.innerHTML =
'<thead><tr>' +
'<th>Commentor</th>' +
'<th>Comment Date</th>' +
'<th>Comment</th>' +
'<th class="is-hidden-print"><span class="is-sr-only">Options</span></th>' +
'</tr></thead>' +
'<tbody></tbody>'
tableElement.innerHTML = `<thead><tr>
<th>Commentor</th>
<th>Comment Date</th>
<th>Comment</th>
<th class="is-hidden-print"><span class="is-sr-only">Options</span></th>
</tr></thead>
<tbody></tbody>`
for (const lotOccupancyComment of lotOccupancyComments) {
const tableRowElement = document.createElement('tr')
tableRowElement.dataset.lotOccupancyCommentId =
lotOccupancyComment.lotOccupancyCommentId!.toString()
lotOccupancyComment.lotOccupancyCommentId?.toString()
tableRowElement.innerHTML =
'<td>' +
cityssm.escapeHTML(lotOccupancyComment.recordCreate_userName ?? '') +
'</td>' +
'<td>' +
(lotOccupancyComment.lotOccupancyCommentDateString ?? '') +
(lotOccupancyComment.lotOccupancyCommentTime === 0
? ''
: ' ' + lotOccupancyComment.lotOccupancyCommentTimePeriodString!) +
'</td>' +
'<td>' +
cityssm.escapeHTML(lotOccupancyComment.lotOccupancyComment ?? '') +
'</td>' +
('<td class="is-hidden-print">' +
'<div class="buttons are-small is-justify-content-end">' +
('<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>Edit</span>' +
'</button>') +
('<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>' +
'</button>') +
'</div>' +
'</td>')
tableRowElement.innerHTML = `<td>${cityssm.escapeHTML(lotOccupancyComment.recordCreate_userName ?? '')}</td>
<td>
${cityssm.escapeHTML(
lotOccupancyComment.lotOccupancyCommentDateString ?? ''
)}
${cityssm.escapeHTML(
lotOccupancyComment.lotOccupancyCommentTime === 0
? ''
: lotOccupancyComment.lotOccupancyCommentTimePeriodString ?? ''
)}
</td>
<td>${cityssm.escapeHTML(lotOccupancyComment.lotOccupancyComment ?? '')}</td>
<td class="is-hidden-print">
<div class="buttons are-small is-justify-content-end">
<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>Edit</span>
</button>
<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>
</button>
</div>
</td>`
tableRowElement
.querySelector('.button--edit')!
.addEventListener('click', openEditLotOccupancyComment)
.querySelector('.button--edit')
?.addEventListener('click', openEditLotOccupancyComment)
tableRowElement
.querySelector('.button--delete')!
.addEventListener('click', deleteLotOccupancyComment)
.querySelector('.button--delete')
?.addEventListener('click', deleteLotOccupancyComment)
tableElement.querySelector('tbody')!.append(tableRowElement)
tableElement.querySelector('tbody')?.append(tableRowElement)
}
containerElement.innerHTML = ''
@ -243,15 +247,17 @@ document.querySelector('#button--addComment')?.addEventListener('click', () => {
submitEvent.preventDefault()
cityssm.postJSON(
los.urlPrefix + '/lotOccupancies/doAddLotOccupancyComment',
`${los.urlPrefix}/lotOccupancies/doAddLotOccupancyComment`,
addFormElement,
(responseJSON: {
success: boolean
errorMessage?: string
lotOccupancyComments?: recordTypes.LotOccupancyComment[]
}) => {
(rawResponseJSON) => {
const responseJSON = rawResponseJSON as {
success: boolean
errorMessage?: string
lotOccupancyComments: recordTypes.LotOccupancyComment[]
}
if (responseJSON.success) {
lotOccupancyComments = responseJSON.lotOccupancyComments!
lotOccupancyComments = responseJSON.lotOccupancyComments
addCloseModalFunction()
renderLotOccupancyComments()
} else {
@ -282,7 +288,8 @@ document.querySelector('#button--addComment')?.addEventListener('click', () => {
) as HTMLTextAreaElement
).focus()
addFormElement = modalElement.querySelector('form')!
addFormElement = modalElement.querySelector('form') as HTMLFormElement
addFormElement.addEventListener('submit', addComment)
addCloseModalFunction = closeModalFunction

File diff suppressed because one or more lines are too long