Skip to content

Commit

Permalink
linting
Browse files Browse the repository at this point in the history
  • Loading branch information
dangowans committed Jun 27, 2024
1 parent c9bf3ab commit 1ca3ea0
Show file tree
Hide file tree
Showing 19 changed files with 805 additions and 897 deletions.
486 changes: 225 additions & 261 deletions public-typescript/adminTables.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions public-typescript/adminTables/adminTables.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// eslint-disable-next-line @eslint-community/eslint-comments/disable-enable-pair
/* eslint-disable unicorn/prefer-module */

import type * as globalTypes from '../../types/globalTypes.js'
import type { LOS } from '../../types/globalTypes.js'

declare const exports: Record<string, unknown>
;(() => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const los = exports.los as globalTypes.LOS
const los = exports.los as LOS

// eslint-disable-next-line @typescript-eslint/no-unused-vars
function refreshFontAwesomeIcon(changeEvent: Event): void {
Expand Down
176 changes: 77 additions & 99 deletions public-typescript/adminTables/adminTablesLotOccupantTypes.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
"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 });
let lotOccupantTypes = exports.lotOccupantTypes;
delete exports.lotOccupantTypes;
function updateLotOccupantType(submitEvent) {
submitEvent.preventDefault();
cityssm.postJSON(los.urlPrefix + '/admin/doUpdateLotOccupantType', submitEvent.currentTarget, (rawResponseJSON) => {
cityssm.postJSON(`${los.urlPrefix}/admin/doUpdateLotOccupantType`, submitEvent.currentTarget, (rawResponseJSON) => {
var _a;
const responseJSON = rawResponseJSON;
if (responseJSON.success) {
Expand All @@ -28,7 +29,7 @@ function deleteLotOccupantType(clickEvent) {
const tableRowElement = clickEvent.currentTarget.closest('tr');
const lotOccupantTypeId = tableRowElement.dataset.lotOccupantTypeId;
function doDelete() {
cityssm.postJSON(los.urlPrefix + '/admin/doDeleteLotOccupantType', {
cityssm.postJSON(`${los.urlPrefix}/admin/doDeleteLotOccupantType`, {
lotOccupantTypeId
}, (rawResponseJSON) => {
var _a;
Expand Down Expand Up @@ -71,11 +72,9 @@ function moveLotOccupantType(clickEvent) {
const buttonElement = clickEvent.currentTarget;
const tableRowElement = buttonElement.closest('tr');
const lotOccupantTypeId = tableRowElement.dataset.lotOccupantTypeId;
cityssm.postJSON(los.urlPrefix +
'/admin/' +
(buttonElement.dataset.direction === 'up'
? 'doMoveLotOccupantTypeUp'
: 'doMoveLotOccupantTypeDown'), {
cityssm.postJSON(`${los.urlPrefix}/admin/${buttonElement.dataset.direction === 'up'
? 'doMoveLotOccupantTypeUp'
: 'doMoveLotOccupantTypeDown'}`, {
lotOccupantTypeId,
moveToEnd: clickEvent.shiftKey ? '1' : '0'
}, (rawResponseJSON) => {
Expand All @@ -95,8 +94,10 @@ function moveLotOccupantType(clickEvent) {
});
}
function renderLotOccupantTypes() {
var _a, _b;
const containerElement = document.querySelector('#container--lotOccupantTypes');
if (lotOccupantTypes.length === 0) {
// eslint-disable-next-line no-unsanitized/property
containerElement.innerHTML = `<tr><td colspan="3">
<div class="message is-warning">
<p class="message-body">There are no active ${los.escapedAliases.lot} ${los.escapedAliases.occupant} types.</p>
Expand All @@ -109,118 +110,95 @@ function renderLotOccupantTypes() {
const tableRowElement = document.createElement('tr');
tableRowElement.dataset.lotOccupantTypeId =
lotOccupantType.lotOccupantTypeId.toString();
const formId = 'form--lotOccupantType-' + lotOccupantType.lotOccupantTypeId.toString();
tableRowElement.innerHTML =
'<td>' +
('<div class="field">' +
'<div class="control">' +
'<input class="input" name="lotOccupantType" type="text"' +
(' value="' +
cityssm.escapeHTML(lotOccupantType.lotOccupantType) +
'"') +
(' form="' + formId + '"') +
(' aria-label="' +
los.escapedAliases.Lot +
' ' +
los.escapedAliases.Occupant +
' Type"') +
' maxlength="100" required />' +
'</div>' +
'</div>') +
'</td>' +
'<td>' +
('<div class="field has-addons">' +
'<div class="control"><span class="button is-static">fa-</span></div>' +
'<div class="control">' +
'<input class="input" name="fontAwesomeIconClass" type="text"' +
(' value="' +
cityssm.escapeHTML(lotOccupantType.fontAwesomeIconClass) +
'"') +
(' form="' + formId + '"') +
' list="datalist--fontAwesomeIconClass"' +
' aria-label="Icon Name"' +
' maxlength="50" />' +
'</div>' +
'<div class="control"><span class="button is-static">' +
'<i class="fas fa-fw fa-' +
cityssm.escapeHTML(lotOccupantType.fontAwesomeIconClass) +
'"></i></span></div>' +
'</div>') +
'</td>' +
'<td>' +
('<div class="field">' +
'<div class="control">' +
'<input class="input" name="occupantCommentTitle" type="text"' +
(' value="' +
cityssm.escapeHTML(lotOccupantType.occupantCommentTitle) +
'"') +
(' form="' + formId + '"') +
(' aria-label="' + los.escapedAliases.Occupant + ' Comment Title"') +
' maxlength="50" />' +
'</div>' +
'</div>') +
'</td>' +
('<td>' +
('<form id="' + formId + '">') +
'<input name="lotOccupantTypeId" type="hidden"' +
(' value="' + lotOccupantType.lotOccupantTypeId.toString() + '"') +
' />' +
'<button class="button is-success" type="submit" aria-label="Save"><i class="fas fa-save" aria-hidden="true"></i></button>' +
'</form>' +
'</td>') +
'<td class="is-nowrap">' +
'<div class="field is-grouped">' +
'<div class="control">' +
los.getMoveUpDownButtonFieldHTML('button--moveLotOccupantTypeUp', 'button--moveLotOccupantTypeDown', false) +
'</div>' +
'<div class="control">' +
'<button class="button is-danger is-light button--deleteLotOccupantType"' +
' data-tooltip="Delete ' +
los.escapedAliases.Lot +
' ' +
los.escapedAliases.Occupant +
' Type" type="button"' +
' aria-label="Delete ' +
los.escapedAliases.Lot +
' ' +
los.escapedAliases.Occupant +
' Type">' +
'<i class="fas fa-trash" aria-hidden="true"></i>' +
'</button>' +
'</div>' +
'</div>' +
'</td>';
const formId = `form--lotOccupantType-${lotOccupantType.lotOccupantTypeId.toString()}`;
// eslint-disable-next-line no-unsanitized/property
tableRowElement.innerHTML = `<td>
<div class="field">
<div class="control">
<input class="input" name="lotOccupantType" type="text"
value="${cityssm.escapeHTML(lotOccupantType.lotOccupantType)}"
form="${formId}"
aria-label="${los.escapedAliases.Lot} ${los.escapedAliases.Occupant} Type" maxlength="100" required />
</div>
</div>
</td><td>
<div class="field has-addons">
<div class="control">
<span class="button is-static">fa-</span>
</div>
<div class="control">
<input class="input" name="fontAwesomeIconClass" type="text"
value="${cityssm.escapeHTML(lotOccupantType.fontAwesomeIconClass)}"
form="${formId}"
list="datalist--fontAwesomeIconClass" aria-label="Icon Name" maxlength="50" />
</div>
<div class="control">
<span class="button is-static">
<i class="fas fa-fw fa-${cityssm.escapeHTML(lotOccupantType.fontAwesomeIconClass)}"></i>
</span>
</div>
</div>
</td><td>
<div class="field">
<div class="control">
<input class="input" name="occupantCommentTitle" type="text"
value="${cityssm.escapeHTML(lotOccupantType.occupantCommentTitle)}"
form="${formId}"
aria-label="${los.escapedAliases.Occupant} Comment Title" maxlength="50" />
</div>
</div>
</td><td>
<form id="${formId}">
<input name="lotOccupantTypeId" type="hidden"
value="${lotOccupantType.lotOccupantTypeId.toString()}" />
<button class="button is-success" type="submit" aria-label="Save">
<i class="fas fa-save" aria-hidden="true"></i>
</button>
</form>
</td><td class="is-nowrap">
<div class="field is-grouped">
<div class="control">
${los.getMoveUpDownButtonFieldHTML('button--moveLotOccupantTypeUp', 'button--moveLotOccupantTypeDown', false)}
</div>
<div class="control">
<button class="button is-danger is-light button--deleteLotOccupantType"
data-tooltip="Delete ${los.escapedAliases.Lot} ${los.escapedAliases.Occupant} Type"
type="button"
aria-label="Delete ${los.escapedAliases.Lot} ${los.escapedAliases.Occupant} Type">
<i class="fas fa-trash" aria-hidden="true"></i>
</button>
</div>
</div>
</td>`;
const fontAwesomeInputElement = tableRowElement.querySelector("input[name='fontAwesomeIconClass']");
fontAwesomeInputElement.addEventListener('keyup', refreshFontAwesomeIcon);
fontAwesomeInputElement.addEventListener('change', refreshFontAwesomeIcon);
tableRowElement
.querySelector('form')
.addEventListener('submit', updateLotOccupantType);
(_a = tableRowElement
.querySelector('form')) === null || _a === void 0 ? void 0 : _a.addEventListener('submit', updateLotOccupantType);
tableRowElement.querySelector('.button--moveLotOccupantTypeUp').addEventListener('click', moveLotOccupantType);
tableRowElement.querySelector('.button--moveLotOccupantTypeDown').addEventListener('click', moveLotOccupantType);
tableRowElement
.querySelector('.button--deleteLotOccupantType')
.addEventListener('click', deleteLotOccupantType);
(_b = tableRowElement
.querySelector('.button--deleteLotOccupantType')) === null || _b === void 0 ? void 0 : _b.addEventListener('click', deleteLotOccupantType);
containerElement.append(tableRowElement);
}
}
;
document.querySelector('#form--addLotOccupantType').addEventListener('submit', (submitEvent) => {
submitEvent.preventDefault();
const formElement = submitEvent.currentTarget;
cityssm.postJSON(los.urlPrefix + '/admin/doAddLotOccupantType', formElement, (rawResponseJSON) => {
var _a;
cityssm.postJSON(`${los.urlPrefix}/admin/doAddLotOccupantType`, formElement, (rawResponseJSON) => {
var _a, _b;
const responseJSON = rawResponseJSON;
if (responseJSON.success) {
lotOccupantTypes = responseJSON.lotOccupantTypes;
renderLotOccupantTypes();
formElement.reset();
formElement.querySelector('input').focus();
(_a = formElement.querySelector('input')) === null || _a === void 0 ? void 0 : _a.focus();
}
else {
bulmaJS.alert({
title: `Error Adding ${los.escapedAliases.Lot} ${los.escapedAliases.Occupant} Type`,
message: (_a = responseJSON.errorMessage) !== null && _a !== void 0 ? _a : '',
message: (_b = responseJSON.errorMessage) !== null && _b !== void 0 ? _b : '',
contextualColorName: 'danger'
});
}
Expand Down
Loading

0 comments on commit 1ca3ea0

Please sign in to comment.