From 3e15918d6d214044a98fe6b73a694edcf72567b7 Mon Sep 17 00:00:00 2001 From: Dan Gowans Date: Fri, 2 Sep 2022 09:56:40 -0400 Subject: [PATCH] formatting with prettier --- .prettierignore | 2 + .prettierrc.json | 6 + app.js | 3 +- app.ts | 148 +- cypress.config.js | 8 +- cypress.config.ts | 15 +- gulpfile.js | 12 +- gulpfile.ts | 38 +- handlers/admin-get/fees.ts | 25 +- handlers/admin-get/tables.ts | 15 +- handlers/admin-post/doAddFee.ts | 27 +- handlers/admin-post/doAddFeeCategory.ts | 27 +- handlers/admin-post/doAddLotOccupantType.ts | 17 +- handlers/admin-post/doAddLotStatus.ts | 17 +- handlers/admin-post/doAddWorkOrderType.ts | 17 +- handlers/admin-post/doDeleteFee.ts | 27 +- handlers/admin-post/doDeleteFeeCategory.ts | 32 +- .../admin-post/doDeleteLotOccupantType.ts | 22 +- handlers/admin-post/doDeleteLotStatus.ts | 17 +- handlers/admin-post/doDeleteWorkOrderType.ts | 22 +- handlers/admin-post/doMoveFeeCategoryDown.ts | 26 +- handlers/admin-post/doMoveFeeCategoryUp.ts | 26 +- handlers/admin-post/doMoveFeeDown.ts | 26 +- handlers/admin-post/doMoveFeeUp.ts | 26 +- .../admin-post/doMoveLotOccupantTypeDown.ts | 17 +- .../admin-post/doMoveLotOccupantTypeUp.ts | 17 +- handlers/admin-post/doMoveLotStatusDown.ts | 17 +- handlers/admin-post/doMoveLotStatusUp.ts | 17 +- .../admin-post/doMoveWorkOrderTypeDown.ts | 17 +- handlers/admin-post/doMoveWorkOrderTypeUp.ts | 17 +- handlers/admin-post/doUpdateFee.ts | 27 +- handlers/admin-post/doUpdateFeeCategory.ts | 27 +- .../admin-post/doUpdateLotOccupantType.ts | 17 +- handlers/admin-post/doUpdateLotStatus.ts | 17 +- handlers/admin-post/doUpdateWorkOrderType.ts | 17 +- public-typescript/adminFees.js | 292 ++- public-typescript/adminFees.ts | 801 ++++--- public-typescript/adminTables.js | 403 ++-- public-typescript/adminTables.ts | 741 ++++--- public-typescript/lotEdit.js | 94 +- public-typescript/lotEdit.ts | 211 +- public-typescript/lotOccupancyEdit.js | 708 ++++--- public-typescript/lotOccupancyEdit.ts | 1875 +++++++++++------ public-typescript/lotOccupancySearch.js | 173 +- public-typescript/lotOccupancySearch.ts | 246 ++- public-typescript/lotSearch.js | 136 +- public-typescript/lotSearch.ts | 195 +- public-typescript/lotView.ts | 13 +- public-typescript/main.js | 12 +- public-typescript/main.ts | 72 +- public-typescript/mapEdit.js | 19 +- public-typescript/mapEdit.ts | 104 +- public-typescript/mapSearch.js | 92 +- public-typescript/mapSearch.ts | 144 +- public-typescript/mapView.js | 4 +- public-typescript/mapView.ts | 28 +- public-typescript/workOrderSearch.js | 119 +- public-typescript/workOrderSearch.ts | 169 +- routes/admin.js | 2 + routes/admin.ts | 216 +- routes/dashboard.ts | 3 - routes/login.js | 28 +- routes/login.ts | 71 +- routes/lotOccupancies.ts | 125 +- routes/lots.ts | 78 +- routes/maps.ts | 53 +- routes/reports.ts | 16 +- routes/workOrders.ts | 20 +- temp/legacy.importFromCSV.js | 130 +- temp/legacy.importFromCSV.ts | 1069 ++++++---- test/1_serverCypress.js | 3 +- test/1_serverCypress.ts | 27 +- test/_globals.ts | 29 +- test/version.ts | 8 +- types/configTypes.ts | 90 +- types/globalTypes.js | 3 +- types/globalTypes.ts | 6 +- types/recordTypes.js | 3 +- types/recordTypes.ts | 377 ++-- views/_menu-admin.ejs | 6 + views/dashboard.ejs | 17 + 81 files changed, 5771 insertions(+), 4068 deletions(-) create mode 100644 .prettierignore create mode 100644 .prettierrc.json diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 00000000..7e3fea52 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,2 @@ +*.ejs +*.js \ No newline at end of file diff --git a/.prettierrc.json b/.prettierrc.json new file mode 100644 index 00000000..622ac0bf --- /dev/null +++ b/.prettierrc.json @@ -0,0 +1,6 @@ +{ + "trailingComma": "none", + "tabWidth": 4, + "semi": true, + "singleQuote": false +} diff --git a/app.js b/app.js index c91c78d7..5216c67f 100644 --- a/app.js +++ b/app.js @@ -131,7 +131,8 @@ app.use((_request, _response, next) => { }); app.use((error, request, response) => { response.locals.message = error.message; - response.locals.error = request.app.get("env") === "development" ? error : {}; + response.locals.error = + request.app.get("env") === "development" ? error : {}; response.status(error.status || 500); response.render("error"); }); diff --git a/app.ts b/app.ts index 5602aeaa..a6d00a73 100644 --- a/app.ts +++ b/app.ts @@ -24,29 +24,23 @@ import * as dateTimeFns from "@cityssm/expressjs-server-js/dateTimeFns.js"; import * as stringFns from "@cityssm/expressjs-server-js/stringFns.js"; import * as htmlFns from "@cityssm/expressjs-server-js/htmlFns.js"; -import { - version -} from "./version.js"; +import { version } from "./version.js"; import * as databaseInitializer from "./helpers/initializer.database.js"; import debug from "debug"; const debugApp = debug("lot-occupancy-system:app"); - /* * INITALIZE THE DATABASE */ - databaseInitializer.initializeDatabase(); - /* * INITIALIZE APP */ - const __dirname = "."; export const app = express(); @@ -70,15 +64,18 @@ app.use((request, _response, next) => { app.use(express.json()); -app.use(express.urlencoded({ - extended: false -})); +app.use( + express.urlencoded({ + extended: false + }) +); app.use(cookieParser()); -app.use(csurf({ - cookie: true -})); - +app.use( + csurf({ + cookie: true + }) +); /* * Rate Limiter @@ -91,12 +88,10 @@ const limiter = rateLimit({ app.use(limiter); - /* * STATIC ROUTES */ - const urlPrefix = configFunctions.getProperty("reverseProxy.urlPrefix"); if (urlPrefix !== "") { @@ -105,48 +100,59 @@ if (urlPrefix !== "") { app.use(urlPrefix, express.static(path.join("public"))); -app.use(urlPrefix + "/lib/fa", - express.static(path.join("node_modules", "@fortawesome", "fontawesome-free"))); +app.use( + urlPrefix + "/lib/fa", + express.static( + path.join("node_modules", "@fortawesome", "fontawesome-free") + ) +); -app.use(urlPrefix + "/lib/cityssm-bulma-webapp-js", - express.static(path.join("node_modules", "@cityssm", "bulma-webapp-js"))); +app.use( + urlPrefix + "/lib/cityssm-bulma-webapp-js", + express.static(path.join("node_modules", "@cityssm", "bulma-webapp-js")) +); -app.use(urlPrefix + "/lib/cityssm-bulma-js", - express.static(path.join("node_modules", "@cityssm", "bulma-js", "dist"))); - -app.use(urlPrefix + "/lib/leaflet", - express.static(path.join("node_modules", "leaflet", "dist"))); +app.use( + urlPrefix + "/lib/cityssm-bulma-js", + express.static(path.join("node_modules", "@cityssm", "bulma-js", "dist")) +); +app.use( + urlPrefix + "/lib/leaflet", + express.static(path.join("node_modules", "leaflet", "dist")) +); /* * SESSION MANAGEMENT */ -const sessionCookieName: string = configFunctions.getProperty("session.cookieName"); +const sessionCookieName: string = + configFunctions.getProperty("session.cookieName"); const FileStoreSession = FileStore(session); // Initialize session -app.use(session({ - store: new FileStoreSession({ - path: "./data/sessions", - logFn: debug("general-licence-manager:session"), - retries: 10 - }), - name: sessionCookieName, - secret: configFunctions.getProperty("session.secret"), - resave: true, - saveUninitialized: false, - rolling: true, - cookie: { - maxAge: configFunctions.getProperty("session.maxAgeMillis"), - sameSite: "strict" - } -})); +app.use( + session({ + store: new FileStoreSession({ + path: "./data/sessions", + logFn: debug("general-licence-manager:session"), + retries: 10 + }), + name: sessionCookieName, + secret: configFunctions.getProperty("session.secret"), + resave: true, + saveUninitialized: false, + rolling: true, + cookie: { + maxAge: configFunctions.getProperty("session.maxAgeMillis"), + sameSite: "strict" + } + }) +); // Clear cookie if no corresponding session app.use((request, response, next) => { - if (request.cookies[sessionCookieName] && !request.session.user) { response.clearCookie(sessionCookieName); } @@ -155,25 +161,27 @@ app.use((request, response, next) => { }); // Redirect logged in users -const sessionChecker = (request: express.Request, response: express.Response, next: express.NextFunction) => { - +const sessionChecker = ( + request: express.Request, + response: express.Response, + next: express.NextFunction +) => { if (request.session.user && request.cookies[sessionCookieName]) { return next(); } - return response.redirect(`${urlPrefix}/login?redirect=${request.originalUrl}`); + return response.redirect( + `${urlPrefix}/login?redirect=${request.originalUrl}` + ); }; - /* * ROUTES */ - // Make the user and config objects available to the templates app.use((request, response, next) => { - response.locals.buildNumber = version; response.locals.user = request.session.user; @@ -184,12 +192,13 @@ app.use((request, response, next) => { response.locals.stringFunctions = stringFns; response.locals.htmlFunctions = htmlFns; - response.locals.urlPrefix = configFunctions.getProperty("reverseProxy.urlPrefix"); + response.locals.urlPrefix = configFunctions.getProperty( + "reverseProxy.urlPrefix" + ); next(); }); - app.get(urlPrefix + "/", sessionChecker, (_request, response) => { response.redirect(urlPrefix + "/dashboard"); }); @@ -211,40 +220,41 @@ app.all(urlPrefix + "/keepAlive", (_request, response) => { app.use(urlPrefix + "/login", routerLogin); app.get(urlPrefix + "/logout", (request, response) => { - if (request.session.user && request.cookies[sessionCookieName]) { - // eslint-disable-next-line unicorn/no-null request.session.destroy(null); request.session = undefined; response.clearCookie(sessionCookieName); response.redirect(urlPrefix + "/"); - } else { response.redirect(urlPrefix + "/login"); } }); - // Catch 404 and forward to error handler app.use((_request, _response, next) => { next(createError(404)); }); // Error handler -app.use((error: { - status: number;message: string - }, - request: express.Request, response: express.Response) => { +app.use( + ( + error: { + status: number; + message: string; + }, + request: express.Request, + response: express.Response + ) => { + // Set locals, only providing error in development + response.locals.message = error.message; + response.locals.error = + request.app.get("env") === "development" ? error : {}; - // Set locals, only providing error in development - response.locals.message = error.message; - response.locals.error = request.app.get("env") === "development" ? error : {}; + // Render the error page + response.status(error.status || 500); + response.render("error"); + } +); - // Render the error page - response.status(error.status || 500); - response.render("error"); -}); - - -export default app; \ No newline at end of file +export default app; diff --git a/cypress.config.js b/cypress.config.js index 52a52c89..bc81052e 100644 --- a/cypress.config.js +++ b/cypress.config.js @@ -1,9 +1,9 @@ import { defineConfig } from "cypress"; export default defineConfig({ e2e: { - "baseUrl": "http://localhost:7000", - "specPattern": "cypress/e2e/**/*.cy.ts", - "supportFile": false, - "projectId": "xya1fn" + baseUrl: "http://localhost:7000", + specPattern: "cypress/e2e/**/*.cy.ts", + supportFile: false, + projectId: "xya1fn" } }); diff --git a/cypress.config.ts b/cypress.config.ts index 015850bf..4d91cb24 100644 --- a/cypress.config.ts +++ b/cypress.config.ts @@ -2,12 +2,11 @@ import { defineConfig } from "cypress"; - export default defineConfig({ - e2e: { - "baseUrl": "http://localhost:7000", - "specPattern": "cypress/e2e/**/*.cy.ts", - "supportFile": false, - "projectId": "xya1fn" - } -}); \ No newline at end of file + e2e: { + baseUrl: "http://localhost:7000", + specPattern: "cypress/e2e/**/*.cy.ts", + supportFile: false, + projectId: "xya1fn" + } +}); diff --git a/gulpfile.js b/gulpfile.js index 03052c3d..aa104277 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,19 +1,21 @@ import gulp from "gulp"; import changed from "gulp-changed"; import minify from "gulp-minify"; -import dartSass from 'sass'; -import gulpSass from 'gulp-sass'; +import dartSass from "sass"; +import gulpSass from "gulp-sass"; const sass = gulpSass(dartSass); const publicSCSSDestination = "public/stylesheets"; const publicSCSSFunction = () => { - return gulp.src("public-scss/*.scss") - .pipe(sass({ outputStyle: 'compressed' }).on('error', sass.logError)) + return gulp + .src("public-scss/*.scss") + .pipe(sass({ outputStyle: "compressed" }).on("error", sass.logError)) .pipe(gulp.dest(publicSCSSDestination)); }; gulp.task("public-scss", publicSCSSFunction); const publicJavascriptsDestination = "public/javascripts"; const publicJavascriptsMinFunction = () => { - return gulp.src("public-typescript/*.js", { allowEmpty: true }) + return gulp + .src("public-typescript/*.js", { allowEmpty: true }) .pipe(changed(publicJavascriptsDestination, { extension: ".min.js" })) diff --git a/gulpfile.ts b/gulpfile.ts index 3ea07d0c..4ba13fc3 100644 --- a/gulpfile.ts +++ b/gulpfile.ts @@ -4,8 +4,8 @@ import gulp from "gulp"; import changed from "gulp-changed"; import minify from "gulp-minify"; -import dartSass from 'sass'; -import gulpSass from 'gulp-sass'; +import dartSass from "sass"; +import gulpSass from "gulp-sass"; const sass = gulpSass(dartSass); /* @@ -15,10 +15,10 @@ const sass = gulpSass(dartSass); const publicSCSSDestination = "public/stylesheets"; const publicSCSSFunction = () => { - - return gulp.src("public-scss/*.scss") - .pipe(sass({outputStyle: 'compressed'}).on('error', sass.logError)) - .pipe(gulp.dest(publicSCSSDestination)); + return gulp + .src("public-scss/*.scss") + .pipe(sass({ outputStyle: "compressed" }).on("error", sass.logError)) + .pipe(gulp.dest(publicSCSSDestination)); }; gulp.task("public-scss", publicSCSSFunction); @@ -30,13 +30,15 @@ gulp.task("public-scss", publicSCSSFunction); const publicJavascriptsDestination = "public/javascripts"; const publicJavascriptsMinFunction = () => { - - return gulp.src("public-typescript/*.js", { allowEmpty: true }) - .pipe(changed(publicJavascriptsDestination, { - extension: ".min.js" - })) - .pipe(minify({ noSource: true, ext: { min: ".min.js" } })) - .pipe(gulp.dest(publicJavascriptsDestination)); + return gulp + .src("public-typescript/*.js", { allowEmpty: true }) + .pipe( + changed(publicJavascriptsDestination, { + extension: ".min.js" + }) + ) + .pipe(minify({ noSource: true, ext: { min: ".min.js" } })) + .pipe(gulp.dest(publicJavascriptsDestination)); }; gulp.task("public-javascript-min", publicJavascriptsMinFunction); @@ -46,8 +48,8 @@ gulp.task("public-javascript-min", publicJavascriptsMinFunction); */ const watchFunction = () => { - gulp.watch("public-scss/*.scss", publicSCSSFunction); - gulp.watch("public-typescript/*.js", publicJavascriptsMinFunction); + gulp.watch("public-scss/*.scss", publicSCSSFunction); + gulp.watch("public-typescript/*.js", publicJavascriptsMinFunction); }; gulp.task("watch", watchFunction); @@ -57,7 +59,7 @@ gulp.task("watch", watchFunction); */ gulp.task("default", () => { - publicJavascriptsMinFunction(); - publicSCSSFunction(); - watchFunction(); + publicJavascriptsMinFunction(); + publicSCSSFunction(); + watchFunction(); }); diff --git a/handlers/admin-get/fees.ts b/handlers/admin-get/fees.ts index 36e85284..eef189c1 100644 --- a/handlers/admin-get/fees.ts +++ b/handlers/admin-get/fees.ts @@ -1,19 +1,19 @@ -import type { - RequestHandler -} from "express"; - -import { getLotTypes, getOccupancyTypes } from "../../helpers/functions.cache.js"; +import type { RequestHandler } from "express"; import { - getFeeCategories -} from "../../helpers/lotOccupancyDB/getFeeCategories.js"; + getLotTypes, + getOccupancyTypes +} from "../../helpers/functions.cache.js"; +import { getFeeCategories } from "../../helpers/lotOccupancyDB/getFeeCategories.js"; export const handler: RequestHandler = (_request, response) => { - - const feeCategories = getFeeCategories({}, { - includeFees: true - }); + const feeCategories = getFeeCategories( + {}, + { + includeFees: true + } + ); const occupancyTypes = getOccupancyTypes(); const lotTypes = getLotTypes(); @@ -26,5 +26,4 @@ export const handler: RequestHandler = (_request, response) => { }); }; - -export default handler; \ No newline at end of file +export default handler; diff --git a/handlers/admin-get/tables.ts b/handlers/admin-get/tables.ts index 9b558dde..6b074e52 100644 --- a/handlers/admin-get/tables.ts +++ b/handlers/admin-get/tables.ts @@ -1,12 +1,12 @@ -import type { - RequestHandler -} from "express"; - -import { getLotOccupantTypes, getLotStatuses, getWorkOrderTypes } from "../../helpers/functions.cache.js"; +import type { RequestHandler } from "express"; +import { + getLotOccupantTypes, + getLotStatuses, + getWorkOrderTypes +} from "../../helpers/functions.cache.js"; export const handler: RequestHandler = (_request, response) => { - const workOrderTypes = getWorkOrderTypes(); const lotStatuses = getLotStatuses(); const lotOccupantTypes = getLotOccupantTypes(); @@ -19,5 +19,4 @@ export const handler: RequestHandler = (_request, response) => { }); }; - -export default handler; \ No newline at end of file +export default handler; diff --git a/handlers/admin-post/doAddFee.ts b/handlers/admin-post/doAddFee.ts index e104edf6..8e94e922 100644 --- a/handlers/admin-post/doAddFee.ts +++ b/handlers/admin-post/doAddFee.ts @@ -1,24 +1,18 @@ -import type { - RequestHandler -} from "express"; - -import { - addFee -} from "../../helpers/lotOccupancyDB/addFee.js"; - -import { - getFeeCategories -} from "../../helpers/lotOccupancyDB/getFeeCategories.js"; +import type { RequestHandler } from "express"; +import { addFee } from "../../helpers/lotOccupancyDB/addFee.js"; +import { getFeeCategories } from "../../helpers/lotOccupancyDB/getFeeCategories.js"; export const handler: RequestHandler = async (request, response) => { - const feeId = addFee(request.body, request.session); - const feeCategories = getFeeCategories({}, { - includeFees: true - }); + const feeCategories = getFeeCategories( + {}, + { + includeFees: true + } + ); response.json({ success: true, @@ -27,5 +21,4 @@ export const handler: RequestHandler = async (request, response) => { }); }; - -export default handler; \ No newline at end of file +export default handler; diff --git a/handlers/admin-post/doAddFeeCategory.ts b/handlers/admin-post/doAddFeeCategory.ts index d3438e82..bb80eafd 100644 --- a/handlers/admin-post/doAddFeeCategory.ts +++ b/handlers/admin-post/doAddFeeCategory.ts @@ -1,24 +1,18 @@ -import type { - RequestHandler -} from "express"; - -import { - addFeeCategory -} from "../../helpers/lotOccupancyDB/addFeeCategory.js"; - -import { - getFeeCategories -} from "../../helpers/lotOccupancyDB/getFeeCategories.js"; +import type { RequestHandler } from "express"; +import { addFeeCategory } from "../../helpers/lotOccupancyDB/addFeeCategory.js"; +import { getFeeCategories } from "../../helpers/lotOccupancyDB/getFeeCategories.js"; export const handler: RequestHandler = async (request, response) => { - const feeCategoryId = addFeeCategory(request.body, request.session); - const feeCategories = getFeeCategories({}, { - includeFees: true - }); + const feeCategories = getFeeCategories( + {}, + { + includeFees: true + } + ); response.json({ success: true, @@ -27,5 +21,4 @@ export const handler: RequestHandler = async (request, response) => { }); }; - -export default handler; \ No newline at end of file +export default handler; diff --git a/handlers/admin-post/doAddLotOccupantType.ts b/handlers/admin-post/doAddLotOccupantType.ts index b13b68f7..cc6c3ddd 100644 --- a/handlers/admin-post/doAddLotOccupantType.ts +++ b/handlers/admin-post/doAddLotOccupantType.ts @@ -1,18 +1,10 @@ -import type { - RequestHandler -} from "express"; +import type { RequestHandler } from "express"; -import { - addLotOccupantType -} from "../../helpers/lotOccupancyDB/addLotOccupantType.js"; - -import { - getLotOccupantTypes -} from "../../helpers/functions.cache.js"; +import { addLotOccupantType } from "../../helpers/lotOccupancyDB/addLotOccupantType.js"; +import { getLotOccupantTypes } from "../../helpers/functions.cache.js"; export const handler: RequestHandler = async (request, response) => { - const lotOccupantTypeId = addLotOccupantType(request.body, request.session); const lotOccupantTypes = getLotOccupantTypes(); @@ -24,5 +16,4 @@ export const handler: RequestHandler = async (request, response) => { }); }; - -export default handler; \ No newline at end of file +export default handler; diff --git a/handlers/admin-post/doAddLotStatus.ts b/handlers/admin-post/doAddLotStatus.ts index 29a3d042..e163b9cc 100644 --- a/handlers/admin-post/doAddLotStatus.ts +++ b/handlers/admin-post/doAddLotStatus.ts @@ -1,18 +1,10 @@ -import type { - RequestHandler -} from "express"; +import type { RequestHandler } from "express"; -import { - addLotStatus -} from "../../helpers/lotOccupancyDB/addLotStatus.js"; - -import { - getLotStatuses -} from "../../helpers/functions.cache.js"; +import { addLotStatus } from "../../helpers/lotOccupancyDB/addLotStatus.js"; +import { getLotStatuses } from "../../helpers/functions.cache.js"; export const handler: RequestHandler = async (request, response) => { - const lotStatusId = addLotStatus(request.body, request.session); const lotStatuses = getLotStatuses(); @@ -24,5 +16,4 @@ export const handler: RequestHandler = async (request, response) => { }); }; - -export default handler; \ No newline at end of file +export default handler; diff --git a/handlers/admin-post/doAddWorkOrderType.ts b/handlers/admin-post/doAddWorkOrderType.ts index ebbf65d0..42df698a 100644 --- a/handlers/admin-post/doAddWorkOrderType.ts +++ b/handlers/admin-post/doAddWorkOrderType.ts @@ -1,18 +1,10 @@ -import type { - RequestHandler -} from "express"; +import type { RequestHandler } from "express"; -import { - addWorkOrderType -} from "../../helpers/lotOccupancyDB/addWorkOrderType.js"; - -import { - getWorkOrderTypes -} from "../../helpers/functions.cache.js"; +import { addWorkOrderType } from "../../helpers/lotOccupancyDB/addWorkOrderType.js"; +import { getWorkOrderTypes } from "../../helpers/functions.cache.js"; export const handler: RequestHandler = async (request, response) => { - const workOrderTypeId = addWorkOrderType(request.body, request.session); const workOrderTypes = getWorkOrderTypes(); @@ -24,5 +16,4 @@ export const handler: RequestHandler = async (request, response) => { }); }; - -export default handler; \ No newline at end of file +export default handler; diff --git a/handlers/admin-post/doDeleteFee.ts b/handlers/admin-post/doDeleteFee.ts index b5ce4442..0ea9f946 100644 --- a/handlers/admin-post/doDeleteFee.ts +++ b/handlers/admin-post/doDeleteFee.ts @@ -1,24 +1,18 @@ -import type { - RequestHandler -} from "express"; - -import { - deleteFee -} from "../../helpers/lotOccupancyDB/deleteFee.js"; - -import { - getFeeCategories -} from "../../helpers/lotOccupancyDB/getFeeCategories.js"; +import type { RequestHandler } from "express"; +import { deleteFee } from "../../helpers/lotOccupancyDB/deleteFee.js"; +import { getFeeCategories } from "../../helpers/lotOccupancyDB/getFeeCategories.js"; export const handler: RequestHandler = async (request, response) => { - const success = deleteFee(request.body.feeId, request.session); - const feeCategories = getFeeCategories({}, { - includeFees: true - }); + const feeCategories = getFeeCategories( + {}, + { + includeFees: true + } + ); response.json({ success, @@ -26,5 +20,4 @@ export const handler: RequestHandler = async (request, response) => { }); }; - -export default handler; \ No newline at end of file +export default handler; diff --git a/handlers/admin-post/doDeleteFeeCategory.ts b/handlers/admin-post/doDeleteFeeCategory.ts index e82af450..592629ed 100644 --- a/handlers/admin-post/doDeleteFeeCategory.ts +++ b/handlers/admin-post/doDeleteFeeCategory.ts @@ -1,24 +1,21 @@ -import type { - RequestHandler -} from "express"; - -import { - deleteFeeCategory -} from "../../helpers/lotOccupancyDB/deleteFeeCategory.js"; - -import { - getFeeCategories -} from "../../helpers/lotOccupancyDB/getFeeCategories.js"; +import type { RequestHandler } from "express"; +import { deleteFeeCategory } from "../../helpers/lotOccupancyDB/deleteFeeCategory.js"; +import { getFeeCategories } from "../../helpers/lotOccupancyDB/getFeeCategories.js"; export const handler: RequestHandler = async (request, response) => { + const success = deleteFeeCategory( + request.body.feeCategoryId, + request.session + ); - const success = deleteFeeCategory(request.body.feeCategoryId, request.session); - - const feeCategories = getFeeCategories({}, { - includeFees: true - }); + const feeCategories = getFeeCategories( + {}, + { + includeFees: true + } + ); response.json({ success, @@ -26,5 +23,4 @@ export const handler: RequestHandler = async (request, response) => { }); }; - -export default handler; \ No newline at end of file +export default handler; diff --git a/handlers/admin-post/doDeleteLotOccupantType.ts b/handlers/admin-post/doDeleteLotOccupantType.ts index 7df6b0ad..7231c33f 100644 --- a/handlers/admin-post/doDeleteLotOccupantType.ts +++ b/handlers/admin-post/doDeleteLotOccupantType.ts @@ -1,19 +1,14 @@ -import type { - RequestHandler -} from "express"; +import type { RequestHandler } from "express"; -import { - deleteLotOccupantType -} from "../../helpers/lotOccupancyDB/deleteLotOccupantType.js"; - -import { - getLotOccupantTypes -} from "../../helpers/functions.cache.js"; +import { deleteLotOccupantType } from "../../helpers/lotOccupancyDB/deleteLotOccupantType.js"; +import { getLotOccupantTypes } from "../../helpers/functions.cache.js"; export const handler: RequestHandler = async (request, response) => { - - const success = deleteLotOccupantType(request.body.lotOccupantTypeId, request.session); + const success = deleteLotOccupantType( + request.body.lotOccupantTypeId, + request.session + ); const lotOccupantTypes = getLotOccupantTypes(); @@ -23,5 +18,4 @@ export const handler: RequestHandler = async (request, response) => { }); }; - -export default handler; \ No newline at end of file +export default handler; diff --git a/handlers/admin-post/doDeleteLotStatus.ts b/handlers/admin-post/doDeleteLotStatus.ts index ddd55799..2651119a 100644 --- a/handlers/admin-post/doDeleteLotStatus.ts +++ b/handlers/admin-post/doDeleteLotStatus.ts @@ -1,18 +1,10 @@ -import type { - RequestHandler -} from "express"; +import type { RequestHandler } from "express"; -import { - deleteLotStatus -} from "../../helpers/lotOccupancyDB/deleteLotStatus.js"; - -import { - getLotStatuses -} from "../../helpers/functions.cache.js"; +import { deleteLotStatus } from "../../helpers/lotOccupancyDB/deleteLotStatus.js"; +import { getLotStatuses } from "../../helpers/functions.cache.js"; export const handler: RequestHandler = async (request, response) => { - const success = deleteLotStatus(request.body.lotStatusId, request.session); const lotStatuses = getLotStatuses(); @@ -23,5 +15,4 @@ export const handler: RequestHandler = async (request, response) => { }); }; - -export default handler; \ No newline at end of file +export default handler; diff --git a/handlers/admin-post/doDeleteWorkOrderType.ts b/handlers/admin-post/doDeleteWorkOrderType.ts index ca5be76d..10d83de1 100644 --- a/handlers/admin-post/doDeleteWorkOrderType.ts +++ b/handlers/admin-post/doDeleteWorkOrderType.ts @@ -1,19 +1,14 @@ -import type { - RequestHandler -} from "express"; +import type { RequestHandler } from "express"; -import { - deleteWorkOrderType -} from "../../helpers/lotOccupancyDB/deleteWorkOrderType.js"; - -import { - getWorkOrderTypes -} from "../../helpers/functions.cache.js"; +import { deleteWorkOrderType } from "../../helpers/lotOccupancyDB/deleteWorkOrderType.js"; +import { getWorkOrderTypes } from "../../helpers/functions.cache.js"; export const handler: RequestHandler = async (request, response) => { - - const success = deleteWorkOrderType(request.body.workOrderTypeId, request.session); + const success = deleteWorkOrderType( + request.body.workOrderTypeId, + request.session + ); const workOrderTypes = getWorkOrderTypes(); @@ -23,5 +18,4 @@ export const handler: RequestHandler = async (request, response) => { }); }; - -export default handler; \ No newline at end of file +export default handler; diff --git a/handlers/admin-post/doMoveFeeCategoryDown.ts b/handlers/admin-post/doMoveFeeCategoryDown.ts index 3196bc1d..36d885ff 100644 --- a/handlers/admin-post/doMoveFeeCategoryDown.ts +++ b/handlers/admin-post/doMoveFeeCategoryDown.ts @@ -1,23 +1,18 @@ -import type { - RequestHandler -} from "express"; +import type { RequestHandler } from "express"; -import { - moveFeeCategoryDown -} from "../../helpers/lotOccupancyDB/moveFeeCategoryDown.js"; - -import { - getFeeCategories -} from "../../helpers/lotOccupancyDB/getFeeCategories.js"; +import { moveFeeCategoryDown } from "../../helpers/lotOccupancyDB/moveFeeCategoryDown.js"; +import { getFeeCategories } from "../../helpers/lotOccupancyDB/getFeeCategories.js"; export const handler: RequestHandler = async (request, response) => { - const success = moveFeeCategoryDown(request.body.feeCategoryId); - const feeCategories = getFeeCategories({}, { - includeFees: true - }); + const feeCategories = getFeeCategories( + {}, + { + includeFees: true + } + ); response.json({ success, @@ -25,5 +20,4 @@ export const handler: RequestHandler = async (request, response) => { }); }; - -export default handler; \ No newline at end of file +export default handler; diff --git a/handlers/admin-post/doMoveFeeCategoryUp.ts b/handlers/admin-post/doMoveFeeCategoryUp.ts index 194b4964..ab5c485e 100644 --- a/handlers/admin-post/doMoveFeeCategoryUp.ts +++ b/handlers/admin-post/doMoveFeeCategoryUp.ts @@ -1,23 +1,18 @@ -import type { - RequestHandler -} from "express"; +import type { RequestHandler } from "express"; -import { - moveFeeCategoryUp -} from "../../helpers/lotOccupancyDB/moveFeeCategoryUp.js"; - -import { - getFeeCategories -} from "../../helpers/lotOccupancyDB/getFeeCategories.js"; +import { moveFeeCategoryUp } from "../../helpers/lotOccupancyDB/moveFeeCategoryUp.js"; +import { getFeeCategories } from "../../helpers/lotOccupancyDB/getFeeCategories.js"; export const handler: RequestHandler = async (request, response) => { - const success = moveFeeCategoryUp(request.body.feeCategoryId); - const feeCategories = getFeeCategories({}, { - includeFees: true - }); + const feeCategories = getFeeCategories( + {}, + { + includeFees: true + } + ); response.json({ success, @@ -25,5 +20,4 @@ export const handler: RequestHandler = async (request, response) => { }); }; - -export default handler; \ No newline at end of file +export default handler; diff --git a/handlers/admin-post/doMoveFeeDown.ts b/handlers/admin-post/doMoveFeeDown.ts index e57252a4..d1dcb369 100644 --- a/handlers/admin-post/doMoveFeeDown.ts +++ b/handlers/admin-post/doMoveFeeDown.ts @@ -1,23 +1,18 @@ -import type { - RequestHandler -} from "express"; +import type { RequestHandler } from "express"; -import { - moveFeeDown -} from "../../helpers/lotOccupancyDB/moveFeeDown.js"; - -import { - getFeeCategories -} from "../../helpers/lotOccupancyDB/getFeeCategories.js"; +import { moveFeeDown } from "../../helpers/lotOccupancyDB/moveFeeDown.js"; +import { getFeeCategories } from "../../helpers/lotOccupancyDB/getFeeCategories.js"; export const handler: RequestHandler = async (request, response) => { - const success = moveFeeDown(request.body.feeId); - const feeCategories = getFeeCategories({}, { - includeFees: true - }); + const feeCategories = getFeeCategories( + {}, + { + includeFees: true + } + ); response.json({ success, @@ -25,5 +20,4 @@ export const handler: RequestHandler = async (request, response) => { }); }; - -export default handler; \ No newline at end of file +export default handler; diff --git a/handlers/admin-post/doMoveFeeUp.ts b/handlers/admin-post/doMoveFeeUp.ts index e1fd6f9a..4e882ec8 100644 --- a/handlers/admin-post/doMoveFeeUp.ts +++ b/handlers/admin-post/doMoveFeeUp.ts @@ -1,23 +1,18 @@ -import type { - RequestHandler -} from "express"; +import type { RequestHandler } from "express"; -import { - moveFeeUp -} from "../../helpers/lotOccupancyDB/moveFeeUp.js"; - -import { - getFeeCategories -} from "../../helpers/lotOccupancyDB/getFeeCategories.js"; +import { moveFeeUp } from "../../helpers/lotOccupancyDB/moveFeeUp.js"; +import { getFeeCategories } from "../../helpers/lotOccupancyDB/getFeeCategories.js"; export const handler: RequestHandler = async (request, response) => { - const success = moveFeeUp(request.body.feeId); - const feeCategories = getFeeCategories({}, { - includeFees: true - }); + const feeCategories = getFeeCategories( + {}, + { + includeFees: true + } + ); response.json({ success, @@ -25,5 +20,4 @@ export const handler: RequestHandler = async (request, response) => { }); }; - -export default handler; \ No newline at end of file +export default handler; diff --git a/handlers/admin-post/doMoveLotOccupantTypeDown.ts b/handlers/admin-post/doMoveLotOccupantTypeDown.ts index a2709d40..f0100cbc 100644 --- a/handlers/admin-post/doMoveLotOccupantTypeDown.ts +++ b/handlers/admin-post/doMoveLotOccupantTypeDown.ts @@ -1,18 +1,10 @@ -import type { - RequestHandler -} from "express"; +import type { RequestHandler } from "express"; -import { - moveLotOccupantTypeDown -} from "../../helpers/lotOccupancyDB/moveLotOccupantTypeDown.js"; - -import { - getLotOccupantTypes -} from "../../helpers/functions.cache.js"; +import { moveLotOccupantTypeDown } from "../../helpers/lotOccupancyDB/moveLotOccupantTypeDown.js"; +import { getLotOccupantTypes } from "../../helpers/functions.cache.js"; export const handler: RequestHandler = async (request, response) => { - const success = moveLotOccupantTypeDown(request.body.lotOccupantTypeId); const lotOccupantTypes = getLotOccupantTypes(); @@ -23,5 +15,4 @@ export const handler: RequestHandler = async (request, response) => { }); }; - -export default handler; \ No newline at end of file +export default handler; diff --git a/handlers/admin-post/doMoveLotOccupantTypeUp.ts b/handlers/admin-post/doMoveLotOccupantTypeUp.ts index 63cc2a6e..52a687f7 100644 --- a/handlers/admin-post/doMoveLotOccupantTypeUp.ts +++ b/handlers/admin-post/doMoveLotOccupantTypeUp.ts @@ -1,18 +1,10 @@ -import type { - RequestHandler -} from "express"; +import type { RequestHandler } from "express"; -import { - moveLotOccupantTypeUp -} from "../../helpers/lotOccupancyDB/moveLotOccupantTypeUp.js"; - -import { - getLotOccupantTypes -} from "../../helpers/functions.cache.js"; +import { moveLotOccupantTypeUp } from "../../helpers/lotOccupancyDB/moveLotOccupantTypeUp.js"; +import { getLotOccupantTypes } from "../../helpers/functions.cache.js"; export const handler: RequestHandler = async (request, response) => { - const success = moveLotOccupantTypeUp(request.body.lotOccupantTypeId); const lotOccupantTypes = getLotOccupantTypes(); @@ -23,5 +15,4 @@ export const handler: RequestHandler = async (request, response) => { }); }; - -export default handler; \ No newline at end of file +export default handler; diff --git a/handlers/admin-post/doMoveLotStatusDown.ts b/handlers/admin-post/doMoveLotStatusDown.ts index 19219a0d..3208eb10 100644 --- a/handlers/admin-post/doMoveLotStatusDown.ts +++ b/handlers/admin-post/doMoveLotStatusDown.ts @@ -1,18 +1,10 @@ -import type { - RequestHandler -} from "express"; +import type { RequestHandler } from "express"; -import { - moveLotStatusDown -} from "../../helpers/lotOccupancyDB/moveLotStatusDown.js"; - -import { - getLotStatuses -} from "../../helpers/functions.cache.js"; +import { moveLotStatusDown } from "../../helpers/lotOccupancyDB/moveLotStatusDown.js"; +import { getLotStatuses } from "../../helpers/functions.cache.js"; export const handler: RequestHandler = async (request, response) => { - const success = moveLotStatusDown(request.body.lotStatusId); const lotStatuses = getLotStatuses(); @@ -23,5 +15,4 @@ export const handler: RequestHandler = async (request, response) => { }); }; - -export default handler; \ No newline at end of file +export default handler; diff --git a/handlers/admin-post/doMoveLotStatusUp.ts b/handlers/admin-post/doMoveLotStatusUp.ts index 3a28f84a..6afeb108 100644 --- a/handlers/admin-post/doMoveLotStatusUp.ts +++ b/handlers/admin-post/doMoveLotStatusUp.ts @@ -1,18 +1,10 @@ -import type { - RequestHandler -} from "express"; +import type { RequestHandler } from "express"; -import { - moveLotStatusUp -} from "../../helpers/lotOccupancyDB/moveLotStatusUp.js"; - -import { - getLotStatuses -} from "../../helpers/functions.cache.js"; +import { moveLotStatusUp } from "../../helpers/lotOccupancyDB/moveLotStatusUp.js"; +import { getLotStatuses } from "../../helpers/functions.cache.js"; export const handler: RequestHandler = async (request, response) => { - const success = moveLotStatusUp(request.body.lotStatusId); const lotStatuses = getLotStatuses(); @@ -23,5 +15,4 @@ export const handler: RequestHandler = async (request, response) => { }); }; - -export default handler; \ No newline at end of file +export default handler; diff --git a/handlers/admin-post/doMoveWorkOrderTypeDown.ts b/handlers/admin-post/doMoveWorkOrderTypeDown.ts index 8b66bd41..a553269d 100644 --- a/handlers/admin-post/doMoveWorkOrderTypeDown.ts +++ b/handlers/admin-post/doMoveWorkOrderTypeDown.ts @@ -1,18 +1,10 @@ -import type { - RequestHandler -} from "express"; +import type { RequestHandler } from "express"; -import { - moveWorkOrderTypeDown -} from "../../helpers/lotOccupancyDB/moveWorkOrderTypeDown.js"; - -import { - getWorkOrderTypes -} from "../../helpers/functions.cache.js"; +import { moveWorkOrderTypeDown } from "../../helpers/lotOccupancyDB/moveWorkOrderTypeDown.js"; +import { getWorkOrderTypes } from "../../helpers/functions.cache.js"; export const handler: RequestHandler = async (request, response) => { - const success = moveWorkOrderTypeDown(request.body.workOrderTypeId); const workOrderTypes = getWorkOrderTypes(); @@ -23,5 +15,4 @@ export const handler: RequestHandler = async (request, response) => { }); }; - -export default handler; \ No newline at end of file +export default handler; diff --git a/handlers/admin-post/doMoveWorkOrderTypeUp.ts b/handlers/admin-post/doMoveWorkOrderTypeUp.ts index 428e2531..5826a907 100644 --- a/handlers/admin-post/doMoveWorkOrderTypeUp.ts +++ b/handlers/admin-post/doMoveWorkOrderTypeUp.ts @@ -1,18 +1,10 @@ -import type { - RequestHandler -} from "express"; +import type { RequestHandler } from "express"; -import { - moveWorkOrderTypeUp -} from "../../helpers/lotOccupancyDB/moveWorkOrderTypeUp.js"; - -import { - getWorkOrderTypes -} from "../../helpers/functions.cache.js"; +import { moveWorkOrderTypeUp } from "../../helpers/lotOccupancyDB/moveWorkOrderTypeUp.js"; +import { getWorkOrderTypes } from "../../helpers/functions.cache.js"; export const handler: RequestHandler = async (request, response) => { - const success = moveWorkOrderTypeUp(request.body.workOrderTypeId); const workOrderTypes = getWorkOrderTypes(); @@ -23,5 +15,4 @@ export const handler: RequestHandler = async (request, response) => { }); }; - -export default handler; \ No newline at end of file +export default handler; diff --git a/handlers/admin-post/doUpdateFee.ts b/handlers/admin-post/doUpdateFee.ts index a91bbb1e..1d3a3074 100644 --- a/handlers/admin-post/doUpdateFee.ts +++ b/handlers/admin-post/doUpdateFee.ts @@ -1,24 +1,18 @@ -import type { - RequestHandler -} from "express"; - -import { - updateFee -} from "../../helpers/lotOccupancyDB/updateFee.js"; - -import { - getFeeCategories -} from "../../helpers/lotOccupancyDB/getFeeCategories.js"; +import type { RequestHandler } from "express"; +import { updateFee } from "../../helpers/lotOccupancyDB/updateFee.js"; +import { getFeeCategories } from "../../helpers/lotOccupancyDB/getFeeCategories.js"; export const handler: RequestHandler = async (request, response) => { - const success = updateFee(request.body, request.session); - const feeCategories = getFeeCategories({}, { - includeFees: true - }); + const feeCategories = getFeeCategories( + {}, + { + includeFees: true + } + ); response.json({ success, @@ -26,5 +20,4 @@ export const handler: RequestHandler = async (request, response) => { }); }; - -export default handler; \ No newline at end of file +export default handler; diff --git a/handlers/admin-post/doUpdateFeeCategory.ts b/handlers/admin-post/doUpdateFeeCategory.ts index 52f9ba53..b95ff2e3 100644 --- a/handlers/admin-post/doUpdateFeeCategory.ts +++ b/handlers/admin-post/doUpdateFeeCategory.ts @@ -1,24 +1,18 @@ -import type { - RequestHandler -} from "express"; - -import { - updateFeeCategory -} from "../../helpers/lotOccupancyDB/updateFeeCategory.js"; - -import { - getFeeCategories -} from "../../helpers/lotOccupancyDB/getFeeCategories.js"; +import type { RequestHandler } from "express"; +import { updateFeeCategory } from "../../helpers/lotOccupancyDB/updateFeeCategory.js"; +import { getFeeCategories } from "../../helpers/lotOccupancyDB/getFeeCategories.js"; export const handler: RequestHandler = async (request, response) => { - const success = updateFeeCategory(request.body, request.session); - const feeCategories = getFeeCategories({}, { - includeFees: true - }); + const feeCategories = getFeeCategories( + {}, + { + includeFees: true + } + ); response.json({ success, @@ -26,5 +20,4 @@ export const handler: RequestHandler = async (request, response) => { }); }; - -export default handler; \ No newline at end of file +export default handler; diff --git a/handlers/admin-post/doUpdateLotOccupantType.ts b/handlers/admin-post/doUpdateLotOccupantType.ts index b103cc20..0144f562 100644 --- a/handlers/admin-post/doUpdateLotOccupantType.ts +++ b/handlers/admin-post/doUpdateLotOccupantType.ts @@ -1,18 +1,10 @@ -import type { - RequestHandler -} from "express"; +import type { RequestHandler } from "express"; -import { - updateLotOccupantType -} from "../../helpers/lotOccupancyDB/updateLotOccupantType.js"; - -import { - getLotOccupantTypes -} from "../../helpers/functions.cache.js"; +import { updateLotOccupantType } from "../../helpers/lotOccupancyDB/updateLotOccupantType.js"; +import { getLotOccupantTypes } from "../../helpers/functions.cache.js"; export const handler: RequestHandler = async (request, response) => { - const success = updateLotOccupantType(request.body, request.session); const lotOccupantTypes = getLotOccupantTypes(); @@ -23,5 +15,4 @@ export const handler: RequestHandler = async (request, response) => { }); }; - -export default handler; \ No newline at end of file +export default handler; diff --git a/handlers/admin-post/doUpdateLotStatus.ts b/handlers/admin-post/doUpdateLotStatus.ts index c4046989..a2bf1515 100644 --- a/handlers/admin-post/doUpdateLotStatus.ts +++ b/handlers/admin-post/doUpdateLotStatus.ts @@ -1,18 +1,10 @@ -import type { - RequestHandler -} from "express"; +import type { RequestHandler } from "express"; -import { - updateLotStatus -} from "../../helpers/lotOccupancyDB/updateLotStatus.js"; - -import { - getLotStatuses -} from "../../helpers/functions.cache.js"; +import { updateLotStatus } from "../../helpers/lotOccupancyDB/updateLotStatus.js"; +import { getLotStatuses } from "../../helpers/functions.cache.js"; export const handler: RequestHandler = async (request, response) => { - const success = updateLotStatus(request.body, request.session); const lotStatuses = getLotStatuses(); @@ -23,5 +15,4 @@ export const handler: RequestHandler = async (request, response) => { }); }; - -export default handler; \ No newline at end of file +export default handler; diff --git a/handlers/admin-post/doUpdateWorkOrderType.ts b/handlers/admin-post/doUpdateWorkOrderType.ts index f5cff47a..e43646d8 100644 --- a/handlers/admin-post/doUpdateWorkOrderType.ts +++ b/handlers/admin-post/doUpdateWorkOrderType.ts @@ -1,18 +1,10 @@ -import type { - RequestHandler -} from "express"; +import type { RequestHandler } from "express"; -import { - updateWorkOrderType -} from "../../helpers/lotOccupancyDB/updateWorkOrderType.js"; - -import { - getWorkOrderTypes -} from "../../helpers/functions.cache.js"; +import { updateWorkOrderType } from "../../helpers/lotOccupancyDB/updateWorkOrderType.js"; +import { getWorkOrderTypes } from "../../helpers/functions.cache.js"; export const handler: RequestHandler = async (request, response) => { - const success = updateWorkOrderType(request.body, request.session); const workOrderTypes = getWorkOrderTypes(); @@ -23,5 +15,4 @@ export const handler: RequestHandler = async (request, response) => { }); }; - -export default handler; \ No newline at end of file +export default handler; diff --git a/public-typescript/adminFees.js b/public-typescript/adminFees.js index 84daa4b4..97bbc899 100644 --- a/public-typescript/adminFees.js +++ b/public-typescript/adminFees.js @@ -8,53 +8,58 @@ Object.defineProperty(exports, "__esModule", { value: true }); delete exports.feeCategories; const renderFeeCategories = () => { if (feeCategories.length === 0) { - feeCategoriesContainerElement.innerHTML = "
" + - "

There are no available fees.

" + - "
"; + feeCategoriesContainerElement.innerHTML = + '
' + + '

There are no available fees.

' + + "
"; return; } feeCategoriesContainerElement.innerHTML = ""; for (const feeCategory of feeCategories) { const feeCategoryContainerElement = document.createElement("section"); - feeCategoryContainerElement.className = "container--feeCategory mb-5"; - feeCategoryContainerElement.dataset.feeCategoryId = feeCategory.feeCategoryId.toString(); - feeCategoryContainerElement.insertAdjacentHTML("beforeend", "
" + - ("
" + - "
" + - "

" + cityssm.escapeHTML(feeCategory.feeCategory) + "

" + + feeCategoryContainerElement.className = + "container--feeCategory mb-5"; + feeCategoryContainerElement.dataset.feeCategoryId = + feeCategory.feeCategoryId.toString(); + feeCategoryContainerElement.insertAdjacentHTML("beforeend", '
' + + ('
' + + '
' + + '

' + + cityssm.escapeHTML(feeCategory.feeCategory) + + "

" + "
" + "
") + - ("
" + - (feeCategory.fees.length === 0 ? - "
" + - "" + - "
" : - "") + - ("
" + - "
" + : "") + + ('
' + + '" + "
") + - ("
" + - "" + "
") + - ("
" + - "
" + - "
" + - "" + "
" + - "
" + - "" + "
" + "
" + @@ -62,8 +67,10 @@ Object.defineProperty(exports, "__esModule", { value: true }); "
") + "
"); if (feeCategory.fees.length === 0) { - feeCategoryContainerElement.insertAdjacentHTML("beforeend", "
" + - "

There are no fees in the \"" + cityssm.escapeHTML(feeCategory.feeCategory) + "\" category.

" + + feeCategoryContainerElement.insertAdjacentHTML("beforeend", '
' + + '

There are no fees in the "' + + cityssm.escapeHTML(feeCategory.feeCategory) + + '" category.

' + "
"); } else { @@ -71,85 +78,116 @@ Object.defineProperty(exports, "__esModule", { value: true }); panelElement.className = "panel"; for (const fee of feeCategory.fees) { const panelBlockElement = document.createElement("div"); - panelBlockElement.className = "panel-block is-block container--fee"; + panelBlockElement.className = + "panel-block is-block container--fee"; panelBlockElement.dataset.feeId = fee.feeId.toString(); - panelBlockElement.innerHTML = "
" + - ("
" + - "

" + - "" + cityssm.escapeHTML(fee.feeName) + "
" + - "" + cityssm.escapeHTML(fee.feeDescription).replace(/\n/g, "
") + "
" + - "

" + - "

" + - (fee.isRequired ? - "Required" : - "") + - (fee.occupancyTypeId ? - " " + - cityssm.escapeHTML(fee.occupancyType) + "" : - "") + - (fee.lotTypeId ? - " " + - cityssm.escapeHTML(fee.lotType) + "" : - "") + - "

" + - "
") + - ("
" + - (fee.feeFunction ? - cityssm.escapeHTML(fee.feeFunction) + "
" + - "Fee Function" : - "$" + fee.feeAmount.toFixed(2) + "
" + - "Fee") + - "
") + - ("
" + - (fee.taxPercentage ? - fee.taxPercentage + "%" : - "$" + fee.taxAmount.toFixed(2)) + - "
Tax" + - "
") + - ("
" + - (fee.includeQuantity ? - cityssm.escapeHTML(fee.quantityUnit) + "
" + - "Quantity" : - "") + - "
") + - ("
" + - "
" + - "
" + - "" + - "
" + - "
" + - "" + - "
" + - "
" + - "
") + - "
"; - panelBlockElement.querySelector("a").addEventListener("click", openEditFee); - panelBlockElement.querySelector(".button--moveFeeUp").addEventListener("click", moveFeeUp); - panelBlockElement.querySelector(".button--moveFeeDown").addEventListener("click", moveFeeDown); + panelBlockElement.innerHTML = + '
' + + ('
' + + "

" + + '' + + cityssm.escapeHTML(fee.feeName) + + "
" + + "" + + cityssm + .escapeHTML(fee.feeDescription) + .replace(/\n/g, "
") + + "
" + + "

" + + '

' + + (fee.isRequired + ? 'Required' + : "") + + (fee.occupancyTypeId + ? ' ' + + cityssm.escapeHTML(fee.occupancyType) + + "" + : "") + + (fee.lotTypeId + ? ' ' + + cityssm.escapeHTML(fee.lotType) + + "" + : "") + + "

" + + "
") + + ('
' + + (fee.feeFunction + ? cityssm.escapeHTML(fee.feeFunction) + + "
" + + "Fee Function" + : "$" + + fee.feeAmount.toFixed(2) + + "
" + + "Fee") + + "
") + + ('
' + + (fee.taxPercentage + ? fee.taxPercentage + "%" + : "$" + fee.taxAmount.toFixed(2)) + + "
Tax" + + "
") + + ('
' + + (fee.includeQuantity + ? cityssm.escapeHTML(fee.quantityUnit) + + "
" + + "Quantity" + : "") + + "
") + + ('
' + + '
' + + '
' + + '" + + "
" + + '
' + + '" + + "
" + + "
" + + "
") + + "
"; + panelBlockElement + .querySelector("a") + .addEventListener("click", openEditFee); + panelBlockElement + .querySelector(".button--moveFeeUp") + .addEventListener("click", moveFeeUp); + panelBlockElement + .querySelector(".button--moveFeeDown") + .addEventListener("click", moveFeeDown); panelElement.append(panelBlockElement); } feeCategoryContainerElement.append(panelElement); } if (feeCategory.fees.length === 0) { - feeCategoryContainerElement.querySelector(".button--deleteFeeCategory") + feeCategoryContainerElement + .querySelector(".button--deleteFeeCategory") .addEventListener("click", confirmDeleteFeeCategory); } - feeCategoryContainerElement.querySelector(".button--editFeeCategory") + feeCategoryContainerElement + .querySelector(".button--editFeeCategory") .addEventListener("click", openEditFeeCategory); - feeCategoryContainerElement.querySelector(".button--addFee") + feeCategoryContainerElement + .querySelector(".button--addFee") .addEventListener("click", openAddFee); - feeCategoryContainerElement.querySelector(".button--moveFeeCategoryUp") + feeCategoryContainerElement + .querySelector(".button--moveFeeCategoryUp") .addEventListener("click", moveFeeCategoryUp); - feeCategoryContainerElement.querySelector(".button--moveFeeCategoryDown") + feeCategoryContainerElement + .querySelector(".button--moveFeeCategoryDown") .addEventListener("click", moveFeeCategoryDown); feeCategoriesContainerElement.append(feeCategoryContainerElement); } }; - document.querySelector("#button--addFeeCategory").addEventListener("click", () => { + document + .querySelector("#button--addFeeCategory") + .addEventListener("click", () => { let addCloseModalFunction; const doAddFeeCategory = (submitEvent) => { submitEvent.preventDefault(); @@ -173,7 +211,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); bulmaJS.toggleHtmlClipped(); modalElement.querySelector("#feeCategoryAdd--feeCategory").focus(); addCloseModalFunction = closeModalFunction; - modalElement.querySelector("form").addEventListener("submit", doAddFeeCategory); + modalElement + .querySelector("form") + .addEventListener("submit", doAddFeeCategory); }, onremoved: () => { bulmaJS.toggleHtmlClipped(); @@ -211,7 +251,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); onshown: (modalElement, closeModalFunction) => { bulmaJS.toggleHtmlClipped(); editCloseModalFunction = closeModalFunction; - modalElement.querySelector("form").addEventListener("submit", doUpdateFeeCategory); + modalElement + .querySelector("form") + .addEventListener("submit", doUpdateFeeCategory); modalElement.querySelector("#feeCategoryEdit--feeCategory").focus(); }, onremoved: () => { @@ -319,7 +361,8 @@ Object.defineProperty(exports, "__esModule", { value: true }); const occupancyTypeElement = modalElement.querySelector("#feeAdd--occupancyTypeId"); for (const occupancyType of exports.occupancyTypes) { const optionElement = document.createElement("option"); - optionElement.value = occupancyType.occupancyTypeId.toString(); + optionElement.value = + occupancyType.occupancyTypeId.toString(); optionElement.textContent = occupancyType.occupancyType; occupancyTypeElement.append(optionElement); } @@ -336,23 +379,33 @@ Object.defineProperty(exports, "__esModule", { value: true }); onshown: (modalElement, closeModalFunction) => { bulmaJS.toggleHtmlClipped(); addCloseModalFunction = closeModalFunction; - modalElement.querySelector("form").addEventListener("submit", doAddFee); + modalElement + .querySelector("form") + .addEventListener("submit", doAddFee); modalElement.querySelector("#feeAdd--feeName").focus(); - modalElement.querySelector("#feeAdd--feeFunction").addEventListener("change", () => { + modalElement + .querySelector("#feeAdd--feeFunction") + .addEventListener("change", () => { const feeAmountElement = modalElement.querySelector("#feeAdd--feeAmount"); const feeFunctionElement = modalElement.querySelector("#feeAdd--feeFunction"); if (feeFunctionElement.value === "") { - feeFunctionElement.closest(".select").classList.remove("is-success"); + feeFunctionElement + .closest(".select") + .classList.remove("is-success"); feeAmountElement.classList.add("is-success"); feeAmountElement.disabled = false; } else { - feeFunctionElement.closest(".select").classList.add("is-success"); + feeFunctionElement + .closest(".select") + .classList.add("is-success"); feeAmountElement.classList.remove("is-success"); feeAmountElement.disabled = true; } }); - modalElement.querySelector("#feeAdd--taxPercentage").addEventListener("keyup", () => { + modalElement + .querySelector("#feeAdd--taxPercentage") + .addEventListener("keyup", () => { const taxAmountElement = modalElement.querySelector("#feeAdd--taxAmount"); const taxPercentageElement = modalElement.querySelector("#feeAdd--taxPercentage"); if (taxPercentageElement.value === "") { @@ -366,7 +419,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); taxAmountElement.disabled = true; } }); - modalElement.querySelector("#feeAdd--includeQuantity").addEventListener("change", () => { + modalElement + .querySelector("#feeAdd--includeQuantity") + .addEventListener("change", () => { modalElement.querySelector("#feeAdd--quantityUnit").disabled = modalElement.querySelector("#feeAdd--includeQuantity").value === ""; }); @@ -440,12 +495,16 @@ Object.defineProperty(exports, "__esModule", { value: true }); const feeAmountElement = editModalElement.querySelector("#feeEdit--feeAmount"); const feeFunctionElement = editModalElement.querySelector("#feeEdit--feeFunction"); if (feeFunctionElement.value === "") { - feeFunctionElement.closest(".select").classList.remove("is-success"); + feeFunctionElement + .closest(".select") + .classList.remove("is-success"); feeAmountElement.classList.add("is-success"); feeAmountElement.disabled = false; } else { - feeFunctionElement.closest(".select").classList.add("is-success"); + feeFunctionElement + .closest(".select") + .classList.add("is-success"); feeAmountElement.classList.remove("is-success"); feeAmountElement.disabled = true; } @@ -487,7 +546,8 @@ Object.defineProperty(exports, "__esModule", { value: true }); const occupancyTypeElement = modalElement.querySelector("#feeEdit--occupancyTypeId"); for (const occupancyType of exports.occupancyTypes) { const optionElement = document.createElement("option"); - optionElement.value = occupancyType.occupancyTypeId.toString(); + optionElement.value = + occupancyType.occupancyTypeId.toString(); optionElement.textContent = occupancyType.occupancyType; if (occupancyType.occupancyTypeId === fee.occupancyTypeId) { optionElement.selected = true; @@ -505,11 +565,15 @@ Object.defineProperty(exports, "__esModule", { value: true }); lotTypeElement.append(optionElement); } modalElement.querySelector("#feeEdit--feeAmount").value = fee.feeAmount ? fee.feeAmount.toFixed(2) : ""; - modalElement.querySelector("#feeEdit--feeFunction").addEventListener("change", toggleFeeFields); + modalElement + .querySelector("#feeEdit--feeFunction") + .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.value = fee.taxPercentage + ? fee.taxPercentage.toString() + : ""; taxPercentageElement.addEventListener("keyup", toggleTaxFields); toggleTaxFields(); const includeQuantityElement = modalElement.querySelector("#feeEdit--includeQuantity"); @@ -527,9 +591,13 @@ Object.defineProperty(exports, "__esModule", { value: true }); onshown: (modalElement, closeModalFunction) => { bulmaJS.toggleHtmlClipped(); editCloseModalFunction = closeModalFunction; - modalElement.querySelector("form").addEventListener("submit", doUpdateFee); + modalElement + .querySelector("form") + .addEventListener("submit", doUpdateFee); bulmaJS.init(modalElement); - modalElement.querySelector(".button--deleteFee").addEventListener("click", confirmDeleteFee); + modalElement + .querySelector(".button--deleteFee") + .addEventListener("click", confirmDeleteFee); }, onremoved: () => { bulmaJS.toggleHtmlClipped(); diff --git a/public-typescript/adminFees.ts b/public-typescript/adminFees.ts index b67a4d5a..3823ed8c 100644 --- a/public-typescript/adminFees.ts +++ b/public-typescript/adminFees.ts @@ -3,33 +3,30 @@ import type * as globalTypes from "../types/globalTypes"; import type * as recordTypes from "../types/recordTypes"; -import type { - cityssmGlobal -} from "@cityssm/bulma-webapp-js/src/types"; +import type { cityssmGlobal } from "@cityssm/bulma-webapp-js/src/types"; -import type { - BulmaJS -} from "@cityssm/bulma-js/types"; +import type { BulmaJS } from "@cityssm/bulma-js/types"; declare const cityssm: cityssmGlobal; declare const bulmaJS: BulmaJS; - (() => { - const los = (exports.los as globalTypes.LOS); + const los = exports.los as globalTypes.LOS; const urlPrefix = document.querySelector("main").dataset.urlPrefix; - const feeCategoriesContainerElement = document.querySelector("#container--feeCategories") as HTMLElement; + const feeCategoriesContainerElement = document.querySelector( + "#container--feeCategories" + ) as HTMLElement; let feeCategories: recordTypes.FeeCategory[] = exports.feeCategories; delete exports.feeCategories; const renderFeeCategories = () => { - if (feeCategories.length === 0) { - feeCategoriesContainerElement.innerHTML = "
" + - "

There are no available fees.

" + + feeCategoriesContainerElement.innerHTML = + '
' + + '

There are no available fees.

' + "
"; return; @@ -38,131 +35,165 @@ declare const bulmaJS: BulmaJS; feeCategoriesContainerElement.innerHTML = ""; for (const feeCategory of feeCategories) { + const feeCategoryContainerElement = + document.createElement("section"); + feeCategoryContainerElement.className = + "container--feeCategory mb-5"; + feeCategoryContainerElement.dataset.feeCategoryId = + feeCategory.feeCategoryId.toString(); - const feeCategoryContainerElement = document.createElement("section"); - feeCategoryContainerElement.className = "container--feeCategory mb-5"; - feeCategoryContainerElement.dataset.feeCategoryId = feeCategory.feeCategoryId.toString(); - - feeCategoryContainerElement.insertAdjacentHTML("beforeend", - "
" + - ("
" + - "
" + - "

" + cityssm.escapeHTML(feeCategory.feeCategory) + "

" + - "
" + - "
") + - ("
" + - (feeCategory.fees.length === 0 ? - "
" + - "" + - "
" : - "") + - ("
" + - "" + - "
") + - ("
" + - "" + - "
") + - ("
" + - "
" + - "
" + - "" + - "
" + - "
" + - "" + - "
" + + feeCategoryContainerElement.insertAdjacentHTML( + "beforeend", + '
' + + ('
' + + '
' + + '

' + + cityssm.escapeHTML(feeCategory.feeCategory) + + "

" + "
" + "
") + - "
") + - "
"); + ('
' + + (feeCategory.fees.length === 0 + ? '
' + + '" + + "
" + : "") + + ('
' + + '" + + "
") + + ('
' + + '" + + "
") + + ('
' + + '
' + + '
' + + '" + + "
" + + '
' + + '" + + "
" + + "
" + + "
") + + "
") + + "
" + ); if (feeCategory.fees.length === 0) { - feeCategoryContainerElement.insertAdjacentHTML("beforeend", - "
" + - "

There are no fees in the \"" + cityssm.escapeHTML(feeCategory.feeCategory) + "\" category.

" + - "
"); + feeCategoryContainerElement.insertAdjacentHTML( + "beforeend", + '
' + + '

There are no fees in the "' + + cityssm.escapeHTML(feeCategory.feeCategory) + + '" category.

' + + "
" + ); } else { - const panelElement = document.createElement("div"); panelElement.className = "panel"; for (const fee of feeCategory.fees) { - const panelBlockElement = document.createElement("div"); - panelBlockElement.className = "panel-block is-block container--fee"; + panelBlockElement.className = + "panel-block is-block container--fee"; panelBlockElement.dataset.feeId = fee.feeId.toString(); - panelBlockElement.innerHTML = "
" + - ("
" + + panelBlockElement.innerHTML = + '
' + + ('
' + "

" + - "" + cityssm.escapeHTML(fee.feeName) + "
" + - "" + cityssm.escapeHTML(fee.feeDescription).replace(/\n/g, "
") + "
" + + '' + + cityssm.escapeHTML(fee.feeName) + + "
" + + "" + + cityssm + .escapeHTML(fee.feeDescription) + .replace(/\n/g, "
") + + "
" + "

" + - "

" + - (fee.isRequired ? - "Required" : - "") + - (fee.occupancyTypeId ? - " " + - cityssm.escapeHTML(fee.occupancyType) + "" : - "") + - (fee.lotTypeId ? - " " + - cityssm.escapeHTML(fee.lotType) + "" : - "") + + '

' + + (fee.isRequired + ? 'Required' + : "") + + (fee.occupancyTypeId + ? ' ' + + cityssm.escapeHTML(fee.occupancyType) + + "" + : "") + + (fee.lotTypeId + ? ' ' + + cityssm.escapeHTML(fee.lotType) + + "" + : "") + "

" + "
") + - ("
" + - (fee.feeFunction ? - cityssm.escapeHTML(fee.feeFunction) + "
" + - "Fee Function" : - "$" + fee.feeAmount.toFixed(2) + "
" + - "Fee") + + ('
' + + (fee.feeFunction + ? cityssm.escapeHTML(fee.feeFunction) + + "
" + + "Fee Function" + : "$" + + fee.feeAmount.toFixed(2) + + "
" + + "Fee") + "
") + - ("
" + - (fee.taxPercentage ? - fee.taxPercentage + "%" : - "$" + fee.taxAmount.toFixed(2)) + + ('
' + + (fee.taxPercentage + ? fee.taxPercentage + "%" + : "$" + fee.taxAmount.toFixed(2)) + "
Tax" + "
") + - ("
" + - (fee.includeQuantity ? - cityssm.escapeHTML(fee.quantityUnit) + "
" + - "Quantity" : - "") + + ('
' + + (fee.includeQuantity + ? cityssm.escapeHTML(fee.quantityUnit) + + "
" + + "Quantity" + : "") + "
") + - ("
" + - "
" + - "
" + - "" + "
" + - "
" + - "" + "
" + "
" + "
") + "
"; - panelBlockElement.querySelector("a").addEventListener("click", openEditFee); + panelBlockElement + .querySelector("a") + .addEventListener("click", openEditFee); - panelBlockElement.querySelector(".button--moveFeeUp").addEventListener("click", moveFeeUp); - panelBlockElement.querySelector(".button--moveFeeDown").addEventListener("click", moveFeeDown); + panelBlockElement + .querySelector(".button--moveFeeUp") + .addEventListener("click", moveFeeUp); + panelBlockElement + .querySelector(".button--moveFeeDown") + .addEventListener("click", moveFeeDown); panelElement.append(panelBlockElement); } @@ -171,76 +202,95 @@ declare const bulmaJS: BulmaJS; } if (feeCategory.fees.length === 0) { - feeCategoryContainerElement.querySelector(".button--deleteFeeCategory") + feeCategoryContainerElement + .querySelector(".button--deleteFeeCategory") .addEventListener("click", confirmDeleteFeeCategory); } - feeCategoryContainerElement.querySelector(".button--editFeeCategory") + feeCategoryContainerElement + .querySelector(".button--editFeeCategory") .addEventListener("click", openEditFeeCategory); - feeCategoryContainerElement.querySelector(".button--addFee") + feeCategoryContainerElement + .querySelector(".button--addFee") .addEventListener("click", openAddFee); - feeCategoryContainerElement.querySelector(".button--moveFeeCategoryUp") + feeCategoryContainerElement + .querySelector(".button--moveFeeCategoryUp") .addEventListener("click", moveFeeCategoryUp); - feeCategoryContainerElement.querySelector(".button--moveFeeCategoryDown") + feeCategoryContainerElement + .querySelector(".button--moveFeeCategoryDown") .addEventListener("click", moveFeeCategoryDown); feeCategoriesContainerElement.append(feeCategoryContainerElement); } }; - /* * Fee Categories */ - document.querySelector("#button--addFeeCategory").addEventListener("click", () => { + document + .querySelector("#button--addFeeCategory") + .addEventListener("click", () => { + let addCloseModalFunction: () => void; - let addCloseModalFunction: () => void; + const doAddFeeCategory = (submitEvent: SubmitEvent) => { + submitEvent.preventDefault(); - const doAddFeeCategory = (submitEvent: SubmitEvent) => { - submitEvent.preventDefault(); - - cityssm.postJSON(urlPrefix + "/admin/doAddFeeCategory", - submitEvent.currentTarget, - (responseJSON: { - success: boolean;errorMessage ? : string;feeCategories: recordTypes.FeeCategory[]; - }) => { - - if (responseJSON.success) { - feeCategories = responseJSON.feeCategories; - addCloseModalFunction(); - renderFeeCategories(); - } else { - bulmaJS.alert({ - title: "Error Creating Fee Category", - message: responseJSON.errorMessage, - contextualColorName: "danger" - }); + cityssm.postJSON( + urlPrefix + "/admin/doAddFeeCategory", + submitEvent.currentTarget, + (responseJSON: { + success: boolean; + errorMessage?: string; + feeCategories: recordTypes.FeeCategory[]; + }) => { + if (responseJSON.success) { + feeCategories = responseJSON.feeCategories; + addCloseModalFunction(); + renderFeeCategories(); + } else { + bulmaJS.alert({ + title: "Error Creating Fee Category", + message: responseJSON.errorMessage, + contextualColorName: "danger" + }); + } } - }); - }; + ); + }; - cityssm.openHtmlModal("adminFees-addFeeCategory", { + cityssm.openHtmlModal("adminFees-addFeeCategory", { + onshown: (modalElement, closeModalFunction) => { + bulmaJS.toggleHtmlClipped(); + ( + modalElement.querySelector( + "#feeCategoryAdd--feeCategory" + ) as HTMLInputElement + ).focus(); - onshown: (modalElement, closeModalFunction) => { - bulmaJS.toggleHtmlClipped(); - (modalElement.querySelector("#feeCategoryAdd--feeCategory") as HTMLInputElement).focus(); - - addCloseModalFunction = closeModalFunction; - modalElement.querySelector("form").addEventListener("submit", doAddFeeCategory); - }, - onremoved: () => { - bulmaJS.toggleHtmlClipped(); - } + addCloseModalFunction = closeModalFunction; + modalElement + .querySelector("form") + .addEventListener("submit", doAddFeeCategory); + }, + onremoved: () => { + bulmaJS.toggleHtmlClipped(); + } + }); }); - }); const openEditFeeCategory = (clickEvent: Event) => { - - const feeCategoryId = Number.parseInt(((clickEvent.currentTarget as HTMLElement).closest(".container--feeCategory") as HTMLElement).dataset.feeCategoryId, 10); + const feeCategoryId = Number.parseInt( + ( + (clickEvent.currentTarget as HTMLElement).closest( + ".container--feeCategory" + ) as HTMLElement + ).dataset.feeCategoryId, + 10 + ); const feeCategory = feeCategories.find((currentFeeCategory) => { return currentFeeCategory.feeCategoryId === feeCategoryId; @@ -251,14 +301,14 @@ declare const bulmaJS: BulmaJS; const doUpdateFeeCategory = (submitEvent: SubmitEvent) => { submitEvent.preventDefault(); - cityssm.postJSON(urlPrefix + "/admin/doUpdateFeeCategory", + cityssm.postJSON( + urlPrefix + "/admin/doUpdateFeeCategory", submitEvent.currentTarget, (responseJSON: { success: boolean; - errorMessage ? : string; + errorMessage?: string; feeCategories: recordTypes.FeeCategory[]; }) => { - if (responseJSON.success) { feeCategories = responseJSON.feeCategories; editCloseModalFunction(); @@ -270,22 +320,37 @@ declare const bulmaJS: BulmaJS; contextualColorName: "danger" }); } - }); - } + } + ); + }; cityssm.openHtmlModal("adminFees-editFeeCategory", { onshow: (modalElement) => { - (modalElement.querySelector("#feeCategoryEdit--feeCategoryId") as HTMLInputElement).value = feeCategory.feeCategoryId.toString(); - (modalElement.querySelector("#feeCategoryEdit--feeCategory") as HTMLInputElement).value = feeCategory.feeCategory; + ( + modalElement.querySelector( + "#feeCategoryEdit--feeCategoryId" + ) as HTMLInputElement + ).value = feeCategory.feeCategoryId.toString(); + ( + modalElement.querySelector( + "#feeCategoryEdit--feeCategory" + ) as HTMLInputElement + ).value = feeCategory.feeCategory; }, onshown: (modalElement, closeModalFunction) => { bulmaJS.toggleHtmlClipped(); editCloseModalFunction = closeModalFunction; - modalElement.querySelector("form").addEventListener("submit", doUpdateFeeCategory); + modalElement + .querySelector("form") + .addEventListener("submit", doUpdateFeeCategory); - (modalElement.querySelector("#feeCategoryEdit--feeCategory") as HTMLInputElement).focus(); + ( + modalElement.querySelector( + "#feeCategoryEdit--feeCategory" + ) as HTMLInputElement + ).focus(); }, onremoved: () => { bulmaJS.toggleHtmlClipped(); @@ -294,18 +359,26 @@ declare const bulmaJS: BulmaJS; }; const confirmDeleteFeeCategory = (clickEvent: Event) => { - - const feeCategoryId = Number.parseInt(((clickEvent.currentTarget as HTMLElement).closest(".container--feeCategory") as HTMLElement).dataset.feeCategoryId, 10); + const feeCategoryId = Number.parseInt( + ( + (clickEvent.currentTarget as HTMLElement).closest( + ".container--feeCategory" + ) as HTMLElement + ).dataset.feeCategoryId, + 10 + ); const doDelete = () => { - - cityssm.postJSON(urlPrefix + "/admin/doDeleteFeeCategory", { + cityssm.postJSON( + urlPrefix + "/admin/doDeleteFeeCategory", + { feeCategoryId }, (responseJSON: { - success: boolean;errorMessage ? : string;feeCategories ? : recordTypes.FeeCategory[]; + success: boolean; + errorMessage?: string; + feeCategories?: recordTypes.FeeCategory[]; }) => { - if (responseJSON.success) { feeCategories = responseJSON.feeCategories; renderFeeCategories(); @@ -316,7 +389,8 @@ declare const bulmaJS: BulmaJS; contextualColorName: "danger" }); } - }); + } + ); }; bulmaJS.confirm({ @@ -327,20 +401,28 @@ declare const bulmaJS: BulmaJS; text: "Yes, Delete the Fee Category", callbackFunction: doDelete } - }) + }); }; const moveFeeCategoryUp = (clickEvent: Event) => { + const feeCategoryId = Number.parseInt( + ( + (clickEvent.currentTarget as HTMLElement).closest( + ".container--feeCategory" + ) as HTMLElement + ).dataset.feeCategoryId, + 10 + ); - const feeCategoryId = Number.parseInt(((clickEvent.currentTarget as HTMLElement).closest(".container--feeCategory") as HTMLElement).dataset.feeCategoryId, 10); - - cityssm.postJSON(urlPrefix + "/admin/doMoveFeeCategoryUp", { + cityssm.postJSON( + urlPrefix + "/admin/doMoveFeeCategoryUp", + { feeCategoryId }, (responseJSON: { success: boolean; - errorMessage ? : string; - feeCategories ? : recordTypes.FeeCategory[]; + errorMessage?: string; + feeCategories?: recordTypes.FeeCategory[]; }) => { if (responseJSON.success) { feeCategories = responseJSON.feeCategories; @@ -352,20 +434,29 @@ declare const bulmaJS: BulmaJS; contextualColorName: "danger" }); } - }); + } + ); }; const moveFeeCategoryDown = (clickEvent: Event) => { + const feeCategoryId = Number.parseInt( + ( + (clickEvent.currentTarget as HTMLElement).closest( + ".container--feeCategory" + ) as HTMLElement + ).dataset.feeCategoryId, + 10 + ); - const feeCategoryId = Number.parseInt(((clickEvent.currentTarget as HTMLElement).closest(".container--feeCategory") as HTMLElement).dataset.feeCategoryId, 10); - - cityssm.postJSON(urlPrefix + "/admin/doMoveFeeCategoryDown", { + cityssm.postJSON( + urlPrefix + "/admin/doMoveFeeCategoryDown", + { feeCategoryId }, (responseJSON: { success: boolean; - errorMessage ? : string; - feeCategories ? : recordTypes.FeeCategory[]; + errorMessage?: string; + feeCategories?: recordTypes.FeeCategory[]; }) => { if (responseJSON.success) { feeCategories = responseJSON.feeCategories; @@ -377,7 +468,8 @@ declare const bulmaJS: BulmaJS; contextualColorName: "danger" }); } - }); + } + ); }; /* @@ -385,20 +477,28 @@ declare const bulmaJS: BulmaJS; */ const openAddFee = (clickEvent: Event) => { - - const feeCategoryId = Number.parseInt(((clickEvent.currentTarget as HTMLElement).closest(".container--feeCategory") as HTMLElement).dataset.feeCategoryId, 10); + const feeCategoryId = Number.parseInt( + ( + (clickEvent.currentTarget as HTMLElement).closest( + ".container--feeCategory" + ) as HTMLElement + ).dataset.feeCategoryId, + 10 + ); let addCloseModalFunction: () => void; const doAddFee = (submitEvent: SubmitEvent) => { submitEvent.preventDefault(); - cityssm.postJSON(urlPrefix + "/admin/doAddFee", + cityssm.postJSON( + urlPrefix + "/admin/doAddFee", submitEvent.currentTarget, (responseJSON: { - success: boolean;errorMessage ? : string;feeCategories: recordTypes.FeeCategory[]; + success: boolean; + errorMessage?: string; + feeCategories: recordTypes.FeeCategory[]; }) => { - if (responseJSON.success) { feeCategories = responseJSON.feeCategories; addCloseModalFunction(); @@ -410,16 +510,17 @@ declare const bulmaJS: BulmaJS; contextualColorName: "danger" }); } - }); + } + ); }; cityssm.openHtmlModal("adminFees-addFee", { onshow: (modalElement) => { - - const feeCategoryElement = modalElement.querySelector("#feeAdd--feeCategoryId") as HTMLSelectElement; + const feeCategoryElement = modalElement.querySelector( + "#feeAdd--feeCategoryId" + ) as HTMLSelectElement; for (const feeCategory of feeCategories) { - const optionElement = document.createElement("option"); optionElement.value = feeCategory.feeCategoryId.toString(); optionElement.textContent = feeCategory.feeCategory; @@ -431,83 +532,116 @@ declare const bulmaJS: BulmaJS; feeCategoryElement.append(optionElement); } - const occupancyTypeElement = modalElement.querySelector("#feeAdd--occupancyTypeId") as HTMLSelectElement; + const occupancyTypeElement = modalElement.querySelector( + "#feeAdd--occupancyTypeId" + ) as HTMLSelectElement; for (const occupancyType of exports.occupancyTypes as recordTypes.OccupancyType[]) { - const optionElement = document.createElement("option"); - optionElement.value = occupancyType.occupancyTypeId.toString(); + optionElement.value = + occupancyType.occupancyTypeId.toString(); optionElement.textContent = occupancyType.occupancyType; occupancyTypeElement.append(optionElement); } - const lotTypeElement = modalElement.querySelector("#feeAdd--lotTypeId") as HTMLSelectElement; + const lotTypeElement = modalElement.querySelector( + "#feeAdd--lotTypeId" + ) as HTMLSelectElement; for (const lotType of exports.lotTypes as recordTypes.LotType[]) { - const optionElement = document.createElement("option"); optionElement.value = lotType.lotTypeId.toString(); optionElement.textContent = lotType.lotType; lotTypeElement.append(optionElement); } - (modalElement.querySelector("#feeAdd--taxPercentage") as HTMLInputElement).value = (exports.taxPercentageDefault as number).toString(); + ( + modalElement.querySelector( + "#feeAdd--taxPercentage" + ) as HTMLInputElement + ).value = (exports.taxPercentageDefault as number).toString(); los.populateAliases(modalElement); }, onshown: (modalElement, closeModalFunction) => { - bulmaJS.toggleHtmlClipped(); addCloseModalFunction = closeModalFunction; - modalElement.querySelector("form").addEventListener("submit", doAddFee); + modalElement + .querySelector("form") + .addEventListener("submit", doAddFee); - (modalElement.querySelector("#feeAdd--feeName") as HTMLInputElement).focus(); + ( + modalElement.querySelector( + "#feeAdd--feeName" + ) as HTMLInputElement + ).focus(); - modalElement.querySelector("#feeAdd--feeFunction").addEventListener("change", () => { + modalElement + .querySelector("#feeAdd--feeFunction") + .addEventListener("change", () => { + const feeAmountElement = modalElement.querySelector( + "#feeAdd--feeAmount" + ) as HTMLInputElement; + const feeFunctionElement = modalElement.querySelector( + "#feeAdd--feeFunction" + ) as HTMLSelectElement; - const feeAmountElement = modalElement.querySelector("#feeAdd--feeAmount") as HTMLInputElement; - const feeFunctionElement = modalElement.querySelector("#feeAdd--feeFunction") as HTMLSelectElement; + if (feeFunctionElement.value === "") { + feeFunctionElement + .closest(".select") + .classList.remove("is-success"); - if (feeFunctionElement.value === "") { - feeFunctionElement.closest(".select").classList.remove("is-success"); + feeAmountElement.classList.add("is-success"); + feeAmountElement.disabled = false; + } else { + feeFunctionElement + .closest(".select") + .classList.add("is-success"); - feeAmountElement.classList.add("is-success"); - feeAmountElement.disabled = false; + feeAmountElement.classList.remove("is-success"); + feeAmountElement.disabled = true; + } + }); - } else { - feeFunctionElement.closest(".select").classList.add("is-success"); + modalElement + .querySelector("#feeAdd--taxPercentage") + .addEventListener("keyup", () => { + const taxAmountElement = modalElement.querySelector( + "#feeAdd--taxAmount" + ) as HTMLInputElement; + const taxPercentageElement = modalElement.querySelector( + "#feeAdd--taxPercentage" + ) as HTMLInputElement; - feeAmountElement.classList.remove("is-success"); - feeAmountElement.disabled = true; - } - }); + if (taxPercentageElement.value === "") { + taxPercentageElement.classList.remove("is-success"); - modalElement.querySelector("#feeAdd--taxPercentage").addEventListener("keyup", () => { + taxAmountElement.classList.add("is-success"); + taxAmountElement.disabled = false; + } else { + taxPercentageElement.classList.add("is-success"); - const taxAmountElement = modalElement.querySelector("#feeAdd--taxAmount") as HTMLInputElement; - const taxPercentageElement = modalElement.querySelector("#feeAdd--taxPercentage") as HTMLInputElement; + taxAmountElement.classList.remove("is-success"); + taxAmountElement.disabled = true; + } + }); - 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; - } - }); - - modalElement.querySelector("#feeAdd--includeQuantity").addEventListener("change", () => { - - (modalElement.querySelector("#feeAdd--quantityUnit") as HTMLInputElement).disabled = - (modalElement.querySelector("#feeAdd--includeQuantity") as HTMLSelectElement).value === ""; - }); + modalElement + .querySelector("#feeAdd--includeQuantity") + .addEventListener("change", () => { + ( + modalElement.querySelector( + "#feeAdd--quantityUnit" + ) as HTMLInputElement + ).disabled = + ( + modalElement.querySelector( + "#feeAdd--includeQuantity" + ) as HTMLSelectElement + ).value === ""; + }); }, onremoved: () => { bulmaJS.toggleHtmlClipped(); @@ -518,10 +652,18 @@ declare const bulmaJS: BulmaJS; const openEditFee = (clickEvent: Event) => { clickEvent.preventDefault(); - const feeContainerElement = (clickEvent.currentTarget as HTMLElement).closest(".container--fee") as HTMLElement; + const feeContainerElement = ( + clickEvent.currentTarget as HTMLElement + ).closest(".container--fee") as HTMLElement; const feeId = Number.parseInt(feeContainerElement.dataset.feeId, 10); - const feeCategoryId = Number.parseInt((feeContainerElement.closest(".container--feeCategory") as HTMLElement).dataset.feeCategoryId); + const feeCategoryId = Number.parseInt( + ( + feeContainerElement.closest( + ".container--feeCategory" + ) as HTMLElement + ).dataset.feeCategoryId + ); const feeCategory = feeCategories.find((currentFeeCategory) => { return currentFeeCategory.feeCategoryId === feeCategoryId; @@ -537,14 +679,14 @@ declare const bulmaJS: BulmaJS; const doUpdateFee = (submitEvent: SubmitEvent) => { submitEvent.preventDefault(); - cityssm.postJSON(urlPrefix + "/admin/doUpdateFee", + cityssm.postJSON( + urlPrefix + "/admin/doUpdateFee", submitEvent.currentTarget, (responseJSON: { success: boolean; - errorMessage ? : string; - feeCategories ? : recordTypes.FeeCategory[]; + errorMessage?: string; + feeCategories?: recordTypes.FeeCategory[]; }) => { - if (responseJSON.success) { feeCategories = responseJSON.feeCategories; editCloseModalFunction(); @@ -556,23 +698,24 @@ declare const bulmaJS: BulmaJS; contextualColorName: "danger" }); } - }); + } + ); }; const confirmDeleteFee = (clickEvent: Event) => { clickEvent.preventDefault(); const doDelete = () => { - - cityssm.postJSON(urlPrefix + "/admin/doDeleteFee", { + cityssm.postJSON( + urlPrefix + "/admin/doDeleteFee", + { feeId }, (responseJSON: { success: boolean; - errorMessage ? : string; - feeCategories ? : recordTypes.FeeCategory[]; + errorMessage?: string; + feeCategories?: recordTypes.FeeCategory[]; }) => { - if (responseJSON.success) { feeCategories = responseJSON.feeCategories; editCloseModalFunction(); @@ -584,7 +727,8 @@ declare const bulmaJS: BulmaJS; contextualColorName: "danger" }); } - }); + } + ); }; bulmaJS.confirm({ @@ -599,18 +743,24 @@ declare const bulmaJS: BulmaJS; }; const toggleFeeFields = () => { - - const feeAmountElement = editModalElement.querySelector("#feeEdit--feeAmount") as HTMLInputElement; - const feeFunctionElement = editModalElement.querySelector("#feeEdit--feeFunction") as HTMLSelectElement; + const feeAmountElement = editModalElement.querySelector( + "#feeEdit--feeAmount" + ) as HTMLInputElement; + const feeFunctionElement = editModalElement.querySelector( + "#feeEdit--feeFunction" + ) as HTMLSelectElement; if (feeFunctionElement.value === "") { - feeFunctionElement.closest(".select").classList.remove("is-success"); + feeFunctionElement + .closest(".select") + .classList.remove("is-success"); feeAmountElement.classList.add("is-success"); feeAmountElement.disabled = false; - } else { - feeFunctionElement.closest(".select").classList.add("is-success"); + feeFunctionElement + .closest(".select") + .classList.add("is-success"); feeAmountElement.classList.remove("is-success"); feeAmountElement.disabled = true; @@ -618,16 +768,18 @@ declare const bulmaJS: BulmaJS; }; const toggleTaxFields = () => { - - const taxAmountElement = editModalElement.querySelector("#feeEdit--taxAmount") as HTMLInputElement; - const taxPercentageElement = editModalElement.querySelector("#feeEdit--taxPercentage") as HTMLInputElement; + const taxAmountElement = editModalElement.querySelector( + "#feeEdit--taxAmount" + ) as HTMLInputElement; + const taxPercentageElement = editModalElement.querySelector( + "#feeEdit--taxPercentage" + ) as HTMLInputElement; if (taxPercentageElement.value === "") { taxPercentageElement.classList.remove("is-success"); taxAmountElement.classList.add("is-success"); taxAmountElement.disabled = false; - } else { taxPercentageElement.classList.add("is-success"); @@ -637,22 +789,33 @@ declare const bulmaJS: BulmaJS; }; const toggleQuantityFields = () => { - - (editModalElement.querySelector("#feeEdit--quantityUnit") as HTMLInputElement).disabled = - (editModalElement.querySelector("#feeEdit--includeQuantity") as HTMLSelectElement).value === ""; + ( + editModalElement.querySelector( + "#feeEdit--quantityUnit" + ) as HTMLInputElement + ).disabled = + ( + editModalElement.querySelector( + "#feeEdit--includeQuantity" + ) as HTMLSelectElement + ).value === ""; }; cityssm.openHtmlModal("adminFees-editFee", { onshow: (modalElement) => { - editModalElement = modalElement; - (modalElement.querySelector("#feeEdit--feeId") as HTMLInputElement).value = fee.feeId.toString(); + ( + modalElement.querySelector( + "#feeEdit--feeId" + ) as HTMLInputElement + ).value = fee.feeId.toString(); - const feeCategoryElement = modalElement.querySelector("#feeEdit--feeCategoryId") as HTMLSelectElement; + const feeCategoryElement = modalElement.querySelector( + "#feeEdit--feeCategoryId" + ) as HTMLSelectElement; for (const feeCategory of feeCategories) { - const optionElement = document.createElement("option"); optionElement.value = feeCategory.feeCategoryId.toString(); optionElement.textContent = feeCategory.feeCategory; @@ -664,15 +827,25 @@ declare const bulmaJS: BulmaJS; feeCategoryElement.append(optionElement); } - (modalElement.querySelector("#feeEdit--feeName") as HTMLInputElement).value = fee.feeName; - (modalElement.querySelector("#feeEdit--feeDescription") as HTMLTextAreaElement).value = fee.feeDescription; + ( + modalElement.querySelector( + "#feeEdit--feeName" + ) as HTMLInputElement + ).value = fee.feeName; + ( + modalElement.querySelector( + "#feeEdit--feeDescription" + ) as HTMLTextAreaElement + ).value = fee.feeDescription; - const occupancyTypeElement = modalElement.querySelector("#feeEdit--occupancyTypeId") as HTMLSelectElement; + const occupancyTypeElement = modalElement.querySelector( + "#feeEdit--occupancyTypeId" + ) as HTMLSelectElement; for (const occupancyType of exports.occupancyTypes as recordTypes.OccupancyType[]) { - const optionElement = document.createElement("option"); - optionElement.value = occupancyType.occupancyTypeId.toString(); + optionElement.value = + occupancyType.occupancyTypeId.toString(); optionElement.textContent = occupancyType.occupancyType; if (occupancyType.occupancyTypeId === fee.occupancyTypeId) { @@ -682,10 +855,11 @@ declare const bulmaJS: BulmaJS; occupancyTypeElement.append(optionElement); } - const lotTypeElement = modalElement.querySelector("#feeEdit--lotTypeId") as HTMLSelectElement; + const lotTypeElement = modalElement.querySelector( + "#feeEdit--lotTypeId" + ) as HTMLSelectElement; for (const lotType of exports.lotTypes as recordTypes.LotType[]) { - const optionElement = document.createElement("option"); optionElement.value = lotType.lotTypeId.toString(); optionElement.textContent = lotType.lotType; @@ -697,48 +871,78 @@ declare const bulmaJS: BulmaJS; lotTypeElement.append(optionElement); } - (modalElement.querySelector("#feeEdit--feeAmount") as HTMLInputElement).value = fee.feeAmount ? fee.feeAmount.toFixed(2) : ""; - modalElement.querySelector("#feeEdit--feeFunction").addEventListener("change", toggleFeeFields); + ( + modalElement.querySelector( + "#feeEdit--feeAmount" + ) as HTMLInputElement + ).value = fee.feeAmount ? fee.feeAmount.toFixed(2) : ""; + modalElement + .querySelector("#feeEdit--feeFunction") + .addEventListener("change", toggleFeeFields); toggleFeeFields(); - (modalElement.querySelector("#feeEdit--taxAmount") as HTMLInputElement).value = fee.taxAmount ? fee.taxAmount.toFixed(2) : ""; + ( + modalElement.querySelector( + "#feeEdit--taxAmount" + ) as HTMLInputElement + ).value = fee.taxAmount ? fee.taxAmount.toFixed(2) : ""; - const taxPercentageElement = modalElement.querySelector("#feeEdit--taxPercentage") as HTMLInputElement; - taxPercentageElement.value = fee.taxPercentage ? fee.taxPercentage.toString() : ""; + const taxPercentageElement = modalElement.querySelector( + "#feeEdit--taxPercentage" + ) as HTMLInputElement; + taxPercentageElement.value = fee.taxPercentage + ? fee.taxPercentage.toString() + : ""; taxPercentageElement.addEventListener("keyup", toggleTaxFields); toggleTaxFields(); - const includeQuantityElement = modalElement.querySelector("#feeEdit--includeQuantity") as HTMLSelectElement; + const includeQuantityElement = modalElement.querySelector( + "#feeEdit--includeQuantity" + ) as HTMLSelectElement; if (fee.includeQuantity) { includeQuantityElement.value = "1"; } - includeQuantityElement.addEventListener("change", toggleQuantityFields); + includeQuantityElement.addEventListener( + "change", + toggleQuantityFields + ); - (modalElement.querySelector("#feeEdit--quantityUnit") as HTMLInputElement).value = fee.quantityUnit || ""; + ( + modalElement.querySelector( + "#feeEdit--quantityUnit" + ) as HTMLInputElement + ).value = fee.quantityUnit || ""; toggleQuantityFields(); if (fee.isRequired) { - (modalElement.querySelector("#feeEdit--isRequired") as HTMLSelectElement).value = "1"; + ( + modalElement.querySelector( + "#feeEdit--isRequired" + ) as HTMLSelectElement + ).value = "1"; } los.populateAliases(modalElement); }, onshown: (modalElement, closeModalFunction) => { - bulmaJS.toggleHtmlClipped(); editCloseModalFunction = closeModalFunction; - modalElement.querySelector("form").addEventListener("submit", doUpdateFee); + modalElement + .querySelector("form") + .addEventListener("submit", doUpdateFee); bulmaJS.init(modalElement); - modalElement.querySelector(".button--deleteFee").addEventListener("click", confirmDeleteFee); + modalElement + .querySelector(".button--deleteFee") + .addEventListener("click", confirmDeleteFee); }, onremoved: () => { bulmaJS.toggleHtmlClipped(); @@ -747,18 +951,21 @@ declare const bulmaJS: BulmaJS; }; const moveFeeUp = (clickEvent: Event) => { - - const feeContainerElement = (clickEvent.currentTarget as HTMLElement).closest(".container--fee") as HTMLElement; + const feeContainerElement = ( + clickEvent.currentTarget as HTMLElement + ).closest(".container--fee") as HTMLElement; const feeId = Number.parseInt(feeContainerElement.dataset.feeId, 10); - cityssm.postJSON(urlPrefix + "/admin/doMoveFeeUp", { + cityssm.postJSON( + urlPrefix + "/admin/doMoveFeeUp", + { feeId }, (responseJSON: { success: boolean; - errorMessage ? : string; - feeCategories ? : recordTypes.FeeCategory[]; + errorMessage?: string; + feeCategories?: recordTypes.FeeCategory[]; }) => { if (responseJSON.success) { feeCategories = responseJSON.feeCategories; @@ -770,22 +977,26 @@ declare const bulmaJS: BulmaJS; contextualColorName: "danger" }); } - }); + } + ); }; const moveFeeDown = (clickEvent: Event) => { - - const feeContainerElement = (clickEvent.currentTarget as HTMLElement).closest(".container--fee") as HTMLElement; + const feeContainerElement = ( + clickEvent.currentTarget as HTMLElement + ).closest(".container--fee") as HTMLElement; const feeId = Number.parseInt(feeContainerElement.dataset.feeId, 10); - cityssm.postJSON(urlPrefix + "/admin/doMoveFeeDown", { + cityssm.postJSON( + urlPrefix + "/admin/doMoveFeeDown", + { feeId }, (responseJSON: { success: boolean; - errorMessage ? : string; - feeCategories ? : recordTypes.FeeCategory[]; + errorMessage?: string; + feeCategories?: recordTypes.FeeCategory[]; }) => { if (responseJSON.success) { feeCategories = responseJSON.feeCategories; @@ -797,13 +1008,13 @@ declare const bulmaJS: BulmaJS; contextualColorName: "danger" }); } - }); + } + ); }; - /* * Initialize */ renderFeeCategories(); -})(); \ No newline at end of file +})(); diff --git a/public-typescript/adminTables.js b/public-typescript/adminTables.js index bd031a07..f5f88ccd 100644 --- a/public-typescript/adminTables.js +++ b/public-typescript/adminTables.js @@ -105,59 +105,76 @@ Object.defineProperty(exports, "__esModule", { value: true }); const renderWorkOrderTypes = () => { const containerElement = document.querySelector("#container--workOrderTypes"); if (workOrderTypes.length === 0) { - containerElement.innerHTML = "" + - "" + - "
" + - "

There are no active work order types.

" + - "
" + - "" + - ""; + containerElement.innerHTML = + "" + + '' + + '
' + + '

There are no active work order types.

' + + "
" + + "" + + ""; return; } containerElement.innerHTML = ""; for (const workOrderType of workOrderTypes) { const tableRowElement = document.createElement("tr"); - tableRowElement.dataset.workOrderTypeId = workOrderType.workOrderTypeId.toString(); - tableRowElement.innerHTML = "" + - "
" + - "" + - ("
" + - "
" + - "" + + tableRowElement.dataset.workOrderTypeId = + workOrderType.workOrderTypeId.toString(); + tableRowElement.innerHTML = + "" + + "" + + '' + + ('
' + + '
' + + '' + + "
" + + '
' + + '' + + "
" + + "
") + + "" + + "" + + '' + + '
' + + '
' + + ('
' + + '
' + + '' + + "
" + + '
' + + '' + + "
" + + "
") + "
" + - "
" + - "" + + '
' + + '" + "
" + - "
") + - "" + - "" + - "" + - "
" + - "
" + - ("
" + - "
" + - "" + "
" + - "
" + - "" + - "
" + - "
") + - "
" + - "
" + - "" + - "
" + - "
" + - ""; - tableRowElement.querySelector("form").addEventListener("submit", updateWorkOrderType); - tableRowElement.querySelector(".button--moveWorkOrderTypeUp").addEventListener("click", moveWorkOrderTypeUp); - tableRowElement.querySelector(".button--moveWorkOrderTypeDown").addEventListener("click", moveWorkOrderTypeDown); - tableRowElement.querySelector(".button--deleteWorkOrderType").addEventListener("click", deleteWorkOrderType); + ""; + tableRowElement + .querySelector("form") + .addEventListener("submit", updateWorkOrderType); + tableRowElement + .querySelector(".button--moveWorkOrderTypeUp") + .addEventListener("click", moveWorkOrderTypeUp); + tableRowElement + .querySelector(".button--moveWorkOrderTypeDown") + .addEventListener("click", moveWorkOrderTypeDown); + tableRowElement + .querySelector(".button--deleteWorkOrderType") + .addEventListener("click", deleteWorkOrderType); containerElement.append(tableRowElement); } }; - document.querySelector("#form--addWorkOrderType").addEventListener("submit", (submitEvent) => { + document + .querySelector("#form--addWorkOrderType") + .addEventListener("submit", (submitEvent) => { submitEvent.preventDefault(); const formElement = submitEvent.currentTarget; cityssm.postJSON(urlPrefix + "/admin/doAddWorkOrderType", formElement, (responseJSON) => { @@ -185,7 +202,8 @@ Object.defineProperty(exports, "__esModule", { value: true }); if (responseJSON.success) { lotStatuses = responseJSON.lotStatuses; bulmaJS.alert({ - message: exports.aliases.lot + " Status Updated Successfully", + message: exports.aliases.lot + + " Status Updated Successfully", contextualColorName: "success" }); } @@ -214,13 +232,16 @@ Object.defineProperty(exports, "__esModule", { value: true }); tableRowElement.remove(); } bulmaJS.alert({ - message: exports.aliases.lot + " Status Deleted Successfully", + message: exports.aliases.lot + + " Status Deleted Successfully", contextualColorName: "success" }); } else { bulmaJS.alert({ - title: "Error Deleting " + exports.aliases.lot + " Status", + title: "Error Deleting " + + exports.aliases.lot + + " Status", message: responseJSON.errorMessage, contextualColorName: "danger" }); @@ -230,7 +251,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); bulmaJS.confirm({ title: "Delete " + exports.aliases.lot + " Status", message: "Are you sure you want to delete this status?
" + - "Note that no " + exports.aliases.lots.toLowerCase() + " will be removed.", + "Note that no " + + exports.aliases.lots.toLowerCase() + + " will be removed.", messageIsHtml: true, contextualColorName: "warning", okButton: { @@ -280,59 +303,78 @@ Object.defineProperty(exports, "__esModule", { value: true }); const renderLotStatuses = () => { const containerElement = document.querySelector("#container--lotStatuses"); if (workOrderTypes.length === 0) { - containerElement.innerHTML = "" + - "" + - "
" + - "

There are no active " + cityssm.escapeHTML(exports.aliases.lot.toLowerCase()) + " statuses.

" + - "
" + - "" + - ""; + containerElement.innerHTML = + "" + + '' + + '
' + + '

There are no active ' + + cityssm.escapeHTML(exports.aliases.lot.toLowerCase()) + + " statuses.

" + + "
" + + "" + + ""; return; } containerElement.innerHTML = ""; for (const lotStatus of lotStatuses) { const tableRowElement = document.createElement("tr"); - tableRowElement.dataset.lotStatusId = lotStatus.lotStatusId.toString(); - tableRowElement.innerHTML = "" + - "
" + - "" + - ("
" + - "
" + - "" + + tableRowElement.dataset.lotStatusId = + lotStatus.lotStatusId.toString(); + tableRowElement.innerHTML = + "" + + "" + + '' + + ('
' + + '
' + + '' + + "
" + + '
' + + '' + + "
" + + "
") + + "" + + "" + + '' + + '
' + + '
' + + ('
' + + '
' + + '' + + "
" + + '
' + + '' + + "
" + + "
") + "
" + - "
" + - "" + + '
' + + '" + "
" + - "
") + - "" + - "" + - "" + - "
" + - "
" + - ("
" + - "
" + - "" + "
" + - "
" + - "" + - "
" + - "
") + - "
" + - "
" + - "" + - "
" + - "
" + - ""; - tableRowElement.querySelector("form").addEventListener("submit", updateLotStatus); - tableRowElement.querySelector(".button--moveLotStatusUp").addEventListener("click", moveLotStatusUp); - tableRowElement.querySelector(".button--moveLotStatusDown").addEventListener("click", moveLotStatusDown); - tableRowElement.querySelector(".button--deleteLotStatus").addEventListener("click", deleteLotStatus); + ""; + tableRowElement + .querySelector("form") + .addEventListener("submit", updateLotStatus); + tableRowElement + .querySelector(".button--moveLotStatusUp") + .addEventListener("click", moveLotStatusUp); + tableRowElement + .querySelector(".button--moveLotStatusDown") + .addEventListener("click", moveLotStatusDown); + tableRowElement + .querySelector(".button--deleteLotStatus") + .addEventListener("click", deleteLotStatus); containerElement.append(tableRowElement); } }; - document.querySelector("#form--addLotStatus").addEventListener("submit", (submitEvent) => { + document + .querySelector("#form--addLotStatus") + .addEventListener("submit", (submitEvent) => { submitEvent.preventDefault(); const formElement = submitEvent.currentTarget; cityssm.postJSON(urlPrefix + "/admin/doAddLotStatus", formElement, (responseJSON) => { @@ -344,7 +386,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); } else { bulmaJS.alert({ - title: "Error Adding " + exports.aliases.lot + " Status", + title: "Error Adding " + + exports.aliases.lot + + " Status", message: responseJSON.errorMessage, contextualColorName: "danger" }); @@ -360,13 +404,20 @@ Object.defineProperty(exports, "__esModule", { value: true }); if (responseJSON.success) { lotOccupantTypes = responseJSON.lotOccupantTypes; bulmaJS.alert({ - message: exports.aliases.lot + " " + exports.aliases.occupant + " Type Updated Successfully", + message: exports.aliases.lot + + " " + + exports.aliases.occupant + + " Type Updated Successfully", contextualColorName: "success" }); } else { bulmaJS.alert({ - title: "Error Updating " + exports.aliases.lot + " " + exports.aliases.occupant + " Type", + title: "Error Updating " + + exports.aliases.lot + + " " + + exports.aliases.occupant + + " Type", message: responseJSON.errorMessage, contextualColorName: "danger" }); @@ -389,13 +440,20 @@ Object.defineProperty(exports, "__esModule", { value: true }); tableRowElement.remove(); } bulmaJS.alert({ - message: exports.aliases.lot + " " + exports.aliases.occupant + " Type Deleted Successfully", + message: exports.aliases.lot + + " " + + exports.aliases.occupant + + " Type Deleted Successfully", contextualColorName: "success" }); } else { bulmaJS.alert({ - title: "Error Deleting " + exports.aliases.lot + " " + exports.aliases.occupant + " Type", + title: "Error Deleting " + + exports.aliases.lot + + " " + + exports.aliases.occupant + + " Type", message: responseJSON.errorMessage, contextualColorName: "danger" }); @@ -403,13 +461,29 @@ Object.defineProperty(exports, "__esModule", { value: true }); }); }; bulmaJS.confirm({ - title: "Delete " + exports.aliases.lot + " " + exports.aliases.occupant + " Type", - message: "Are you sure you want to delete this " + exports.aliases.lot.toLowerCase() + " " + exports.aliases.occupant.toLowerCase() + " type?
" + - "Note that no " + exports.aliases.lot.toLowerCase() + " " + exports.aliases.occupancy.toLowerCase() + " will be removed.", + title: "Delete " + + exports.aliases.lot + + " " + + exports.aliases.occupant + + " Type", + message: "Are you sure you want to delete this " + + exports.aliases.lot.toLowerCase() + + " " + + exports.aliases.occupant.toLowerCase() + + " type?
" + + "Note that no " + + exports.aliases.lot.toLowerCase() + + " " + + exports.aliases.occupancy.toLowerCase() + + " will be removed.", messageIsHtml: true, contextualColorName: "warning", okButton: { - text: "Yes, Delete " + exports.aliases.lot + " " + exports.aliases.occupant + " Type", + text: "Yes, Delete " + + exports.aliases.lot + + " " + + exports.aliases.occupant + + " Type", callbackFunction: doDelete } }); @@ -426,7 +500,11 @@ Object.defineProperty(exports, "__esModule", { value: true }); } else { bulmaJS.alert({ - title: "Error Moving " + exports.aliases.lot + " " + exports.aliases.occupant + " Type", + title: "Error Moving " + + exports.aliases.lot + + " " + + exports.aliases.occupant + + " Type", message: responseJSON.errorMessage, contextualColorName: "danger" }); @@ -445,7 +523,11 @@ Object.defineProperty(exports, "__esModule", { value: true }); } else { bulmaJS.alert({ - title: "Error Moving " + exports.aliases.lot + " " + exports.aliases.occupant + " Type", + title: "Error Moving " + + exports.aliases.lot + + " " + + exports.aliases.occupant + + " Type", message: responseJSON.errorMessage, contextualColorName: "danger" }); @@ -455,61 +537,90 @@ Object.defineProperty(exports, "__esModule", { value: true }); const renderLotOccupantTypes = () => { const containerElement = document.querySelector("#container--lotOccupantTypes"); if (workOrderTypes.length === 0) { - containerElement.innerHTML = "" + - "" + - "
" + - "

There are no active " + cityssm.escapeHTML(exports.aliases.lot.toLowerCase()) + " " + cityssm.escapeHTML(exports.aliases.occupant.toLowerCase()) + " types.

" + - "
" + - "" + - ""; + containerElement.innerHTML = + "" + + '' + + '
' + + '

There are no active ' + + cityssm.escapeHTML(exports.aliases.lot.toLowerCase()) + + " " + + cityssm.escapeHTML(exports.aliases.occupant.toLowerCase()) + + " types.

" + + "
" + + "" + + ""; return; } containerElement.innerHTML = ""; for (const lotOccupantType of lotOccupantTypes) { const tableRowElement = document.createElement("tr"); - tableRowElement.dataset.lotOccupantTypeId = lotOccupantType.lotOccupantTypeId.toString(); - tableRowElement.innerHTML = "" + - "
" + - "" + - ("
" + - "
" + - "" + + tableRowElement.dataset.lotOccupantTypeId = + lotOccupantType.lotOccupantTypeId.toString(); + tableRowElement.innerHTML = + "" + + "" + + '' + + ('
' + + '
' + + '' + + "
" + + '
' + + '' + + "
" + + "
") + + "" + + "" + + '' + + '
' + + '
' + + ('
' + + '
' + + '' + + "
" + + '
' + + '' + + "
" + + "
") + "
" + - "
" + - "" + + '
' + + '" + "
" + - "
") + - "" + - "" + - "" + - "
" + - "
" + - ("
" + - "
" + - "" + "
" + - "
" + - "" + - "
" + - "
") + - "
" + - "
" + - "" + - "
" + - "
" + - ""; - tableRowElement.querySelector("form").addEventListener("submit", updateLotOccupantType); - tableRowElement.querySelector(".button--moveLotOccupantTypeUp").addEventListener("click", moveLotOccupantTypeUp); - tableRowElement.querySelector(".button--moveLotOccupantTypeDown").addEventListener("click", moveLotOccupantTypeDown); - tableRowElement.querySelector(".button--deleteLotOccupantType").addEventListener("click", deleteLotOccupantType); + ""; + tableRowElement + .querySelector("form") + .addEventListener("submit", updateLotOccupantType); + tableRowElement + .querySelector(".button--moveLotOccupantTypeUp") + .addEventListener("click", moveLotOccupantTypeUp); + tableRowElement + .querySelector(".button--moveLotOccupantTypeDown") + .addEventListener("click", moveLotOccupantTypeDown); + tableRowElement + .querySelector(".button--deleteLotOccupantType") + .addEventListener("click", deleteLotOccupantType); containerElement.append(tableRowElement); } }; - document.querySelector("#form--addLotOccupantType").addEventListener("submit", (submitEvent) => { + document + .querySelector("#form--addLotOccupantType") + .addEventListener("submit", (submitEvent) => { submitEvent.preventDefault(); const formElement = submitEvent.currentTarget; cityssm.postJSON(urlPrefix + "/admin/doAddLotOccupantType", formElement, (responseJSON) => { @@ -521,7 +632,11 @@ Object.defineProperty(exports, "__esModule", { value: true }); } else { bulmaJS.alert({ - title: "Error Adding " + exports.aliases.lot + " " + exports.aliases.occupant + " Type", + title: "Error Adding " + + exports.aliases.lot + + " " + + exports.aliases.occupant + + " Type", message: responseJSON.errorMessage, contextualColorName: "danger" }); diff --git a/public-typescript/adminTables.ts b/public-typescript/adminTables.ts index 91a485ba..18e4c125 100644 --- a/public-typescript/adminTables.ts +++ b/public-typescript/adminTables.ts @@ -2,18 +2,13 @@ import type * as recordTypes from "../types/recordTypes"; -import type { - cityssmGlobal -} from "@cityssm/bulma-webapp-js/src/types"; +import type { cityssmGlobal } from "@cityssm/bulma-webapp-js/src/types"; -import type { - BulmaJS -} from "@cityssm/bulma-js/types"; +import type { BulmaJS } from "@cityssm/bulma-js/types"; declare const cityssm: cityssmGlobal; declare const bulmaJS: BulmaJS; - (() => { const urlPrefix = document.querySelector("main").dataset.urlPrefix; @@ -25,25 +20,23 @@ declare const bulmaJS: BulmaJS; delete exports.workOrderTypes; const updateWorkOrderType = (submitEvent: SubmitEvent) => { - submitEvent.preventDefault(); - cityssm.postJSON(urlPrefix + "/admin/doUpdateWorkOrderType", + cityssm.postJSON( + urlPrefix + "/admin/doUpdateWorkOrderType", submitEvent.currentTarget, (responseJSON: { success: boolean; - errorMessage ? : string; - workOrderTypes ? : recordTypes.WorkOrderType[]; + errorMessage?: string; + workOrderTypes?: recordTypes.WorkOrderType[]; }) => { if (responseJSON.success) { - workOrderTypes = responseJSON.workOrderTypes; bulmaJS.alert({ message: "Work Order Type Updated Successfully", contextualColorName: "success" }); - } else { bulmaJS.alert({ title: "Error Updating Work Order Type", @@ -51,28 +44,29 @@ declare const bulmaJS: BulmaJS; contextualColorName: "danger" }); } - }); + } + ); }; const deleteWorkOrderType = (clickEvent: Event) => { - - const tableRowElement = (clickEvent.currentTarget as HTMLElement).closest("tr"); + const tableRowElement = ( + clickEvent.currentTarget as HTMLElement + ).closest("tr"); const workOrderTypeId = tableRowElement.dataset.workOrderTypeId; const doDelete = () => { - - cityssm.postJSON(urlPrefix + "/admin/doDeleteWorkOrderType", { + cityssm.postJSON( + urlPrefix + "/admin/doDeleteWorkOrderType", + { workOrderTypeId }, (responseJSON: { success: boolean; - errorMessage ? : string; - workOrderTypes ? : recordTypes.WorkOrderType[]; + errorMessage?: string; + workOrderTypes?: recordTypes.WorkOrderType[]; }) => { - if (responseJSON.success) { - workOrderTypes = responseJSON.workOrderTypes; if (workOrderTypes.length === 0) { @@ -85,7 +79,6 @@ declare const bulmaJS: BulmaJS; message: "Work Order Type Deleted Successfully", contextualColorName: "success" }); - } else { bulmaJS.alert({ title: "Error Deleting Work Order Type", @@ -93,12 +86,14 @@ declare const bulmaJS: BulmaJS; contextualColorName: "danger" }); } - }); + } + ); }; bulmaJS.confirm({ title: "Delete Work Order Type", - message: "Are you sure you want to delete this work order type?
" + + message: + "Are you sure you want to delete this work order type?
" + "Note that no work orders will be removed.", messageIsHtml: true, contextualColorName: "warning", @@ -110,25 +105,25 @@ declare const bulmaJS: BulmaJS; }; const moveWorkOrderTypeUp = (clickEvent: Event) => { - - const tableRowElement = (clickEvent.currentTarget as HTMLElement).closest("tr"); + const tableRowElement = ( + clickEvent.currentTarget as HTMLElement + ).closest("tr"); const workOrderTypeId = tableRowElement.dataset.workOrderTypeId; - cityssm.postJSON(urlPrefix + "/admin/doMoveWorkOrderTypeUp", { + cityssm.postJSON( + urlPrefix + "/admin/doMoveWorkOrderTypeUp", + { workOrderTypeId }, (responseJSON: { success: boolean; - errorMessage ? : string; - workOrderTypes ? : recordTypes.WorkOrderType[]; + errorMessage?: string; + workOrderTypes?: recordTypes.WorkOrderType[]; }) => { - if (responseJSON.success) { - workOrderTypes = responseJSON.workOrderTypes; renderWorkOrderTypes(); - } else { bulmaJS.alert({ title: "Error Moving Work Order Type", @@ -136,29 +131,30 @@ declare const bulmaJS: BulmaJS; contextualColorName: "danger" }); } - }); + } + ); }; const moveWorkOrderTypeDown = (clickEvent: Event) => { - - const tableRowElement = (clickEvent.currentTarget as HTMLElement).closest("tr"); + const tableRowElement = ( + clickEvent.currentTarget as HTMLElement + ).closest("tr"); const workOrderTypeId = tableRowElement.dataset.workOrderTypeId; - cityssm.postJSON(urlPrefix + "/admin/doMoveWorkOrderTypeDown", { + cityssm.postJSON( + urlPrefix + "/admin/doMoveWorkOrderTypeDown", + { workOrderTypeId }, (responseJSON: { success: boolean; - errorMessage ? : string; - workOrderTypes ? : recordTypes.WorkOrderType[]; + errorMessage?: string; + workOrderTypes?: recordTypes.WorkOrderType[]; }) => { - if (responseJSON.success) { - workOrderTypes = responseJSON.workOrderTypes; renderWorkOrderTypes(); - } else { bulmaJS.alert({ title: "Error Moving Work Order Type", @@ -166,18 +162,21 @@ declare const bulmaJS: BulmaJS; contextualColorName: "danger" }); } - }); + } + ); }; const renderWorkOrderTypes = () => { - - const containerElement = document.querySelector("#container--workOrderTypes") as HTMLTableSectionElement; + const containerElement = document.querySelector( + "#container--workOrderTypes" + ) as HTMLTableSectionElement; if (workOrderTypes.length === 0) { - containerElement.innerHTML = "" + - "" + - "
" + - "

There are no active work order types.

" + + containerElement.innerHTML = + "" + + '' + + '
' + + '

There are no active work order types.

' + "
" + "" + ""; @@ -188,82 +187,96 @@ declare const bulmaJS: BulmaJS; containerElement.innerHTML = ""; for (const workOrderType of workOrderTypes) { - const tableRowElement = document.createElement("tr"); - tableRowElement.dataset.workOrderTypeId = workOrderType.workOrderTypeId.toString(); + tableRowElement.dataset.workOrderTypeId = + workOrderType.workOrderTypeId.toString(); - tableRowElement.innerHTML = "" + + tableRowElement.innerHTML = + "" + "
" + - "" + - ("
" + - "
" + - "" + + '' + + ('
' + + '
' + + '' + "
" + - "
" + - "" + + '
' + + '' + "
" + "
") + "" + "" + - "" + - "
" + - "
" + - ("
" + - "
" + - "" + + '' + + '
' + + '
' + + ('
' + + '
' + + '' + "
" + - "
" + - "" + + '
' + + '' + "
" + "
") + "
" + - "
" + - "" + "
" + "
" + ""; - tableRowElement.querySelector("form").addEventListener("submit", updateWorkOrderType); - tableRowElement.querySelector(".button--moveWorkOrderTypeUp").addEventListener("click", moveWorkOrderTypeUp); - tableRowElement.querySelector(".button--moveWorkOrderTypeDown").addEventListener("click", moveWorkOrderTypeDown); - tableRowElement.querySelector(".button--deleteWorkOrderType").addEventListener("click", deleteWorkOrderType); + tableRowElement + .querySelector("form") + .addEventListener("submit", updateWorkOrderType); + tableRowElement + .querySelector(".button--moveWorkOrderTypeUp") + .addEventListener("click", moveWorkOrderTypeUp); + tableRowElement + .querySelector(".button--moveWorkOrderTypeDown") + .addEventListener("click", moveWorkOrderTypeDown); + tableRowElement + .querySelector(".button--deleteWorkOrderType") + .addEventListener("click", deleteWorkOrderType); containerElement.append(tableRowElement); } - }; - document.querySelector("#form--addWorkOrderType").addEventListener("submit", (submitEvent: SubmitEvent) => { + document + .querySelector("#form--addWorkOrderType") + .addEventListener("submit", (submitEvent: SubmitEvent) => { + submitEvent.preventDefault(); - submitEvent.preventDefault(); + const formElement = submitEvent.currentTarget as HTMLFormElement; - const formElement = submitEvent.currentTarget as HTMLFormElement; - - cityssm.postJSON(urlPrefix + "/admin/doAddWorkOrderType", - formElement, - (responseJSON: { - success: boolean; - errorMessage ? : string; - workOrderTypes ? : recordTypes.WorkOrderType[]; - }) => { - - if (responseJSON.success) { - workOrderTypes = responseJSON.workOrderTypes; - renderWorkOrderTypes(); - formElement.reset(); - formElement.querySelector("input").focus(); - } else { - bulmaJS.alert({ - title: "Error Adding Work Order Type", - message: responseJSON.errorMessage, - contextualColorName: "danger" - }); + cityssm.postJSON( + urlPrefix + "/admin/doAddWorkOrderType", + formElement, + (responseJSON: { + success: boolean; + errorMessage?: string; + workOrderTypes?: recordTypes.WorkOrderType[]; + }) => { + if (responseJSON.success) { + workOrderTypes = responseJSON.workOrderTypes; + renderWorkOrderTypes(); + formElement.reset(); + formElement.querySelector("input").focus(); + } else { + bulmaJS.alert({ + title: "Error Adding Work Order Type", + message: responseJSON.errorMessage, + contextualColorName: "danger" + }); + } } - }); - }); + ); + }); renderWorkOrderTypes(); @@ -275,54 +288,56 @@ declare const bulmaJS: BulmaJS; delete exports.lotStatuses; const updateLotStatus = (submitEvent: SubmitEvent) => { - submitEvent.preventDefault(); - cityssm.postJSON(urlPrefix + "/admin/doUpdateLotStatus", + cityssm.postJSON( + urlPrefix + "/admin/doUpdateLotStatus", submitEvent.currentTarget, (responseJSON: { success: boolean; - errorMessage ? : string; - lotStatuses ? : recordTypes.LotStatus[]; + errorMessage?: string; + lotStatuses?: recordTypes.LotStatus[]; }) => { if (responseJSON.success) { - lotStatuses = responseJSON.lotStatuses; bulmaJS.alert({ - message: exports.aliases.lot + " Status Updated Successfully", + message: + exports.aliases.lot + + " Status Updated Successfully", contextualColorName: "success" }); - } else { bulmaJS.alert({ - title: "Error Updating " + exports.aliases.lot + " Status", + title: + "Error Updating " + exports.aliases.lot + " Status", message: responseJSON.errorMessage, contextualColorName: "danger" }); } - }); + } + ); }; const deleteLotStatus = (clickEvent: Event) => { - - const tableRowElement = (clickEvent.currentTarget as HTMLElement).closest("tr"); + const tableRowElement = ( + clickEvent.currentTarget as HTMLElement + ).closest("tr"); const lotStatusId = tableRowElement.dataset.lotStatusId; const doDelete = () => { - - cityssm.postJSON(urlPrefix + "/admin/doDeleteLotStatus", { + cityssm.postJSON( + urlPrefix + "/admin/doDeleteLotStatus", + { lotStatusId }, (responseJSON: { success: boolean; - errorMessage ? : string; - lotStatuses ? : recordTypes.LotStatus[]; + errorMessage?: string; + lotStatuses?: recordTypes.LotStatus[]; }) => { - if (responseJSON.success) { - lotStatuses = responseJSON.lotStatuses; if (lotStatuses.length === 0) { @@ -332,24 +347,32 @@ declare const bulmaJS: BulmaJS; } bulmaJS.alert({ - message: exports.aliases.lot + " Status Deleted Successfully", + message: + exports.aliases.lot + + " Status Deleted Successfully", contextualColorName: "success" }); - } else { bulmaJS.alert({ - title: "Error Deleting " + exports.aliases.lot + " Status", + title: + "Error Deleting " + + exports.aliases.lot + + " Status", message: responseJSON.errorMessage, contextualColorName: "danger" }); } - }); + } + ); }; bulmaJS.confirm({ title: "Delete " + exports.aliases.lot + " Status", - message: "Are you sure you want to delete this status?
" + - "Note that no " + exports.aliases.lots.toLowerCase() + " will be removed.", + message: + "Are you sure you want to delete this status?
" + + "Note that no " + + exports.aliases.lots.toLowerCase() + + " will be removed.", messageIsHtml: true, contextualColorName: "warning", okButton: { @@ -360,74 +383,82 @@ declare const bulmaJS: BulmaJS; }; const moveLotStatusUp = (clickEvent: Event) => { - - const tableRowElement = (clickEvent.currentTarget as HTMLElement).closest("tr"); + const tableRowElement = ( + clickEvent.currentTarget as HTMLElement + ).closest("tr"); const lotStatusId = tableRowElement.dataset.lotStatusId; - cityssm.postJSON(urlPrefix + "/admin/doMoveLotStatusUp", { + cityssm.postJSON( + urlPrefix + "/admin/doMoveLotStatusUp", + { lotStatusId }, (responseJSON: { success: boolean; - errorMessage ? : string; - lotStatuses ? : recordTypes.LotStatus[]; + errorMessage?: string; + lotStatuses?: recordTypes.LotStatus[]; }) => { - if (responseJSON.success) { - lotStatuses = responseJSON.lotStatuses; renderLotStatuses(); - } else { bulmaJS.alert({ - title: "Error Moving " + exports.aliases.lot + " Status", + title: + "Error Moving " + exports.aliases.lot + " Status", message: responseJSON.errorMessage, contextualColorName: "danger" }); } - }); + } + ); }; const moveLotStatusDown = (clickEvent: Event) => { - - const tableRowElement = (clickEvent.currentTarget as HTMLElement).closest("tr"); + const tableRowElement = ( + clickEvent.currentTarget as HTMLElement + ).closest("tr"); const lotStatusId = tableRowElement.dataset.lotStatusId; - cityssm.postJSON(urlPrefix + "/admin/doMoveLotStatusDown", { + cityssm.postJSON( + urlPrefix + "/admin/doMoveLotStatusDown", + { lotStatusId }, (responseJSON: { success: boolean; - errorMessage ? : string; - lotStatuses ? : recordTypes.LotStatus[]; + errorMessage?: string; + lotStatuses?: recordTypes.LotStatus[]; }) => { - if (responseJSON.success) { - lotStatuses = responseJSON.lotStatuses; renderLotStatuses(); - } else { bulmaJS.alert({ - title: "Error Moving " + exports.aliases.lot + " Status", + title: + "Error Moving " + exports.aliases.lot + " Status", message: responseJSON.errorMessage, contextualColorName: "danger" }); } - }); + } + ); }; const renderLotStatuses = () => { - - const containerElement = document.querySelector("#container--lotStatuses") as HTMLTableSectionElement; + const containerElement = document.querySelector( + "#container--lotStatuses" + ) as HTMLTableSectionElement; if (workOrderTypes.length === 0) { - containerElement.innerHTML = "" + - "" + - "
" + - "

There are no active " + cityssm.escapeHTML(exports.aliases.lot.toLowerCase()) + " statuses.

" + + containerElement.innerHTML = + "" + + '' + + '
' + + '

There are no active ' + + cityssm.escapeHTML(exports.aliases.lot.toLowerCase()) + + " statuses.

" + "
" + "" + ""; @@ -438,82 +469,99 @@ declare const bulmaJS: BulmaJS; containerElement.innerHTML = ""; for (const lotStatus of lotStatuses) { - const tableRowElement = document.createElement("tr"); - tableRowElement.dataset.lotStatusId = lotStatus.lotStatusId.toString(); + tableRowElement.dataset.lotStatusId = + lotStatus.lotStatusId.toString(); - tableRowElement.innerHTML = "" + + tableRowElement.innerHTML = + "" + "
" + - "" + - ("
" + - "
" + - "" + + '' + + ('
' + + '
' + + '' + "
" + - "
" + - "" + + '
' + + '' + "
" + "
") + "" + "" + - "" + - "
" + - "
" + - ("
" + - "
" + - "" + + '' + + '
' + + '
' + + ('
' + + '
' + + '' + "
" + - "
" + - "" + + '
' + + '' + "
" + "
") + "
" + - "
" + - "" + "
" + "
" + ""; - tableRowElement.querySelector("form").addEventListener("submit", updateLotStatus); - tableRowElement.querySelector(".button--moveLotStatusUp").addEventListener("click", moveLotStatusUp); - tableRowElement.querySelector(".button--moveLotStatusDown").addEventListener("click", moveLotStatusDown); - tableRowElement.querySelector(".button--deleteLotStatus").addEventListener("click", deleteLotStatus); + tableRowElement + .querySelector("form") + .addEventListener("submit", updateLotStatus); + tableRowElement + .querySelector(".button--moveLotStatusUp") + .addEventListener("click", moveLotStatusUp); + tableRowElement + .querySelector(".button--moveLotStatusDown") + .addEventListener("click", moveLotStatusDown); + tableRowElement + .querySelector(".button--deleteLotStatus") + .addEventListener("click", deleteLotStatus); containerElement.append(tableRowElement); } - }; - document.querySelector("#form--addLotStatus").addEventListener("submit", (submitEvent: SubmitEvent) => { + document + .querySelector("#form--addLotStatus") + .addEventListener("submit", (submitEvent: SubmitEvent) => { + submitEvent.preventDefault(); - submitEvent.preventDefault(); + const formElement = submitEvent.currentTarget as HTMLFormElement; - const formElement = submitEvent.currentTarget as HTMLFormElement; - - cityssm.postJSON(urlPrefix + "/admin/doAddLotStatus", - formElement, - (responseJSON: { - success: boolean; - errorMessage ? : string; - lotStatuses ? : recordTypes.LotStatus[]; - }) => { - - if (responseJSON.success) { - lotStatuses = responseJSON.lotStatuses; - renderLotStatuses(); - formElement.reset(); - formElement.querySelector("input").focus(); - } else { - bulmaJS.alert({ - title: "Error Adding " + exports.aliases.lot + " Status", - message: responseJSON.errorMessage, - contextualColorName: "danger" - }); + cityssm.postJSON( + urlPrefix + "/admin/doAddLotStatus", + formElement, + (responseJSON: { + success: boolean; + errorMessage?: string; + lotStatuses?: recordTypes.LotStatus[]; + }) => { + if (responseJSON.success) { + lotStatuses = responseJSON.lotStatuses; + renderLotStatuses(); + formElement.reset(); + formElement.querySelector("input").focus(); + } else { + bulmaJS.alert({ + title: + "Error Adding " + + exports.aliases.lot + + " Status", + message: responseJSON.errorMessage, + contextualColorName: "danger" + }); + } } - }); - }); + ); + }); renderLotStatuses(); @@ -521,59 +569,67 @@ declare const bulmaJS: BulmaJS; * Lot Occupant Types */ - - let lotOccupantTypes: recordTypes.LotOccupantType[] = exports.lotOccupantTypes; + let lotOccupantTypes: recordTypes.LotOccupantType[] = + exports.lotOccupantTypes; delete exports.lotOccupantTypes; const updateLotOccupantType = (submitEvent: SubmitEvent) => { - submitEvent.preventDefault(); - cityssm.postJSON(urlPrefix + "/admin/doUpdateLotOccupantType", + cityssm.postJSON( + urlPrefix + "/admin/doUpdateLotOccupantType", submitEvent.currentTarget, (responseJSON: { success: boolean; - errorMessage ? : string; - lotOccupantTypes ? : recordTypes.LotOccupantType[]; + errorMessage?: string; + lotOccupantTypes?: recordTypes.LotOccupantType[]; }) => { if (responseJSON.success) { - lotOccupantTypes = responseJSON.lotOccupantTypes; bulmaJS.alert({ - message: exports.aliases.lot + " " + exports.aliases.occupant + " Type Updated Successfully", + message: + exports.aliases.lot + + " " + + exports.aliases.occupant + + " Type Updated Successfully", contextualColorName: "success" }); - } else { bulmaJS.alert({ - title: "Error Updating " + exports.aliases.lot + " " + exports.aliases.occupant + " Type", + title: + "Error Updating " + + exports.aliases.lot + + " " + + exports.aliases.occupant + + " Type", message: responseJSON.errorMessage, contextualColorName: "danger" }); } - }); + } + ); }; const deleteLotOccupantType = (clickEvent: Event) => { - - const tableRowElement = (clickEvent.currentTarget as HTMLElement).closest("tr"); + const tableRowElement = ( + clickEvent.currentTarget as HTMLElement + ).closest("tr"); const lotOccupantTypeId = tableRowElement.dataset.lotOccupantTypeId; const doDelete = () => { - - cityssm.postJSON(urlPrefix + "/admin/doDeleteLotOccupantType", { + cityssm.postJSON( + urlPrefix + "/admin/doDeleteLotOccupantType", + { lotOccupantTypeId }, (responseJSON: { success: boolean; - errorMessage ? : string; - lotOccupantTypes ? : recordTypes.LotOccupantType[]; + errorMessage?: string; + lotOccupantTypes?: recordTypes.LotOccupantType[]; }) => { - if (responseJSON.success) { - lotOccupantTypes = responseJSON.lotOccupantTypes; if (lotOccupantTypes.length === 0) { @@ -583,102 +639,148 @@ declare const bulmaJS: BulmaJS; } bulmaJS.alert({ - message: exports.aliases.lot + " " + exports.aliases.occupant + " Type Deleted Successfully", + message: + exports.aliases.lot + + " " + + exports.aliases.occupant + + " Type Deleted Successfully", contextualColorName: "success" }); - } else { bulmaJS.alert({ - title: "Error Deleting " + exports.aliases.lot + " " + exports.aliases.occupant + " Type", + title: + "Error Deleting " + + exports.aliases.lot + + " " + + exports.aliases.occupant + + " Type", message: responseJSON.errorMessage, contextualColorName: "danger" }); } - }); + } + ); }; bulmaJS.confirm({ - title: "Delete " + exports.aliases.lot + " " + exports.aliases.occupant + " Type", - message: "Are you sure you want to delete this " + exports.aliases.lot.toLowerCase() + " " + exports.aliases.occupant.toLowerCase() + " type?
" + - "Note that no " + exports.aliases.lot.toLowerCase() + " " + exports.aliases.occupancy.toLowerCase() + " will be removed.", + title: + "Delete " + + exports.aliases.lot + + " " + + exports.aliases.occupant + + " Type", + message: + "Are you sure you want to delete this " + + exports.aliases.lot.toLowerCase() + + " " + + exports.aliases.occupant.toLowerCase() + + " type?
" + + "Note that no " + + exports.aliases.lot.toLowerCase() + + " " + + exports.aliases.occupancy.toLowerCase() + + " will be removed.", messageIsHtml: true, contextualColorName: "warning", okButton: { - text: "Yes, Delete " + exports.aliases.lot + " " + exports.aliases.occupant + " Type", + text: + "Yes, Delete " + + exports.aliases.lot + + " " + + exports.aliases.occupant + + " Type", callbackFunction: doDelete } }); }; const moveLotOccupantTypeUp = (clickEvent: Event) => { - - const tableRowElement = (clickEvent.currentTarget as HTMLElement).closest("tr"); + const tableRowElement = ( + clickEvent.currentTarget as HTMLElement + ).closest("tr"); const lotOccupantTypeId = tableRowElement.dataset.lotOccupantTypeId; - cityssm.postJSON(urlPrefix + "/admin/doMoveLotOccupantTypeUp", { - lotOccupantTypeId + cityssm.postJSON( + urlPrefix + "/admin/doMoveLotOccupantTypeUp", + { + lotOccupantTypeId }, (responseJSON: { success: boolean; - errorMessage ? : string; - lotOccupantTypes ? : recordTypes.LotOccupantType[]; + errorMessage?: string; + lotOccupantTypes?: recordTypes.LotOccupantType[]; }) => { - if (responseJSON.success) { - lotOccupantTypes = responseJSON.lotOccupantTypes; renderLotOccupantTypes(); - } else { bulmaJS.alert({ - title: "Error Moving " + exports.aliases.lot + " " + exports.aliases.occupant + " Type", + title: + "Error Moving " + + exports.aliases.lot + + " " + + exports.aliases.occupant + + " Type", message: responseJSON.errorMessage, contextualColorName: "danger" }); } - }); + } + ); }; const moveLotOccupantTypeDown = (clickEvent: Event) => { - - const tableRowElement = (clickEvent.currentTarget as HTMLElement).closest("tr"); + const tableRowElement = ( + clickEvent.currentTarget as HTMLElement + ).closest("tr"); const lotOccupantTypeId = tableRowElement.dataset.lotOccupantTypeId; - cityssm.postJSON(urlPrefix + "/admin/doMoveLotOccupantTypeDown", { - lotOccupantTypeId + cityssm.postJSON( + urlPrefix + "/admin/doMoveLotOccupantTypeDown", + { + lotOccupantTypeId }, (responseJSON: { success: boolean; - errorMessage ? : string; - lotOccupantTypes ? : recordTypes.LotOccupantType[]; + errorMessage?: string; + lotOccupantTypes?: recordTypes.LotOccupantType[]; }) => { - if (responseJSON.success) { - lotOccupantTypes = responseJSON.lotOccupantTypes; renderLotOccupantTypes(); - } else { bulmaJS.alert({ - title: "Error Moving " + exports.aliases.lot + " " + exports.aliases.occupant + " Type", + title: + "Error Moving " + + exports.aliases.lot + + " " + + exports.aliases.occupant + + " Type", message: responseJSON.errorMessage, contextualColorName: "danger" }); } - }); + } + ); }; const renderLotOccupantTypes = () => { - - const containerElement = document.querySelector("#container--lotOccupantTypes") as HTMLTableSectionElement; + const containerElement = document.querySelector( + "#container--lotOccupantTypes" + ) as HTMLTableSectionElement; if (workOrderTypes.length === 0) { - containerElement.innerHTML = "" + - "" + - "
" + - "

There are no active " + cityssm.escapeHTML(exports.aliases.lot.toLowerCase()) + " " + cityssm.escapeHTML(exports.aliases.occupant.toLowerCase()) + " types.

" + + containerElement.innerHTML = + "" + + '' + + '
' + + '

There are no active ' + + cityssm.escapeHTML(exports.aliases.lot.toLowerCase()) + + " " + + cityssm.escapeHTML(exports.aliases.occupant.toLowerCase()) + + " types.

" + "
" + "" + ""; @@ -689,84 +791,111 @@ declare const bulmaJS: BulmaJS; containerElement.innerHTML = ""; for (const lotOccupantType of lotOccupantTypes) { - const tableRowElement = document.createElement("tr"); - tableRowElement.dataset.lotOccupantTypeId = lotOccupantType.lotOccupantTypeId.toString(); + tableRowElement.dataset.lotOccupantTypeId = + lotOccupantType.lotOccupantTypeId.toString(); - tableRowElement.innerHTML = "" + + tableRowElement.innerHTML = + "" + "
" + - "" + - ("
" + - "
" + - "" + + '' + + ('
' + + '
' + + '' + "
" + - "
" + - "" + + '
' + + '' + "
" + "
") + "" + "" + - "" + - "
" + - "
" + - ("
" + - "
" + - "" + + '' + + '
' + + '
' + + ('
' + + '
' + + '' + "
" + - "
" + - "" + + '
' + + '' + "
" + "
") + "
" + - "
" + - "" + "
" + "
" + ""; - tableRowElement.querySelector("form").addEventListener("submit", updateLotOccupantType); - tableRowElement.querySelector(".button--moveLotOccupantTypeUp").addEventListener("click", moveLotOccupantTypeUp); - tableRowElement.querySelector(".button--moveLotOccupantTypeDown").addEventListener("click", moveLotOccupantTypeDown); - tableRowElement.querySelector(".button--deleteLotOccupantType").addEventListener("click", deleteLotOccupantType); + tableRowElement + .querySelector("form") + .addEventListener("submit", updateLotOccupantType); + tableRowElement + .querySelector(".button--moveLotOccupantTypeUp") + .addEventListener("click", moveLotOccupantTypeUp); + tableRowElement + .querySelector(".button--moveLotOccupantTypeDown") + .addEventListener("click", moveLotOccupantTypeDown); + tableRowElement + .querySelector(".button--deleteLotOccupantType") + .addEventListener("click", deleteLotOccupantType); containerElement.append(tableRowElement); } - }; - document.querySelector("#form--addLotOccupantType").addEventListener("submit", (submitEvent: SubmitEvent) => { + document + .querySelector("#form--addLotOccupantType") + .addEventListener("submit", (submitEvent: SubmitEvent) => { + submitEvent.preventDefault(); - submitEvent.preventDefault(); + const formElement = submitEvent.currentTarget as HTMLFormElement; - const formElement = submitEvent.currentTarget as HTMLFormElement; - - cityssm.postJSON(urlPrefix + "/admin/doAddLotOccupantType", - formElement, - (responseJSON: { - success: boolean; - errorMessage ? : string; - lotOccupantTypes ? : recordTypes.LotOccupantType[]; - }) => { - - if (responseJSON.success) { - lotOccupantTypes = responseJSON.lotOccupantTypes; - renderLotOccupantTypes(); - formElement.reset(); - formElement.querySelector("input").focus(); - } else { - bulmaJS.alert({ - title: "Error Adding " + exports.aliases.lot + " " + exports.aliases.occupant + " Type", - message: responseJSON.errorMessage, - contextualColorName: "danger" - }); + cityssm.postJSON( + urlPrefix + "/admin/doAddLotOccupantType", + formElement, + (responseJSON: { + success: boolean; + errorMessage?: string; + lotOccupantTypes?: recordTypes.LotOccupantType[]; + }) => { + if (responseJSON.success) { + lotOccupantTypes = responseJSON.lotOccupantTypes; + renderLotOccupantTypes(); + formElement.reset(); + formElement.querySelector("input").focus(); + } else { + bulmaJS.alert({ + title: + "Error Adding " + + exports.aliases.lot + + " " + + exports.aliases.occupant + + " Type", + message: responseJSON.errorMessage, + contextualColorName: "danger" + }); + } } - }); - }); + ); + }); renderLotOccupantTypes(); -})(); \ No newline at end of file +})(); diff --git a/public-typescript/lotEdit.js b/public-typescript/lotEdit.js index 0bb63a78..0628d8e3 100644 --- a/public-typescript/lotEdit.js +++ b/public-typescript/lotEdit.js @@ -3,15 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true }); (() => { const los = exports.los; const urlPrefix = document.querySelector("main").dataset.urlPrefix; - const lotId = document.querySelector("#lot--lotId").value; - const isCreate = (lotId === ""); + const lotId = document.querySelector("#lot--lotId") + .value; + const isCreate = lotId === ""; const formElement = document.querySelector("#form--lot"); const updateLot = (formEvent) => { formEvent.preventDefault(); cityssm.postJSON(urlPrefix + "/lots/" + (isCreate ? "doCreateLot" : "doUpdateLot"), formElement, (responseJSON) => { if (responseJSON.success) { if (isCreate) { - window.location.href = urlPrefix + "/lots/" + responseJSON.lotId + "/edit"; + window.location.href = + urlPrefix + "/lots/" + responseJSON.lotId + "/edit"; } else { bulmaJS.alert({ @@ -34,7 +36,8 @@ Object.defineProperty(exports, "__esModule", { value: true }); let lotComments = exports.lotComments; delete exports.lotComments; const openEditLotComment = (clickEvent) => { - const lotCommentId = Number.parseInt(clickEvent.currentTarget.closest("tr").dataset.lotCommentId, 10); + const lotCommentId = Number.parseInt(clickEvent.currentTarget.closest("tr").dataset + .lotCommentId, 10); const lotComment = lotComments.find((currentLotComment) => { return currentLotComment.lotCommentId === lotCommentId; }); @@ -79,7 +82,8 @@ Object.defineProperty(exports, "__esModule", { value: true }); }); }; const deleteLotComment = (clickEvent) => { - const lotCommentId = Number.parseInt(clickEvent.currentTarget.closest("tr").dataset.lotCommentId, 10); + const lotCommentId = Number.parseInt(clickEvent.currentTarget.closest("tr").dataset + .lotCommentId, 10); const doDelete = () => { cityssm.postJSON(urlPrefix + "/lots/doDeleteLotComment", { lotId, @@ -111,42 +115,56 @@ Object.defineProperty(exports, "__esModule", { value: true }); const renderLotComments = () => { const containerElement = document.querySelector("#container--lotComments"); if (lotComments.length === 0) { - containerElement.innerHTML = "
" + - "

There are no comments to display.

" + - "
"; + containerElement.innerHTML = + '
' + + '

There are no comments to display.

' + + "
"; return; } const tableElement = document.createElement("table"); tableElement.className = "table is-fullwidth is-striped is-hoverable"; - tableElement.innerHTML = "" + - "Commentor" + - "Comment Date" + - "Comment" + - "Options" + - "" + - ""; + tableElement.innerHTML = + "" + + "Commentor" + + "Comment Date" + + "Comment" + + 'Options' + + "" + + ""; for (const lotComment of lotComments) { const tableRowElement = document.createElement("tr"); - tableRowElement.dataset.lotCommentId = lotComment.lotCommentId.toString(); - tableRowElement.innerHTML = "" + cityssm.escapeHTML(lotComment.recordCreate_userName) + "" + + tableRowElement.dataset.lotCommentId = + lotComment.lotCommentId.toString(); + tableRowElement.innerHTML = "" + - lotComment.lotCommentDateString + - (lotComment.lotCommentTime === 0 ? "" : " " + lotComment.lotCommentTimeString) + - "" + - "" + cityssm.escapeHTML(lotComment.lotComment) + "" + - ("" + - "
" + - ("") + - ("") + - "
" + - ""); - tableRowElement.querySelector(".button--edit").addEventListener("click", openEditLotComment); - tableRowElement.querySelector(".button--delete").addEventListener("click", deleteLotComment); + cityssm.escapeHTML(lotComment.recordCreate_userName) + + "" + + "" + + lotComment.lotCommentDateString + + (lotComment.lotCommentTime === 0 + ? "" + : " " + lotComment.lotCommentTimeString) + + "" + + "" + + cityssm.escapeHTML(lotComment.lotComment) + + "" + + ('' + + '
' + + ('") + + ('") + + "
" + + ""); + tableRowElement + .querySelector(".button--edit") + .addEventListener("click", openEditLotComment); + tableRowElement + .querySelector(".button--delete") + .addEventListener("click", deleteLotComment); tableElement.querySelector("tbody").append(tableRowElement); } containerElement.innerHTML = ""; @@ -168,7 +186,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); onshow(modalElement) { los.populateAliases(modalElement); modalElement.querySelector("#lotCommentAdd--lotId").value = lotId; - modalElement.querySelector("form").addEventListener("submit", doAddComment); + modalElement + .querySelector("form") + .addEventListener("submit", doAddComment); }, onshown(modalElement, closeModalFunction) { bulmaJS.toggleHtmlClipped(); @@ -182,7 +202,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); }); }; if (!isCreate) { - document.querySelector("#lotComments--add").addEventListener("click", openAddCommentModal); + document + .querySelector("#lotComments--add") + .addEventListener("click", openAddCommentModal); renderLotComments(); } })(); diff --git a/public-typescript/lotEdit.ts b/public-typescript/lotEdit.ts index d0cf5e1e..ae6a4c94 100644 --- a/public-typescript/lotEdit.ts +++ b/public-typescript/lotEdit.ts @@ -3,25 +3,21 @@ import type * as globalTypes from "../types/globalTypes"; import type * as recordTypes from "../types/recordTypes"; -import type { - cityssmGlobal -} from "@cityssm/bulma-webapp-js/src/types"; +import type { cityssmGlobal } from "@cityssm/bulma-webapp-js/src/types"; -import type { - BulmaJS -} from "@cityssm/bulma-js/types"; +import type { BulmaJS } from "@cityssm/bulma-js/types"; declare const cityssm: cityssmGlobal; declare const bulmaJS: BulmaJS; - (() => { - const los = (exports.los as globalTypes.LOS); + const los = exports.los as globalTypes.LOS; const urlPrefix = document.querySelector("main").dataset.urlPrefix; - const lotId = (document.querySelector("#lot--lotId") as HTMLInputElement).value; - const isCreate = (lotId === ""); + const lotId = (document.querySelector("#lot--lotId") as HTMLInputElement) + .value; + const isCreate = lotId === ""; // Main form @@ -30,18 +26,22 @@ declare const bulmaJS: BulmaJS; const updateLot = (formEvent: SubmitEvent) => { formEvent.preventDefault(); - cityssm.postJSON(urlPrefix + "/lots/" + (isCreate ? "doCreateLot" : "doUpdateLot"), + cityssm.postJSON( + urlPrefix + "/lots/" + (isCreate ? "doCreateLot" : "doUpdateLot"), formElement, (responseJSON: { - success: boolean;lotId ? : number;errorMessage ? : string + success: boolean; + lotId?: number; + errorMessage?: string; }) => { - if (responseJSON.success) { if (isCreate) { - window.location.href = urlPrefix + "/lots/" + responseJSON.lotId + "/edit"; + window.location.href = + urlPrefix + "/lots/" + responseJSON.lotId + "/edit"; } else { bulmaJS.alert({ - message: exports.aliases.lot + " Updated Successfully", + message: + exports.aliases.lot + " Updated Successfully", contextualColorName: "success" }); } @@ -52,7 +52,8 @@ declare const bulmaJS: BulmaJS; contextualColorName: "danger" }); } - }); + } + ); }; formElement.addEventListener("submit", updateLot); @@ -63,10 +64,13 @@ declare const bulmaJS: BulmaJS; let lotComments: recordTypes.LotComment[] = exports.lotComments; delete exports.lotComments; - - const openEditLotComment = (clickEvent: Event) => { - const lotCommentId = Number.parseInt((clickEvent.currentTarget as HTMLElement).closest("tr").dataset.lotCommentId, 10); + const openEditLotComment = (clickEvent: Event) => { + const lotCommentId = Number.parseInt( + (clickEvent.currentTarget as HTMLElement).closest("tr").dataset + .lotCommentId, + 10 + ); const lotComment = lotComments.find((currentLotComment) => { return currentLotComment.lotCommentId === lotCommentId; @@ -76,17 +80,16 @@ declare const bulmaJS: BulmaJS; let editCloseModalFunction: () => void; const editComment = (submitEvent: SubmitEvent) => { - submitEvent.preventDefault(); - cityssm.postJSON(urlPrefix + "/lots/doUpdateLotComment", + cityssm.postJSON( + urlPrefix + "/lots/doUpdateLotComment", editFormElement, (responseJSON: { success: boolean; - errorMessage ? : string; - lotComments ? : recordTypes.LotComment[]; + errorMessage?: string; + lotComments?: recordTypes.LotComment[]; }) => { - if (responseJSON.success) { lotComments = responseJSON.lotComments; editCloseModalFunction(); @@ -98,25 +101,49 @@ declare const bulmaJS: BulmaJS; contextualColorName: "danger" }); } - }); + } + ); }; cityssm.openHtmlModal("lot-editComment", { onshow: (modalElement) => { los.populateAliases(modalElement); - (modalElement.querySelector("#lotCommentEdit--lotId") as HTMLInputElement).value = lotId; - (modalElement.querySelector("#lotCommentEdit--lotCommentId") as HTMLInputElement).value = lotCommentId.toString(); + ( + modalElement.querySelector( + "#lotCommentEdit--lotId" + ) as HTMLInputElement + ).value = lotId; + ( + modalElement.querySelector( + "#lotCommentEdit--lotCommentId" + ) as HTMLInputElement + ).value = lotCommentId.toString(); - (modalElement.querySelector("#lotCommentEdit--lotComment") as HTMLInputElement).value = lotComment.lotComment; - (modalElement.querySelector("#lotCommentEdit--lotCommentDateString") as HTMLInputElement).value = lotComment.lotCommentDateString; - (modalElement.querySelector("#lotCommentEdit--lotCommentTimeString") as HTMLInputElement).value = lotComment.lotCommentTimeString; + ( + modalElement.querySelector( + "#lotCommentEdit--lotComment" + ) as HTMLInputElement + ).value = lotComment.lotComment; + ( + modalElement.querySelector( + "#lotCommentEdit--lotCommentDateString" + ) as HTMLInputElement + ).value = lotComment.lotCommentDateString; + ( + modalElement.querySelector( + "#lotCommentEdit--lotCommentTimeString" + ) as HTMLInputElement + ).value = lotComment.lotCommentTimeString; }, onshown: (modalElement, closeModalFunction) => { - bulmaJS.toggleHtmlClipped(); - (modalElement.querySelector("#lotCommentEdit--lotComment") as HTMLTextAreaElement).focus(); + ( + modalElement.querySelector( + "#lotCommentEdit--lotComment" + ) as HTMLTextAreaElement + ).focus(); editFormElement = modalElement.querySelector("form"); editFormElement.addEventListener("submit", editComment); @@ -130,17 +157,22 @@ declare const bulmaJS: BulmaJS; }; const deleteLotComment = (clickEvent: Event) => { - - const lotCommentId = Number.parseInt((clickEvent.currentTarget as HTMLElement).closest("tr").dataset.lotCommentId, 10); + const lotCommentId = Number.parseInt( + (clickEvent.currentTarget as HTMLElement).closest("tr").dataset + .lotCommentId, + 10 + ); const doDelete = () => { - cityssm.postJSON(urlPrefix + "/lots/doDeleteLotComment", { + cityssm.postJSON( + urlPrefix + "/lots/doDeleteLotComment", + { lotId, lotCommentId }, (responseJSON: { success: boolean; - errorMessage ? : string; + errorMessage?: string; lotComments: recordTypes.LotComment[]; }) => { if (responseJSON.success) { @@ -153,7 +185,8 @@ declare const bulmaJS: BulmaJS; contextualColorName: "danger" }); } - }); + } + ); }; bulmaJS.confirm({ @@ -167,53 +200,66 @@ declare const bulmaJS: BulmaJS; }); }; - const renderLotComments = () => { - - const containerElement = document.querySelector("#container--lotComments") as HTMLElement; + const containerElement = document.querySelector( + "#container--lotComments" + ) as HTMLElement; if (lotComments.length === 0) { - containerElement.innerHTML = "
" + - "

There are no comments to display.

" + + containerElement.innerHTML = + '
' + + '

There are no comments to display.

' + "
"; return; } const tableElement = document.createElement("table"); tableElement.className = "table is-fullwidth is-striped is-hoverable"; - tableElement.innerHTML = "" + + tableElement.innerHTML = + "" + "Commentor" + "Comment Date" + "Comment" + - "Options" + + 'Options' + "" + ""; for (const lotComment of lotComments) { - const tableRowElement = document.createElement("tr"); - tableRowElement.dataset.lotCommentId = lotComment.lotCommentId.toString(); + tableRowElement.dataset.lotCommentId = + lotComment.lotCommentId.toString(); - tableRowElement.innerHTML = "" + cityssm.escapeHTML(lotComment.recordCreate_userName) + "" + + tableRowElement.innerHTML = + "" + + cityssm.escapeHTML(lotComment.recordCreate_userName) + + "" + "" + lotComment.lotCommentDateString + - (lotComment.lotCommentTime === 0 ? "" : " " + lotComment.lotCommentTimeString) + + (lotComment.lotCommentTime === 0 + ? "" + : " " + lotComment.lotCommentTimeString) + "" + - "" + cityssm.escapeHTML(lotComment.lotComment) + "" + - ("" + - "
" + - ("") + - ("") + "
" + ""); - tableRowElement.querySelector(".button--edit").addEventListener("click", openEditLotComment); - tableRowElement.querySelector(".button--delete").addEventListener("click", deleteLotComment); + tableRowElement + .querySelector(".button--edit") + .addEventListener("click", openEditLotComment); + tableRowElement + .querySelector(".button--delete") + .addEventListener("click", deleteLotComment); tableElement.querySelector("tbody").append(tableRowElement); } @@ -223,44 +269,63 @@ declare const bulmaJS: BulmaJS; }; const openAddCommentModal = () => { - let addCommentCloseModalFunction: () => void; const doAddComment = (formEvent: SubmitEvent) => { formEvent.preventDefault(); - cityssm.postJSON(urlPrefix + "/lots/doAddLotComment", - formEvent.currentTarget, - (responseJSON: {success: boolean; lotComments?: recordTypes.LotComment[]}) => { - - if (responseJSON.success) { - lotComments = responseJSON.lotComments; - renderLotComments(); - addCommentCloseModalFunction(); + cityssm.postJSON( + urlPrefix + "/lots/doAddLotComment", + formEvent.currentTarget, + (responseJSON: { + success: boolean; + lotComments?: recordTypes.LotComment[]; + }) => { + if (responseJSON.success) { + lotComments = responseJSON.lotComments; + renderLotComments(); + addCommentCloseModalFunction(); + } } - }); + ); }; cityssm.openHtmlModal("lot-addComment", { onshow(modalElement) { los.populateAliases(modalElement); - (modalElement.querySelector("#lotCommentAdd--lotId") as HTMLInputElement).value = lotId; - modalElement.querySelector("form").addEventListener("submit", doAddComment); + ( + modalElement.querySelector( + "#lotCommentAdd--lotId" + ) as HTMLInputElement + ).value = lotId; + modalElement + .querySelector("form") + .addEventListener("submit", doAddComment); }, onshown(modalElement, closeModalFunction) { bulmaJS.toggleHtmlClipped(); addCommentCloseModalFunction = closeModalFunction; - (modalElement.querySelector("#lotCommentAdd--lotComment") as HTMLTextAreaElement).focus(); + ( + modalElement.querySelector( + "#lotCommentAdd--lotComment" + ) as HTMLTextAreaElement + ).focus(); }, onremoved() { bulmaJS.toggleHtmlClipped(); - (document.querySelector("#lotComments--add") as HTMLButtonElement).focus(); + ( + document.querySelector( + "#lotComments--add" + ) as HTMLButtonElement + ).focus(); } }); }; if (!isCreate) { - document.querySelector("#lotComments--add").addEventListener("click", openAddCommentModal); + document + .querySelector("#lotComments--add") + .addEventListener("click", openAddCommentModal); renderLotComments(); } -})(); \ No newline at end of file +})(); diff --git a/public-typescript/lotOccupancyEdit.js b/public-typescript/lotOccupancyEdit.js index ce53ad25..105478d2 100644 --- a/public-typescript/lotOccupancyEdit.js +++ b/public-typescript/lotOccupancyEdit.js @@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const los = exports.los; const urlPrefix = document.querySelector("main").dataset.urlPrefix; const lotOccupancyId = document.querySelector("#lotOccupancy--lotOccupancyId").value; - const isCreate = (lotOccupancyId === ""); + const isCreate = lotOccupancyId === ""; let hasUnsavedChanges = false; let refreshAfterSave = isCreate; const setUnsavedChanges = () => { @@ -20,15 +20,23 @@ Object.defineProperty(exports, "__esModule", { value: true }); const formElement = document.querySelector("#form--lotOccupancy"); formElement.addEventListener("submit", (formEvent) => { formEvent.preventDefault(); - cityssm.postJSON(urlPrefix + "/lotOccupancies/" + (isCreate ? "doCreateLotOccupancy" : "doUpdateLotOccupancy"), formElement, (responseJSON) => { + cityssm.postJSON(urlPrefix + + "/lotOccupancies/" + + (isCreate ? "doCreateLotOccupancy" : "doUpdateLotOccupancy"), formElement, (responseJSON) => { if (responseJSON.success) { clearUnsavedChanges(); if (isCreate || refreshAfterSave) { - window.location.href = urlPrefix + "/lotOccupancies/" + responseJSON.lotOccupancyId + "/edit?t=" + Date.now(); + window.location.href = + urlPrefix + + "/lotOccupancies/" + + responseJSON.lotOccupancyId + + "/edit?t=" + + Date.now(); } else { bulmaJS.alert({ - message: exports.aliases.occupancy + " Updated Successfully", + message: exports.aliases.occupancy + + " Updated Successfully", contextualColorName: "success" }); } @@ -47,14 +55,19 @@ Object.defineProperty(exports, "__esModule", { value: true }); formInputElement.addEventListener("change", setUnsavedChanges); } if (!isCreate) { - document.querySelector("#button--deleteLotOccupancy").addEventListener("click", (clickEvent) => { + document + .querySelector("#button--deleteLotOccupancy") + .addEventListener("click", (clickEvent) => { clickEvent.preventDefault(); const doDelete = () => { cityssm.postJSON(urlPrefix + "/lotOccupancies/doDeleteLotOccupancy", { lotOccupancyId }, (responseJSON) => { if (responseJSON.success) { - window.location.href = urlPrefix + "/lotOccupancies?t=" + Date.now(); + window.location.href = + urlPrefix + + "/lotOccupancies?t=" + + Date.now(); } else { bulmaJS.alert({ @@ -81,44 +94,66 @@ Object.defineProperty(exports, "__esModule", { value: true }); const lotOccupancyFieldsContainerElement = document.querySelector("#container--lotOccupancyFields"); occupancyTypeIdElement.addEventListener("change", () => { if (occupancyTypeIdElement.value === "") { - lotOccupancyFieldsContainerElement.innerHTML = "
" + - "

Select the " + exports.aliases.occupancy.toLowerCase() + " type to load the available fields.

" + - "
"; + lotOccupancyFieldsContainerElement.innerHTML = + '
' + + '

Select the ' + + exports.aliases.occupancy.toLowerCase() + + " type to load the available fields.

" + + "
"; return; } cityssm.postJSON(urlPrefix + "/lotOccupancies/doGetOccupancyTypeFields", { occupancyTypeId: occupancyTypeIdElement.value }, (responseJSON) => { if (responseJSON.occupancyTypeFields.length === 0) { - lotOccupancyFieldsContainerElement.innerHTML = "
" + - "

There are no additional fields for this " + exports.aliases.occupancy.toLowerCase() + " type.

" + - "
"; + lotOccupancyFieldsContainerElement.innerHTML = + '
' + + '

There are no additional fields for this ' + + exports.aliases.occupancy.toLowerCase() + + " type.

" + + "
"; return; } lotOccupancyFieldsContainerElement.innerHTML = ""; let occupancyTypeFieldIds = ""; for (const occupancyTypeField of responseJSON.occupancyTypeFields) { - occupancyTypeFieldIds += "," + occupancyTypeField.occupancyTypeFieldId; + occupancyTypeFieldIds += + "," + occupancyTypeField.occupancyTypeFieldId; const fieldElement = document.createElement("div"); fieldElement.className = "field"; - fieldElement.innerHTML = "" + - "
"; - fieldElement.querySelector("label").textContent = occupancyTypeField.occupancyTypeField; + fieldElement.innerHTML = + '' + + '
'; + fieldElement.querySelector("label").textContent = + occupancyTypeField.occupancyTypeField; const inputElement = document.createElement("input"); inputElement.className = "input"; - inputElement.id = "lotOccupancy--lotOccupancyFieldValue_" + occupancyTypeField.occupancyTypeFieldId; - inputElement.name = "lotOccupancyFieldValue_" + occupancyTypeField.occupancyTypeFieldId; + inputElement.id = + "lotOccupancy--lotOccupancyFieldValue_" + + occupancyTypeField.occupancyTypeFieldId; + inputElement.name = + "lotOccupancyFieldValue_" + + occupancyTypeField.occupancyTypeFieldId; inputElement.type = "text"; inputElement.required = occupancyTypeField.isRequired; - inputElement.minLength = occupancyTypeField.minimumLength; - inputElement.maxLength = occupancyTypeField.maximumLength; - if (occupancyTypeField.pattern && occupancyTypeField.pattern !== "") { + inputElement.minLength = + occupancyTypeField.minimumLength; + inputElement.maxLength = + occupancyTypeField.maximumLength; + if (occupancyTypeField.pattern && + occupancyTypeField.pattern !== "") { inputElement.pattern = occupancyTypeField.pattern; } - fieldElement.querySelector(".control").append(inputElement); + fieldElement + .querySelector(".control") + .append(inputElement); lotOccupancyFieldsContainerElement.append(fieldElement); } - lotOccupancyFieldsContainerElement.insertAdjacentHTML("beforeend", ""); + lotOccupancyFieldsContainerElement.insertAdjacentHTML("beforeend", ''); }); }); } @@ -128,7 +163,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); if (occupancyTypeIdElement.value !== originalOccupancyTypeId) { bulmaJS.confirm({ title: "Confirm Change", - message: "Are you sure you want to change the " + exports.aliases.occupancy.toLowerCase() + " type?\n" + + message: "Are you sure you want to change the " + + exports.aliases.occupancy.toLowerCase() + + " type?\n" + "This change affects the additional fields associated with this record, and may also affect the available fees.", contextualColorName: "warning", okButton: { @@ -140,7 +177,8 @@ Object.defineProperty(exports, "__esModule", { value: true }); cancelButton: { text: "Revert the Change", callbackFunction: () => { - occupancyTypeIdElement.value = originalOccupancyTypeId; + occupancyTypeIdElement.value = + originalOccupancyTypeId; } } }); @@ -149,7 +187,8 @@ Object.defineProperty(exports, "__esModule", { value: true }); } const lotNameElement = document.querySelector("#lotOccupancy--lotName"); lotNameElement.addEventListener("click", (clickEvent) => { - const currentLotName = clickEvent.currentTarget.value; + const currentLotName = clickEvent.currentTarget + .value; let lotSelectCloseModalFunction; let lotSelectFormElement; let lotSelectResultsElement; @@ -162,17 +201,19 @@ Object.defineProperty(exports, "__esModule", { value: true }); lotSelectCloseModalFunction(); }; const searchLots = () => { - lotSelectResultsElement.innerHTML = "

" + - "
" + - "Searching..." + - "

"; + lotSelectResultsElement.innerHTML = + '

' + + '
' + + "Searching..." + + "

"; cityssm.postJSON(urlPrefix + "/lots/doSearchLots", lotSelectFormElement, (responseJSON) => { if (responseJSON.count === 0) { - lotSelectResultsElement.innerHTML = "
" + - "

" + - "No results." + - "

" + - "
"; + lotSelectResultsElement.innerHTML = + '
' + + '

' + + "No results." + + "

" + + "
"; return; } const panelElement = document.createElement("div"); @@ -183,19 +224,25 @@ Object.defineProperty(exports, "__esModule", { value: true }); panelBlockElement.href = "#"; panelBlockElement.dataset.lotId = lot.lotId.toString(); panelBlockElement.dataset.lotName = lot.lotName; - panelBlockElement.innerHTML = "
" + - ("
" + - cityssm.escapeHTML(lot.lotName) + "
" + - "" + cityssm.escapeHTML(lot.mapName) + "" + - "
") + - ("
" + - cityssm.escapeHTML(lot.lotStatus) + "
" + - "" + - (lot.lotOccupancyCount > 0 ? - "Currently Occupied" : "") + - "" + - "
") + - "
"; + panelBlockElement.innerHTML = + '
' + + ('
' + + cityssm.escapeHTML(lot.lotName) + + "
" + + '' + + cityssm.escapeHTML(lot.mapName) + + "" + + "
") + + ('
' + + cityssm.escapeHTML(lot.lotStatus) + + "
" + + '' + + (lot.lotOccupancyCount > 0 + ? "Currently Occupied" + : "") + + "" + + "
") + + "
"; panelBlockElement.addEventListener("click", selectLot); panelElement.append(panelBlockElement); } @@ -221,7 +268,8 @@ Object.defineProperty(exports, "__esModule", { value: true }); if (currentLotName !== "") { occupancyStatusFilterElement.value = ""; } - lotSelectFormElement = modalElement.querySelector("#form--lotSelect"); + lotSelectFormElement = + modalElement.querySelector("#form--lotSelect"); lotSelectResultsElement = modalElement.querySelector("#resultsContainer--lotSelect"); lotSelectFormElement.addEventListener("submit", (submitEvent) => { submitEvent.preventDefault(); @@ -233,19 +281,25 @@ Object.defineProperty(exports, "__esModule", { value: true }); } }); }); - document.querySelector(".is-lot-view-button").addEventListener("click", () => { + document + .querySelector(".is-lot-view-button") + .addEventListener("click", () => { const lotId = document.querySelector("#lotOccupancy--lotId").value; if (lotId) { window.open(urlPrefix + "/lots/" + lotId); } else { bulmaJS.alert({ - message: "No " + exports.aliases.lot.toLowerCase() + " selected.", + message: "No " + + exports.aliases.lot.toLowerCase() + + " selected.", contextualColorName: "info" }); } }); - document.querySelector(".is-clear-lot-button").addEventListener("click", () => { + document + .querySelector(".is-clear-lot-button") + .addEventListener("click", () => { if (lotNameElement.disabled) { bulmaJS.alert({ message: "You need to unlock the field before clearing it.", @@ -258,18 +312,21 @@ Object.defineProperty(exports, "__esModule", { value: true }); setUnsavedChanges(); } }); - document.querySelector("#lotOccupancy--occupancyStartDateString").addEventListener("change", () => { - document.querySelector("#lotOccupancy--occupancyEndDateString").min = - document.querySelector("#lotOccupancy--occupancyStartDateString").value; + document + .querySelector("#lotOccupancy--occupancyStartDateString") + .addEventListener("change", () => { + document.querySelector("#lotOccupancy--occupancyEndDateString").min = document.querySelector("#lotOccupancy--occupancyStartDateString").value; }); los.initializeUnlockFieldButtons(formElement); if (!isCreate) { let lotOccupancyOccupants = exports.lotOccupancyOccupants; delete exports.lotOccupancyOccupants; const openEditLotOccupancyOccupant = (clickEvent) => { - const lotOccupantIndex = Number.parseInt(clickEvent.currentTarget.closest("tr").dataset.lotOccupantIndex, 10); + const lotOccupantIndex = Number.parseInt(clickEvent.currentTarget.closest("tr").dataset + .lotOccupantIndex, 10); const lotOccupancyOccupant = lotOccupancyOccupants.find((currentLotOccupancyOccupant) => { - return currentLotOccupancyOccupant.lotOccupantIndex === lotOccupantIndex; + return (currentLotOccupancyOccupant.lotOccupantIndex === + lotOccupantIndex); }); let editFormElement; let editCloseModalFunction; @@ -277,13 +334,15 @@ Object.defineProperty(exports, "__esModule", { value: true }); submitEvent.preventDefault(); cityssm.postJSON(urlPrefix + "/lotOccupancies/doUpdateLotOccupancyOccupant", editFormElement, (responseJSON) => { if (responseJSON.success) { - lotOccupancyOccupants = responseJSON.lotOccupancyOccupants; + lotOccupancyOccupants = + responseJSON.lotOccupancyOccupants; editCloseModalFunction(); renderLotOccupancyOccupants(); } else { bulmaJS.alert({ - title: "Error Updating " + exports.aliases.occupant, + title: "Error Updating " + + exports.aliases.occupant, message: responseJSON.errorMessage, contextualColorName: "danger" }); @@ -299,9 +358,12 @@ Object.defineProperty(exports, "__esModule", { value: true }); let lotOccupantTypeSelected = false; for (const lotOccupantType of exports.lotOccupantTypes) { const optionElement = document.createElement("option"); - optionElement.value = lotOccupantType.lotOccupantTypeId.toString(); - optionElement.textContent = lotOccupantType.lotOccupantType; - if (lotOccupantType.lotOccupantTypeId === lotOccupancyOccupant.lotOccupantTypeId) { + optionElement.value = + lotOccupantType.lotOccupantTypeId.toString(); + optionElement.textContent = + lotOccupantType.lotOccupantType; + if (lotOccupantType.lotOccupantTypeId === + lotOccupancyOccupant.lotOccupantTypeId) { optionElement.selected = true; lotOccupantTypeSelected = true; } @@ -309,8 +371,10 @@ Object.defineProperty(exports, "__esModule", { value: true }); } if (!lotOccupantTypeSelected) { const optionElement = document.createElement("option"); - optionElement.value = lotOccupancyOccupant.lotOccupantTypeId.toString(); - optionElement.textContent = lotOccupancyOccupant.lotOccupantType; + optionElement.value = + lotOccupancyOccupant.lotOccupantTypeId.toString(); + optionElement.textContent = + lotOccupancyOccupant.lotOccupantType; optionElement.selected = true; lotOccupantTypeSelectElement.append(optionElement); } @@ -342,12 +406,14 @@ Object.defineProperty(exports, "__esModule", { value: true }); lotOccupantIndex }, (responseJSON) => { if (responseJSON.success) { - lotOccupancyOccupants = responseJSON.lotOccupancyOccupants; + lotOccupancyOccupants = + responseJSON.lotOccupancyOccupants; renderLotOccupancyOccupants(); } else { bulmaJS.alert({ - title: "Error Removing " + exports.aliases.occupant, + title: "Error Removing " + + exports.aliases.occupant, message: responseJSON.errorMessage, contextualColorName: "danger" }); @@ -356,7 +422,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); }; bulmaJS.confirm({ title: "Remove " + exports.aliases.occupant + "?", - message: "Are you sure you want to remove this " + exports.aliases.occupant.toLowerCase() + "?", + message: "Are you sure you want to remove this " + + exports.aliases.occupant.toLowerCase() + + "?", okButton: { text: "Yes, Remove " + exports.aliases.occupant, callbackFunction: doDelete @@ -368,64 +436,98 @@ Object.defineProperty(exports, "__esModule", { value: true }); const occupantsContainer = document.querySelector("#container--lotOccupancyOccupants"); cityssm.clearElement(occupantsContainer); if (lotOccupancyOccupants.length === 0) { - occupantsContainer.innerHTML = "
" + - "

There are no " + exports.aliases.occupants.toLowerCase() + " associated with this record.

" + - "
"; + occupantsContainer.innerHTML = + '
' + + '

There are no ' + + exports.aliases.occupants.toLowerCase() + + " associated with this record.

" + + "
"; return; } const tableElement = document.createElement("table"); - tableElement.className = "table is-fullwidth is-striped is-hoverable"; - tableElement.innerHTML = "" + - "" + exports.aliases.occupant + " Type" + - "" + exports.aliases.occupant + "" + - "Address" + - "Phone Number" + - "Options" + - "" + - ""; + tableElement.className = + "table is-fullwidth is-striped is-hoverable"; + tableElement.innerHTML = + "" + + "" + + exports.aliases.occupant + + " Type" + + "" + + exports.aliases.occupant + + "" + + "Address" + + "Phone Number" + + 'Options' + + "" + + ""; for (const lotOccupancyOccupant of lotOccupancyOccupants) { const tableRowElement = document.createElement("tr"); - tableRowElement.dataset.lotOccupantIndex = lotOccupancyOccupant.lotOccupantIndex.toString(); - tableRowElement.innerHTML = ("" + cityssm.escapeHTML(lotOccupancyOccupant.lotOccupantType) + "") + - ("" + cityssm.escapeHTML(lotOccupancyOccupant.occupantName) + "") + - ("" + - cityssm.escapeHTML(lotOccupancyOccupant.occupantAddress1) + "
" + - (lotOccupancyOccupant.occupantAddress2 ? cityssm.escapeHTML(lotOccupancyOccupant.occupantAddress2) + "
" : "") + - (lotOccupancyOccupant.occupantCity ? cityssm.escapeHTML(lotOccupancyOccupant.occupantCity) + ", " : "") + cityssm.escapeHTML(lotOccupancyOccupant.occupantProvince) + "
" + - cityssm.escapeHTML(lotOccupancyOccupant.occupantPostalCode) + - "") + - ("" + cityssm.escapeHTML(lotOccupancyOccupant.occupantPhoneNumber) + "") + - ("" + - "
" + - ("") + - ("") + - "
" + - ""); - tableRowElement.querySelector(".button--edit").addEventListener("click", openEditLotOccupancyOccupant); - tableRowElement.querySelector(".button--delete").addEventListener("click", deleteLotOccupancyOccupant); + tableRowElement.dataset.lotOccupantIndex = + lotOccupancyOccupant.lotOccupantIndex.toString(); + tableRowElement.innerHTML = + "" + + cityssm.escapeHTML(lotOccupancyOccupant.lotOccupantType) + + "" + + ("" + + cityssm.escapeHTML(lotOccupancyOccupant.occupantName) + + "") + + ("" + + cityssm.escapeHTML(lotOccupancyOccupant.occupantAddress1) + + "
" + + (lotOccupancyOccupant.occupantAddress2 + ? cityssm.escapeHTML(lotOccupancyOccupant.occupantAddress2) + "
" + : "") + + (lotOccupancyOccupant.occupantCity + ? cityssm.escapeHTML(lotOccupancyOccupant.occupantCity) + ", " + : "") + + cityssm.escapeHTML(lotOccupancyOccupant.occupantProvince) + + "
" + + cityssm.escapeHTML(lotOccupancyOccupant.occupantPostalCode) + + "") + + ("" + + cityssm.escapeHTML(lotOccupancyOccupant.occupantPhoneNumber) + + "") + + ('' + + '
' + + ('") + + ('") + + "
" + + ""); + tableRowElement + .querySelector(".button--edit") + .addEventListener("click", openEditLotOccupancyOccupant); + tableRowElement + .querySelector(".button--delete") + .addEventListener("click", deleteLotOccupancyOccupant); tableElement.querySelector("tbody").append(tableRowElement); } occupantsContainer.append(tableElement); }; - document.querySelector("#button--addOccupant").addEventListener("click", () => { + document + .querySelector("#button--addOccupant") + .addEventListener("click", () => { let addFormElement; let addCloseModalFunction; const addOccupant = (submitEvent) => { submitEvent.preventDefault(); cityssm.postJSON(urlPrefix + "/lotOccupancies/doAddLotOccupancyOccupant", addFormElement, (responseJSON) => { if (responseJSON.success) { - lotOccupancyOccupants = responseJSON.lotOccupancyOccupants; + lotOccupancyOccupants = + responseJSON.lotOccupancyOccupants; addCloseModalFunction(); renderLotOccupancyOccupants(); } else { bulmaJS.alert({ - title: "Error Adding " + exports.aliases.occupant, + title: "Error Adding " + + exports.aliases.occupant, message: responseJSON.errorMessage, contextualColorName: "danger" }); @@ -439,8 +541,10 @@ Object.defineProperty(exports, "__esModule", { value: true }); const lotOccupantTypeSelectElement = modalElement.querySelector("#lotOccupancyOccupantAdd--lotOccupantTypeId"); for (const lotOccupantType of exports.lotOccupantTypes) { const optionElement = document.createElement("option"); - optionElement.value = lotOccupantType.lotOccupantTypeId.toString(); - optionElement.textContent = lotOccupantType.lotOccupantType; + optionElement.value = + lotOccupantType.lotOccupantTypeId.toString(); + optionElement.textContent = + lotOccupantType.lotOccupantType; lotOccupantTypeSelectElement.append(optionElement); } modalElement.querySelector("#lotOccupancyOccupantAdd--occupantCity").value = exports.occupantCityDefault; @@ -464,9 +568,11 @@ Object.defineProperty(exports, "__esModule", { value: true }); let lotOccupancyComments = exports.lotOccupancyComments; delete exports.lotOccupancyComments; const openEditLotOccupancyComment = (clickEvent) => { - const lotOccupancyCommentId = Number.parseInt(clickEvent.currentTarget.closest("tr").dataset.lotOccupancyCommentId, 10); + const lotOccupancyCommentId = Number.parseInt(clickEvent.currentTarget.closest("tr").dataset + .lotOccupancyCommentId, 10); const lotOccupancyComment = lotOccupancyComments.find((currentLotOccupancyComment) => { - return currentLotOccupancyComment.lotOccupancyCommentId === lotOccupancyCommentId; + return (currentLotOccupancyComment.lotOccupancyCommentId === + lotOccupancyCommentId); }); let editFormElement; let editCloseModalFunction; @@ -474,7 +580,8 @@ Object.defineProperty(exports, "__esModule", { value: true }); submitEvent.preventDefault(); cityssm.postJSON(urlPrefix + "/lotOccupancies/doUpdateLotOccupancyComment", editFormElement, (responseJSON) => { if (responseJSON.success) { - lotOccupancyComments = responseJSON.lotOccupancyComments; + lotOccupancyComments = + responseJSON.lotOccupancyComments; editCloseModalFunction(); renderLotOccupancyComments(); } @@ -509,14 +616,16 @@ Object.defineProperty(exports, "__esModule", { value: true }); }); }; const deleteLotOccupancyComment = (clickEvent) => { - const lotOccupancyCommentId = Number.parseInt(clickEvent.currentTarget.closest("tr").dataset.lotOccupancyCommentId, 10); + const lotOccupancyCommentId = Number.parseInt(clickEvent.currentTarget.closest("tr").dataset + .lotOccupancyCommentId, 10); const doDelete = () => { cityssm.postJSON(urlPrefix + "/lotOccupancies/doDeleteLotOccupancyComment", { lotOccupancyId, lotOccupancyCommentId }, (responseJSON) => { if (responseJSON.success) { - lotOccupancyComments = responseJSON.lotOccupancyComments; + lotOccupancyComments = + responseJSON.lotOccupancyComments; renderLotOccupancyComments(); } else { @@ -541,55 +650,74 @@ Object.defineProperty(exports, "__esModule", { value: true }); const renderLotOccupancyComments = () => { const containerElement = document.querySelector("#container--lotOccupancyComments"); if (lotOccupancyComments.length === 0) { - containerElement.innerHTML = "
" + - "

There are no comments associated with this record.

" + - "
"; + containerElement.innerHTML = + '
' + + '

There are no comments associated with this record.

' + + "
"; return; } const tableElement = document.createElement("table"); - tableElement.className = "table is-fullwidth is-striped is-hoverable"; - tableElement.innerHTML = "" + - "Commentor" + - "Comment Date" + - "Comment" + - "Options" + - "" + - ""; + tableElement.className = + "table is-fullwidth is-striped is-hoverable"; + tableElement.innerHTML = + "" + + "Commentor" + + "Comment Date" + + "Comment" + + 'Options' + + "" + + ""; for (const lotOccupancyComment of lotOccupancyComments) { const tableRowElement = document.createElement("tr"); - tableRowElement.dataset.lotOccupancyCommentId = lotOccupancyComment.lotOccupancyCommentId.toString(); - tableRowElement.innerHTML = "" + cityssm.escapeHTML(lotOccupancyComment.recordCreate_userName) + "" + + tableRowElement.dataset.lotOccupancyCommentId = + lotOccupancyComment.lotOccupancyCommentId.toString(); + tableRowElement.innerHTML = "" + - lotOccupancyComment.lotOccupancyCommentDateString + - (lotOccupancyComment.lotOccupancyCommentTime === 0 ? "" : " " + lotOccupancyComment.lotOccupancyCommentTimeString) + - "" + - "" + cityssm.escapeHTML(lotOccupancyComment.lotOccupancyComment) + "" + - ("" + - "
" + - ("") + - ("") + - "
" + - ""); - tableRowElement.querySelector(".button--edit").addEventListener("click", openEditLotOccupancyComment); - tableRowElement.querySelector(".button--delete").addEventListener("click", deleteLotOccupancyComment); + cityssm.escapeHTML(lotOccupancyComment.recordCreate_userName) + + "" + + "" + + lotOccupancyComment.lotOccupancyCommentDateString + + (lotOccupancyComment.lotOccupancyCommentTime === 0 + ? "" + : " " + + lotOccupancyComment.lotOccupancyCommentTimeString) + + "" + + "" + + cityssm.escapeHTML(lotOccupancyComment.lotOccupancyComment) + + "" + + ('' + + '
' + + ('") + + ('") + + "
" + + ""); + tableRowElement + .querySelector(".button--edit") + .addEventListener("click", openEditLotOccupancyComment); + tableRowElement + .querySelector(".button--delete") + .addEventListener("click", deleteLotOccupancyComment); tableElement.querySelector("tbody").append(tableRowElement); } containerElement.innerHTML = ""; containerElement.append(tableElement); }; - document.querySelector("#button--addComment").addEventListener("click", () => { + document + .querySelector("#button--addComment") + .addEventListener("click", () => { let addFormElement; let addCloseModalFunction; const addComment = (submitEvent) => { submitEvent.preventDefault(); cityssm.postJSON(urlPrefix + "/lotOccupancies/doAddLotOccupancyComment", addFormElement, (responseJSON) => { if (responseJSON.success) { - lotOccupancyComments = responseJSON.lotOccupancyComments; + lotOccupancyComments = + responseJSON.lotOccupancyComments; addCloseModalFunction(); renderLotOccupancyComments(); } @@ -628,7 +756,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); const getFeeGrandTotal = () => { let feeGrandTotal = 0; for (const lotOccupancyFee of lotOccupancyFees) { - feeGrandTotal += (lotOccupancyFee.feeAmount + lotOccupancyFee.taxAmount) * lotOccupancyFee.quantity; + feeGrandTotal += + (lotOccupancyFee.feeAmount + lotOccupancyFee.taxAmount) * + lotOccupancyFee.quantity; } return feeGrandTotal; }; @@ -658,68 +788,89 @@ Object.defineProperty(exports, "__esModule", { value: true }); contextualColorName: "warning", okButton: { text: "Yes, Delete Fee", - callbackFunction: doDelete, + callbackFunction: doDelete } }); }; const renderLotOccupancyFees = () => { if (lotOccupancyFees.length === 0) { - lotOccupancyFeesContainerElement.innerHTML = "
" + - "

There are no fees associated with this record.

" + - "
"; + lotOccupancyFeesContainerElement.innerHTML = + '
' + + '

There are no fees associated with this record.

' + + "
"; renderLotOccupancyTransactions(); return; } - lotOccupancyFeesContainerElement.innerHTML = "" + - ("" + - "" + - "" + - "" + - "" + - "" + - "" + - "" + - "") + - "" + - ("" + - "" + - "" + - "" + - "") + - "
FeeUnit Cost×QuantityequalsTotalOptions
Subtotal
Tax
Grand Total
"; + lotOccupancyFeesContainerElement.innerHTML = + '' + + ("" + + "" + + '' + + '' + + '' + + '' + + '' + + '' + + "") + + "" + + ("" + + '' + + '' + + '' + + "") + + "
FeeUnit Cost×QuantityequalsTotalOptions
Subtotal
Tax
Grand Total
"; let feeAmountTotal = 0; let taxAmountTotal = 0; for (const lotOccupancyFee of lotOccupancyFees) { const tableRowElement = document.createElement("tr"); tableRowElement.className = "container--lotOccupancyFee"; - tableRowElement.dataset.feeId = lotOccupancyFee.feeId.toString(); - tableRowElement.dataset.includeQuantity = (lotOccupancyFee.includeQuantity ? "1" : "0"); - tableRowElement.innerHTML = ("" + - cityssm.escapeHTML(lotOccupancyFee.feeName) + - "") + - (lotOccupancyFee.quantity === 1 ? - "" : - "$" + lotOccupancyFee.feeAmount.toFixed(2) + "" + - "×" + - "" + lotOccupancyFee.quantity + "" + - "=") + - "$" + (lotOccupancyFee.feeAmount * lotOccupancyFee.quantity).toFixed(2) + "" + - ("" + - "" + - ""); - tableRowElement.querySelector("button").addEventListener("click", deleteLotOccupancyFee); - lotOccupancyFeesContainerElement.querySelector("tbody").append(tableRowElement); - feeAmountTotal += (lotOccupancyFee.feeAmount * lotOccupancyFee.quantity); - taxAmountTotal += (lotOccupancyFee.taxAmount * lotOccupancyFee.quantity); + tableRowElement.dataset.feeId = + lotOccupancyFee.feeId.toString(); + tableRowElement.dataset.includeQuantity = + lotOccupancyFee.includeQuantity ? "1" : "0"; + tableRowElement.innerHTML = + '' + + cityssm.escapeHTML(lotOccupancyFee.feeName) + + "" + + (lotOccupancyFee.quantity === 1 + ? "" + : '$' + + lotOccupancyFee.feeAmount.toFixed(2) + + "" + + "×" + + '' + + lotOccupancyFee.quantity + + "" + + "=") + + '$' + + (lotOccupancyFee.feeAmount * lotOccupancyFee.quantity).toFixed(2) + + "" + + ('' + + '" + + ""); + tableRowElement + .querySelector("button") + .addEventListener("click", deleteLotOccupancyFee); + lotOccupancyFeesContainerElement + .querySelector("tbody") + .append(tableRowElement); + feeAmountTotal += + lotOccupancyFee.feeAmount * lotOccupancyFee.quantity; + taxAmountTotal += + lotOccupancyFee.taxAmount * lotOccupancyFee.quantity; } lotOccupancyFeesContainerElement.querySelector("#lotOccupancyFees--feeAmountTotal").textContent = "$" + feeAmountTotal.toFixed(2); lotOccupancyFeesContainerElement.querySelector("#lotOccupancyFees--taxAmountTotal").textContent = "$" + taxAmountTotal.toFixed(2); lotOccupancyFeesContainerElement.querySelector("#lotOccupancyFees--grandTotal").textContent = "$" + (feeAmountTotal + taxAmountTotal).toFixed(2); renderLotOccupancyTransactions(); }; - document.querySelector("#button--addFee").addEventListener("click", () => { + document + .querySelector("#button--addFee") + .addEventListener("click", () => { if (hasUnsavedChanges) { bulmaJS.alert({ message: "Please save all unsaved changes before adding fees.", @@ -737,7 +888,8 @@ Object.defineProperty(exports, "__esModule", { value: true }); quantity }, (responseJSON) => { if (responseJSON.success) { - lotOccupancyFees = responseJSON.lotOccupancyFees; + lotOccupancyFees = + responseJSON.lotOccupancyFees; renderLotOccupancyFees(); filterFees(); } @@ -765,7 +917,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); onshown: (modalElement, closeModalFunction) => { quantityCloseModalFunction = closeModalFunction; quantityElement = modalElement.querySelector("#lotOccupancyFeeQuantity--quantity"); - modalElement.querySelector("form").addEventListener("submit", doSetQuantity); + modalElement + .querySelector("form") + .addEventListener("submit", doSetQuantity); } }); }; @@ -774,7 +928,8 @@ Object.defineProperty(exports, "__esModule", { value: true }); const feeId = Number.parseInt(clickEvent.currentTarget.dataset.feeId, 10); const feeCategoryId = Number.parseInt(clickEvent.currentTarget.closest(".container--feeCategory").dataset.feeCategoryId, 10); const feeCategory = feeCategories.find((currentFeeCategory) => { - return currentFeeCategory.feeCategoryId === feeCategoryId; + return (currentFeeCategory.feeCategoryId === + feeCategoryId); }); const fee = feeCategory.fees.find((currentFee) => { return currentFee.feeId === feeId; @@ -787,22 +942,34 @@ Object.defineProperty(exports, "__esModule", { value: true }); } }; const filterFees = () => { - const filterStringPieces = feeFilterElement.value.trim().toLowerCase().split(" "); + const filterStringPieces = feeFilterElement.value + .trim() + .toLowerCase() + .split(" "); feeFilterResultsElement.innerHTML = ""; for (const feeCategory of feeCategories) { const categoryContainerElement = document.createElement("div"); - categoryContainerElement.className = "container--feeCategory"; - categoryContainerElement.dataset.feeCategoryId = feeCategory.feeCategoryId.toString(); - categoryContainerElement.innerHTML = "

" + cityssm.escapeHTML(feeCategory.feeCategory) + "

" + - "
"; + categoryContainerElement.className = + "container--feeCategory"; + categoryContainerElement.dataset.feeCategoryId = + feeCategory.feeCategoryId.toString(); + categoryContainerElement.innerHTML = + '

' + + cityssm.escapeHTML(feeCategory.feeCategory) + + "

" + + '
'; let hasFees = false; for (const fee of feeCategory.fees) { - if (lotOccupancyFeesContainerElement.querySelector(".container--lotOccupancyFee[data-fee-id='" + fee.feeId + "'][data-include-quantity='0']")) { + if (lotOccupancyFeesContainerElement.querySelector(".container--lotOccupancyFee[data-fee-id='" + + fee.feeId + + "'][data-include-quantity='0']")) { continue; } let includeFee = true; for (const filterStringPiece of filterStringPieces) { - if (!fee.feeName.toLowerCase().includes(filterStringPiece)) { + if (!fee.feeName + .toLowerCase() + .includes(filterStringPiece)) { includeFee = false; break; } @@ -812,13 +979,24 @@ Object.defineProperty(exports, "__esModule", { value: true }); } hasFees = true; const panelBlockElement = document.createElement("a"); - panelBlockElement.className = "panel-block is-block container--fee"; - panelBlockElement.dataset.feeId = fee.feeId.toString(); + panelBlockElement.className = + "panel-block is-block container--fee"; + panelBlockElement.dataset.feeId = + fee.feeId.toString(); panelBlockElement.href = "#"; - panelBlockElement.innerHTML = "" + cityssm.escapeHTML(fee.feeName) + "
" + - "" + cityssm.escapeHTML(fee.feeDescription).replace(/\n/g, "
") + "
"; + panelBlockElement.innerHTML = + "" + + cityssm.escapeHTML(fee.feeName) + + "
" + + "" + + cityssm + .escapeHTML(fee.feeDescription) + .replace(/\n/g, "
") + + "
"; panelBlockElement.addEventListener("click", tryAddFee); - categoryContainerElement.querySelector(".panel").append(panelBlockElement); + categoryContainerElement + .querySelector(".panel") + .append(panelBlockElement); } if (hasFees) { feeFilterResultsElement.append(categoryContainerElement); @@ -856,19 +1034,22 @@ Object.defineProperty(exports, "__esModule", { value: true }); const getTransactionGrandTotal = () => { let transactionGrandTotal = 0; for (const lotOccupancyTransaction of lotOccupancyTransactions) { - transactionGrandTotal += lotOccupancyTransaction.transactionAmount; + transactionGrandTotal += + lotOccupancyTransaction.transactionAmount; } return transactionGrandTotal; }; const deleteLotOccupancyTransaction = (clickEvent) => { const transactionIndex = clickEvent.currentTarget.closest(".container--lotOccupancyTransaction").dataset.transactionIndex; const doDelete = () => { - cityssm.postJSON(urlPrefix + "/lotOccupancies/doDeleteLotOccupancyTransaction", { + cityssm.postJSON(urlPrefix + + "/lotOccupancies/doDeleteLotOccupancyTransaction", { lotOccupancyId, transactionIndex }, (responseJSON) => { if (responseJSON.success) { - lotOccupancyTransactions = responseJSON.lotOccupancyTransactions; + lotOccupancyTransactions = + responseJSON.lotOccupancyTransactions; renderLotOccupancyTransactions(); } else { @@ -886,71 +1067,98 @@ Object.defineProperty(exports, "__esModule", { value: true }); contextualColorName: "warning", okButton: { text: "Yes, Delete Transaction", - callbackFunction: doDelete, + callbackFunction: doDelete } }); }; const renderLotOccupancyTransactions = () => { if (lotOccupancyTransactions.length === 0) { - lotOccupancyTransactionsContainerElement.innerHTML = "
" + - "

There are no transactions associated with this record.

" + - "
"; + lotOccupancyTransactionsContainerElement.innerHTML = + '
' + + '

There are no transactions associated with this record.

' + + "
"; return; } - lotOccupancyTransactionsContainerElement.innerHTML = "" + - "" + - "" + - "" + - "" + - "" + - "" + - "" + - ("" + - "" + - "" + - "" + - "") + - "
Date" + cityssm.escapeHTML(exports.aliases.externalReceiptNumber) + "AmountOptions
Transaction Total
"; + lotOccupancyTransactionsContainerElement.innerHTML = + '' + + "" + + '' + + "" + + '' + + '' + + "" + + "" + + ("" + + '' + + '' + + '' + + "") + + "
Date" + + cityssm.escapeHTML(exports.aliases.externalReceiptNumber) + + "AmountOptions
Transaction Total
"; let transactionGrandTotal = 0; for (const lotOccupancyTransaction of lotOccupancyTransactions) { - transactionGrandTotal += lotOccupancyTransaction.transactionAmount; + transactionGrandTotal += + lotOccupancyTransaction.transactionAmount; const tableRowElement = document.createElement("tr"); - tableRowElement.className = "container--lotOccupancyTransaction"; - tableRowElement.dataset.transactionIndex = lotOccupancyTransaction.transactionIndex.toString(); - tableRowElement.innerHTML = "" + lotOccupancyTransaction.transactionDateString + "" + - ("" + - cityssm.escapeHTML(lotOccupancyTransaction.externalReceiptNumber) + "
" + - "" + cityssm.escapeHTML(lotOccupancyTransaction.transactionNote) + "" + - "") + - ("$" + lotOccupancyTransaction.transactionAmount.toFixed(2) + "") + - ("" + - "" + - ""); - tableRowElement.querySelector("button").addEventListener("click", deleteLotOccupancyTransaction); - lotOccupancyTransactionsContainerElement.querySelector("tbody").append(tableRowElement); + tableRowElement.className = + "container--lotOccupancyTransaction"; + tableRowElement.dataset.transactionIndex = + lotOccupancyTransaction.transactionIndex.toString(); + tableRowElement.innerHTML = + "" + + lotOccupancyTransaction.transactionDateString + + "" + + ("" + + cityssm.escapeHTML(lotOccupancyTransaction.externalReceiptNumber) + + "
" + + "" + + cityssm.escapeHTML(lotOccupancyTransaction.transactionNote) + + "" + + "") + + ('$' + + lotOccupancyTransaction.transactionAmount.toFixed(2) + + "") + + ('' + + '" + + ""); + tableRowElement + .querySelector("button") + .addEventListener("click", deleteLotOccupancyTransaction); + lotOccupancyTransactionsContainerElement + .querySelector("tbody") + .append(tableRowElement); } lotOccupancyTransactionsContainerElement.querySelector("#lotOccupancyTransactions--grandTotal").textContent = "$" + transactionGrandTotal.toFixed(2); const feeGrandTotal = getFeeGrandTotal(); if (feeGrandTotal > transactionGrandTotal) { - lotOccupancyTransactionsContainerElement.insertAdjacentHTML("afterbegin", "
" + - "
" + - "
" + - "
Outstanding Balance
" + - "
$" + (feeGrandTotal - transactionGrandTotal).toFixed(2) + "
" + + lotOccupancyTransactionsContainerElement.insertAdjacentHTML("afterbegin", '
' + + '
' + + '
' + + '
Outstanding Balance
' + + '
$' + + (feeGrandTotal - transactionGrandTotal).toFixed(2) + + "
" + "
" + "
" + "
"); } }; - document.querySelector("#button--addTransaction").addEventListener("click", () => { + document + .querySelector("#button--addTransaction") + .addEventListener("click", () => { let addCloseModalFunction; const doAddTransaction = (submitEvent) => { submitEvent.preventDefault(); - cityssm.postJSON(urlPrefix + "/lotOccupancies/doAddLotOccupancyTransaction", submitEvent.currentTarget, (responseJSON) => { + cityssm.postJSON(urlPrefix + + "/lotOccupancies/doAddLotOccupancyTransaction", submitEvent.currentTarget, (responseJSON) => { if (responseJSON.success) { - lotOccupancyTransactions = responseJSON.lotOccupancyTransactions; + lotOccupancyTransactions = + responseJSON.lotOccupancyTransactions; addCloseModalFunction(); renderLotOccupancyTransactions(); } @@ -977,7 +1185,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); onshown: (modalElement, closeModalFunction) => { bulmaJS.toggleHtmlClipped(); addCloseModalFunction = closeModalFunction; - modalElement.querySelector("form").addEventListener("submit", doAddTransaction); + modalElement + .querySelector("form") + .addEventListener("submit", doAddTransaction); }, onremoved: () => { bulmaJS.toggleHtmlClipped(); diff --git a/public-typescript/lotOccupancyEdit.ts b/public-typescript/lotOccupancyEdit.ts index 2ec5c87b..7d9b2f6c 100644 --- a/public-typescript/lotOccupancyEdit.ts +++ b/public-typescript/lotOccupancyEdit.ts @@ -3,26 +3,24 @@ import type * as globalTypes from "../types/globalTypes"; import type * as recordTypes from "../types/recordTypes"; -import type { - cityssmGlobal -} from "@cityssm/bulma-webapp-js/src/types"; +import type { cityssmGlobal } from "@cityssm/bulma-webapp-js/src/types"; -import type { - BulmaJS -} from "@cityssm/bulma-js/types"; +import type { BulmaJS } from "@cityssm/bulma-js/types"; declare const cityssm: cityssmGlobal; declare const bulmaJS: BulmaJS; - (() => { - - const los = (exports.los as globalTypes.LOS); + const los = exports.los as globalTypes.LOS; const urlPrefix = document.querySelector("main").dataset.urlPrefix; - const lotOccupancyId = (document.querySelector("#lotOccupancy--lotOccupancyId") as HTMLInputElement).value; - const isCreate = (lotOccupancyId === ""); + const lotOccupancyId = ( + document.querySelector( + "#lotOccupancy--lotOccupancyId" + ) as HTMLInputElement + ).value; + const isCreate = lotOccupancyId === ""; /* * Main form @@ -43,28 +41,38 @@ declare const bulmaJS: BulmaJS; cityssm.disableNavBlocker(); }; - const formElement = document.querySelector("#form--lotOccupancy") as HTMLFormElement; + const formElement = document.querySelector( + "#form--lotOccupancy" + ) as HTMLFormElement; formElement.addEventListener("submit", (formEvent) => { formEvent.preventDefault(); - cityssm.postJSON(urlPrefix + "/lotOccupancies/" + (isCreate ? "doCreateLotOccupancy" : "doUpdateLotOccupancy"), + cityssm.postJSON( + urlPrefix + + "/lotOccupancies/" + + (isCreate ? "doCreateLotOccupancy" : "doUpdateLotOccupancy"), formElement, (responseJSON: { success: boolean; - lotOccupancyId ? : number; - errorMessage ? : string; + lotOccupancyId?: number; + errorMessage?: string; }) => { - if (responseJSON.success) { - clearUnsavedChanges(); if (isCreate || refreshAfterSave) { - window.location.href = urlPrefix + "/lotOccupancies/" + responseJSON.lotOccupancyId + "/edit?t=" + Date.now(); + window.location.href = + urlPrefix + + "/lotOccupancies/" + + responseJSON.lotOccupancyId + + "/edit?t=" + + Date.now(); } else { bulmaJS.alert({ - message: exports.aliases.occupancy + " Updated Successfully", + message: + exports.aliases.occupancy + + " Updated Successfully", contextualColorName: "success" }); } @@ -75,7 +83,8 @@ declare const bulmaJS: BulmaJS; contextualColorName: "danger" }); } - }); + } + ); }); const formInputElements = formElement.querySelectorAll("input, select"); @@ -85,72 +94,89 @@ declare const bulmaJS: BulmaJS; } if (!isCreate) { - document.querySelector("#button--deleteLotOccupancy").addEventListener("click", (clickEvent) => { - clickEvent.preventDefault(); + document + .querySelector("#button--deleteLotOccupancy") + .addEventListener("click", (clickEvent) => { + clickEvent.preventDefault(); - const doDelete = () => { - cityssm.postJSON(urlPrefix + "/lotOccupancies/doDeleteLotOccupancy", { - lotOccupancyId - }, - (responseJSON: { - success: boolean;errorMessage ? : string; - }) => { - - if (responseJSON.success) { - window.location.href = urlPrefix + "/lotOccupancies?t=" + Date.now(); - } else { - bulmaJS.alert({ - title: "Error Deleting Record", - message: responseJSON.errorMessage, - contextualColorName: "danger" - }); + const doDelete = () => { + cityssm.postJSON( + urlPrefix + "/lotOccupancies/doDeleteLotOccupancy", + { + lotOccupancyId + }, + (responseJSON: { + success: boolean; + errorMessage?: string; + }) => { + if (responseJSON.success) { + window.location.href = + urlPrefix + + "/lotOccupancies?t=" + + Date.now(); + } else { + bulmaJS.alert({ + title: "Error Deleting Record", + message: responseJSON.errorMessage, + contextualColorName: "danger" + }); + } } - }); - } + ); + }; - bulmaJS.confirm({ - title: "Delete " + exports.aliases.occupancy + " Record", - message: "Are you sure you want to delete this record?", - contextualColorName: "warning", - okButton: { - text: "Yes, Delete", - callbackFunction: doDelete - } + bulmaJS.confirm({ + title: "Delete " + exports.aliases.occupancy + " Record", + message: "Are you sure you want to delete this record?", + contextualColorName: "warning", + okButton: { + text: "Yes, Delete", + callbackFunction: doDelete + } + }); }); - }); } // Occupancy Type - const occupancyTypeIdElement = document.querySelector("#lotOccupancy--occupancyTypeId") as HTMLSelectElement; + const occupancyTypeIdElement = document.querySelector( + "#lotOccupancy--occupancyTypeId" + ) as HTMLSelectElement; if (isCreate) { - - const lotOccupancyFieldsContainerElement = document.querySelector("#container--lotOccupancyFields") as HTMLElement; + const lotOccupancyFieldsContainerElement = document.querySelector( + "#container--lotOccupancyFields" + ) as HTMLElement; occupancyTypeIdElement.addEventListener("change", () => { - if (occupancyTypeIdElement.value === "") { - lotOccupancyFieldsContainerElement.innerHTML = "
" + - "

Select the " + exports.aliases.occupancy.toLowerCase() + " type to load the available fields.

" + + lotOccupancyFieldsContainerElement.innerHTML = + '
' + + '

Select the ' + + exports.aliases.occupancy.toLowerCase() + + " type to load the available fields.

" + "
"; - return + return; } - cityssm.postJSON(urlPrefix + "/lotOccupancies/doGetOccupancyTypeFields", { + cityssm.postJSON( + urlPrefix + "/lotOccupancies/doGetOccupancyTypeFields", + { occupancyTypeId: occupancyTypeIdElement.value }, (responseJSON: { - occupancyTypeFields: recordTypes.OccupancyTypeField[] + occupancyTypeFields: recordTypes.OccupancyTypeField[]; }) => { - if (responseJSON.occupancyTypeFields.length === 0) { - lotOccupancyFieldsContainerElement.innerHTML = "
" + - "

There are no additional fields for this " + exports.aliases.occupancy.toLowerCase() + " type.

" + + lotOccupancyFieldsContainerElement.innerHTML = + '
' + + '

There are no additional fields for this ' + + exports.aliases.occupancy.toLowerCase() + + " type.

" + "
"; - return + return; } lotOccupancyFieldsContainerElement.innerHTML = ""; @@ -158,51 +184,70 @@ declare const bulmaJS: BulmaJS; let occupancyTypeFieldIds = ""; for (const occupancyTypeField of responseJSON.occupancyTypeFields) { - - occupancyTypeFieldIds += "," + occupancyTypeField.occupancyTypeFieldId; + occupancyTypeFieldIds += + "," + occupancyTypeField.occupancyTypeFieldId; const fieldElement = document.createElement("div"); fieldElement.className = "field"; - fieldElement.innerHTML = "" + - "
"; + fieldElement.innerHTML = + '' + + '
'; - fieldElement.querySelector("label").textContent = occupancyTypeField.occupancyTypeField; + fieldElement.querySelector("label").textContent = + occupancyTypeField.occupancyTypeField; const inputElement = document.createElement("input"); inputElement.className = "input"; - inputElement.id = "lotOccupancy--lotOccupancyFieldValue_" + occupancyTypeField.occupancyTypeFieldId; - inputElement.name = "lotOccupancyFieldValue_" + occupancyTypeField.occupancyTypeFieldId; + inputElement.id = + "lotOccupancy--lotOccupancyFieldValue_" + + occupancyTypeField.occupancyTypeFieldId; + inputElement.name = + "lotOccupancyFieldValue_" + + occupancyTypeField.occupancyTypeFieldId; inputElement.type = "text"; inputElement.required = occupancyTypeField.isRequired; - inputElement.minLength = occupancyTypeField.minimumLength; - inputElement.maxLength = occupancyTypeField.maximumLength; + inputElement.minLength = + occupancyTypeField.minimumLength; + inputElement.maxLength = + occupancyTypeField.maximumLength; - if (occupancyTypeField.pattern && occupancyTypeField.pattern !== "") { + if ( + occupancyTypeField.pattern && + occupancyTypeField.pattern !== "" + ) { inputElement.pattern = occupancyTypeField.pattern; } - fieldElement.querySelector(".control").append(inputElement); + fieldElement + .querySelector(".control") + .append(inputElement); lotOccupancyFieldsContainerElement.append(fieldElement); } - lotOccupancyFieldsContainerElement.insertAdjacentHTML("beforeend", - ""); - }); + lotOccupancyFieldsContainerElement.insertAdjacentHTML( + "beforeend", + '' + ); + } + ); }); - } else { - const originalOccupancyTypeId = occupancyTypeIdElement.value; occupancyTypeIdElement.addEventListener("change", () => { - if (occupancyTypeIdElement.value !== originalOccupancyTypeId) { - bulmaJS.confirm({ title: "Confirm Change", - message: "Are you sure you want to change the " + exports.aliases.occupancy.toLowerCase() + " type?\n" + + message: + "Are you sure you want to change the " + + exports.aliases.occupancy.toLowerCase() + + " type?\n" + "This change affects the additional fields associated with this record, and may also affect the available fees.", contextualColorName: "warning", okButton: { @@ -214,7 +259,8 @@ declare const bulmaJS: BulmaJS; cancelButton: { text: "Revert the Change", callbackFunction: () => { - occupancyTypeIdElement.value = originalOccupancyTypeId; + occupancyTypeIdElement.value = + originalOccupancyTypeId; } } }); @@ -224,11 +270,13 @@ declare const bulmaJS: BulmaJS; // Lot Selector - const lotNameElement = document.querySelector("#lotOccupancy--lotName") as HTMLInputElement; + const lotNameElement = document.querySelector( + "#lotOccupancy--lotName" + ) as HTMLInputElement; lotNameElement.addEventListener("click", (clickEvent) => { - - const currentLotName = (clickEvent.currentTarget as HTMLInputElement).value; + const currentLotName = (clickEvent.currentTarget as HTMLInputElement) + .value; let lotSelectCloseModalFunction: () => void; @@ -240,8 +288,16 @@ declare const bulmaJS: BulmaJS; const selectedLotElement = clickEvent.currentTarget as HTMLElement; - (document.querySelector("#lotOccupancy--lotId") as HTMLInputElement).value = selectedLotElement.dataset.lotId; - (document.querySelector("#lotOccupancy--lotName") as HTMLInputElement).value = selectedLotElement.dataset.lotName; + ( + document.querySelector( + "#lotOccupancy--lotId" + ) as HTMLInputElement + ).value = selectedLotElement.dataset.lotId; + ( + document.querySelector( + "#lotOccupancy--lotName" + ) as HTMLInputElement + ).value = selectedLotElement.dataset.lotName; setUnsavedChanges(); @@ -249,61 +305,67 @@ declare const bulmaJS: BulmaJS; }; const searchLots = () => { - - lotSelectResultsElement.innerHTML = "

" + - "
" + + lotSelectResultsElement.innerHTML = + '

' + + '
' + "Searching..." + "

"; - cityssm.postJSON(urlPrefix + "/lots/doSearchLots", lotSelectFormElement, (responseJSON: { - count: number; - lots: recordTypes.Lot[]; - }) => { + cityssm.postJSON( + urlPrefix + "/lots/doSearchLots", + lotSelectFormElement, + (responseJSON: { count: number; lots: recordTypes.Lot[] }) => { + if (responseJSON.count === 0) { + lotSelectResultsElement.innerHTML = + '
' + + '

' + + "No results." + + "

" + + "
"; - if (responseJSON.count === 0) { - lotSelectResultsElement.innerHTML = "
" + - "

" + - "No results." + - "

" + - "
"; + return; + } - return; + const panelElement = document.createElement("div"); + panelElement.className = "panel"; + + for (const lot of responseJSON.lots) { + const panelBlockElement = document.createElement("a"); + panelBlockElement.className = "panel-block is-block"; + panelBlockElement.href = "#"; + + panelBlockElement.dataset.lotId = lot.lotId.toString(); + panelBlockElement.dataset.lotName = lot.lotName; + + panelBlockElement.innerHTML = + '
' + + ('
' + + cityssm.escapeHTML(lot.lotName) + + "
" + + '' + + cityssm.escapeHTML(lot.mapName) + + "" + + "
") + + ('
' + + cityssm.escapeHTML(lot.lotStatus as string) + + "
" + + '' + + (lot.lotOccupancyCount > 0 + ? "Currently Occupied" + : "") + + "" + + "
") + + "
"; + + panelBlockElement.addEventListener("click", selectLot); + + panelElement.append(panelBlockElement); + } + + lotSelectResultsElement.innerHTML = ""; + lotSelectResultsElement.append(panelElement); } - - const panelElement = document.createElement("div"); - panelElement.className = "panel"; - - for (const lot of responseJSON.lots) { - - const panelBlockElement = document.createElement("a"); - panelBlockElement.className = "panel-block is-block"; - panelBlockElement.href = "#"; - - panelBlockElement.dataset.lotId = lot.lotId.toString(); - panelBlockElement.dataset.lotName = lot.lotName; - - panelBlockElement.innerHTML = "
" + - ("
" + - cityssm.escapeHTML(lot.lotName) + "
" + - "" + cityssm.escapeHTML(lot.mapName) + "" + - "
") + - ("
" + - cityssm.escapeHTML(lot.lotStatus as string) + "
" + - "" + - (lot.lotOccupancyCount > 0 ? - "Currently Occupied" : "") + - "" + - "
") + - "
"; - - panelBlockElement.addEventListener("click", selectLot); - - panelElement.append(panelBlockElement); - } - - lotSelectResultsElement.innerHTML = ""; - lotSelectResultsElement.append(panelElement); - }); + ); }; cityssm.openHtmlModal("lotOccupancy-selectLot", { @@ -311,33 +373,51 @@ declare const bulmaJS: BulmaJS; los.populateAliases(modalElement); }, onshown: (modalElement, closeModalFunction) => { - bulmaJS.toggleHtmlClipped(); lotSelectCloseModalFunction = closeModalFunction; - const lotNameFilterElement = modalElement.querySelector("#lotSelect--lotName") as HTMLInputElement; + const lotNameFilterElement = modalElement.querySelector( + "#lotSelect--lotName" + ) as HTMLInputElement; - if ((document.querySelector("#lotOccupancy--lotId") as HTMLInputElement).value !== "") { + if ( + ( + document.querySelector( + "#lotOccupancy--lotId" + ) as HTMLInputElement + ).value !== "" + ) { lotNameFilterElement.value = currentLotName; } lotNameFilterElement.focus(); lotNameFilterElement.addEventListener("change", searchLots); - const occupancyStatusFilterElement = modalElement.querySelector("#lotSelect--occupancyStatus") as HTMLSelectElement; - occupancyStatusFilterElement.addEventListener("change", searchLots); + const occupancyStatusFilterElement = modalElement.querySelector( + "#lotSelect--occupancyStatus" + ) as HTMLSelectElement; + occupancyStatusFilterElement.addEventListener( + "change", + searchLots + ); if (currentLotName !== "") { occupancyStatusFilterElement.value = ""; } - lotSelectFormElement = modalElement.querySelector("#form--lotSelect"); - lotSelectResultsElement = modalElement.querySelector("#resultsContainer--lotSelect"); + lotSelectFormElement = + modalElement.querySelector("#form--lotSelect"); + lotSelectResultsElement = modalElement.querySelector( + "#resultsContainer--lotSelect" + ); - lotSelectFormElement.addEventListener("submit", (submitEvent) => { - submitEvent.preventDefault(); - }); + lotSelectFormElement.addEventListener( + "submit", + (submitEvent) => { + submitEvent.preventDefault(); + } + ); searchLots(); }, @@ -347,41 +427,62 @@ declare const bulmaJS: BulmaJS; }); }); - document.querySelector(".is-lot-view-button").addEventListener("click", () => { + document + .querySelector(".is-lot-view-button") + .addEventListener("click", () => { + const lotId = ( + document.querySelector( + "#lotOccupancy--lotId" + ) as HTMLInputElement + ).value; - const lotId = (document.querySelector("#lotOccupancy--lotId") as HTMLInputElement).value; + if (lotId) { + window.open(urlPrefix + "/lots/" + lotId); + } else { + bulmaJS.alert({ + message: + "No " + + exports.aliases.lot.toLowerCase() + + " selected.", + contextualColorName: "info" + }); + } + }); - if (lotId) { - window.open(urlPrefix + "/lots/" + lotId); - } else { - bulmaJS.alert({ - message: "No " + exports.aliases.lot.toLowerCase() + " selected.", - contextualColorName: "info" - }); - } - }); - - document.querySelector(".is-clear-lot-button").addEventListener("click", () => { - - if (lotNameElement.disabled) { - bulmaJS.alert({ - message: "You need to unlock the field before clearing it.", - contextualColorName: "info" - }); - } else { - lotNameElement.value = "(No " + exports.aliases.lot + ")"; - (document.querySelector("#lotOccupancy--lotId") as HTMLInputElement).value = ""; - setUnsavedChanges(); - } - }); + document + .querySelector(".is-clear-lot-button") + .addEventListener("click", () => { + if (lotNameElement.disabled) { + bulmaJS.alert({ + message: "You need to unlock the field before clearing it.", + contextualColorName: "info" + }); + } else { + lotNameElement.value = "(No " + exports.aliases.lot + ")"; + ( + document.querySelector( + "#lotOccupancy--lotId" + ) as HTMLInputElement + ).value = ""; + setUnsavedChanges(); + } + }); // Start Date - document.querySelector("#lotOccupancy--occupancyStartDateString").addEventListener("change", () => { - - (document.querySelector("#lotOccupancy--occupancyEndDateString") as HTMLInputElement).min = - (document.querySelector("#lotOccupancy--occupancyStartDateString") as HTMLInputElement).value; - }); + document + .querySelector("#lotOccupancy--occupancyStartDateString") + .addEventListener("change", () => { + ( + document.querySelector( + "#lotOccupancy--occupancyEndDateString" + ) as HTMLInputElement + ).min = ( + document.querySelector( + "#lotOccupancy--occupancyStartDateString" + ) as HTMLInputElement + ).value; + }); los.initializeUnlockFieldButtons(formElement); @@ -390,60 +491,91 @@ declare const bulmaJS: BulmaJS; */ if (!isCreate) { - let lotOccupancyOccupants: recordTypes.LotOccupancyOccupant[] = exports.lotOccupancyOccupants; + let lotOccupancyOccupants: recordTypes.LotOccupancyOccupant[] = + exports.lotOccupancyOccupants; delete exports.lotOccupancyOccupants; const openEditLotOccupancyOccupant = (clickEvent: Event) => { - const lotOccupantIndex = Number.parseInt((clickEvent.currentTarget as HTMLElement).closest("tr").dataset.lotOccupantIndex, 10); + const lotOccupantIndex = Number.parseInt( + (clickEvent.currentTarget as HTMLElement).closest("tr").dataset + .lotOccupantIndex, + 10 + ); - const lotOccupancyOccupant = lotOccupancyOccupants.find((currentLotOccupancyOccupant) => { - return currentLotOccupancyOccupant.lotOccupantIndex === lotOccupantIndex; - }); + const lotOccupancyOccupant = lotOccupancyOccupants.find( + (currentLotOccupancyOccupant) => { + return ( + currentLotOccupancyOccupant.lotOccupantIndex === + lotOccupantIndex + ); + } + ); let editFormElement: HTMLFormElement; let editCloseModalFunction: () => void; const editOccupant = (submitEvent: SubmitEvent) => { - submitEvent.preventDefault(); - cityssm.postJSON(urlPrefix + "/lotOccupancies/doUpdateLotOccupancyOccupant", + cityssm.postJSON( + urlPrefix + "/lotOccupancies/doUpdateLotOccupancyOccupant", editFormElement, (responseJSON: { - success: boolean;errorMessage ? : string;lotOccupancyOccupants ? : recordTypes.LotOccupancyOccupant[]; + success: boolean; + errorMessage?: string; + lotOccupancyOccupants?: recordTypes.LotOccupancyOccupant[]; }) => { - if (responseJSON.success) { - lotOccupancyOccupants = responseJSON.lotOccupancyOccupants; + lotOccupancyOccupants = + responseJSON.lotOccupancyOccupants; editCloseModalFunction(); renderLotOccupancyOccupants(); } else { bulmaJS.alert({ - title: "Error Updating " + exports.aliases.occupant, + title: + "Error Updating " + + exports.aliases.occupant, message: responseJSON.errorMessage, contextualColorName: "danger" }); } - }); + } + ); }; cityssm.openHtmlModal("lotOccupancy-editOccupant", { onshow: (modalElement) => { los.populateAliases(modalElement); - (modalElement.querySelector("#lotOccupancyOccupantEdit--lotOccupancyId") as HTMLInputElement).value = lotOccupancyId; - (modalElement.querySelector("#lotOccupancyOccupantEdit--lotOccupantIndex") as HTMLInputElement).value = lotOccupantIndex.toString(); + ( + modalElement.querySelector( + "#lotOccupancyOccupantEdit--lotOccupancyId" + ) as HTMLInputElement + ).value = lotOccupancyId; + ( + modalElement.querySelector( + "#lotOccupancyOccupantEdit--lotOccupantIndex" + ) as HTMLInputElement + ).value = lotOccupantIndex.toString(); - const lotOccupantTypeSelectElement = modalElement.querySelector("#lotOccupancyOccupantEdit--lotOccupantTypeId") as HTMLSelectElement; + const lotOccupantTypeSelectElement = + modalElement.querySelector( + "#lotOccupancyOccupantEdit--lotOccupantTypeId" + ) as HTMLSelectElement; let lotOccupantTypeSelected = false; - for (const lotOccupantType of (exports.lotOccupantTypes as recordTypes.LotOccupantType[])) { + for (const lotOccupantType of exports.lotOccupantTypes as recordTypes.LotOccupantType[]) { const optionElement = document.createElement("option"); - optionElement.value = lotOccupantType.lotOccupantTypeId.toString(); - optionElement.textContent = lotOccupantType.lotOccupantType; + optionElement.value = + lotOccupantType.lotOccupantTypeId.toString(); + optionElement.textContent = + lotOccupantType.lotOccupantType; - if (lotOccupantType.lotOccupantTypeId === lotOccupancyOccupant.lotOccupantTypeId) { + if ( + lotOccupantType.lotOccupantTypeId === + lotOccupancyOccupant.lotOccupantTypeId + ) { optionElement.selected = true; lotOccupantTypeSelected = true; } @@ -454,26 +586,59 @@ declare const bulmaJS: BulmaJS; if (!lotOccupantTypeSelected) { const optionElement = document.createElement("option"); - optionElement.value = lotOccupancyOccupant.lotOccupantTypeId.toString(); - optionElement.textContent = lotOccupancyOccupant.lotOccupantType as string; + optionElement.value = + lotOccupancyOccupant.lotOccupantTypeId.toString(); + optionElement.textContent = + lotOccupancyOccupant.lotOccupantType as string; optionElement.selected = true; lotOccupantTypeSelectElement.append(optionElement); } - (modalElement.querySelector("#lotOccupancyOccupantEdit--occupantName") as HTMLInputElement).value = lotOccupancyOccupant.occupantName; - (modalElement.querySelector("#lotOccupancyOccupantEdit--occupantAddress1") as HTMLInputElement).value = lotOccupancyOccupant.occupantAddress1; - (modalElement.querySelector("#lotOccupancyOccupantEdit--occupantAddress2") as HTMLInputElement).value = lotOccupancyOccupant.occupantAddress2; - (modalElement.querySelector("#lotOccupancyOccupantEdit--occupantCity") as HTMLInputElement).value = lotOccupancyOccupant.occupantCity; - (modalElement.querySelector("#lotOccupancyOccupantEdit--occupantProvince") as HTMLInputElement).value = lotOccupancyOccupant.occupantProvince; - (modalElement.querySelector("#lotOccupancyOccupantEdit--occupantPostalCode") as HTMLInputElement).value = lotOccupancyOccupant.occupantPostalCode; - (modalElement.querySelector("#lotOccupancyOccupantEdit--occupantPhoneNumber") as HTMLInputElement).value = lotOccupancyOccupant.occupantPhoneNumber; + ( + modalElement.querySelector( + "#lotOccupancyOccupantEdit--occupantName" + ) as HTMLInputElement + ).value = lotOccupancyOccupant.occupantName; + ( + modalElement.querySelector( + "#lotOccupancyOccupantEdit--occupantAddress1" + ) as HTMLInputElement + ).value = lotOccupancyOccupant.occupantAddress1; + ( + modalElement.querySelector( + "#lotOccupancyOccupantEdit--occupantAddress2" + ) as HTMLInputElement + ).value = lotOccupancyOccupant.occupantAddress2; + ( + modalElement.querySelector( + "#lotOccupancyOccupantEdit--occupantCity" + ) as HTMLInputElement + ).value = lotOccupancyOccupant.occupantCity; + ( + modalElement.querySelector( + "#lotOccupancyOccupantEdit--occupantProvince" + ) as HTMLInputElement + ).value = lotOccupancyOccupant.occupantProvince; + ( + modalElement.querySelector( + "#lotOccupancyOccupantEdit--occupantPostalCode" + ) as HTMLInputElement + ).value = lotOccupancyOccupant.occupantPostalCode; + ( + modalElement.querySelector( + "#lotOccupancyOccupantEdit--occupantPhoneNumber" + ) as HTMLInputElement + ).value = lotOccupancyOccupant.occupantPhoneNumber; }, onshown: (modalElement, closeModalFunction) => { - bulmaJS.toggleHtmlClipped(); - (modalElement.querySelector("#lotOccupancyOccupantEdit--lotOccupantTypeId") as HTMLInputElement).focus(); + ( + modalElement.querySelector( + "#lotOccupancyOccupantEdit--lotOccupantTypeId" + ) as HTMLInputElement + ).focus(); editFormElement = modalElement.querySelector("form"); editFormElement.addEventListener("submit", editOccupant); @@ -487,33 +652,45 @@ declare const bulmaJS: BulmaJS; }; const deleteLotOccupancyOccupant = (clickEvent: Event) => { - - const lotOccupantIndex = (clickEvent.currentTarget as HTMLElement).closest("tr").dataset.lotOccupantIndex; + const lotOccupantIndex = ( + clickEvent.currentTarget as HTMLElement + ).closest("tr").dataset.lotOccupantIndex; const doDelete = () => { - cityssm.postJSON(urlPrefix + "/lotOccupancies/doDeleteLotOccupancyOccupant", { + cityssm.postJSON( + urlPrefix + "/lotOccupancies/doDeleteLotOccupancyOccupant", + { lotOccupancyId, lotOccupantIndex }, (responseJSON: { - success: boolean;errorMessage ? : string;lotOccupancyOccupants: recordTypes.LotOccupancyOccupant[]; + success: boolean; + errorMessage?: string; + lotOccupancyOccupants: recordTypes.LotOccupancyOccupant[]; }) => { if (responseJSON.success) { - lotOccupancyOccupants = responseJSON.lotOccupancyOccupants; + lotOccupancyOccupants = + responseJSON.lotOccupancyOccupants; renderLotOccupancyOccupants(); } else { bulmaJS.alert({ - title: "Error Removing " + exports.aliases.occupant, + title: + "Error Removing " + + exports.aliases.occupant, message: responseJSON.errorMessage, contextualColorName: "danger" }); } - }); + } + ); }; bulmaJS.confirm({ title: "Remove " + exports.aliases.occupant + "?", - message: "Are you sure you want to remove this " + exports.aliases.occupant.toLowerCase() + "?", + message: + "Are you sure you want to remove this " + + exports.aliases.occupant.toLowerCase() + + "?", okButton: { text: "Yes, Remove " + exports.aliases.occupant, callbackFunction: doDelete @@ -523,59 +700,103 @@ declare const bulmaJS: BulmaJS; }; const renderLotOccupancyOccupants = () => { - - const occupantsContainer = document.querySelector("#container--lotOccupancyOccupants") as HTMLElement; + const occupantsContainer = document.querySelector( + "#container--lotOccupancyOccupants" + ) as HTMLElement; cityssm.clearElement(occupantsContainer); if (lotOccupancyOccupants.length === 0) { - occupantsContainer.innerHTML = "
" + - "

There are no " + exports.aliases.occupants.toLowerCase() + " associated with this record.

" + + occupantsContainer.innerHTML = + '
' + + '

There are no ' + + exports.aliases.occupants.toLowerCase() + + " associated with this record.

" + "
"; return; } 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 = "" + - "" + exports.aliases.occupant + " Type" + - "" + exports.aliases.occupant + "" + + tableElement.innerHTML = + "" + + "" + + exports.aliases.occupant + + " Type" + + "" + + exports.aliases.occupant + + "" + "Address" + "Phone Number" + - "Options" + + 'Options' + "" + ""; for (const lotOccupancyOccupant of lotOccupancyOccupants) { - const tableRowElement = document.createElement("tr"); - tableRowElement.dataset.lotOccupantIndex = lotOccupancyOccupant.lotOccupantIndex.toString(); + tableRowElement.dataset.lotOccupantIndex = + lotOccupancyOccupant.lotOccupantIndex.toString(); - tableRowElement.innerHTML = ("" + cityssm.escapeHTML(lotOccupancyOccupant.lotOccupantType as string) + "") + - ("" + cityssm.escapeHTML(lotOccupancyOccupant.occupantName) + "") + + tableRowElement.innerHTML = + "" + + cityssm.escapeHTML( + lotOccupancyOccupant.lotOccupantType as string + ) + + "" + ("" + - cityssm.escapeHTML(lotOccupancyOccupant.occupantAddress1) + "
" + - (lotOccupancyOccupant.occupantAddress2 ? cityssm.escapeHTML(lotOccupancyOccupant.occupantAddress2) + "
" : "") + - (lotOccupancyOccupant.occupantCity ? cityssm.escapeHTML(lotOccupancyOccupant.occupantCity) + ", " : "") + cityssm.escapeHTML(lotOccupancyOccupant.occupantProvince) + "
" + - cityssm.escapeHTML(lotOccupancyOccupant.occupantPostalCode) + + cityssm.escapeHTML(lotOccupancyOccupant.occupantName) + "") + - ("" + cityssm.escapeHTML(lotOccupancyOccupant.occupantPhoneNumber) + "") + - ("" + - "
" + - ("") + - ("") + "
" + ""); - tableRowElement.querySelector(".button--edit").addEventListener("click", openEditLotOccupancyOccupant); - tableRowElement.querySelector(".button--delete").addEventListener("click", deleteLotOccupancyOccupant); + tableRowElement + .querySelector(".button--edit") + .addEventListener("click", openEditLotOccupancyOccupant); + tableRowElement + .querySelector(".button--delete") + .addEventListener("click", deleteLotOccupancyOccupant); tableElement.querySelector("tbody").append(tableRowElement); } @@ -583,69 +804,96 @@ declare const bulmaJS: BulmaJS; occupantsContainer.append(tableElement); }; - document.querySelector("#button--addOccupant").addEventListener("click", () => { + document + .querySelector("#button--addOccupant") + .addEventListener("click", () => { + let addFormElement: HTMLFormElement; + let addCloseModalFunction: () => void; - let addFormElement: HTMLFormElement; - let addCloseModalFunction: () => void; + const addOccupant = (submitEvent: SubmitEvent) => { + submitEvent.preventDefault(); - const addOccupant = (submitEvent: SubmitEvent) => { - - submitEvent.preventDefault(); - - cityssm.postJSON(urlPrefix + "/lotOccupancies/doAddLotOccupancyOccupant", - addFormElement, - (responseJSON: { - success: boolean;errorMessage ? : string;lotOccupancyOccupants ? : recordTypes.LotOccupancyOccupant[]; - }) => { - - if (responseJSON.success) { - lotOccupancyOccupants = responseJSON.lotOccupancyOccupants; - addCloseModalFunction(); - renderLotOccupancyOccupants(); - } else { - bulmaJS.alert({ - title: "Error Adding " + exports.aliases.occupant, - message: responseJSON.errorMessage, - contextualColorName: "danger" - }); + cityssm.postJSON( + urlPrefix + "/lotOccupancies/doAddLotOccupancyOccupant", + addFormElement, + (responseJSON: { + success: boolean; + errorMessage?: string; + lotOccupancyOccupants?: recordTypes.LotOccupancyOccupant[]; + }) => { + if (responseJSON.success) { + lotOccupancyOccupants = + responseJSON.lotOccupancyOccupants; + addCloseModalFunction(); + renderLotOccupancyOccupants(); + } else { + bulmaJS.alert({ + title: + "Error Adding " + + exports.aliases.occupant, + message: responseJSON.errorMessage, + contextualColorName: "danger" + }); + } } - }); - }; + ); + }; - cityssm.openHtmlModal("lotOccupancy-addOccupant", { - onshow: (modalElement) => { - los.populateAliases(modalElement); + cityssm.openHtmlModal("lotOccupancy-addOccupant", { + onshow: (modalElement) => { + los.populateAliases(modalElement); - (modalElement.querySelector("#lotOccupancyOccupantAdd--lotOccupancyId") as HTMLInputElement).value = lotOccupancyId; + ( + modalElement.querySelector( + "#lotOccupancyOccupantAdd--lotOccupancyId" + ) as HTMLInputElement + ).value = lotOccupancyId; - const lotOccupantTypeSelectElement = modalElement.querySelector("#lotOccupancyOccupantAdd--lotOccupantTypeId") as HTMLSelectElement; + const lotOccupantTypeSelectElement = + modalElement.querySelector( + "#lotOccupancyOccupantAdd--lotOccupantTypeId" + ) as HTMLSelectElement; - for (const lotOccupantType of (exports.lotOccupantTypes as recordTypes.LotOccupantType[])) { - const optionElement = document.createElement("option"); - optionElement.value = lotOccupantType.lotOccupantTypeId.toString(); - optionElement.textContent = lotOccupantType.lotOccupantType; - lotOccupantTypeSelectElement.append(optionElement); + for (const lotOccupantType of exports.lotOccupantTypes as recordTypes.LotOccupantType[]) { + const optionElement = + document.createElement("option"); + optionElement.value = + lotOccupantType.lotOccupantTypeId.toString(); + optionElement.textContent = + lotOccupantType.lotOccupantType; + lotOccupantTypeSelectElement.append(optionElement); + } + + ( + modalElement.querySelector( + "#lotOccupancyOccupantAdd--occupantCity" + ) as HTMLInputElement + ).value = exports.occupantCityDefault; + ( + modalElement.querySelector( + "#lotOccupancyOccupantAdd--occupantProvince" + ) as HTMLInputElement + ).value = exports.occupantProvinceDefault; + }, + onshown: (modalElement, closeModalFunction) => { + bulmaJS.toggleHtmlClipped(); + + ( + modalElement.querySelector( + "#lotOccupancyOccupantAdd--lotOccupantTypeId" + ) as HTMLInputElement + ).focus(); + + addFormElement = modalElement.querySelector("form"); + addFormElement.addEventListener("submit", addOccupant); + + addCloseModalFunction = closeModalFunction; + }, + onremoved: () => { + bulmaJS.toggleHtmlClipped(); } - - (modalElement.querySelector("#lotOccupancyOccupantAdd--occupantCity") as HTMLInputElement).value = exports.occupantCityDefault; - (modalElement.querySelector("#lotOccupancyOccupantAdd--occupantProvince") as HTMLInputElement).value = exports.occupantProvinceDefault; - }, - onshown: (modalElement, closeModalFunction) => { - - bulmaJS.toggleHtmlClipped(); - - (modalElement.querySelector("#lotOccupancyOccupantAdd--lotOccupantTypeId") as HTMLInputElement).focus(); - - addFormElement = modalElement.querySelector("form"); - addFormElement.addEventListener("submit", addOccupant); - - addCloseModalFunction = closeModalFunction; - }, - onremoved: () => { - bulmaJS.toggleHtmlClipped(); - } + }); }); - }); renderLotOccupancyOccupants(); } @@ -655,34 +903,43 @@ declare const bulmaJS: BulmaJS; */ if (!isCreate) { - let lotOccupancyComments: recordTypes.LotOccupancyComment[] = exports.lotOccupancyComments; + let lotOccupancyComments: recordTypes.LotOccupancyComment[] = + exports.lotOccupancyComments; delete exports.lotOccupancyComments; const openEditLotOccupancyComment = (clickEvent: Event) => { + const lotOccupancyCommentId = Number.parseInt( + (clickEvent.currentTarget as HTMLElement).closest("tr").dataset + .lotOccupancyCommentId, + 10 + ); - const lotOccupancyCommentId = Number.parseInt((clickEvent.currentTarget as HTMLElement).closest("tr").dataset.lotOccupancyCommentId, 10); - - const lotOccupancyComment = lotOccupancyComments.find((currentLotOccupancyComment) => { - return currentLotOccupancyComment.lotOccupancyCommentId === lotOccupancyCommentId; - }); + const lotOccupancyComment = lotOccupancyComments.find( + (currentLotOccupancyComment) => { + return ( + currentLotOccupancyComment.lotOccupancyCommentId === + lotOccupancyCommentId + ); + } + ); let editFormElement: HTMLFormElement; let editCloseModalFunction: () => void; const editComment = (submitEvent: SubmitEvent) => { - submitEvent.preventDefault(); - cityssm.postJSON(urlPrefix + "/lotOccupancies/doUpdateLotOccupancyComment", + cityssm.postJSON( + urlPrefix + "/lotOccupancies/doUpdateLotOccupancyComment", editFormElement, (responseJSON: { success: boolean; - errorMessage ? : string; - lotOccupancyComments ? : recordTypes.LotOccupancyComment[]; + errorMessage?: string; + lotOccupancyComments?: recordTypes.LotOccupancyComment[]; }) => { - if (responseJSON.success) { - lotOccupancyComments = responseJSON.lotOccupancyComments; + lotOccupancyComments = + responseJSON.lotOccupancyComments; editCloseModalFunction(); renderLotOccupancyComments(); } else { @@ -692,25 +949,49 @@ declare const bulmaJS: BulmaJS; contextualColorName: "danger" }); } - }); + } + ); }; cityssm.openHtmlModal("lotOccupancy-editComment", { onshow: (modalElement) => { los.populateAliases(modalElement); - (modalElement.querySelector("#lotOccupancyCommentEdit--lotOccupancyId") as HTMLInputElement).value = lotOccupancyId; - (modalElement.querySelector("#lotOccupancyCommentEdit--lotOccupancyCommentId") as HTMLInputElement).value = lotOccupancyCommentId.toString(); + ( + modalElement.querySelector( + "#lotOccupancyCommentEdit--lotOccupancyId" + ) as HTMLInputElement + ).value = lotOccupancyId; + ( + modalElement.querySelector( + "#lotOccupancyCommentEdit--lotOccupancyCommentId" + ) as HTMLInputElement + ).value = lotOccupancyCommentId.toString(); - (modalElement.querySelector("#lotOccupancyCommentEdit--lotOccupancyComment") as HTMLInputElement).value = lotOccupancyComment.lotOccupancyComment; - (modalElement.querySelector("#lotOccupancyCommentEdit--lotOccupancyCommentDateString") as HTMLInputElement).value = lotOccupancyComment.lotOccupancyCommentDateString; - (modalElement.querySelector("#lotOccupancyCommentEdit--lotOccupancyCommentTimeString") as HTMLInputElement).value = lotOccupancyComment.lotOccupancyCommentTimeString; + ( + modalElement.querySelector( + "#lotOccupancyCommentEdit--lotOccupancyComment" + ) as HTMLInputElement + ).value = lotOccupancyComment.lotOccupancyComment; + ( + modalElement.querySelector( + "#lotOccupancyCommentEdit--lotOccupancyCommentDateString" + ) as HTMLInputElement + ).value = lotOccupancyComment.lotOccupancyCommentDateString; + ( + modalElement.querySelector( + "#lotOccupancyCommentEdit--lotOccupancyCommentTimeString" + ) as HTMLInputElement + ).value = lotOccupancyComment.lotOccupancyCommentTimeString; }, onshown: (modalElement, closeModalFunction) => { - bulmaJS.toggleHtmlClipped(); - (modalElement.querySelector("#lotOccupancyCommentEdit--lotOccupancyComment") as HTMLTextAreaElement).focus(); + ( + modalElement.querySelector( + "#lotOccupancyCommentEdit--lotOccupancyComment" + ) as HTMLTextAreaElement + ).focus(); editFormElement = modalElement.querySelector("form"); editFormElement.addEventListener("submit", editComment); @@ -724,21 +1005,27 @@ declare const bulmaJS: BulmaJS; }; const deleteLotOccupancyComment = (clickEvent: Event) => { - - const lotOccupancyCommentId = Number.parseInt((clickEvent.currentTarget as HTMLElement).closest("tr").dataset.lotOccupancyCommentId, 10); + const lotOccupancyCommentId = Number.parseInt( + (clickEvent.currentTarget as HTMLElement).closest("tr").dataset + .lotOccupancyCommentId, + 10 + ); const doDelete = () => { - cityssm.postJSON(urlPrefix + "/lotOccupancies/doDeleteLotOccupancyComment", { + cityssm.postJSON( + urlPrefix + "/lotOccupancies/doDeleteLotOccupancyComment", + { lotOccupancyId, lotOccupancyCommentId }, (responseJSON: { success: boolean; - errorMessage ? : string; + errorMessage?: string; lotOccupancyComments: recordTypes.LotOccupancyComment[]; }) => { if (responseJSON.success) { - lotOccupancyComments = responseJSON.lotOccupancyComments; + lotOccupancyComments = + responseJSON.lotOccupancyComments; renderLotOccupancyComments(); } else { bulmaJS.alert({ @@ -747,7 +1034,8 @@ declare const bulmaJS: BulmaJS; contextualColorName: "danger" }); } - }); + } + ); }; bulmaJS.confirm({ @@ -762,51 +1050,71 @@ declare const bulmaJS: BulmaJS; }; const renderLotOccupancyComments = () => { - - const containerElement = document.querySelector("#container--lotOccupancyComments") as HTMLElement; + const containerElement = document.querySelector( + "#container--lotOccupancyComments" + ) as HTMLElement; if (lotOccupancyComments.length === 0) { - containerElement.innerHTML = "
" + - "

There are no comments associated with this record.

" + + containerElement.innerHTML = + '
' + + '

There are no comments associated with this record.

' + "
"; return; } const tableElement = document.createElement("table"); - tableElement.className = "table is-fullwidth is-striped is-hoverable"; - tableElement.innerHTML = "" + + tableElement.className = + "table is-fullwidth is-striped is-hoverable"; + tableElement.innerHTML = + "" + "Commentor" + "Comment Date" + "Comment" + - "Options" + + 'Options' + "" + ""; for (const lotOccupancyComment of lotOccupancyComments) { - const tableRowElement = document.createElement("tr"); - tableRowElement.dataset.lotOccupancyCommentId = lotOccupancyComment.lotOccupancyCommentId.toString(); + tableRowElement.dataset.lotOccupancyCommentId = + lotOccupancyComment.lotOccupancyCommentId.toString(); - tableRowElement.innerHTML = "" + cityssm.escapeHTML(lotOccupancyComment.recordCreate_userName) + "" + + tableRowElement.innerHTML = + "" + + cityssm.escapeHTML( + lotOccupancyComment.recordCreate_userName + ) + + "" + "" + lotOccupancyComment.lotOccupancyCommentDateString + - (lotOccupancyComment.lotOccupancyCommentTime === 0 ? "" : " " + lotOccupancyComment.lotOccupancyCommentTimeString) + + (lotOccupancyComment.lotOccupancyCommentTime === 0 + ? "" + : " " + + lotOccupancyComment.lotOccupancyCommentTimeString) + "" + - "" + cityssm.escapeHTML(lotOccupancyComment.lotOccupancyComment) + "" + - ("" + - "
" + - ("") + - ("") + "
" + ""); - tableRowElement.querySelector(".button--edit").addEventListener("click", openEditLotOccupancyComment); - tableRowElement.querySelector(".button--delete").addEventListener("click", deleteLotOccupancyComment); + tableRowElement + .querySelector(".button--edit") + .addEventListener("click", openEditLotOccupancyComment); + tableRowElement + .querySelector(".button--delete") + .addEventListener("click", deleteLotOccupancyComment); tableElement.querySelector("tbody").append(tableRowElement); } @@ -815,61 +1123,68 @@ declare const bulmaJS: BulmaJS; containerElement.append(tableElement); }; + document + .querySelector("#button--addComment") + .addEventListener("click", () => { + let addFormElement: HTMLFormElement; + let addCloseModalFunction: () => void; - document.querySelector("#button--addComment").addEventListener("click", () => { + const addComment = (submitEvent: SubmitEvent) => { + submitEvent.preventDefault(); - let addFormElement: HTMLFormElement; - let addCloseModalFunction: () => void; - - const addComment = (submitEvent: SubmitEvent) => { - - submitEvent.preventDefault(); - - cityssm.postJSON(urlPrefix + "/lotOccupancies/doAddLotOccupancyComment", - addFormElement, - (responseJSON: { - success: boolean; - errorMessage ? : string; - lotOccupancyComments ? : recordTypes.LotOccupancyComment[]; - }) => { - - if (responseJSON.success) { - lotOccupancyComments = responseJSON.lotOccupancyComments; - addCloseModalFunction(); - renderLotOccupancyComments(); - } else { - bulmaJS.alert({ - title: "Error Adding Comment", - message: responseJSON.errorMessage, - contextualColorName: "danger" - }); + cityssm.postJSON( + urlPrefix + "/lotOccupancies/doAddLotOccupancyComment", + addFormElement, + (responseJSON: { + success: boolean; + errorMessage?: string; + lotOccupancyComments?: recordTypes.LotOccupancyComment[]; + }) => { + if (responseJSON.success) { + lotOccupancyComments = + responseJSON.lotOccupancyComments; + addCloseModalFunction(); + renderLotOccupancyComments(); + } else { + bulmaJS.alert({ + title: "Error Adding Comment", + message: responseJSON.errorMessage, + contextualColorName: "danger" + }); + } } - }); - }; + ); + }; - cityssm.openHtmlModal("lotOccupancy-addComment", { - onshow: (modalElement) => { - los.populateAliases(modalElement); + cityssm.openHtmlModal("lotOccupancy-addComment", { + onshow: (modalElement) => { + los.populateAliases(modalElement); - (modalElement.querySelector("#lotOccupancyCommentAdd--lotOccupancyId") as HTMLInputElement).value = lotOccupancyId; - }, - onshown: (modalElement, closeModalFunction) => { + ( + modalElement.querySelector( + "#lotOccupancyCommentAdd--lotOccupancyId" + ) as HTMLInputElement + ).value = lotOccupancyId; + }, + onshown: (modalElement, closeModalFunction) => { + bulmaJS.toggleHtmlClipped(); - bulmaJS.toggleHtmlClipped(); + ( + modalElement.querySelector( + "#lotOccupancyCommentAdd--lotOccupancyComment" + ) as HTMLTextAreaElement + ).focus(); - (modalElement.querySelector("#lotOccupancyCommentAdd--lotOccupancyComment") as HTMLTextAreaElement).focus(); + addFormElement = modalElement.querySelector("form"); + addFormElement.addEventListener("submit", addComment); - addFormElement = modalElement.querySelector("form"); - addFormElement.addEventListener("submit", addComment); - - addCloseModalFunction = closeModalFunction; - }, - onremoved: () => { - bulmaJS.toggleHtmlClipped(); - } + addCloseModalFunction = closeModalFunction; + }, + onremoved: () => { + bulmaJS.toggleHtmlClipped(); + } + }); }); - }); - renderLotOccupancyComments(); } @@ -879,36 +1194,45 @@ declare const bulmaJS: BulmaJS; */ if (!isCreate) { - - let lotOccupancyFees: recordTypes.LotOccupancyFee[] = exports.lotOccupancyFees; + let lotOccupancyFees: recordTypes.LotOccupancyFee[] = + exports.lotOccupancyFees; delete exports.lotOccupancyFees; - const lotOccupancyFeesContainerElement = document.querySelector("#container--lotOccupancyFees") as HTMLElement; + const lotOccupancyFeesContainerElement = document.querySelector( + "#container--lotOccupancyFees" + ) as HTMLElement; const getFeeGrandTotal = (): number => { - let feeGrandTotal = 0; for (const lotOccupancyFee of lotOccupancyFees) { - feeGrandTotal += (lotOccupancyFee.feeAmount + lotOccupancyFee.taxAmount) * lotOccupancyFee.quantity; + feeGrandTotal += + (lotOccupancyFee.feeAmount + lotOccupancyFee.taxAmount) * + lotOccupancyFee.quantity; } return feeGrandTotal; }; const deleteLotOccupancyFee = (clickEvent: Event) => { - - const feeId = ((clickEvent.currentTarget as HTMLElement).closest(".container--lotOccupancyFee") as HTMLElement).dataset.feeId; + const feeId = ( + (clickEvent.currentTarget as HTMLElement).closest( + ".container--lotOccupancyFee" + ) as HTMLElement + ).dataset.feeId; const doDelete = () => { - cityssm.postJSON(urlPrefix + "/lotOccupancies/doDeleteLotOccupancyFee", { + cityssm.postJSON( + urlPrefix + "/lotOccupancies/doDeleteLotOccupancyFee", + { lotOccupancyId, feeId }, (responseJSON: { - success: boolean;errorMessage ? : string;lotOccupancyFees ? : recordTypes.LotOccupancyFee[]; + success: boolean; + errorMessage?: string; + lotOccupancyFees?: recordTypes.LotOccupancyFee[]; }) => { - if (responseJSON.success) { lotOccupancyFees = responseJSON.lotOccupancyFees; renderLotOccupancyFees(); @@ -919,7 +1243,8 @@ declare const bulmaJS: BulmaJS; contextualColorName: "danger" }); } - }); + } + ); }; bulmaJS.confirm({ @@ -928,16 +1253,16 @@ declare const bulmaJS: BulmaJS; contextualColorName: "warning", okButton: { text: "Yes, Delete Fee", - callbackFunction: doDelete, + callbackFunction: doDelete } }); }; const renderLotOccupancyFees = () => { - if (lotOccupancyFees.length === 0) { - lotOccupancyFeesContainerElement.innerHTML = "
" + - "

There are no fees associated with this record.

" + + lotOccupancyFeesContainerElement.innerHTML = + '
' + + '

There are no fees associated with this record.

' + "
"; renderLotOccupancyTransactions(); @@ -945,21 +1270,22 @@ declare const bulmaJS: BulmaJS; return; } - lotOccupancyFeesContainerElement.innerHTML = "" + + lotOccupancyFeesContainerElement.innerHTML = + '
' + ("" + "" + - "" + - "" + - "" + - "" + - "" + - "" + + '' + + '' + + '' + + '' + + '' + + '' + "") + "" + ("" + - "" + - "" + - "" + + '' + + '' + + '' + "") + "
FeeUnit Cost×QuantityequalsTotalOptionsUnit Cost×QuantityequalsTotalOptions
Subtotal
Tax
Grand Total
Subtotal
Tax
Grand Total
"; @@ -967,253 +1293,361 @@ declare const bulmaJS: BulmaJS; let taxAmountTotal = 0; for (const lotOccupancyFee of lotOccupancyFees) { - const tableRowElement = document.createElement("tr"); tableRowElement.className = "container--lotOccupancyFee"; - tableRowElement.dataset.feeId = lotOccupancyFee.feeId.toString(); - tableRowElement.dataset.includeQuantity = (lotOccupancyFee.includeQuantity ? "1" : "0"); + tableRowElement.dataset.feeId = + lotOccupancyFee.feeId.toString(); + tableRowElement.dataset.includeQuantity = + lotOccupancyFee.includeQuantity ? "1" : "0"; - tableRowElement.innerHTML = ("" + - cityssm.escapeHTML(lotOccupancyFee.feeName) + - "") + - (lotOccupancyFee.quantity === 1 ? - "" : - "$" + lotOccupancyFee.feeAmount.toFixed(2) + "" + - "×" + - "" + lotOccupancyFee.quantity + "" + - "=") + - "$" + (lotOccupancyFee.feeAmount * lotOccupancyFee.quantity).toFixed(2) + "" + - ("" + - "" + ""); - tableRowElement.querySelector("button").addEventListener("click", deleteLotOccupancyFee); + tableRowElement + .querySelector("button") + .addEventListener("click", deleteLotOccupancyFee); - lotOccupancyFeesContainerElement.querySelector("tbody").append(tableRowElement); + lotOccupancyFeesContainerElement + .querySelector("tbody") + .append(tableRowElement); - feeAmountTotal += (lotOccupancyFee.feeAmount * lotOccupancyFee.quantity); - taxAmountTotal += (lotOccupancyFee.taxAmount * lotOccupancyFee.quantity); + feeAmountTotal += + lotOccupancyFee.feeAmount * lotOccupancyFee.quantity; + taxAmountTotal += + lotOccupancyFee.taxAmount * lotOccupancyFee.quantity; } - (lotOccupancyFeesContainerElement.querySelector("#lotOccupancyFees--feeAmountTotal") as HTMLElement).textContent = "$" + feeAmountTotal.toFixed(2); - (lotOccupancyFeesContainerElement.querySelector("#lotOccupancyFees--taxAmountTotal") as HTMLElement).textContent = "$" + taxAmountTotal.toFixed(2); - (lotOccupancyFeesContainerElement.querySelector("#lotOccupancyFees--grandTotal") as HTMLElement).textContent = "$" + (feeAmountTotal + taxAmountTotal).toFixed(2); + ( + lotOccupancyFeesContainerElement.querySelector( + "#lotOccupancyFees--feeAmountTotal" + ) as HTMLElement + ).textContent = "$" + feeAmountTotal.toFixed(2); + ( + lotOccupancyFeesContainerElement.querySelector( + "#lotOccupancyFees--taxAmountTotal" + ) as HTMLElement + ).textContent = "$" + taxAmountTotal.toFixed(2); + ( + lotOccupancyFeesContainerElement.querySelector( + "#lotOccupancyFees--grandTotal" + ) as HTMLElement + ).textContent = "$" + (feeAmountTotal + taxAmountTotal).toFixed(2); renderLotOccupancyTransactions(); }; - document.querySelector("#button--addFee").addEventListener("click", () => { - - if (hasUnsavedChanges) { - bulmaJS.alert({ - message: "Please save all unsaved changes before adding fees.", - contextualColorName: "warning" - }); - return; - } - - let feeCategories: recordTypes.FeeCategory[]; - - let feeFilterElement: HTMLInputElement; - let feeFilterResultsElement: HTMLElement; - - const doAddFee = (feeId: number, quantity: number | string = 1) => { - - cityssm.postJSON(urlPrefix + "/lotOccupancies/doAddLotOccupancyFee", { - lotOccupancyId, - feeId, - quantity - }, - (responseJSON: { - success: boolean; - errorMessage ? : string; - lotOccupancyFees ? : recordTypes.LotOccupancyFee[]; - }) => { - - if (responseJSON.success) { - lotOccupancyFees = responseJSON.lotOccupancyFees; - renderLotOccupancyFees(); - filterFees(); - - } else { - bulmaJS.alert({ - title: "Error Adding Fee", - message: responseJSON.errorMessage, - contextualColorName: "danger" - }); - } + document + .querySelector("#button--addFee") + .addEventListener("click", () => { + if (hasUnsavedChanges) { + bulmaJS.alert({ + message: + "Please save all unsaved changes before adding fees.", + contextualColorName: "warning" }); - }; - - const doSetQuantityAndAddFee = (fee: recordTypes.Fee) => { - - let quantityElement: HTMLInputElement; - let quantityCloseModalFunction: () => void; - - const doSetQuantity = (submitEvent: SubmitEvent) => { - - submitEvent.preventDefault(); - doAddFee(fee.feeId, quantityElement.value); - quantityCloseModalFunction(); - }; - - cityssm.openHtmlModal("lotOccupancy-setFeeQuantity", { - onshow: (modalElement) => { - (modalElement.querySelector("#lotOccupancyFeeQuantity--quantityUnit") as HTMLElement).textContent = fee.quantityUnit; - }, - onshown: (modalElement, closeModalFunction) => { - quantityCloseModalFunction = closeModalFunction; - quantityElement = modalElement.querySelector("#lotOccupancyFeeQuantity--quantity"); - modalElement.querySelector("form").addEventListener("submit", doSetQuantity); - } - }); - }; - - const tryAddFee = (clickEvent: Event) => { - clickEvent.preventDefault(); - - const feeId = Number.parseInt((clickEvent.currentTarget as HTMLElement).dataset.feeId, 10); - const feeCategoryId = Number.parseInt(((clickEvent.currentTarget as HTMLElement).closest(".container--feeCategory") as HTMLElement).dataset.feeCategoryId, 10); - - const feeCategory = feeCategories.find((currentFeeCategory) => { - return currentFeeCategory.feeCategoryId === feeCategoryId; - }); - - const fee = feeCategory.fees.find((currentFee) => { - return currentFee.feeId === feeId; - }); - - if (fee.includeQuantity) { - doSetQuantityAndAddFee(fee); - } else { - doAddFee(feeId); + return; } - }; - const filterFees = () => { + let feeCategories: recordTypes.FeeCategory[]; - const filterStringPieces = feeFilterElement.value.trim().toLowerCase().split(" "); + let feeFilterElement: HTMLInputElement; + let feeFilterResultsElement: HTMLElement; - feeFilterResultsElement.innerHTML = ""; - - for (const feeCategory of feeCategories) { - - const categoryContainerElement = document.createElement("div"); - categoryContainerElement.className = "container--feeCategory"; - categoryContainerElement.dataset.feeCategoryId = feeCategory.feeCategoryId.toString(); - categoryContainerElement.innerHTML = "

" + cityssm.escapeHTML(feeCategory.feeCategory) + "

" + - "
"; - - let hasFees = false; - - for (const fee of feeCategory.fees) { - - if (lotOccupancyFeesContainerElement.querySelector(".container--lotOccupancyFee[data-fee-id='" + fee.feeId + "'][data-include-quantity='0']")) { - continue; - } - - let includeFee = true; - - for (const filterStringPiece of filterStringPieces) { - if (!fee.feeName.toLowerCase().includes(filterStringPiece)) { - includeFee = false; - break; - } - } - - if (!includeFee) { - continue; - } - - hasFees = true; - - const panelBlockElement = document.createElement("a"); - panelBlockElement.className = "panel-block is-block container--fee"; - panelBlockElement.dataset.feeId = fee.feeId.toString(); - panelBlockElement.href = "#"; - - panelBlockElement.innerHTML = "" + cityssm.escapeHTML(fee.feeName) + "
" + - "" + cityssm.escapeHTML(fee.feeDescription).replace(/\n/g, "
") + "
"; - - panelBlockElement.addEventListener("click", tryAddFee); - - categoryContainerElement.querySelector(".panel").append(panelBlockElement); - } - - if (hasFees) { - feeFilterResultsElement.append(categoryContainerElement); - } - } - }; - - cityssm.openHtmlModal("lotOccupancy-addFee", { - onshow: (modalElement) => { - - feeFilterElement = modalElement.querySelector("#feeSelect--feeName"); - feeFilterResultsElement = modalElement.querySelector("#resultsContainer--feeSelect"); - - cityssm.postJSON(urlPrefix + "/lotOccupancies/doGetFees", { - lotOccupancyId + const doAddFee = ( + feeId: number, + quantity: number | string = 1 + ) => { + cityssm.postJSON( + urlPrefix + "/lotOccupancies/doAddLotOccupancyFee", + { + lotOccupancyId, + feeId, + quantity }, (responseJSON: { - feeCategories: recordTypes.FeeCategory[] + success: boolean; + errorMessage?: string; + lotOccupancyFees?: recordTypes.LotOccupancyFee[]; }) => { - feeCategories = responseJSON.feeCategories; + if (responseJSON.success) { + lotOccupancyFees = + responseJSON.lotOccupancyFees; + renderLotOccupancyFees(); + filterFees(); + } else { + bulmaJS.alert({ + title: "Error Adding Fee", + message: responseJSON.errorMessage, + contextualColorName: "danger" + }); + } + } + ); + }; - feeFilterElement.disabled = false; - feeFilterElement.addEventListener("keyup", filterFees); - feeFilterElement.focus(); + const doSetQuantityAndAddFee = (fee: recordTypes.Fee) => { + let quantityElement: HTMLInputElement; + let quantityCloseModalFunction: () => void; - filterFees(); - }); - }, - onshown: () => { - bulmaJS.toggleHtmlClipped(); - }, - onhidden: () => { - renderLotOccupancyFees(); - }, - onremoved: () => { - bulmaJS.toggleHtmlClipped(); - } + const doSetQuantity = (submitEvent: SubmitEvent) => { + submitEvent.preventDefault(); + doAddFee(fee.feeId, quantityElement.value); + quantityCloseModalFunction(); + }; + + cityssm.openHtmlModal("lotOccupancy-setFeeQuantity", { + onshow: (modalElement) => { + ( + modalElement.querySelector( + "#lotOccupancyFeeQuantity--quantityUnit" + ) as HTMLElement + ).textContent = fee.quantityUnit; + }, + onshown: (modalElement, closeModalFunction) => { + quantityCloseModalFunction = closeModalFunction; + quantityElement = modalElement.querySelector( + "#lotOccupancyFeeQuantity--quantity" + ); + modalElement + .querySelector("form") + .addEventListener("submit", doSetQuantity); + } + }); + }; + + const tryAddFee = (clickEvent: Event) => { + clickEvent.preventDefault(); + + const feeId = Number.parseInt( + (clickEvent.currentTarget as HTMLElement).dataset.feeId, + 10 + ); + const feeCategoryId = Number.parseInt( + ( + (clickEvent.currentTarget as HTMLElement).closest( + ".container--feeCategory" + ) as HTMLElement + ).dataset.feeCategoryId, + 10 + ); + + const feeCategory = feeCategories.find( + (currentFeeCategory) => { + return ( + currentFeeCategory.feeCategoryId === + feeCategoryId + ); + } + ); + + const fee = feeCategory.fees.find((currentFee) => { + return currentFee.feeId === feeId; + }); + + if (fee.includeQuantity) { + doSetQuantityAndAddFee(fee); + } else { + doAddFee(feeId); + } + }; + + const filterFees = () => { + const filterStringPieces = feeFilterElement.value + .trim() + .toLowerCase() + .split(" "); + + feeFilterResultsElement.innerHTML = ""; + + for (const feeCategory of feeCategories) { + const categoryContainerElement = + document.createElement("div"); + categoryContainerElement.className = + "container--feeCategory"; + categoryContainerElement.dataset.feeCategoryId = + feeCategory.feeCategoryId.toString(); + categoryContainerElement.innerHTML = + '

' + + cityssm.escapeHTML(feeCategory.feeCategory) + + "

" + + '
'; + + let hasFees = false; + + for (const fee of feeCategory.fees) { + if ( + lotOccupancyFeesContainerElement.querySelector( + ".container--lotOccupancyFee[data-fee-id='" + + fee.feeId + + "'][data-include-quantity='0']" + ) + ) { + continue; + } + + let includeFee = true; + + for (const filterStringPiece of filterStringPieces) { + if ( + !fee.feeName + .toLowerCase() + .includes(filterStringPiece) + ) { + includeFee = false; + break; + } + } + + if (!includeFee) { + continue; + } + + hasFees = true; + + const panelBlockElement = + document.createElement("a"); + panelBlockElement.className = + "panel-block is-block container--fee"; + panelBlockElement.dataset.feeId = + fee.feeId.toString(); + panelBlockElement.href = "#"; + + panelBlockElement.innerHTML = + "" + + cityssm.escapeHTML(fee.feeName) + + "
" + + "" + + cityssm + .escapeHTML(fee.feeDescription) + .replace(/\n/g, "
") + + "
"; + + panelBlockElement.addEventListener( + "click", + tryAddFee + ); + + categoryContainerElement + .querySelector(".panel") + .append(panelBlockElement); + } + + if (hasFees) { + feeFilterResultsElement.append( + categoryContainerElement + ); + } + } + }; + + cityssm.openHtmlModal("lotOccupancy-addFee", { + onshow: (modalElement) => { + feeFilterElement = modalElement.querySelector( + "#feeSelect--feeName" + ); + feeFilterResultsElement = modalElement.querySelector( + "#resultsContainer--feeSelect" + ); + + cityssm.postJSON( + urlPrefix + "/lotOccupancies/doGetFees", + { + lotOccupancyId + }, + (responseJSON: { + feeCategories: recordTypes.FeeCategory[]; + }) => { + feeCategories = responseJSON.feeCategories; + + feeFilterElement.disabled = false; + feeFilterElement.addEventListener( + "keyup", + filterFees + ); + feeFilterElement.focus(); + + filterFees(); + } + ); + }, + onshown: () => { + bulmaJS.toggleHtmlClipped(); + }, + onhidden: () => { + renderLotOccupancyFees(); + }, + onremoved: () => { + bulmaJS.toggleHtmlClipped(); + } + }); }); - }); - let lotOccupancyTransactions: recordTypes.LotOccupancyTransaction[] = exports.lotOccupancyTransactions; + let lotOccupancyTransactions: recordTypes.LotOccupancyTransaction[] = + exports.lotOccupancyTransactions; delete exports.lotOccupancyTransactions; - const lotOccupancyTransactionsContainerElement = document.querySelector("#container--lotOccupancyTransactions") as HTMLElement; + const lotOccupancyTransactionsContainerElement = document.querySelector( + "#container--lotOccupancyTransactions" + ) as HTMLElement; const getTransactionGrandTotal = (): number => { - let transactionGrandTotal = 0; for (const lotOccupancyTransaction of lotOccupancyTransactions) { - transactionGrandTotal += lotOccupancyTransaction.transactionAmount; + transactionGrandTotal += + lotOccupancyTransaction.transactionAmount; } return transactionGrandTotal; }; const deleteLotOccupancyTransaction = (clickEvent: Event) => { - - const transactionIndex = ((clickEvent.currentTarget as HTMLElement).closest(".container--lotOccupancyTransaction") as HTMLElement).dataset.transactionIndex; + const transactionIndex = ( + (clickEvent.currentTarget as HTMLElement).closest( + ".container--lotOccupancyTransaction" + ) as HTMLElement + ).dataset.transactionIndex; const doDelete = () => { - cityssm.postJSON(urlPrefix + "/lotOccupancies/doDeleteLotOccupancyTransaction", { + cityssm.postJSON( + urlPrefix + + "/lotOccupancies/doDeleteLotOccupancyTransaction", + { lotOccupancyId, transactionIndex }, (responseJSON: { success: boolean; - errorMessage ? : string; - lotOccupancyTransactions ? : recordTypes.LotOccupancyTransaction[]; + errorMessage?: string; + lotOccupancyTransactions?: recordTypes.LotOccupancyTransaction[]; }) => { - if (responseJSON.success) { - lotOccupancyTransactions = responseJSON.lotOccupancyTransactions; + lotOccupancyTransactions = + responseJSON.lotOccupancyTransactions; renderLotOccupancyTransactions(); } else { bulmaJS.alert({ @@ -1222,7 +1656,8 @@ declare const bulmaJS: BulmaJS; contextualColorName: "danger" }); } - }); + } + ); }; bulmaJS.confirm({ @@ -1231,140 +1666,190 @@ declare const bulmaJS: BulmaJS; contextualColorName: "warning", okButton: { text: "Yes, Delete Transaction", - callbackFunction: doDelete, + callbackFunction: doDelete } }); }; const renderLotOccupancyTransactions = () => { - if (lotOccupancyTransactions.length === 0) { - - lotOccupancyTransactionsContainerElement.innerHTML = "
" + - "

There are no transactions associated with this record.

" + + lotOccupancyTransactionsContainerElement.innerHTML = + '
' + + '

There are no transactions associated with this record.

' + "
"; return; } - lotOccupancyTransactionsContainerElement.innerHTML = "" + + lotOccupancyTransactionsContainerElement.innerHTML = + '
' + "" + - "" + - "" + - "" + - "" + + '' + + "" + + '' + + '' + "" + "" + ("" + - "" + - "" + - "" + + '' + + '' + + '' + "") + "
Date" + cityssm.escapeHTML(exports.aliases.externalReceiptNumber) + "AmountOptionsDate" + + cityssm.escapeHTML(exports.aliases.externalReceiptNumber) + + "AmountOptions
Transaction TotalTransaction Total
"; let transactionGrandTotal = 0; for (const lotOccupancyTransaction of lotOccupancyTransactions) { - - transactionGrandTotal += lotOccupancyTransaction.transactionAmount; + transactionGrandTotal += + lotOccupancyTransaction.transactionAmount; const tableRowElement = document.createElement("tr"); - tableRowElement.className = "container--lotOccupancyTransaction"; - tableRowElement.dataset.transactionIndex = lotOccupancyTransaction.transactionIndex.toString(); + tableRowElement.className = + "container--lotOccupancyTransaction"; + tableRowElement.dataset.transactionIndex = + lotOccupancyTransaction.transactionIndex.toString(); - tableRowElement.innerHTML = "" + lotOccupancyTransaction.transactionDateString + "" + + tableRowElement.innerHTML = + "" + + lotOccupancyTransaction.transactionDateString + + "" + ("" + - cityssm.escapeHTML(lotOccupancyTransaction.externalReceiptNumber) + "
" + - "" + cityssm.escapeHTML(lotOccupancyTransaction.transactionNote) + "" + + cityssm.escapeHTML( + lotOccupancyTransaction.externalReceiptNumber + ) + + "
" + + "" + + cityssm.escapeHTML( + lotOccupancyTransaction.transactionNote + ) + + "" + "") + - ("$" + lotOccupancyTransaction.transactionAmount.toFixed(2) + "") + - ("" + - "" + ""); - tableRowElement.querySelector("button").addEventListener("click", deleteLotOccupancyTransaction); + tableRowElement + .querySelector("button") + .addEventListener("click", deleteLotOccupancyTransaction); - lotOccupancyTransactionsContainerElement.querySelector("tbody").append(tableRowElement); + lotOccupancyTransactionsContainerElement + .querySelector("tbody") + .append(tableRowElement); } - (lotOccupancyTransactionsContainerElement.querySelector("#lotOccupancyTransactions--grandTotal") as HTMLElement).textContent = "$" + transactionGrandTotal.toFixed(2); + ( + lotOccupancyTransactionsContainerElement.querySelector( + "#lotOccupancyTransactions--grandTotal" + ) as HTMLElement + ).textContent = "$" + transactionGrandTotal.toFixed(2); const feeGrandTotal = getFeeGrandTotal(); if (feeGrandTotal > transactionGrandTotal) { - - lotOccupancyTransactionsContainerElement.insertAdjacentHTML("afterbegin", - "
" + - "
" + - "
" + - "
Outstanding Balance
" + - "
$" + (feeGrandTotal - transactionGrandTotal).toFixed(2) + "
" + - "
" + - "
" + - "
"); + lotOccupancyTransactionsContainerElement.insertAdjacentHTML( + "afterbegin", + '
' + + '
' + + '
' + + '
Outstanding Balance
' + + '
$' + + (feeGrandTotal - transactionGrandTotal).toFixed(2) + + "
" + + "
" + + "
" + + "
" + ); } }; - document.querySelector("#button--addTransaction").addEventListener("click", () => { + document + .querySelector("#button--addTransaction") + .addEventListener("click", () => { + let addCloseModalFunction: () => void; - let addCloseModalFunction: () => void; + const doAddTransaction = (submitEvent: SubmitEvent) => { + submitEvent.preventDefault(); - const doAddTransaction = (submitEvent: SubmitEvent) => { - - submitEvent.preventDefault(); - - cityssm.postJSON(urlPrefix + "/lotOccupancies/doAddLotOccupancyTransaction", - submitEvent.currentTarget, - (responseJSON: { - success: boolean; - errorMessage ? : string; - lotOccupancyTransactions ? : recordTypes.LotOccupancyTransaction[]; - }) => { - - if (responseJSON.success) { - lotOccupancyTransactions = responseJSON.lotOccupancyTransactions; - addCloseModalFunction(); - renderLotOccupancyTransactions(); - } else { - bulmaJS.confirm({ - title: "Error Adding Transaction", - message: responseJSON.errorMessage, - contextualColorName: "danger" - }); + cityssm.postJSON( + urlPrefix + + "/lotOccupancies/doAddLotOccupancyTransaction", + submitEvent.currentTarget, + (responseJSON: { + success: boolean; + errorMessage?: string; + lotOccupancyTransactions?: recordTypes.LotOccupancyTransaction[]; + }) => { + if (responseJSON.success) { + lotOccupancyTransactions = + responseJSON.lotOccupancyTransactions; + addCloseModalFunction(); + renderLotOccupancyTransactions(); + } else { + bulmaJS.confirm({ + title: "Error Adding Transaction", + message: responseJSON.errorMessage, + contextualColorName: "danger" + }); + } } - }); - }; + ); + }; - cityssm.openHtmlModal("lotOccupancy-addTransaction", { - onshow: (modalElement) => { - los.populateAliases(modalElement); + cityssm.openHtmlModal("lotOccupancy-addTransaction", { + onshow: (modalElement) => { + los.populateAliases(modalElement); - (modalElement.querySelector("#lotOccupancyTransactionAdd--lotOccupancyId") as HTMLInputElement).value = lotOccupancyId.toString(); + ( + modalElement.querySelector( + "#lotOccupancyTransactionAdd--lotOccupancyId" + ) as HTMLInputElement + ).value = lotOccupancyId.toString(); - const feeGrandTotal = getFeeGrandTotal(); - const transactionGrandTotal = getTransactionGrandTotal(); + const feeGrandTotal = getFeeGrandTotal(); + const transactionGrandTotal = + getTransactionGrandTotal(); - const transactionAmountElement = modalElement.querySelector("#lotOccupancyTransactionAdd--transactionAmount") as HTMLInputElement; + const transactionAmountElement = + modalElement.querySelector( + "#lotOccupancyTransactionAdd--transactionAmount" + ) as HTMLInputElement; - transactionAmountElement.min = (-1 * transactionGrandTotal).toFixed(2); - transactionAmountElement.max = Math.max(feeGrandTotal - transactionGrandTotal, 0).toFixed(2); - transactionAmountElement.value = Math.max(feeGrandTotal - transactionGrandTotal, 0).toFixed(2); - }, - onshown: (modalElement, closeModalFunction) => { - bulmaJS.toggleHtmlClipped(); + transactionAmountElement.min = ( + -1 * transactionGrandTotal + ).toFixed(2); + transactionAmountElement.max = Math.max( + feeGrandTotal - transactionGrandTotal, + 0 + ).toFixed(2); + transactionAmountElement.value = Math.max( + feeGrandTotal - transactionGrandTotal, + 0 + ).toFixed(2); + }, + onshown: (modalElement, closeModalFunction) => { + bulmaJS.toggleHtmlClipped(); - addCloseModalFunction = closeModalFunction; + addCloseModalFunction = closeModalFunction; - modalElement.querySelector("form").addEventListener("submit", doAddTransaction); - }, - onremoved: () => { - bulmaJS.toggleHtmlClipped(); - } + modalElement + .querySelector("form") + .addEventListener("submit", doAddTransaction); + }, + onremoved: () => { + bulmaJS.toggleHtmlClipped(); + } + }); }); - }); renderLotOccupancyFees(); } -})(); \ No newline at end of file +})(); diff --git a/public-typescript/lotOccupancySearch.js b/public-typescript/lotOccupancySearch.js index a1843e4c..679dc2be 100644 --- a/public-typescript/lotOccupancySearch.js +++ b/public-typescript/lotOccupancySearch.js @@ -4,102 +4,155 @@ Object.defineProperty(exports, "__esModule", { value: true }); const urlPrefix = document.querySelector("main").dataset.urlPrefix; const searchFilterFormElement = document.querySelector("#form--searchFilters"); const searchResultsContainerElement = document.querySelector("#container--searchResults"); - const limit = Number.parseInt(document.querySelector("#searchFilter--limit").value, 10); + const limit = Number.parseInt(document.querySelector("#searchFilter--limit") + .value, 10); const offsetElement = document.querySelector("#searchFilter--offset"); const getLotOccupancies = () => { const offset = Number.parseInt(offsetElement.value, 10); - searchResultsContainerElement.innerHTML = "
" + - "
" + - "Loading " + exports.aliases.occupancies + "..." + - "
"; + searchResultsContainerElement.innerHTML = + '
' + + '
' + + "Loading " + + exports.aliases.occupancies + + "..." + + "
"; cityssm.postJSON(urlPrefix + "/lotOccupancies/doSearchLotOccupancies", searchFilterFormElement, (responseJSON) => { if (responseJSON.lotOccupancies.length === 0) { - searchResultsContainerElement.innerHTML = "
" + - "

There are no " + exports.aliases.occupancy.toLowerCase() + " records that meet the search criteria.

" + - "
"; + searchResultsContainerElement.innerHTML = + '
' + + '

There are no ' + + exports.aliases.occupancy.toLowerCase() + + " records that meet the search criteria.

" + + "
"; return; } const resultsTbodyElement = document.createElement("tbody"); const nowDateString = cityssm.dateToString(new Date()); for (const lotOccupancy of responseJSON.lotOccupancies) { let occupancyTimeHTML = ""; - if (lotOccupancy.occupancyStartDateString <= nowDateString && (lotOccupancy.occupancyEndDateString === "" || lotOccupancy.occupancyEndDateString >= nowDateString)) { - occupancyTimeHTML = ""; + if (lotOccupancy.occupancyStartDateString <= + nowDateString && + (lotOccupancy.occupancyEndDateString === "" || + lotOccupancy.occupancyEndDateString >= + nowDateString)) { + occupancyTimeHTML = + ''; } else if (lotOccupancy.occupancyStartDateString > nowDateString) { - occupancyTimeHTML = ""; + occupancyTimeHTML = + ''; } else { - occupancyTimeHTML = ""; + occupancyTimeHTML = + ''; } let occupantsHTML = ""; for (const occupant of lotOccupancy.lotOccupancyOccupants) { - occupantsHTML += cityssm.escapeHTML(occupant.occupantName) + "
"; + occupantsHTML += + cityssm.escapeHTML(occupant.occupantName) + + "
"; } resultsTbodyElement.insertAdjacentHTML("beforeend", "" + - "" + occupancyTimeHTML + "" + + "" + + occupancyTimeHTML + + "" + ("" + - "" + + '' + cityssm.escapeHTML(lotOccupancy.occupancyType) + "" + "") + ("" + - (lotOccupancy.lotName ? cityssm.escapeHTML(lotOccupancy.lotName) : "(No " + cityssm.escapeHTML(exports.aliases.lot) + ")") + "
" + - "" + cityssm.escapeHTML(lotOccupancy.mapName || "") + "" + + (lotOccupancy.lotName + ? cityssm.escapeHTML(lotOccupancy.lotName) + : '(No ' + + cityssm.escapeHTML(exports.aliases.lot) + + ")") + + "
" + + '' + + cityssm.escapeHTML(lotOccupancy.mapName || "") + + "" + "") + ("" + lotOccupancy.occupancyStartDateString + "") + ("" + - (lotOccupancy.occupancyEndDate ? - lotOccupancy.occupancyEndDateString : - "(No End Date)") + + (lotOccupancy.occupancyEndDate + ? lotOccupancy.occupancyEndDateString + : '(No End Date)') + "") + - "" + occupantsHTML + "" + + "" + + occupantsHTML + + "" + ""); } - searchResultsContainerElement.innerHTML = "" + - "" + - "" + - "" + - "" + - "" + - "" + - "" + - "" + - "
" + exports.aliases.occupancy + " Type" + exports.aliases.lot + "Start DateEnd Date" + exports.aliases.occupants + "
" + - "
" + - ("
" + - "
" + - "Displaying " + (offset + 1).toString() + - " to " + Math.min(responseJSON.count, limit + offset) + - " of " + responseJSON.count + - "
" + - "
") + - ("
" + - (offset > 0 ? - "
" + - "" + - "
" : - "") + - (limit + offset < responseJSON.count ? - "
" + - "" + - "
" : - "") + - "
") + - "
"; - searchResultsContainerElement.querySelector("table").append(resultsTbodyElement); + searchResultsContainerElement.innerHTML = + '
' + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "
" + + exports.aliases.occupancy + + " Type" + + exports.aliases.lot + + "Start DateEnd Date" + + exports.aliases.occupants + + "
" + + '
' + + ('
' + + '
' + + "Displaying " + + (offset + 1).toString() + + " to " + + Math.min(responseJSON.count, limit + offset) + + " of " + + responseJSON.count + + "
" + + "
") + + ('
' + + (offset > 0 + ? '
' + + '" + + "
" + : "") + + (limit + offset < responseJSON.count + ? '
' + + '" + + "
" + : "") + + "
") + + "
"; + searchResultsContainerElement + .querySelector("table") + .append(resultsTbodyElement); if (offset > 0) { - searchResultsContainerElement.querySelector("button[data-page='previous']").addEventListener("click", previousAndGetLotOccupancies); + searchResultsContainerElement + .querySelector("button[data-page='previous']") + .addEventListener("click", previousAndGetLotOccupancies); } if (limit + offset < responseJSON.count) { - searchResultsContainerElement.querySelector("button[data-page='next']").addEventListener("click", nextAndGetLotOccupancies); + searchResultsContainerElement + .querySelector("button[data-page='next']") + .addEventListener("click", nextAndGetLotOccupancies); } }); }; diff --git a/public-typescript/lotOccupancySearch.ts b/public-typescript/lotOccupancySearch.ts index 6f3a20fc..bd33777c 100644 --- a/public-typescript/lotOccupancySearch.ts +++ b/public-typescript/lotOccupancySearch.ts @@ -2,43 +2,53 @@ import type * as recordTypes from "../types/recordTypes"; -import type { - cityssmGlobal -} from "@cityssm/bulma-webapp-js/src/types"; - +import type { cityssmGlobal } from "@cityssm/bulma-webapp-js/src/types"; declare const cityssm: cityssmGlobal; - (() => { const urlPrefix = document.querySelector("main").dataset.urlPrefix; - const searchFilterFormElement = document.querySelector("#form--searchFilters") as HTMLFormElement; - const searchResultsContainerElement = document.querySelector("#container--searchResults") as HTMLElement; - - const limit = Number.parseInt((document.querySelector("#searchFilter--limit") as HTMLInputElement).value, 10); - const offsetElement = document.querySelector("#searchFilter--offset") as HTMLInputElement; + const searchFilterFormElement = document.querySelector( + "#form--searchFilters" + ) as HTMLFormElement; + const searchResultsContainerElement = document.querySelector( + "#container--searchResults" + ) as HTMLElement; + const limit = Number.parseInt( + (document.querySelector("#searchFilter--limit") as HTMLInputElement) + .value, + 10 + ); + const offsetElement = document.querySelector( + "#searchFilter--offset" + ) as HTMLInputElement; const getLotOccupancies = () => { - const offset = Number.parseInt(offsetElement.value, 10); - searchResultsContainerElement.innerHTML = "
" + - "
" + - "Loading " + exports.aliases.occupancies + "..." + + searchResultsContainerElement.innerHTML = + '
' + + '
' + + "Loading " + + exports.aliases.occupancies + + "..." + "
"; - cityssm.postJSON(urlPrefix + "/lotOccupancies/doSearchLotOccupancies", searchFilterFormElement, + cityssm.postJSON( + urlPrefix + "/lotOccupancies/doSearchLotOccupancies", + searchFilterFormElement, (responseJSON: { count: number; lotOccupancies: recordTypes.LotOccupancy[]; }) => { - if (responseJSON.lotOccupancies.length === 0) { - - searchResultsContainerElement.innerHTML = "
" + - "

There are no " + exports.aliases.occupancy.toLowerCase() + " records that meet the search criteria.

" + + searchResultsContainerElement.innerHTML = + '
' + + '

There are no ' + + exports.aliases.occupancy.toLowerCase() + + " records that meet the search criteria.

" + "
"; return; @@ -49,116 +59,182 @@ declare const cityssm: cityssmGlobal; const nowDateString = cityssm.dateToString(new Date()); for (const lotOccupancy of responseJSON.lotOccupancies) { - let occupancyTimeHTML = ""; - if (lotOccupancy.occupancyStartDateString <= nowDateString && (lotOccupancy.occupancyEndDateString === "" || lotOccupancy.occupancyEndDateString >= nowDateString)) { - occupancyTimeHTML = ""; - - } else if (lotOccupancy.occupancyStartDateString > nowDateString) { - occupancyTimeHTML = ""; - + if ( + lotOccupancy.occupancyStartDateString <= + nowDateString && + (lotOccupancy.occupancyEndDateString === "" || + lotOccupancy.occupancyEndDateString >= + nowDateString) + ) { + occupancyTimeHTML = + ''; + } else if ( + lotOccupancy.occupancyStartDateString > nowDateString + ) { + occupancyTimeHTML = + ''; } else { - occupancyTimeHTML = ""; + occupancyTimeHTML = + ''; } let occupantsHTML = ""; for (const occupant of lotOccupancy.lotOccupancyOccupants) { - occupantsHTML += cityssm.escapeHTML(occupant.occupantName) + "
"; + occupantsHTML += + cityssm.escapeHTML(occupant.occupantName) + + "
"; } - resultsTbodyElement.insertAdjacentHTML("beforeend", "
" + - "" + - ("") + - ("") + - ("") + - ("") + - "" + - ""); + resultsTbodyElement.insertAdjacentHTML( + "beforeend", + "" + + "" + + ("") + + ("") + + ("") + + ("") + + "" + + "" + ); } - searchResultsContainerElement.innerHTML = "
" + occupancyTimeHTML + "" + - "" + - cityssm.escapeHTML(lotOccupancy.occupancyType as string) + - "" + - "" + - (lotOccupancy.lotName ? cityssm.escapeHTML(lotOccupancy.lotName) : "(No " + cityssm.escapeHTML(exports.aliases.lot) + ")") + "
" + - "" + cityssm.escapeHTML(lotOccupancy.mapName || "") + "" + - "
" + - lotOccupancy.occupancyStartDateString + - "" + - (lotOccupancy.occupancyEndDate ? - lotOccupancy.occupancyEndDateString : - "(No End Date)") + - "" + occupantsHTML + "
" + + occupancyTimeHTML + + "" + + '' + + cityssm.escapeHTML( + lotOccupancy.occupancyType as string + ) + + "" + + "" + + (lotOccupancy.lotName + ? cityssm.escapeHTML(lotOccupancy.lotName) + : '(No ' + + cityssm.escapeHTML(exports.aliases.lot) + + ")") + + "
" + + '' + + cityssm.escapeHTML(lotOccupancy.mapName || "") + + "" + + "
" + + lotOccupancy.occupancyStartDateString + + "" + + (lotOccupancy.occupancyEndDate + ? lotOccupancy.occupancyEndDateString + : '(No End Date)') + + "" + + occupantsHTML + + "
" + + searchResultsContainerElement.innerHTML = + '
' + "" + "" + - "" + - "" + + "" + + "" + "" + "" + - "" + + "" + "" + "
" + exports.aliases.occupancy + " Type" + exports.aliases.lot + "" + + exports.aliases.occupancy + + " Type" + + exports.aliases.lot + + "Start DateEnd Date" + exports.aliases.occupants + "" + + exports.aliases.occupants + + "
" + - "
" + - ("
" + - "
" + - "Displaying " + (offset + 1).toString() + - " to " + Math.min(responseJSON.count, limit + offset) + - " of " + responseJSON.count + + '
' + + ('
' + + '
' + + "Displaying " + + (offset + 1).toString() + + " to " + + Math.min(responseJSON.count, limit + offset) + + " of " + + responseJSON.count + "
" + "
") + - ("
" + - (offset > 0 ? - "
" + - "" + - "
" : - "") + - (limit + offset < responseJSON.count ? - "
" + - "" + - "
" : - "") + + ('
' + + (offset > 0 + ? '
' + + '" + + "
" + : "") + + (limit + offset < responseJSON.count + ? '
' + + '" + + "
" + : "") + "
") + "
"; - searchResultsContainerElement.querySelector("table").append(resultsTbodyElement); + searchResultsContainerElement + .querySelector("table") + .append(resultsTbodyElement); if (offset > 0) { - searchResultsContainerElement.querySelector("button[data-page='previous']").addEventListener("click", previousAndGetLotOccupancies); + searchResultsContainerElement + .querySelector("button[data-page='previous']") + .addEventListener( + "click", + previousAndGetLotOccupancies + ); } if (limit + offset < responseJSON.count) { - searchResultsContainerElement.querySelector("button[data-page='next']").addEventListener("click", nextAndGetLotOccupancies); + searchResultsContainerElement + .querySelector("button[data-page='next']") + .addEventListener("click", nextAndGetLotOccupancies); } - }); + } + ); }; const resetOffsetAndGetLotOccupancies = () => { offsetElement.value = "0"; getLotOccupancies(); - } + }; const previousAndGetLotOccupancies = () => { - offsetElement.value = Math.max(Number.parseInt(offsetElement.value, 10) - limit, 0).toString(); + offsetElement.value = Math.max( + Number.parseInt(offsetElement.value, 10) - limit, + 0 + ).toString(); getLotOccupancies(); }; const nextAndGetLotOccupancies = () => { - offsetElement.value = (Number.parseInt(offsetElement.value, 10) + limit).toString(); + offsetElement.value = ( + Number.parseInt(offsetElement.value, 10) + limit + ).toString(); getLotOccupancies(); }; - const filterElements = searchFilterFormElement.querySelectorAll("input, select") as NodeListOf < HTMLInputElement | HTMLSelectElement > ; + const filterElements = searchFilterFormElement.querySelectorAll( + "input, select" + ) as NodeListOf; for (const filterElement of filterElements) { - filterElement.addEventListener("change", resetOffsetAndGetLotOccupancies); + filterElement.addEventListener( + "change", + resetOffsetAndGetLotOccupancies + ); } searchFilterFormElement.addEventListener("submit", (formEvent) => { @@ -167,4 +243,4 @@ declare const cityssm: cityssmGlobal; }); getLotOccupancies(); -})(); \ No newline at end of file +})(); diff --git a/public-typescript/lotSearch.js b/public-typescript/lotSearch.js index e2fa3884..9c035646 100644 --- a/public-typescript/lotSearch.js +++ b/public-typescript/lotSearch.js @@ -4,81 +4,117 @@ Object.defineProperty(exports, "__esModule", { value: true }); const urlPrefix = document.querySelector("main").dataset.urlPrefix; const searchFilterFormElement = document.querySelector("#form--searchFilters"); const searchResultsContainerElement = document.querySelector("#container--searchResults"); - const limit = Number.parseInt(document.querySelector("#searchFilter--limit").value, 10); + const limit = Number.parseInt(document.querySelector("#searchFilter--limit") + .value, 10); const offsetElement = document.querySelector("#searchFilter--offset"); const getLots = () => { const offset = Number.parseInt(offsetElement.value, 10); - searchResultsContainerElement.innerHTML = "
" + - "
" + - "Loading " + exports.aliases.lots + "..." + - "
"; + searchResultsContainerElement.innerHTML = + '
' + + '
' + + "Loading " + + exports.aliases.lots + + "..." + + "
"; cityssm.postJSON(urlPrefix + "/lots/doSearchLots", searchFilterFormElement, (responseJSON) => { if (responseJSON.lots.length === 0) { - searchResultsContainerElement.innerHTML = "
" + - "

There are no " + exports.aliases.lots.toLowerCase() + " that meet the search criteria.

" + - "
"; + searchResultsContainerElement.innerHTML = + '
' + + '

There are no ' + + exports.aliases.lots.toLowerCase() + + " that meet the search criteria.

" + + "
"; return; } const resultsTbodyElement = document.createElement("tbody"); for (const lot of responseJSON.lots) { resultsTbodyElement.insertAdjacentHTML("beforeend", "
" + ("") + ("") + - "" + + "" + ("") + ""); } - searchResultsContainerElement.innerHTML = "
" + - "" + + '' + lot.lotName + "" + "" + - "" + + '' + lot.mapName + "" + "" + lot.lotType + "" + + lot.lotType + + "" + - lot.lotStatus + "
" + - (lot.lotOccupancyCount > 0 ? "Currently Occupied" : "") + + lot.lotStatus + + "
" + + (lot.lotOccupancyCount > 0 + ? 'Currently Occupied' + : "") + "
" + - "" + - "" + - "" + - "" + - "" + - "" + - "
" + exports.aliases.lot + "" + exports.aliases.map + "" + exports.aliases.lot + " TypeStatus
" + - "
" + - ("
" + - "
" + - "Displaying " + (offset + 1).toString() + - " to " + Math.min(responseJSON.count, limit + offset) + - " of " + responseJSON.count + - "
" + - "
") + - ("
" + - (offset > 0 ? - "
" + - "" + - "
" : - "") + - (limit + offset < responseJSON.count - ? "
" + - "" + - "
" - : "") + - "
") + - "
"; - searchResultsContainerElement.querySelector("table").append(resultsTbodyElement); + searchResultsContainerElement.innerHTML = + '
' + + "" + + "" + + "" + + "" + + "" + + "" + + "
" + + exports.aliases.lot + + "" + + exports.aliases.map + + "" + + exports.aliases.lot + + " TypeStatus
" + + '
' + + ('
' + + '
' + + "Displaying " + + (offset + 1).toString() + + " to " + + Math.min(responseJSON.count, limit + offset) + + " of " + + responseJSON.count + + "
" + + "
") + + ('
' + + (offset > 0 + ? '
' + + '" + + "
" + : "") + + (limit + offset < responseJSON.count + ? '
' + + '" + + "
" + : "") + + "
") + + "
"; + searchResultsContainerElement + .querySelector("table") + .append(resultsTbodyElement); if (offset > 0) { - searchResultsContainerElement.querySelector("button[data-page='previous']").addEventListener("click", previousAndGetLots); + searchResultsContainerElement + .querySelector("button[data-page='previous']") + .addEventListener("click", previousAndGetLots); } if (limit + offset < responseJSON.count) { - searchResultsContainerElement.querySelector("button[data-page='next']").addEventListener("click", nextAndGetLots); + searchResultsContainerElement + .querySelector("button[data-page='next']") + .addEventListener("click", nextAndGetLots); } }); }; diff --git a/public-typescript/lotSearch.ts b/public-typescript/lotSearch.ts index af883415..14392503 100644 --- a/public-typescript/lotSearch.ts +++ b/public-typescript/lotSearch.ts @@ -2,43 +2,50 @@ import type * as recordTypes from "../types/recordTypes"; -import type { - cityssmGlobal -} from "@cityssm/bulma-webapp-js/src/types"; - +import type { cityssmGlobal } from "@cityssm/bulma-webapp-js/src/types"; declare const cityssm: cityssmGlobal; - (() => { const urlPrefix = document.querySelector("main").dataset.urlPrefix; - const searchFilterFormElement = document.querySelector("#form--searchFilters") as HTMLFormElement; - const searchResultsContainerElement = document.querySelector("#container--searchResults") as HTMLElement; - - const limit = Number.parseInt((document.querySelector("#searchFilter--limit") as HTMLInputElement).value, 10); - const offsetElement = document.querySelector("#searchFilter--offset") as HTMLInputElement; + const searchFilterFormElement = document.querySelector( + "#form--searchFilters" + ) as HTMLFormElement; + const searchResultsContainerElement = document.querySelector( + "#container--searchResults" + ) as HTMLElement; + const limit = Number.parseInt( + (document.querySelector("#searchFilter--limit") as HTMLInputElement) + .value, + 10 + ); + const offsetElement = document.querySelector( + "#searchFilter--offset" + ) as HTMLInputElement; const getLots = () => { - const offset = Number.parseInt(offsetElement.value, 10); - searchResultsContainerElement.innerHTML = "
" + - "
" + - "Loading " + exports.aliases.lots + "..." + + searchResultsContainerElement.innerHTML = + '
' + + '
' + + "Loading " + + exports.aliases.lots + + "..." + "
"; - cityssm.postJSON(urlPrefix + "/lots/doSearchLots", searchFilterFormElement, - (responseJSON: { - count: number; - lots: recordTypes.Lot[]; - }) => { - + cityssm.postJSON( + urlPrefix + "/lots/doSearchLots", + searchFilterFormElement, + (responseJSON: { count: number; lots: recordTypes.Lot[] }) => { if (responseJSON.lots.length === 0) { - - searchResultsContainerElement.innerHTML = "
" + - "

There are no " + exports.aliases.lots.toLowerCase() + " that meet the search criteria.

" + + searchResultsContainerElement.innerHTML = + '
' + + '

There are no ' + + exports.aliases.lots.toLowerCase() + + " that meet the search criteria.

" + "
"; return; @@ -47,88 +54,128 @@ declare const cityssm: cityssmGlobal; const resultsTbodyElement = document.createElement("tbody"); for (const lot of responseJSON.lots) { - resultsTbodyElement.insertAdjacentHTML("beforeend", "
" + - ("") + - ("") + - "" + - ("") + - ""); + resultsTbodyElement.insertAdjacentHTML( + "beforeend", + "" + + ("") + + ("") + + "" + + ("") + + "" + ); } - searchResultsContainerElement.innerHTML = "
" + - "" + - lot.lotName + - "" + - "" + - "" + - lot.mapName + - "" + - "" + lot.lotType + "" + - lot.lotStatus + "
" + - (lot.lotOccupancyCount > 0 ? "Currently Occupied" : "") + - "
" + + '' + + lot.lotName + + "" + + "" + + '' + + lot.mapName + + "" + + "" + + lot.lotType + + "" + + lot.lotStatus + + "
" + + (lot.lotOccupancyCount > 0 + ? 'Currently Occupied' + : "") + + "
" + + searchResultsContainerElement.innerHTML = + '
' + "" + - "" + - "" + - "" + + "" + + "" + + "" + "" + "" + "
" + exports.aliases.lot + "" + exports.aliases.map + "" + exports.aliases.lot + " Type" + + exports.aliases.lot + + "" + + exports.aliases.map + + "" + + exports.aliases.lot + + " TypeStatus
" + - "
" + - ("
" + - "
" + - "Displaying " + (offset + 1).toString() + - " to " + Math.min(responseJSON.count, limit + offset) + - " of " + responseJSON.count + + '
' + + ('
' + + '
' + + "Displaying " + + (offset + 1).toString() + + " to " + + Math.min(responseJSON.count, limit + offset) + + " of " + + responseJSON.count + "
" + "
") + - ("
" + - (offset > 0 ? - "
" + - "" + - "
" : - "") + + ('
' + + (offset > 0 + ? '
' + + '" + + "
" + : "") + (limit + offset < responseJSON.count - ? "
" + - "" + - "
" + ? '
' + + '" + + "
" : "") + "
") + "
"; - searchResultsContainerElement.querySelector("table").append(resultsTbodyElement); + searchResultsContainerElement + .querySelector("table") + .append(resultsTbodyElement); if (offset > 0) { - searchResultsContainerElement.querySelector("button[data-page='previous']").addEventListener("click", previousAndGetLots); + searchResultsContainerElement + .querySelector("button[data-page='previous']") + .addEventListener("click", previousAndGetLots); } - + if (limit + offset < responseJSON.count) { - searchResultsContainerElement.querySelector("button[data-page='next']").addEventListener("click", nextAndGetLots); + searchResultsContainerElement + .querySelector("button[data-page='next']") + .addEventListener("click", nextAndGetLots); } - }); + } + ); }; const resetOffsetAndGetLots = () => { offsetElement.value = "0"; getLots(); - } + }; const previousAndGetLots = () => { - offsetElement.value = Math.max(Number.parseInt(offsetElement.value, 10) - limit, 0).toString(); + offsetElement.value = Math.max( + Number.parseInt(offsetElement.value, 10) - limit, + 0 + ).toString(); getLots(); }; const nextAndGetLots = () => { - offsetElement.value = (Number.parseInt(offsetElement.value, 10) + limit).toString(); + offsetElement.value = ( + Number.parseInt(offsetElement.value, 10) + limit + ).toString(); getLots(); }; - const filterElements = searchFilterFormElement.querySelectorAll("input, select") as NodeListOf < HTMLInputElement | HTMLSelectElement > ; + const filterElements = searchFilterFormElement.querySelectorAll( + "input, select" + ) as NodeListOf; for (const filterElement of filterElements) { filterElement.addEventListener("change", resetOffsetAndGetLots); @@ -140,4 +187,4 @@ declare const cityssm: cityssmGlobal; }); getLots(); -})(); \ No newline at end of file +})(); diff --git a/public-typescript/lotView.ts b/public-typescript/lotView.ts index 7f25bac0..538f2232 100644 --- a/public-typescript/lotView.ts +++ b/public-typescript/lotView.ts @@ -3,9 +3,14 @@ import * as globalTypes from "../types/globalTypes"; (() => { - - const mapContainerElement = document.querySelector("#lot--map") as HTMLElement; + const mapContainerElement = document.querySelector( + "#lot--map" + ) as HTMLElement; if (mapContainerElement) { - (exports.los as globalTypes.LOS).highlightMap(mapContainerElement, mapContainerElement.dataset.mapKey, "success"); + (exports.los as globalTypes.LOS).highlightMap( + mapContainerElement, + mapContainerElement.dataset.mapKey, + "success" + ); } -})(); \ No newline at end of file +})(); diff --git a/public-typescript/main.js b/public-typescript/main.js index e2d7a87b..ce01a2dc 100644 --- a/public-typescript/main.js +++ b/public-typescript/main.js @@ -48,22 +48,26 @@ Object.defineProperty(exports, "__esModule", { value: true }); aliasElement.textContent = exports.aliases.lot; break; case "lot": - aliasElement.textContent = exports.aliases.lot.toLowerCase(); + aliasElement.textContent = + exports.aliases.lot.toLowerCase(); break; case "Occupancy": aliasElement.textContent = exports.aliases.occupancy; break; case "occupancy": - aliasElement.textContent = exports.aliases.occupancy.toLowerCase(); + aliasElement.textContent = + exports.aliases.occupancy.toLowerCase(); break; case "Occupant": aliasElement.textContent = exports.aliases.occupant; break; case "occupant": - aliasElement.textContent = exports.aliases.occupant.toLowerCase(); + aliasElement.textContent = + exports.aliases.occupant.toLowerCase(); break; case "ExternalReceiptNumber": - aliasElement.textContent = exports.aliases.externalReceiptNumber; + aliasElement.textContent = + exports.aliases.externalReceiptNumber; break; } } diff --git a/public-typescript/main.ts b/public-typescript/main.ts index 295d2fd6..a654eaa7 100644 --- a/public-typescript/main.ts +++ b/public-typescript/main.ts @@ -3,18 +3,22 @@ import type * as globalTypes from "../types/globalTypes"; (() => { - - const highlightMap = (mapContainerElement: HTMLElement, mapKey: string, contextualClass: "success" | "danger") => { - + const highlightMap = ( + mapContainerElement: HTMLElement, + mapKey: string, + contextualClass: "success" | "danger" + ) => { // Search for ID let svgId = mapKey; let svgElementToHighlight: SVGElement; // eslint-disable-next-line no-constant-condition - while(true) { - svgElementToHighlight = mapContainerElement.querySelector("#" + svgId); - + while (true) { + svgElementToHighlight = mapContainerElement.querySelector( + "#" + svgId + ); + if (svgElementToHighlight || !svgId.includes("-")) { break; } @@ -23,15 +27,17 @@ import type * as globalTypes from "../types/globalTypes"; } if (svgElementToHighlight) { - // eslint-disable-next-line unicorn/no-null svgElementToHighlight.style.fill = null; - - svgElementToHighlight.classList.add("highlight", "is-" + contextualClass); - const childPathElements = svgElementToHighlight.querySelectorAll("path"); + svgElementToHighlight.classList.add( + "highlight", + "is-" + contextualClass + ); + + const childPathElements = + svgElementToHighlight.querySelectorAll("path"); for (const pathElement of childPathElements) { - // eslint-disable-next-line unicorn/no-null pathElement.style.fill = null; } @@ -39,15 +45,19 @@ import type * as globalTypes from "../types/globalTypes"; }; const unlockField = (clickEvent: Event) => { + const fieldElement = (clickEvent.currentTarget as HTMLElement).closest( + ".field" + ); - const fieldElement = (clickEvent.currentTarget as HTMLElement).closest(".field"); - - const inputOrSelectElement = fieldElement.querySelector("input, select") as HTMLInputElement | HTMLSelectElement; + const inputOrSelectElement = fieldElement.querySelector( + "input, select" + ) as HTMLInputElement | HTMLSelectElement; if (inputOrSelectElement.tagName === "INPUT") { inputOrSelectElement.disabled = false; } else { - const optionElements = inputOrSelectElement.querySelectorAll("option"); + const optionElements = + inputOrSelectElement.querySelectorAll("option"); for (const optionElement of optionElements) { optionElement.disabled = false; } @@ -57,8 +67,9 @@ import type * as globalTypes from "../types/globalTypes"; }; const initializeUnlockFieldButtons = (containerElement: HTMLElement) => { - - const unlockFieldButtonElements = containerElement.querySelectorAll(".is-unlock-field-button"); + const unlockFieldButtonElements = containerElement.querySelectorAll( + ".is-unlock-field-button" + ); for (const unlockFieldButtonElement of unlockFieldButtonElements) { unlockFieldButtonElement.addEventListener("click", unlockField); @@ -66,39 +77,42 @@ import type * as globalTypes from "../types/globalTypes"; }; const populateAliases = (containerElement: HTMLElement) => { - - const aliasElements = containerElement.querySelectorAll(".alias") as NodeListOf; + const aliasElements = containerElement.querySelectorAll( + ".alias" + ) as NodeListOf; for (const aliasElement of aliasElements) { - switch (aliasElement.dataset.alias) { - case "Lot": aliasElement.textContent = exports.aliases.lot; break; - + case "lot": - aliasElement.textContent = exports.aliases.lot.toLowerCase(); + aliasElement.textContent = + exports.aliases.lot.toLowerCase(); break; case "Occupancy": aliasElement.textContent = exports.aliases.occupancy; break; - + case "occupancy": - aliasElement.textContent = exports.aliases.occupancy.toLowerCase(); + aliasElement.textContent = + exports.aliases.occupancy.toLowerCase(); break; case "Occupant": aliasElement.textContent = exports.aliases.occupant; break; - + case "occupant": - aliasElement.textContent = exports.aliases.occupant.toLowerCase(); + aliasElement.textContent = + exports.aliases.occupant.toLowerCase(); break; case "ExternalReceiptNumber": - aliasElement.textContent = exports.aliases.externalReceiptNumber; + aliasElement.textContent = + exports.aliases.externalReceiptNumber; break; } } @@ -111,4 +125,4 @@ import type * as globalTypes from "../types/globalTypes"; }; exports.los = los; -})(); \ No newline at end of file +})(); diff --git a/public-typescript/mapEdit.js b/public-typescript/mapEdit.js index 11c0d669..3ecff209 100644 --- a/public-typescript/mapEdit.js +++ b/public-typescript/mapEdit.js @@ -2,15 +2,17 @@ Object.defineProperty(exports, "__esModule", { value: true }); (() => { const urlPrefix = document.querySelector("main").dataset.urlPrefix; - const mapId = document.querySelector("#map--mapId").value; - const isCreate = (mapId === ""); + const mapId = document.querySelector("#map--mapId") + .value; + const isCreate = mapId === ""; const mapForm = document.querySelector("#form--map"); const updateMap = (formEvent) => { formEvent.preventDefault(); cityssm.postJSON(urlPrefix + "/maps/" + (isCreate ? "doCreateMap" : "doUpdateMap"), mapForm, (responseJSON) => { if (responseJSON.success) { if (isCreate) { - window.location.href = urlPrefix + "/maps/" + responseJSON.mapId + "/edit"; + window.location.href = + urlPrefix + "/maps/" + responseJSON.mapId + "/edit"; } else { bulmaJS.alert({ @@ -30,14 +32,17 @@ Object.defineProperty(exports, "__esModule", { value: true }); }; mapForm.addEventListener("submit", updateMap); if (!isCreate) { - document.querySelector("#button--deleteMap").addEventListener("click", (clickEvent) => { + document + .querySelector("#button--deleteMap") + .addEventListener("click", (clickEvent) => { clickEvent.preventDefault(); const doDelete = () => { cityssm.postJSON(urlPrefix + "/maps/doDeleteMap", { mapId }, (responseJSON) => { if (responseJSON.success) { - window.location.href = urlPrefix + "/maps?t=" + Date.now(); + window.location.href = + urlPrefix + "/maps?t=" + Date.now(); } else { bulmaJS.alert({ @@ -50,7 +55,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); }; bulmaJS.confirm({ title: "Delete " + exports.aliases.map, - message: "Are you sure you want to delete this " + exports.aliases.map.toLowerCase() + "?", + message: "Are you sure you want to delete this " + + exports.aliases.map.toLowerCase() + + "?", contextualColorName: "warning", okButton: { text: "Yes, Delete " + exports.aliases.map + "?", diff --git a/public-typescript/mapEdit.ts b/public-typescript/mapEdit.ts index cac34987..f2f1dd3f 100644 --- a/public-typescript/mapEdit.ts +++ b/public-typescript/mapEdit.ts @@ -1,40 +1,39 @@ /* eslint-disable unicorn/prefer-module */ -import type { - cityssmGlobal -} from "@cityssm/bulma-webapp-js/src/types"; -import type { - BulmaJS -} from "@cityssm/bulma-js/types"; +import type { cityssmGlobal } from "@cityssm/bulma-webapp-js/src/types"; +import type { BulmaJS } from "@cityssm/bulma-js/types"; declare const cityssm: cityssmGlobal; declare const bulmaJS: BulmaJS; - (() => { const urlPrefix = document.querySelector("main").dataset.urlPrefix; - const mapId = (document.querySelector("#map--mapId") as HTMLInputElement).value; - const isCreate = (mapId === ""); + const mapId = (document.querySelector("#map--mapId") as HTMLInputElement) + .value; + const isCreate = mapId === ""; const mapForm = document.querySelector("#form--map") as HTMLFormElement; const updateMap = (formEvent: SubmitEvent) => { formEvent.preventDefault(); - cityssm.postJSON(urlPrefix + "/maps/" + (isCreate ? "doCreateMap" : "doUpdateMap"), + cityssm.postJSON( + urlPrefix + "/maps/" + (isCreate ? "doCreateMap" : "doUpdateMap"), mapForm, (responseJSON: { - success: boolean;mapId ? : number, - errorMessage ? : string + success: boolean; + mapId?: number; + errorMessage?: string; }) => { - if (responseJSON.success) { if (isCreate) { - window.location.href = urlPrefix + "/maps/" + responseJSON.mapId + "/edit"; + window.location.href = + urlPrefix + "/maps/" + responseJSON.mapId + "/edit"; } else { bulmaJS.alert({ - message: exports.aliases.map + " Updated Successfully", + message: + exports.aliases.map + " Updated Successfully", contextualColorName: "success" }); } @@ -45,46 +44,55 @@ declare const bulmaJS: BulmaJS; contextualColorName: "danger" }); } - }); + } + ); }; mapForm.addEventListener("submit", updateMap); if (!isCreate) { - - document.querySelector("#button--deleteMap").addEventListener("click", (clickEvent) => { - clickEvent.preventDefault(); + document + .querySelector("#button--deleteMap") + .addEventListener("click", (clickEvent) => { + clickEvent.preventDefault(); - const doDelete = () => { - - cityssm.postJSON(urlPrefix + "/maps/doDeleteMap", { - mapId - }, - (responseJSON: { - success: boolean;errorMessage ? : string; - }) => { - - if (responseJSON.success) { - window.location.href = urlPrefix + "/maps?t=" + Date.now(); - } else { - bulmaJS.alert({ - title: "Error Deleting " + exports.aliases.map, - message: responseJSON.errorMessage, - contextualColorName: "danger" - }); + const doDelete = () => { + cityssm.postJSON( + urlPrefix + "/maps/doDeleteMap", + { + mapId + }, + (responseJSON: { + success: boolean; + errorMessage?: string; + }) => { + if (responseJSON.success) { + window.location.href = + urlPrefix + "/maps?t=" + Date.now(); + } else { + bulmaJS.alert({ + title: + "Error Deleting " + exports.aliases.map, + message: responseJSON.errorMessage, + contextualColorName: "danger" + }); + } } - }); - }; + ); + }; - bulmaJS.confirm({ - title: "Delete " + exports.aliases.map, - message: "Are you sure you want to delete this " + exports.aliases.map.toLowerCase() + "?", - contextualColorName: "warning", - okButton: { - text: "Yes, Delete " + exports.aliases.map + "?", - callbackFunction: doDelete - } + bulmaJS.confirm({ + title: "Delete " + exports.aliases.map, + message: + "Are you sure you want to delete this " + + exports.aliases.map.toLowerCase() + + "?", + contextualColorName: "warning", + okButton: { + text: "Yes, Delete " + exports.aliases.map + "?", + callbackFunction: doDelete + } + }); }); - }); } -})(); \ No newline at end of file +})(); diff --git a/public-typescript/mapSearch.js b/public-typescript/mapSearch.js index 55c05a93..d4d53cc9 100644 --- a/public-typescript/mapSearch.js +++ b/public-typescript/mapSearch.js @@ -6,17 +6,26 @@ Object.defineProperty(exports, "__esModule", { value: true }); const searchFilterElement = document.querySelector("#searchFilter--map"); const searchResultsContainerElement = document.querySelector("#container--searchResults"); const renderResults = () => { - searchResultsContainerElement.innerHTML = "
" + - "
" + - "Loading " + exports.aliases.maps + "..." + - "
"; + searchResultsContainerElement.innerHTML = + '
' + + '
' + + "Loading " + + exports.aliases.maps + + "..." + + "
"; let searchResultCount = 0; const searchResultsTbodyElement = document.createElement("tbody"); - const filterStringSplit = searchFilterElement.value.trim().toLowerCase().split(" "); + const filterStringSplit = searchFilterElement.value + .trim() + .toLowerCase() + .split(" "); for (const map of maps) { - const mapSearchString = (map.mapName + " " + - map.mapDescription + " " + - map.mapAddress1 + " " + + const mapSearchString = (map.mapName + + " " + + map.mapDescription + + " " + + map.mapAddress1 + + " " + map.mapAddress2).toLowerCase(); let showMap = true; for (const filterStringPiece of filterStringSplit) { @@ -29,28 +38,34 @@ Object.defineProperty(exports, "__esModule", { value: true }); continue; } searchResultCount += 1; - const mapName = map.mapName === "" ? - "(No Name)" : - map.mapName; + const mapName = map.mapName === "" ? "(No Name)" : map.mapName; searchResultsTbodyElement.insertAdjacentHTML("beforeend", "
" + ("") + - "" + - "" + - ("") + @@ -58,25 +73,36 @@ Object.defineProperty(exports, "__esModule", { value: true }); } searchResultsContainerElement.innerHTML = ""; if (searchResultCount === 0) { - searchResultsContainerElement.innerHTML = "
" + - "

There are no " + exports.aliases.maps.toLowerCase() + " that meet the search criteria.

" + - "
"; + searchResultsContainerElement.innerHTML = + '
' + + '

There are no ' + + exports.aliases.maps.toLowerCase() + + " that meet the search criteria.

" + + "
"; } else { const searchResultsTableElement = document.createElement("table"); - searchResultsTableElement.className = "table is-fullwidth is-striped is-hoverable"; - searchResultsTableElement.innerHTML = "" + - "" + - "" + - "" + - "" + - ""; + searchResultsTableElement.className = + "table is-fullwidth is-striped is-hoverable"; + searchResultsTableElement.innerHTML = + "" + + "" + + '' + + '' + + '" + + ""; searchResultsTableElement.append(searchResultsTbodyElement); searchResultsContainerElement.append(searchResultsTableElement); } }; searchFilterElement.addEventListener("keyup", renderResults); - document.querySelector("#form--searchFilters").addEventListener("submit", (formEvent) => { + document + .querySelector("#form--searchFilters") + .addEventListener("submit", (formEvent) => { formEvent.preventDefault(); renderResults(); }); diff --git a/public-typescript/mapSearch.ts b/public-typescript/mapSearch.ts index 14fb017c..7252d358 100644 --- a/public-typescript/mapSearch.ts +++ b/public-typescript/mapSearch.ts @@ -2,39 +2,50 @@ import type * as recordTypes from "../types/recordTypes"; -import type { - cityssmGlobal -} from "@cityssm/bulma-webapp-js/src/types"; +import type { cityssmGlobal } from "@cityssm/bulma-webapp-js/src/types"; declare const cityssm: cityssmGlobal; - (() => { const urlPrefix = document.querySelector("main").dataset.urlPrefix; const maps: recordTypes.Map[] = exports.maps; - const searchFilterElement = document.querySelector("#searchFilter--map") as HTMLInputElement; - const searchResultsContainerElement = document.querySelector("#container--searchResults") as HTMLElement; + const searchFilterElement = document.querySelector( + "#searchFilter--map" + ) as HTMLInputElement; + + const searchResultsContainerElement = document.querySelector( + "#container--searchResults" + ) as HTMLElement; const renderResults = () => { - - searchResultsContainerElement.innerHTML = "
" + - "
" + - "Loading " + exports.aliases.maps + "..." + + searchResultsContainerElement.innerHTML = + '
' + + '
' + + "Loading " + + exports.aliases.maps + + "..." + "
"; let searchResultCount = 0; const searchResultsTbodyElement = document.createElement("tbody"); - const filterStringSplit = searchFilterElement.value.trim().toLowerCase().split(" "); + const filterStringSplit = searchFilterElement.value + .trim() + .toLowerCase() + .split(" "); for (const map of maps) { - - const mapSearchString = (map.mapName + " " + - map.mapDescription + " " + - map.mapAddress1 + " " + - map.mapAddress2).toLowerCase(); + const mapSearchString = ( + map.mapName + + " " + + map.mapDescription + + " " + + map.mapAddress1 + + " " + + map.mapAddress2 + ).toLowerCase(); let showMap = true; @@ -51,52 +62,67 @@ declare const cityssm: cityssmGlobal; searchResultCount += 1; - const mapName = map.mapName === "" ? - "(No Name)" : - map.mapName; + const mapName = map.mapName === "" ? "(No Name)" : map.mapName; - searchResultsTbodyElement.insertAdjacentHTML("beforeend", "
" + - ("") + - "" + - "" + - ("") + - ""); + searchResultsTbodyElement.insertAdjacentHTML( + "beforeend", + "" + + ("") + + '" + + '" + + ('") + + "" + ); } searchResultsContainerElement.innerHTML = ""; if (searchResultCount === 0) { - - searchResultsContainerElement.innerHTML = "
" + - "

There are no " + exports.aliases.maps.toLowerCase() + " that meet the search criteria.

" + + searchResultsContainerElement.innerHTML = + '
' + + '

There are no ' + + exports.aliases.maps.toLowerCase() + + " that meet the search criteria.

" + "
"; - } else { - const searchResultsTableElement = document.createElement("table"); - searchResultsTableElement.className = "table is-fullwidth is-striped is-hoverable"; - searchResultsTableElement.innerHTML = "
" + - "" + - "" + - "" + - "" + + searchResultsTableElement.className = + "table is-fullwidth is-striped is-hoverable"; + searchResultsTableElement.innerHTML = + "" + + "" + + '' + + '' + + '" + ""; searchResultsTableElement.append(searchResultsTbodyElement); @@ -106,10 +132,12 @@ declare const cityssm: cityssmGlobal; }; searchFilterElement.addEventListener("keyup", renderResults); - document.querySelector("#form--searchFilters").addEventListener("submit", (formEvent) => { - formEvent.preventDefault(); - renderResults(); - }); + document + .querySelector("#form--searchFilters") + .addEventListener("submit", (formEvent) => { + formEvent.preventDefault(); + renderResults(); + }); renderResults(); -})(); \ No newline at end of file +})(); diff --git a/public-typescript/mapView.js b/public-typescript/mapView.js index 474e52e3..2f267db2 100644 --- a/public-typescript/mapView.js +++ b/public-typescript/mapView.js @@ -8,9 +8,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); const mapCoordinates = [mapLatitude, mapLongitude]; const map = L.map(mapContainerElement); map.setView(mapCoordinates, 15); - L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { + L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", { maxZoom: 19, - attribution: '© OpenStreetMap' + attribution: "© OpenStreetMap" }).addTo(map); L.marker(mapCoordinates).addTo(map); } diff --git a/public-typescript/mapView.ts b/public-typescript/mapView.ts index e5da60ce..a396e5d2 100644 --- a/public-typescript/mapView.ts +++ b/public-typescript/mapView.ts @@ -1,30 +1,34 @@ -import type { cityssmGlobal } from "@cityssm/bulma-webapp-js/src/types"; -import type { BulmaJS } from "@cityssm/bulma-js/types"; +// import type { cityssmGlobal } from "@cityssm/bulma-webapp-js/src/types"; +// import type { BulmaJS } from "@cityssm/bulma-js/types"; import type * as Leaflet from "leaflet"; -declare const cityssm: cityssmGlobal; -declare const bulmaJS: BulmaJS; +// declare const cityssm: cityssmGlobal; +// declare const bulmaJS: BulmaJS; declare const L; (() => { - - const mapContainerElement = document.querySelector("#map--leaflet") as HTMLElement; + const mapContainerElement = document.querySelector( + "#map--leaflet" + ) as HTMLElement; if (mapContainerElement) { - - const mapLatitude = Number.parseFloat(mapContainerElement.dataset.mapLatitude); - const mapLongitude = Number.parseFloat(mapContainerElement.dataset.mapLongitude); + const mapLatitude = Number.parseFloat( + mapContainerElement.dataset.mapLatitude + ); + const mapLongitude = Number.parseFloat( + mapContainerElement.dataset.mapLongitude + ); const mapCoordinates: Leaflet.LatLngTuple = [mapLatitude, mapLongitude]; const map: Leaflet.Map = L.map(mapContainerElement); map.setView(mapCoordinates, 15); - L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { + L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", { maxZoom: 19, - attribution: '© OpenStreetMap' + attribution: "© OpenStreetMap" }).addTo(map); L.marker(mapCoordinates).addTo(map); } -})(); \ No newline at end of file +})(); diff --git a/public-typescript/workOrderSearch.js b/public-typescript/workOrderSearch.js index 2c2eff0e..68675cef 100644 --- a/public-typescript/workOrderSearch.js +++ b/public-typescript/workOrderSearch.js @@ -4,82 +4,103 @@ Object.defineProperty(exports, "__esModule", { value: true }); const urlPrefix = document.querySelector("main").dataset.urlPrefix; const searchFilterFormElement = document.querySelector("#form--searchFilters"); const searchResultsContainerElement = document.querySelector("#container--searchResults"); - const limit = Number.parseInt(document.querySelector("#searchFilter--limit").value, 10); + const limit = Number.parseInt(document.querySelector("#searchFilter--limit") + .value, 10); const offsetElement = document.querySelector("#searchFilter--offset"); const getWorkOrders = () => { const offset = Number.parseInt(offsetElement.value, 10); - searchResultsContainerElement.innerHTML = "
" + - "
" + - "Loading Work Orders..." + - "
"; + searchResultsContainerElement.innerHTML = + '
' + + '
' + + "Loading Work Orders..." + + "
"; cityssm.postJSON(urlPrefix + "/workOrders/doSearchWorkOrders", searchFilterFormElement, (responseJSON) => { if (responseJSON.workOrders.length === 0) { - searchResultsContainerElement.innerHTML = "
" + - "

There are no work orders that meet the search criteria.

" + - "
"; + searchResultsContainerElement.innerHTML = + '
' + + '

There are no work orders that meet the search criteria.

' + + "
"; return; } const resultsTbodyElement = document.createElement("tbody"); for (const workOrder of responseJSON.workOrders) { resultsTbodyElement.insertAdjacentHTML("beforeend", "" + ("") + ("") + - "" + + "" + ("") + ("") + ""); } - searchResultsContainerElement.innerHTML = "
" + - "" + + '' + cityssm.escapeHTML(mapName) + "
" + cityssm.escapeHTML(map.mapAddress1) + "
" + - (map.mapLatitude && map.mapLongitude ? - "" : - "") + + '' + + (map.mapLatitude && map.mapLongitude + ? '' + : "") + "" + - (map.mapSVG ? - "" : - "") + + '' + + (map.mapSVG + ? '' + : "") + "" + - "" + + ('' + + '' + map.lotCount + "" + "
" + exports.aliases.map + "CoordinatesImage" + exports.aliases.lot + " Count
" + + exports.aliases.map + + "CoordinatesImage' + + exports.aliases.lot + + " Count
" + - "" + - cityssm.escapeHTML(mapName) + - "
" + - cityssm.escapeHTML(map.mapAddress1) + - "
" + - (map.mapLatitude && map.mapLongitude ? - "" : - "") + - "" + - (map.mapSVG ? - "" : - "") + - "" + - "" + - map.lotCount + - "" + - "
" + + '' + + cityssm.escapeHTML(mapName) + + "
" + + cityssm.escapeHTML(map.mapAddress1) + + "
' + + (map.mapLatitude && map.mapLongitude + ? '' + : "") + + "' + + (map.mapSVG + ? '' + : "") + + "' + + '' + + map.lotCount + + "" + + "
" + exports.aliases.map + "CoordinatesImage" + exports.aliases.lot + " Count
" + + exports.aliases.map + + "CoordinatesImage' + + exports.aliases.lot + + " Count
" + - "" + + '' + cityssm.escapeHTML(workOrder.workOrderNumber) + "" + "" + cityssm.escapeHTML(workOrder.workOrderType) + "" + cityssm.escapeHTML(workOrder.workOrderDescription) + "" + + cityssm.escapeHTML(workOrder.workOrderDescription) + + "" + workOrder.workOrderOpenDateString + "" + - (workOrder.workOrderCloseDate ? workOrder.workOrderCloseDateString : "(No Close Date)") + + (workOrder.workOrderCloseDate + ? workOrder.workOrderCloseDateString + : '(No Close Date)') + "
" + - "" + - "" + - "" + - "" + - "" + - "" + - "" + - "
Work Order NumberWork Order TypeWork Order DescriptionOpen DateClose Date
" + - "
" + - ("
" + - "
" + - "Displaying " + (offset + 1).toString() + - " to " + Math.min(responseJSON.count, limit + offset) + - " of " + responseJSON.count + - "
" + - "
") + - ("
" + - (offset > 0 ? - "
" + - "" + - "
" : - "") + - (limit + offset < responseJSON.count ? - "
" + - "" + - "
" : - "") + - "
") + - "
"; - searchResultsContainerElement.querySelector("table").append(resultsTbodyElement); + searchResultsContainerElement.innerHTML = + '
' + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "
Work Order NumberWork Order TypeWork Order DescriptionOpen DateClose Date
" + + '
' + + ('
' + + '
' + + "Displaying " + + (offset + 1).toString() + + " to " + + Math.min(responseJSON.count, limit + offset) + + " of " + + responseJSON.count + + "
" + + "
") + + ('
' + + (offset > 0 + ? '
' + + '" + + "
" + : "") + + (limit + offset < responseJSON.count + ? '
' + + '" + + "
" + : "") + + "
") + + "
"; + searchResultsContainerElement + .querySelector("table") + .append(resultsTbodyElement); if (offset > 0) { - searchResultsContainerElement.querySelector("button[data-page='previous']").addEventListener("click", previousAndGetWorkOrders); + searchResultsContainerElement + .querySelector("button[data-page='previous']") + .addEventListener("click", previousAndGetWorkOrders); } if (limit + offset < responseJSON.count) { - searchResultsContainerElement.querySelector("button[data-page='next']").addEventListener("click", nextAndGetWorkOrders); + searchResultsContainerElement + .querySelector("button[data-page='next']") + .addEventListener("click", nextAndGetWorkOrders); } }); }; diff --git a/public-typescript/workOrderSearch.ts b/public-typescript/workOrderSearch.ts index 5ff2c313..a1c3aacd 100644 --- a/public-typescript/workOrderSearch.ts +++ b/public-typescript/workOrderSearch.ts @@ -2,43 +2,49 @@ import type * as recordTypes from "../types/recordTypes"; -import type { - cityssmGlobal -} from "@cityssm/bulma-webapp-js/src/types"; - +import type { cityssmGlobal } from "@cityssm/bulma-webapp-js/src/types"; declare const cityssm: cityssmGlobal; - (() => { const urlPrefix = document.querySelector("main").dataset.urlPrefix; - const searchFilterFormElement = document.querySelector("#form--searchFilters") as HTMLFormElement; - const searchResultsContainerElement = document.querySelector("#container--searchResults") as HTMLElement; - - const limit = Number.parseInt((document.querySelector("#searchFilter--limit") as HTMLInputElement).value, 10); - const offsetElement = document.querySelector("#searchFilter--offset") as HTMLInputElement; + const searchFilterFormElement = document.querySelector( + "#form--searchFilters" + ) as HTMLFormElement; + const searchResultsContainerElement = document.querySelector( + "#container--searchResults" + ) as HTMLElement; + const limit = Number.parseInt( + (document.querySelector("#searchFilter--limit") as HTMLInputElement) + .value, + 10 + ); + const offsetElement = document.querySelector( + "#searchFilter--offset" + ) as HTMLInputElement; const getWorkOrders = () => { - const offset = Number.parseInt(offsetElement.value, 10); - searchResultsContainerElement.innerHTML = "
" + - "
" + + searchResultsContainerElement.innerHTML = + '
' + + '
' + "Loading Work Orders..." + "
"; - cityssm.postJSON(urlPrefix + "/workOrders/doSearchWorkOrders", searchFilterFormElement, + cityssm.postJSON( + urlPrefix + "/workOrders/doSearchWorkOrders", + searchFilterFormElement, (responseJSON: { count: number; workOrders: recordTypes.WorkOrder[]; }) => { - if (responseJSON.workOrders.length === 0) { - - searchResultsContainerElement.innerHTML = "
" + - "

There are no work orders that meet the search criteria.

" + + searchResultsContainerElement.innerHTML = + '
' + + '

There are no work orders that meet the search criteria.

' + "
"; return; @@ -47,28 +53,38 @@ declare const cityssm: cityssmGlobal; const resultsTbodyElement = document.createElement("tbody"); for (const workOrder of responseJSON.workOrders) { - - resultsTbodyElement.insertAdjacentHTML("beforeend", "
" + - ("") + - ("") + - "" + - ("") + + resultsTbodyElement.insertAdjacentHTML( + "beforeend", + "" + ("") + - ""); - + '' + + cityssm.escapeHTML(workOrder.workOrderNumber) + + "" + + "") + + ("") + + "" + + ("") + + ("") + + "" + ); } - searchResultsContainerElement.innerHTML = "
" + - "" + - cityssm.escapeHTML(workOrder.workOrderNumber) + - "" + - "" + - cityssm.escapeHTML(workOrder.workOrderType) + - "" + cityssm.escapeHTML(workOrder.workOrderDescription) + "" + - workOrder.workOrderOpenDateString + - "
" + - (workOrder.workOrderCloseDate ? workOrder.workOrderCloseDateString : "(No Close Date)") + - "
" + + cityssm.escapeHTML(workOrder.workOrderType) + + "" + + cityssm.escapeHTML(workOrder.workOrderDescription) + + "" + + workOrder.workOrderOpenDateString + + "" + + (workOrder.workOrderCloseDate + ? workOrder.workOrderCloseDateString + : '(No Close Date)') + + "
" + + searchResultsContainerElement.innerHTML = + '
' + "" + "" + "" + @@ -77,61 +93,78 @@ declare const cityssm: cityssmGlobal; "" + "" + "
Work Order NumberWork Order TypeClose Date
" + - "
" + - ("
" + - "
" + - "Displaying " + (offset + 1).toString() + - " to " + Math.min(responseJSON.count, limit + offset) + - " of " + responseJSON.count + + '
' + + ('
' + + '
' + + "Displaying " + + (offset + 1).toString() + + " to " + + Math.min(responseJSON.count, limit + offset) + + " of " + + responseJSON.count + "
" + "
") + - ("
" + - (offset > 0 ? - "
" + - "" + - "
" : - "") + - (limit + offset < responseJSON.count ? - "
" + - "" + - "
" : - "") + + ('
' + + (offset > 0 + ? '
' + + '" + + "
" + : "") + + (limit + offset < responseJSON.count + ? '
' + + '" + + "
" + : "") + "
") + "
"; - searchResultsContainerElement.querySelector("table").append(resultsTbodyElement); + searchResultsContainerElement + .querySelector("table") + .append(resultsTbodyElement); if (offset > 0) { - searchResultsContainerElement.querySelector("button[data-page='previous']").addEventListener("click", previousAndGetWorkOrders); + searchResultsContainerElement + .querySelector("button[data-page='previous']") + .addEventListener("click", previousAndGetWorkOrders); } if (limit + offset < responseJSON.count) { - searchResultsContainerElement.querySelector("button[data-page='next']").addEventListener("click", nextAndGetWorkOrders); + searchResultsContainerElement + .querySelector("button[data-page='next']") + .addEventListener("click", nextAndGetWorkOrders); } - }); + } + ); }; const resetOffsetAndGetWorkOrders = () => { offsetElement.value = "0"; getWorkOrders(); - } + }; const previousAndGetWorkOrders = () => { - offsetElement.value = Math.max(Number.parseInt(offsetElement.value, 10) - limit, 0).toString(); + offsetElement.value = Math.max( + Number.parseInt(offsetElement.value, 10) - limit, + 0 + ).toString(); getWorkOrders(); }; const nextAndGetWorkOrders = () => { - offsetElement.value = (Number.parseInt(offsetElement.value, 10) + limit).toString(); + offsetElement.value = ( + Number.parseInt(offsetElement.value, 10) + limit + ).toString(); getWorkOrders(); }; - const filterElements = searchFilterFormElement.querySelectorAll("input, select") as NodeListOf < HTMLInputElement | HTMLSelectElement > ; + const filterElements = searchFilterFormElement.querySelectorAll( + "input, select" + ) as NodeListOf; for (const filterElement of filterElements) { filterElement.addEventListener("change", resetOffsetAndGetWorkOrders); @@ -143,4 +176,4 @@ declare const cityssm: cityssmGlobal; }); getWorkOrders(); -})(); \ No newline at end of file +})(); diff --git a/routes/admin.js b/routes/admin.js index 63c79fa8..b5e6acc9 100644 --- a/routes/admin.js +++ b/routes/admin.js @@ -11,6 +11,7 @@ import handler_doUpdateFee from "../handlers/admin-post/doUpdateFee.js"; import handler_doMoveFeeUp from "../handlers/admin-post/doMoveFeeUp.js"; import handler_doMoveFeeDown from "../handlers/admin-post/doMoveFeeDown.js"; import handler_doDeleteFee from "../handlers/admin-post/doDeleteFee.js"; +import handler_occupancyTypes from "../handlers/admin-get/occupancyTypes.js"; import handler_tables from "../handlers/admin-get/tables.js"; import handler_doAddWorkOrderType from "../handlers/admin-post/doAddWorkOrderType.js"; import handler_doUpdateWorkOrderType from "../handlers/admin-post/doUpdateWorkOrderType.js"; @@ -39,6 +40,7 @@ router.post("/doUpdateFee", permissionHandlers.adminPostHandler, handler_doUpdat router.post("/doMoveFeeUp", permissionHandlers.adminPostHandler, handler_doMoveFeeUp); router.post("/doMoveFeeDown", permissionHandlers.adminPostHandler, handler_doMoveFeeDown); router.post("/doDeleteFee", permissionHandlers.adminPostHandler, handler_doDeleteFee); +router.get("/occupancyTypes", permissionHandlers.adminGetHandler, handler_occupancyTypes); router.get("/tables", permissionHandlers.adminGetHandler, handler_tables); router.post("/doAddWorkOrderType", permissionHandlers.adminPostHandler, handler_doAddWorkOrderType); router.post("/doUpdateWorkOrderType", permissionHandlers.adminPostHandler, handler_doUpdateWorkOrderType); diff --git a/routes/admin.ts b/routes/admin.ts index 3d44cd44..991fb51b 100644 --- a/routes/admin.ts +++ b/routes/admin.ts @@ -1,10 +1,11 @@ -import { - Router -} from "express"; +import { Router } from "express"; import * as permissionHandlers from "../handlers/permissions.js"; +// Fee Management + import handler_fees from "../handlers/admin-get/fees.js"; + import handler_doAddFeeCategory from "../handlers/admin-post/doAddFeeCategory.js"; import handler_doUpdateFeeCategory from "../handlers/admin-post/doUpdateFeeCategory.js"; import handler_doMoveFeeCategoryUp from "../handlers/admin-post/doMoveFeeCategoryUp.js"; @@ -17,6 +18,8 @@ import handler_doMoveFeeUp from "../handlers/admin-post/doMoveFeeUp.js"; import handler_doMoveFeeDown from "../handlers/admin-post/doMoveFeeDown.js"; import handler_doDeleteFee from "../handlers/admin-post/doDeleteFee.js"; +// Config Table Management + import handler_tables from "../handlers/admin-get/tables.js"; import handler_doAddWorkOrderType from "../handlers/admin-post/doAddWorkOrderType.js"; @@ -37,127 +40,172 @@ import handler_doMoveLotOccupantTypeUp from "../handlers/admin-post/doMoveLotOcc import handler_doMoveLotOccupantTypeDown from "../handlers/admin-post/doMoveLotOccupantTypeDown.js"; import handler_doDeleteLotOccupantType from "../handlers/admin-post/doDeleteLotOccupantType.js"; - export const router = Router(); +/* + * Fees + */ + +router.get("/fees", permissionHandlers.adminGetHandler, handler_fees); + +router.post( + "/doAddFeeCategory", + permissionHandlers.adminPostHandler, + handler_doAddFeeCategory +); + +router.post( + "/doUpdateFeeCategory", + permissionHandlers.adminPostHandler, + handler_doUpdateFeeCategory +); + +router.post( + "/doMoveFeeCategoryUp", + permissionHandlers.adminPostHandler, + handler_doMoveFeeCategoryUp +); + +router.post( + "/doMoveFeeCategoryDown", + permissionHandlers.adminPostHandler, + handler_doMoveFeeCategoryDown +); + +router.post( + "/doDeleteFeeCategory", + permissionHandlers.adminPostHandler, + handler_doDeleteFeeCategory +); + +router.post("/doAddFee", permissionHandlers.adminPostHandler, handler_doAddFee); + +router.post( + "/doUpdateFee", + permissionHandlers.adminPostHandler, + handler_doUpdateFee +); + +router.post( + "/doMoveFeeUp", + permissionHandlers.adminPostHandler, + handler_doMoveFeeUp +); + +router.post( + "/doMoveFeeDown", + permissionHandlers.adminPostHandler, + handler_doMoveFeeDown +); + +router.post( + "/doDeleteFee", + permissionHandlers.adminPostHandler, + handler_doDeleteFee +); -// Fees -router.get("/fees", permissionHandlers.adminGetHandler, - handler_fees); +/* + * Config Tables + */ -router.post("/doAddFeeCategory", - permissionHandlers.adminPostHandler, - handler_doAddFeeCategory); - -router.post("/doUpdateFeeCategory", - permissionHandlers.adminPostHandler, - handler_doUpdateFeeCategory); - -router.post("/doMoveFeeCategoryUp", - permissionHandlers.adminPostHandler, - handler_doMoveFeeCategoryUp); - -router.post("/doMoveFeeCategoryDown", - permissionHandlers.adminPostHandler, - handler_doMoveFeeCategoryDown); - -router.post("/doDeleteFeeCategory", - permissionHandlers.adminPostHandler, - handler_doDeleteFeeCategory); - -router.post("/doAddFee", - permissionHandlers.adminPostHandler, - handler_doAddFee); - -router.post("/doUpdateFee", - permissionHandlers.adminPostHandler, - handler_doUpdateFee); - -router.post("/doMoveFeeUp", - permissionHandlers.adminPostHandler, - handler_doMoveFeeUp); - -router.post("/doMoveFeeDown", - permissionHandlers.adminPostHandler, - handler_doMoveFeeDown); - -router.post("/doDeleteFee", - permissionHandlers.adminPostHandler, - handler_doDeleteFee); - -// Config Tables - -router.get("/tables", - permissionHandlers.adminGetHandler, - handler_tables); +router.get("/tables", permissionHandlers.adminGetHandler, handler_tables); // Config Tables - Work Order Types -router.post("/doAddWorkOrderType", +router.post( + "/doAddWorkOrderType", permissionHandlers.adminPostHandler, - handler_doAddWorkOrderType); + handler_doAddWorkOrderType +); -router.post("/doUpdateWorkOrderType", +router.post( + "/doUpdateWorkOrderType", permissionHandlers.adminPostHandler, - handler_doUpdateWorkOrderType); + handler_doUpdateWorkOrderType +); -router.post("/doMoveWorkOrderTypeUp", +router.post( + "/doMoveWorkOrderTypeUp", permissionHandlers.adminPostHandler, - handler_doMoveWorkOrderTypeUp); + handler_doMoveWorkOrderTypeUp +); -router.post("/doMoveWorkOrderTypeDown", +router.post( + "/doMoveWorkOrderTypeDown", permissionHandlers.adminPostHandler, - handler_doMoveWorkOrderTypeDown); + handler_doMoveWorkOrderTypeDown +); -router.post("/doDeleteWorkOrderType", +router.post( + "/doDeleteWorkOrderType", permissionHandlers.adminPostHandler, - handler_doDeleteWorkOrderType); + handler_doDeleteWorkOrderType +); // Config Tables - Lot Statuses -router.post("/doAddLotStatus", +router.post( + "/doAddLotStatus", permissionHandlers.adminPostHandler, - handler_doAddLotStatus); + handler_doAddLotStatus +); -router.post("/doUpdateLotStatus", +router.post( + "/doUpdateLotStatus", permissionHandlers.adminPostHandler, - handler_doUpdateLotStatus); + handler_doUpdateLotStatus +); -router.post("/doMoveLotStatusUp", +router.post( + "/doMoveLotStatusUp", permissionHandlers.adminPostHandler, - handler_doMoveLotStatusUp); + handler_doMoveLotStatusUp +); -router.post("/doMoveLotStatusDown", +router.post( + "/doMoveLotStatusDown", permissionHandlers.adminPostHandler, - handler_doMoveLotStatusDown); + handler_doMoveLotStatusDown +); -router.post("/doDeleteLotStatus", +router.post( + "/doDeleteLotStatus", permissionHandlers.adminPostHandler, - handler_doDeleteLotStatus); + handler_doDeleteLotStatus +); // Config Tables - Lot Occupant Types -router.post("/doAddLotOccupantType", +router.post( + "/doAddLotOccupantType", permissionHandlers.adminPostHandler, - handler_doAddLotOccupantType); + handler_doAddLotOccupantType +); -router.post("/doUpdateLotOccupantType", +router.post( + "/doUpdateLotOccupantType", permissionHandlers.adminPostHandler, - handler_doUpdateLotOccupantType); + handler_doUpdateLotOccupantType +); -router.post("/doMoveLotOccupantTypeUp", +router.post( + "/doMoveLotOccupantTypeUp", permissionHandlers.adminPostHandler, - handler_doMoveLotOccupantTypeUp); + handler_doMoveLotOccupantTypeUp +); -router.post("/doMoveLotOccupantTypeDown", +router.post( + "/doMoveLotOccupantTypeDown", permissionHandlers.adminPostHandler, - handler_doMoveLotOccupantTypeDown); + handler_doMoveLotOccupantTypeDown +); -router.post("/doDeleteLotOccupantType", +router.post( + "/doDeleteLotOccupantType", permissionHandlers.adminPostHandler, - handler_doDeleteLotOccupantType); + handler_doDeleteLotOccupantType +); - -export default router; \ No newline at end of file +export default router; diff --git a/routes/dashboard.ts b/routes/dashboard.ts index f0500596..3a45bc47 100644 --- a/routes/dashboard.ts +++ b/routes/dashboard.ts @@ -2,11 +2,8 @@ import { Router } from "express"; import handler_dashboard from "../handlers/dashboard-get/dashboard.js"; - export const router = Router(); - router.get("/", handler_dashboard); - export default router; diff --git a/routes/login.js b/routes/login.js index 062b359c..8bb1abda 100644 --- a/routes/login.js +++ b/routes/login.js @@ -5,10 +5,10 @@ import { useTestDatabases } from "../data/databasePaths.js"; export const router = Router(); const getSafeRedirectURL = (possibleRedirectURL = "") => { const urlPrefix = configFunctions.getProperty("reverseProxy.urlPrefix"); - if (typeof (possibleRedirectURL) === "string") { - const urlToCheck = (possibleRedirectURL.startsWith(urlPrefix) ? - possibleRedirectURL.slice(urlPrefix.length) : - possibleRedirectURL).toLowerCase(); + if (typeof possibleRedirectURL === "string") { + const urlToCheck = (possibleRedirectURL.startsWith(urlPrefix) + ? possibleRedirectURL.slice(urlPrefix.length) + : possibleRedirectURL).toLowerCase(); switch (urlToCheck) { case "/admin/fees": case "/lotOccupancies": @@ -21,7 +21,8 @@ const getSafeRedirectURL = (possibleRedirectURL = "") => { } return urlPrefix + "/dashboard"; }; -router.route("/") +router + .route("/") .get((request, response) => { const sessionCookieName = configFunctions.getProperty("session.cookieName"); if (request.session.user && request.cookies[sessionCookieName]) { @@ -41,25 +42,26 @@ router.route("/") const userName = request.body.userName; const passwordPlain = request.body.password; const unsafeRedirectURL = request.body.redirect; - const redirectURL = getSafeRedirectURL(typeof (unsafeRedirectURL) === "string" ? - unsafeRedirectURL : - ""); + const redirectURL = getSafeRedirectURL(typeof unsafeRedirectURL === "string" ? unsafeRedirectURL : ""); const isAuthenticated = await authenticationFunctions.authenticate(userName, passwordPlain); let userObject; if (isAuthenticated) { const userNameLowerCase = userName.toLowerCase(); - const canLogin = configFunctions.getProperty("users.canLogin") + const canLogin = configFunctions + .getProperty("users.canLogin") .some((currentUserName) => { return userNameLowerCase === currentUserName.toLowerCase(); }); if (canLogin) { - const canUpdate = configFunctions.getProperty("users.canUpdate") + const canUpdate = configFunctions + .getProperty("users.canUpdate") .some((currentUserName) => { - return userNameLowerCase === currentUserName.toLowerCase(); + return (userNameLowerCase === currentUserName.toLowerCase()); }); - const isAdmin = configFunctions.getProperty("users.isAdmin") + const isAdmin = configFunctions + .getProperty("users.isAdmin") .some((currentUserName) => { - return userNameLowerCase === currentUserName.toLowerCase(); + return (userNameLowerCase === currentUserName.toLowerCase()); }); userObject = { userName: userNameLowerCase, diff --git a/routes/login.ts b/routes/login.ts index 535885e7..10e72ee6 100644 --- a/routes/login.ts +++ b/routes/login.ts @@ -1,6 +1,4 @@ -import { - Router -} from "express"; +import { Router } from "express"; import * as configFunctions from "../helpers/functions.config.js"; @@ -10,19 +8,17 @@ import { useTestDatabases } from "../data/databasePaths.js"; import type * as recordTypes from "../types/recordTypes"; - export const router = Router(); - const getSafeRedirectURL = (possibleRedirectURL = "") => { - const urlPrefix = configFunctions.getProperty("reverseProxy.urlPrefix"); - if (typeof (possibleRedirectURL) === "string") { - - const urlToCheck = (possibleRedirectURL.startsWith(urlPrefix) ? - possibleRedirectURL.slice(urlPrefix.length) : - possibleRedirectURL).toLowerCase(); + if (typeof possibleRedirectURL === "string") { + const urlToCheck = ( + possibleRedirectURL.startsWith(urlPrefix) + ? possibleRedirectURL.slice(urlPrefix.length) + : possibleRedirectURL + ).toLowerCase(); switch (urlToCheck) { case "/admin/fees": @@ -31,7 +27,6 @@ const getSafeRedirectURL = (possibleRedirectURL = "") => { case "/maps": case "/workOrders": case "/reports": - return urlPrefix + urlToCheck; } } @@ -39,20 +34,19 @@ const getSafeRedirectURL = (possibleRedirectURL = "") => { return urlPrefix + "/dashboard"; }; - -router.route("/") +router + .route("/") .get((request, response) => { - - const sessionCookieName = configFunctions.getProperty("session.cookieName"); + const sessionCookieName = + configFunctions.getProperty("session.cookieName"); if (request.session.user && request.cookies[sessionCookieName]) { - - const redirectURL = getSafeRedirectURL((request.query.redirect || "") as string); + const redirectURL = getSafeRedirectURL( + (request.query.redirect || "") as string + ); response.redirect(redirectURL); - } else { - response.render("login", { userName: "", message: "", @@ -62,38 +56,45 @@ router.route("/") } }) .post(async (request, response) => { - const userName = request.body.userName as string; const passwordPlain = request.body.password as string; const unsafeRedirectURL = request.body.redirect; - const redirectURL = getSafeRedirectURL(typeof (unsafeRedirectURL) === "string" ? - unsafeRedirectURL : - ""); + const redirectURL = getSafeRedirectURL( + typeof unsafeRedirectURL === "string" ? unsafeRedirectURL : "" + ); - const isAuthenticated = await authenticationFunctions.authenticate(userName, passwordPlain) + const isAuthenticated = await authenticationFunctions.authenticate( + userName, + passwordPlain + ); let userObject: recordTypes.User; if (isAuthenticated) { - const userNameLowerCase = userName.toLowerCase(); - const canLogin = configFunctions.getProperty("users.canLogin") + const canLogin = configFunctions + .getProperty("users.canLogin") .some((currentUserName) => { return userNameLowerCase === currentUserName.toLowerCase(); }); if (canLogin) { - - const canUpdate = configFunctions.getProperty("users.canUpdate") + const canUpdate = configFunctions + .getProperty("users.canUpdate") .some((currentUserName) => { - return userNameLowerCase === currentUserName.toLowerCase(); + return ( + userNameLowerCase === currentUserName.toLowerCase() + ); }); - const isAdmin = configFunctions.getProperty("users.isAdmin") + const isAdmin = configFunctions + .getProperty("users.isAdmin") .some((currentUserName) => { - return userNameLowerCase === currentUserName.toLowerCase(); + return ( + userNameLowerCase === currentUserName.toLowerCase() + ); }); userObject = { @@ -107,13 +108,10 @@ router.route("/") } if (isAuthenticated && userObject) { - request.session.user = userObject; response.redirect(redirectURL); - } else { - response.render("login", { userName, message: "Login Failed", @@ -123,5 +121,4 @@ router.route("/") } }); - -export default router; \ No newline at end of file +export default router; diff --git a/routes/lotOccupancies.ts b/routes/lotOccupancies.ts index 80319918..74063446 100644 --- a/routes/lotOccupancies.ts +++ b/routes/lotOccupancies.ts @@ -1,6 +1,4 @@ -import { - Router -} from "express"; +import { Router } from "express"; import handler_search from "../handlers/lotOccupancies-get/search.js"; import handler_doSearchLotOccupancies from "../handlers/lotOccupancies-post/doSearchLotOccupancies.js"; @@ -33,103 +31,128 @@ import handler_doDeleteLotOccupancyTransaction from "../handlers/lotOccupancies- import * as permissionHandlers from "../handlers/permissions.js"; - export const router = Router(); // Search -router.get("/", - handler_search); +router.get("/", handler_search); -router.post("/doSearchLotOccupancies", - handler_doSearchLotOccupancies); +router.post("/doSearchLotOccupancies", handler_doSearchLotOccupancies); // Create -router.get("/new", - permissionHandlers.updateGetHandler, - handler_new); - -router.post("/doGetOccupancyTypeFields", - permissionHandlers.updatePostHandler, - handler_doGetOccupancyTypeFields); +router.get("/new", permissionHandlers.updateGetHandler, handler_new); -router.post("/doCreateLotOccupancy", +router.post( + "/doGetOccupancyTypeFields", permissionHandlers.updatePostHandler, - handler_doCreateLotOccupancy); + handler_doGetOccupancyTypeFields +); + +router.post( + "/doCreateLotOccupancy", + permissionHandlers.updatePostHandler, + handler_doCreateLotOccupancy +); // View -router.get("/:lotOccupancyId", - handler_view); +router.get("/:lotOccupancyId", handler_view); -router.get("/:lotOccupancyId/print", - handler_print); +router.get("/:lotOccupancyId/print", handler_print); // Edit -router.get("/:lotOccupancyId/edit", +router.get( + "/:lotOccupancyId/edit", permissionHandlers.updateGetHandler, - handler_edit); + handler_edit +); -router.post("/doUpdateLotOccupancy", +router.post( + "/doUpdateLotOccupancy", permissionHandlers.updatePostHandler, - handler_doUpdateLotOccupancy); + handler_doUpdateLotOccupancy +); -router.post("/doDeleteLotOccupancy", +router.post( + "/doDeleteLotOccupancy", permissionHandlers.updatePostHandler, - handler_doDeleteLotOccupancy); + handler_doDeleteLotOccupancy +); // Occupants -router.post("/doAddLotOccupancyOccupant", +router.post( + "/doAddLotOccupancyOccupant", permissionHandlers.updatePostHandler, - handler_doAddLotOccupancyOccupant); + handler_doAddLotOccupancyOccupant +); -router.post("/doUpdateLotOccupancyOccupant", +router.post( + "/doUpdateLotOccupancyOccupant", permissionHandlers.updatePostHandler, - handler_doUpdateLotOccupancyOccupant); + handler_doUpdateLotOccupancyOccupant +); -router.post("/doDeleteLotOccupancyOccupant", +router.post( + "/doDeleteLotOccupancyOccupant", permissionHandlers.updatePostHandler, - handler_doDeleteLotOccupancyOccupant); + handler_doDeleteLotOccupancyOccupant +); // Comments -router.post("/doAddLotOccupancyComment", +router.post( + "/doAddLotOccupancyComment", permissionHandlers.updatePostHandler, - handler_doAddLotOccupancyComment); + handler_doAddLotOccupancyComment +); -router.post("/doUpdateLotOccupancyComment", +router.post( + "/doUpdateLotOccupancyComment", permissionHandlers.updatePostHandler, - handler_doUpdateLotOccupancyComment); + handler_doUpdateLotOccupancyComment +); -router.post("/doDeleteLotOccupancyComment", +router.post( + "/doDeleteLotOccupancyComment", permissionHandlers.updatePostHandler, - handler_doDeleteLotOccupancyComment); + handler_doDeleteLotOccupancyComment +); // Fees -router.post("/doGetFees", +router.post( + "/doGetFees", permissionHandlers.updatePostHandler, - handler_doGetFees); + handler_doGetFees +); -router.post("/doAddLotOccupancyFee", +router.post( + "/doAddLotOccupancyFee", permissionHandlers.updatePostHandler, - handler_doAddLotOccupancyFee); - -router.post("/doDeleteLotOccupancyFee", + handler_doAddLotOccupancyFee +); + +router.post( + "/doDeleteLotOccupancyFee", permissionHandlers.updatePostHandler, - handler_doDeleteLotOccupancyFee); + handler_doDeleteLotOccupancyFee +); // Transactions -router.post("/doAddLotOccupancyTransaction", +router.post( + "/doAddLotOccupancyTransaction", permissionHandlers.updatePostHandler, - handler_doAddLotOccupancyTransaction); + handler_doAddLotOccupancyTransaction +); -router.post("/doDeleteLotOccupancyTransaction", +router.post( + "/doDeleteLotOccupancyTransaction", permissionHandlers.updatePostHandler, - handler_doDeleteLotOccupancyTransaction); + handler_doDeleteLotOccupancyTransaction +); -export default router; \ No newline at end of file +export default router; diff --git a/routes/lots.ts b/routes/lots.ts index a60def9b..e42ed8e7 100644 --- a/routes/lots.ts +++ b/routes/lots.ts @@ -19,72 +19,58 @@ import handler_doAddLotComment from "../handlers/lots-post/doAddLotComment.js"; import handler_doUpdateLotComment from "../handlers/lots-post/doUpdateLotComment.js"; import handler_doDeleteLotComment from "../handlers/lots-post/doDeleteLotComment.js"; - export const router = Router(); - /* * Lot Search */ +router.get("/", handler_search); -router.get("/", - handler_search); - -router.post("/doSearchLots", - handler_doSearchLots); - +router.post("/doSearchLots", handler_doSearchLots); /* * Lot View / Edit */ +router.get("/new", permissionHandlers.updateGetHandler, handler_new); -router.get("/new", - permissionHandlers.updateGetHandler, - handler_new); +router.get("/:lotId", handler_view); +router.get("/:lotId/next", handler_next); -router.get("/:lotId", - handler_view); +router.get("/:lotId/previous", handler_previous); +router.get("/:lotId/edit", permissionHandlers.updateGetHandler, handler_edit); -router.get("/:lotId/next", - handler_next); +router.post( + "/doCreateLot", + permissionHandlers.updatePostHandler, + handler_doCreateLot +); +router.post( + "/doUpdateLot", + permissionHandlers.updatePostHandler, + handler_doUpdateLot +); -router.get("/:lotId/previous", - handler_previous); +router.post( + "/doAddLotComment", + permissionHandlers.updatePostHandler, + handler_doAddLotComment +); +router.post( + "/doUpdateLotComment", + permissionHandlers.updatePostHandler, + handler_doUpdateLotComment +); -router.get("/:lotId/edit", - permissionHandlers.updateGetHandler, - handler_edit); - - -router.post("/doCreateLot", - permissionHandlers.updatePostHandler, - handler_doCreateLot); - - -router.post("/doUpdateLot", - permissionHandlers.updatePostHandler, - handler_doUpdateLot); - - -router.post("/doAddLotComment", - permissionHandlers.updatePostHandler, - handler_doAddLotComment); - - -router.post("/doUpdateLotComment", - permissionHandlers.updatePostHandler, - handler_doUpdateLotComment); - - -router.post("/doDeleteLotComment", - permissionHandlers.updatePostHandler, - handler_doDeleteLotComment); - +router.post( + "/doDeleteLotComment", + permissionHandlers.updatePostHandler, + handler_doDeleteLotComment +); export default router; diff --git a/routes/maps.ts b/routes/maps.ts index d4619704..73771cf5 100644 --- a/routes/maps.ts +++ b/routes/maps.ts @@ -1,6 +1,4 @@ -import { - Router -} from "express"; +import { Router } from "express"; import * as permissionHandlers from "../handlers/permissions.js"; @@ -14,41 +12,32 @@ import handler_doCreateMap from "../handlers/maps-post/doCreateMap.js"; import handler_doUpdateMap from "../handlers/maps-post/doUpdateMap.js"; import handler_doDeleteMap from "../handlers/maps-post/doDeleteMap.js"; - export const router = Router(); +router.get("/", handler_search); -router.get("/", - handler_search); +router.get("/new", permissionHandlers.updateGetHandler, handler_new); +router.get("/:mapId", handler_view); -router.get("/new", - permissionHandlers.updateGetHandler, - handler_new); +router.get("/:mapId/edit", permissionHandlers.updateGetHandler, handler_edit); +router.post( + "/doCreateMap", + permissionHandlers.updatePostHandler, + handler_doCreateMap +); -router.get("/:mapId", - handler_view); +router.post( + "/doUpdateMap", + permissionHandlers.updatePostHandler, + handler_doUpdateMap +); +router.post( + "/doDeleteMap", + permissionHandlers.updatePostHandler, + handler_doDeleteMap +); -router.get("/:mapId/edit", - permissionHandlers.updateGetHandler, - handler_edit); - - -router.post("/doCreateMap", - permissionHandlers.updatePostHandler, - handler_doCreateMap); - - -router.post("/doUpdateMap", - permissionHandlers.updatePostHandler, - handler_doUpdateMap); - - -router.post("/doDeleteMap", - permissionHandlers.updatePostHandler, - handler_doDeleteMap); - - -export default router; \ No newline at end of file +export default router; diff --git a/routes/reports.ts b/routes/reports.ts index 6d1b92c2..f2f9f266 100644 --- a/routes/reports.ts +++ b/routes/reports.ts @@ -4,23 +4,17 @@ import handler_reportName from "../handlers/reports-get/reportName.js"; import * as dateTimeFns from "@cityssm/expressjs-server-js/dateTimeFns.js"; - export const router = Router(); - router.get("/", (_request, response) => { + const rightNow = new Date(); - const rightNow = new Date(); - - response.render("report-search", { - headTitle: "Reports", - todayDateString: dateTimeFns.dateToString(rightNow) - }); - + response.render("report-search", { + headTitle: "Reports", + todayDateString: dateTimeFns.dateToString(rightNow) + }); }); - router.all("/:reportName", handler_reportName); - export default router; diff --git a/routes/workOrders.ts b/routes/workOrders.ts index f4a6c098..eafa28f3 100644 --- a/routes/workOrders.ts +++ b/routes/workOrders.ts @@ -1,6 +1,4 @@ -import { - Router -} from "express"; +import { Router } from "express"; import * as permissionHandlers from "../handlers/permissions.js"; import * as configFunctions from "../helpers/functions.config.js"; @@ -10,20 +8,12 @@ import handler_doSearchWorkOrders from "../handlers/workOrders-post/doSearchWork import handler_view from "../handlers/workOrders-get/view.js"; - export const router = Router(); +router.get("/", handler_search); -router.get("/", - handler_search); +router.post("/doSearchWorkOrders", handler_doSearchWorkOrders); -router.post("/doSearchWorkOrders", - handler_doSearchWorkOrders); +router.get("/:workOrderId", handler_view); - -router.get("/:workOrderId", - handler_view); - - - -export default router; \ No newline at end of file +export default router; diff --git a/temp/legacy.importFromCSV.js b/temp/legacy.importFromCSV.js index 894f6eb5..bfda6bb7 100644 --- a/temp/legacy.importFromCSV.js +++ b/temp/legacy.importFromCSV.js @@ -42,13 +42,17 @@ function purgeTables() { database.prepare("delete from LotOccupancies").run(); database.prepare("delete from LotComments").run(); database.prepare("delete from Lots").run(); - database.prepare("delete from sqlite_sequence where name in ('Lots', 'LotComments', 'LotOccupancies', 'LotOccupancyComments', 'WorkOrders', 'WorkOrderComments')").run(); + database + .prepare("delete from sqlite_sequence where name in ('Lots', 'LotComments', 'LotOccupancies', 'LotOccupancyComments', 'WorkOrders', 'WorkOrderComments')") + .run(); database.close(); } function purgeConfigTables() { const database = sqlite(databasePath); database.prepare("delete from Maps").run(); - database.prepare("delete from sqlite_sequence where name in ('Maps')").run(); + database + .prepare("delete from sqlite_sequence where name in ('Maps')") + .run(); database.close(); } function getMapByMapDescription(mapDescription) { @@ -56,29 +60,30 @@ function getMapByMapDescription(mapDescription) { readonly: true }); const map = database - .prepare("select * from Maps" + - " where mapDescription = ?") + .prepare("select * from Maps" + " where mapDescription = ?") .get(mapDescription); database.close(); return map; } function formatDateString(year, month, day) { - return ("0000" + year).slice(-4) + "-" + - ("00" + month).slice(-2) + "-" + - ("00" + day).slice(-2); + return (("0000" + year).slice(-4) + + "-" + + ("00" + month).slice(-2) + + "-" + + ("00" + day).slice(-2)); } const cemeteryToMapName = { "00": "Crematorium", - "GC": "New Greenwood - Columbarium", - "HC": "Holy Sepulchre - Columbarium", - "HS": "Holy Sepulchre", - "MA": "Holy Sepulchre - Mausoleum", - "NG": "New Greenwood", - "NW": "Niche Wall", - "OG": "Old Greenwood", - "PG": "Pine Grove", - "UG": "New Greenwood - Urn Garden", - "WK": "West Korah" + GC: "New Greenwood - Columbarium", + HC: "Holy Sepulchre - Columbarium", + HS: "Holy Sepulchre", + MA: "Holy Sepulchre - Mausoleum", + NG: "New Greenwood", + NW: "Niche Wall", + OG: "Old Greenwood", + PG: "Pine Grove", + UG: "New Greenwood - Urn Garden", + WK: "West Korah" }; const mapCache = new Map(); function getMap(dataRow) { @@ -125,16 +130,19 @@ function getFeeIdByFeeDescription(feeDescription) { return feeCache.get(feeDescription); } function buildLotName(lotNamePieces) { - return lotNamePieces.cemetery + "-" + + return (lotNamePieces.cemetery + + "-" + (lotNamePieces.block === "" ? "" : lotNamePieces.block + "-") + - (lotNamePieces.range1 === "0" && lotNamePieces.range2 === "" ? - "" : - (lotNamePieces.range1 + lotNamePieces.range2) + "-") + - (lotNamePieces.lot1 === "0" && lotNamePieces.lot2 === "" ? - "" : - lotNamePieces.lot1 + lotNamePieces.lot2 + "-") + - lotNamePieces.grave1 + lotNamePieces.grave2 + "-" + - lotNamePieces.interment; + (lotNamePieces.range1 === "0" && lotNamePieces.range2 === "" + ? "" + : lotNamePieces.range1 + lotNamePieces.range2 + "-") + + (lotNamePieces.lot1 === "0" && lotNamePieces.lot2 === "" + ? "" + : lotNamePieces.lot1 + lotNamePieces.lot2 + "-") + + lotNamePieces.grave1 + + lotNamePieces.grave2 + + "-" + + lotNamePieces.interment); } const casketLotType = cacheFunctions.getLotTypesByLotType("Casket Grave"); const columbariumLotType = cacheFunctions.getLotTypesByLotType("Columbarium"); @@ -219,16 +227,21 @@ function importFromMasterCSV() { if (masterRow.CM_PRENEED_ORDER) { preneedOccupancyStartDateString = formatDateString(masterRow.CM_PURCHASE_YR, masterRow.CM_PURCHASE_MON, masterRow.CM_PURCHASE_DAY); let occupancyEndDateString = ""; - if (masterRow.CM_INTERMENT_YR !== "" && masterRow.CM_INTERMENT_YR !== "0") { + if (masterRow.CM_INTERMENT_YR !== "" && + masterRow.CM_INTERMENT_YR !== "0") { occupancyEndDateString = formatDateString(masterRow.CM_INTERMENT_YR, masterRow.CM_INTERMENT_MON, masterRow.CM_INTERMENT_DAY); } - if (preneedOccupancyStartDateString === "0000-00-00" && occupancyEndDateString !== "") { + if (preneedOccupancyStartDateString === "0000-00-00" && + occupancyEndDateString !== "") { preneedOccupancyStartDateString = occupancyEndDateString; } - if (preneedOccupancyStartDateString === "0000-00-00" && masterRow.CM_DEATH_YR !== "" && masterRow.CM_DEATH_YR !== "0") { + if (preneedOccupancyStartDateString === "0000-00-00" && + masterRow.CM_DEATH_YR !== "" && + masterRow.CM_DEATH_YR !== "0") { preneedOccupancyStartDateString = formatDateString(masterRow.CM_DEATH_YR, masterRow.CM_DEATH_MON, masterRow.CM_DEATH_DAY); } - if (preneedOccupancyStartDateString === "" || preneedOccupancyStartDateString === "0000-00-00") { + if (preneedOccupancyStartDateString === "" || + preneedOccupancyStartDateString === "0000-00-00") { preneedOccupancyStartDateString = "0001-01-01"; } preneedLotOccupancyId = addLotOccupancy({ @@ -238,7 +251,9 @@ function importFromMasterCSV() { occupancyEndDateString, occupancyTypeFieldIds: "" }, user); - const occupantPostalCode = ((masterRow.CM_POST1 || "") + " " + (masterRow.CM_POST2 || "")).trim(); + const occupantPostalCode = ((masterRow.CM_POST1 || "") + + " " + + (masterRow.CM_POST2 || "")).trim(); addLotOccupancyOccupant({ lotOccupancyId: preneedLotOccupancyId, lotOccupantTypeId: preneedOwnerLotOccupantType.lotOccupantTypeId, @@ -275,20 +290,27 @@ function importFromMasterCSV() { if (masterRow.CM_DECEASED_NAME) { deceasedOccupancyStartDateString = formatDateString(masterRow.CM_INTERMENT_YR, masterRow.CM_INTERMENT_MON, masterRow.CM_INTERMENT_DAY); const occupancyEndDateString = ""; - if (deceasedOccupancyStartDateString === "0000-00-00" && masterRow.CM_DEATH_YR !== "" && masterRow.CM_DEATH_YR !== "0") { + if (deceasedOccupancyStartDateString === "0000-00-00" && + masterRow.CM_DEATH_YR !== "" && + masterRow.CM_DEATH_YR !== "0") { deceasedOccupancyStartDateString = formatDateString(masterRow.CM_DEATH_YR, masterRow.CM_DEATH_MON, masterRow.CM_DEATH_DAY); } - if (deceasedOccupancyStartDateString === "" || deceasedOccupancyStartDateString === "0000-00-00") { + if (deceasedOccupancyStartDateString === "" || + deceasedOccupancyStartDateString === "0000-00-00") { deceasedOccupancyStartDateString = "0001-01-01"; } deceasedLotOccupancyId = addLotOccupancy({ - occupancyTypeId: lotId ? deceasedOccupancyType.occupancyTypeId : cremationOccupancyType.occupancyTypeId, + occupancyTypeId: lotId + ? deceasedOccupancyType.occupancyTypeId + : cremationOccupancyType.occupancyTypeId, lotId, occupancyStartDateString: deceasedOccupancyStartDateString, occupancyEndDateString, occupancyTypeFieldIds: "" }, user); - const deceasedPostalCode = ((masterRow.CM_POST1 || "") + " " + (masterRow.CM_POST2 || "")).trim(); + const deceasedPostalCode = ((masterRow.CM_POST1 || "") + + " " + + (masterRow.CM_POST2 || "")).trim(); addLotOccupancyOccupant({ lotOccupancyId: deceasedLotOccupancyId, lotOccupantTypeId: deceasedLotOccupantType.lotOccupantTypeId, @@ -305,7 +327,8 @@ function importFromMasterCSV() { addOrUpdateLotOccupancyField({ lotOccupancyId: deceasedLotOccupancyId, occupancyTypeFieldId: deceasedOccupancyType.occupancyTypeFields.find((occupancyTypeField) => { - return occupancyTypeField.occupancyTypeField === "Death Date"; + return (occupancyTypeField.occupancyTypeField === + "Death Date"); }).occupancyTypeFieldId, lotOccupancyFieldValue }, user); @@ -314,7 +337,8 @@ function importFromMasterCSV() { addOrUpdateLotOccupancyField({ lotOccupancyId: deceasedLotOccupancyId, occupancyTypeFieldId: deceasedOccupancyType.occupancyTypeFields.find((occupancyTypeField) => { - return occupancyTypeField.occupancyTypeField === "Death Age"; + return (occupancyTypeField.occupancyTypeField === + "Death Age"); }).occupancyTypeFieldId, lotOccupancyFieldValue: masterRow.CM_AGE }, user); @@ -323,7 +347,8 @@ function importFromMasterCSV() { addOrUpdateLotOccupancyField({ lotOccupancyId: deceasedLotOccupancyId, occupancyTypeFieldId: deceasedOccupancyType.occupancyTypeFields.find((occupancyTypeField) => { - return occupancyTypeField.occupancyTypeField === "Death Age Period"; + return (occupancyTypeField.occupancyTypeField === + "Death Age Period"); }).occupancyTypeFieldId, lotOccupancyFieldValue: masterRow.CM_PERIOD }, user); @@ -332,7 +357,8 @@ function importFromMasterCSV() { addOrUpdateLotOccupancyField({ lotOccupancyId: deceasedLotOccupancyId, occupancyTypeFieldId: deceasedOccupancyType.occupancyTypeFields.find((occupancyTypeField) => { - return occupancyTypeField.occupancyTypeField === "Funeral Home"; + return (occupancyTypeField.occupancyTypeField === + "Funeral Home"); }).occupancyTypeFieldId, lotOccupancyFieldValue: masterRow.CM_FUNERAL_HOME }, user); @@ -342,7 +368,8 @@ function importFromMasterCSV() { addOrUpdateLotOccupancyField({ lotOccupancyId: deceasedLotOccupancyId, occupancyTypeFieldId: deceasedOccupancyType.occupancyTypeFields.find((occupancyTypeField) => { - return occupancyTypeField.occupancyTypeField === "Funeral Date"; + return (occupancyTypeField.occupancyTypeField === + "Funeral Date"); }).occupancyTypeFieldId, lotOccupancyFieldValue }, user); @@ -351,7 +378,8 @@ function importFromMasterCSV() { addOrUpdateLotOccupancyField({ lotOccupancyId: deceasedLotOccupancyId, occupancyTypeFieldId: deceasedOccupancyType.occupancyTypeFields.find((occupancyTypeField) => { - return occupancyTypeField.occupancyTypeField === "Container Type"; + return (occupancyTypeField.occupancyTypeField === + "Container Type"); }).occupancyTypeFieldId, lotOccupancyFieldValue: masterRow.CM_CONTAINER_TYPE }, user); @@ -364,7 +392,8 @@ function importFromMasterCSV() { addOrUpdateLotOccupancyField({ lotOccupancyId: deceasedLotOccupancyId, occupancyTypeFieldId: deceasedOccupancyType.occupancyTypeFields.find((occupancyTypeField) => { - return occupancyTypeField.occupancyTypeField === "Committal Type"; + return (occupancyTypeField.occupancyTypeField === + "Committal Type"); }).occupancyTypeFieldId, lotOccupancyFieldValue: commitalType }, user); @@ -392,7 +421,8 @@ function importFromMasterCSV() { workOrderNumber: masterRow.CM_WORK_ORDER, workOrderTypeId: 1, workOrderDescription: "", - workOrderOpenDateString: deceasedOccupancyStartDateString || preneedOccupancyStartDateString + workOrderOpenDateString: deceasedOccupancyStartDateString || + preneedOccupancyStartDateString }, user); if (lotId) { addWorkOrderLot({ @@ -499,7 +529,8 @@ function importFromPrepaidCSV() { offset: 0 }); if (possibleLotOccupancies.lotOccupancies.length > 0) { - lotOccupancyId = possibleLotOccupancies.lotOccupancies[0].lotOccupancyId; + lotOccupancyId = + possibleLotOccupancies.lotOccupancies[0].lotOccupancyId; } } if (!lotOccupancyId) { @@ -597,7 +628,8 @@ function importFromPrepaidCSV() { taxAmount: prepaidRow.CMPP_GST_NICHE }, user); } - if (prepaidRow.CMPP_FEE_DISINTERMENT !== "0.0" && prepaidRow.CMPP_FEE_DISINTERMENT !== "20202.02") { + if (prepaidRow.CMPP_FEE_DISINTERMENT !== "0.0" && + prepaidRow.CMPP_FEE_DISINTERMENT !== "20202.02") { addLotOccupancyFee({ lotOccupancyId, feeId: getFeeIdByFeeDescription("CMPP_FEE_DISINTERMENT"), @@ -620,8 +652,12 @@ function importFromPrepaidCSV() { Number.parseFloat(prepaidRow.CMPP_GST_CREM) + Number.parseFloat(prepaidRow.CMPP_FEE_NICHE) + Number.parseFloat(prepaidRow.CMPP_GST_NICHE) + - Number.parseFloat(prepaidRow.CMPP_FEE_DISINTERMENT === "20202.02" ? "0" : prepaidRow.CMPP_FEE_DISINTERMENT) + - Number.parseFloat(prepaidRow.CMPP_GST_DISINTERMENT === "20202.02" ? "0" : prepaidRow.CMPP_GST_DISINTERMENT); + Number.parseFloat(prepaidRow.CMPP_FEE_DISINTERMENT === "20202.02" + ? "0" + : prepaidRow.CMPP_FEE_DISINTERMENT) + + Number.parseFloat(prepaidRow.CMPP_GST_DISINTERMENT === "20202.02" + ? "0" + : prepaidRow.CMPP_GST_DISINTERMENT); addLotOccupancyTransaction({ lotOccupancyId, externalReceiptNumber: prepaidRow.CMPP_ORDER_NO, diff --git a/temp/legacy.importFromCSV.ts b/temp/legacy.importFromCSV.ts index c2167897..11e31ab5 100644 --- a/temp/legacy.importFromCSV.ts +++ b/temp/legacy.importFromCSV.ts @@ -5,77 +5,42 @@ import papa from "papaparse"; import sqlite from "better-sqlite3"; -import { - lotOccupancyDB as databasePath -} from "../data/databasePaths.js"; +import { lotOccupancyDB as databasePath } from "../data/databasePaths.js"; import * as cacheFunctions from "../helpers/functions.cache.js"; -import { - addMap -} from "../helpers/lotOccupancyDB/addMap.js"; -import { - getMap as getMapFromDatabase -} from "../helpers/lotOccupancyDB/getMap.js"; +import { addMap } from "../helpers/lotOccupancyDB/addMap.js"; +import { getMap as getMapFromDatabase } from "../helpers/lotOccupancyDB/getMap.js"; -import { - addLot -} from "../helpers/lotOccupancyDB/addLot.js"; -import { - updateLotStatus -} from "../helpers/lotOccupancyDB/updateLot.js"; +import { addLot } from "../helpers/lotOccupancyDB/addLot.js"; +import { updateLotStatus } from "../helpers/lotOccupancyDB/updateLot.js"; -import { - addLotOccupancy -} from "../helpers/lotOccupancyDB/addLotOccupancy.js"; +import { addLotOccupancy } from "../helpers/lotOccupancyDB/addLotOccupancy.js"; -import { - addLotOccupancyOccupant -} from "../helpers/lotOccupancyDB/addLotOccupancyOccupant.js"; +import { addLotOccupancyOccupant } from "../helpers/lotOccupancyDB/addLotOccupancyOccupant.js"; -import { - addLotOccupancyComment -} from "../helpers/lotOccupancyDB/addLotOccupancyComment.js"; +import { addLotOccupancyComment } from "../helpers/lotOccupancyDB/addLotOccupancyComment.js"; -import { - addOrUpdateLotOccupancyField -} from "../helpers/lotOccupancyDB/addOrUpdateLotOccupancyField.js"; +import { addOrUpdateLotOccupancyField } from "../helpers/lotOccupancyDB/addOrUpdateLotOccupancyField.js"; -import { - getLot -} from "../helpers/lotOccupancyDB/getLot.js"; +import { getLot } from "../helpers/lotOccupancyDB/getLot.js"; -import { - getLots -} from "../helpers/lotOccupancyDB/getLots.js"; +import { getLots } from "../helpers/lotOccupancyDB/getLots.js"; -import { - getLotOccupancies -} from "../helpers/lotOccupancyDB/getLotOccupancies.js"; +import { getLotOccupancies } from "../helpers/lotOccupancyDB/getLotOccupancies.js"; -import { - addLotOccupancyFee -} from "../helpers/lotOccupancyDB/addLotOccupancyFee.js"; +import { addLotOccupancyFee } from "../helpers/lotOccupancyDB/addLotOccupancyFee.js"; -import { - addLotOccupancyTransaction -} from "../helpers/lotOccupancyDB/addLotOccupancyTransaction.js"; +import { addLotOccupancyTransaction } from "../helpers/lotOccupancyDB/addLotOccupancyTransaction.js"; -import { - addWorkOrder -} from "../helpers/lotOccupancyDB/addWorkOrder.js"; +import { addWorkOrder } from "../helpers/lotOccupancyDB/addWorkOrder.js"; -import { - addWorkOrderLot -} from "../helpers/lotOccupancyDB/addWorkOrderLot.js"; +import { addWorkOrderLot } from "../helpers/lotOccupancyDB/addWorkOrderLot.js"; -import { - addWorkOrderLotOccupancy -} from "../helpers/lotOccupancyDB/addWorkOrderLotOccupancy.js"; +import { addWorkOrderLotOccupancy } from "../helpers/lotOccupancyDB/addWorkOrderLotOccupancy.js"; import type * as recordTypes from "../types/recordTypes"; - interface MasterRecord { CM_SYSREC: string; CM_CEMETERY: string; @@ -125,7 +90,6 @@ interface MasterRecord { CM_DEPTH: string; } - interface PrepaidRecord { CMPP_SYSREC: string; CMPP_PREPAID_FOR_NAME: string; @@ -170,7 +134,6 @@ interface PrepaidRecord { CMPP_REMARK2: string; } - const user: recordTypes.PartialSession = { user: { userName: "import.unix", @@ -181,7 +144,6 @@ const user: recordTypes.PartialSession = { } }; - function purgeTables() { const database = sqlite(databasePath); database.prepare("delete from WorkOrderComments").run(); @@ -196,28 +158,30 @@ function purgeTables() { database.prepare("delete from LotOccupancies").run(); database.prepare("delete from LotComments").run(); database.prepare("delete from Lots").run(); - database.prepare("delete from sqlite_sequence where name in ('Lots', 'LotComments', 'LotOccupancies', 'LotOccupancyComments', 'WorkOrders', 'WorkOrderComments')").run(); + database + .prepare( + "delete from sqlite_sequence where name in ('Lots', 'LotComments', 'LotOccupancies', 'LotOccupancyComments', 'WorkOrders', 'WorkOrderComments')" + ) + .run(); database.close(); } - function purgeConfigTables() { const database = sqlite(databasePath); database.prepare("delete from Maps").run(); - database.prepare("delete from sqlite_sequence where name in ('Maps')").run(); + database + .prepare("delete from sqlite_sequence where name in ('Maps')") + .run(); database.close(); } - function getMapByMapDescription(mapDescription: string) { - const database = sqlite(databasePath, { readonly: true }); const map: recordTypes.Map = database - .prepare("select * from Maps" + - " where mapDescription = ?") + .prepare("select * from Maps" + " where mapDescription = ?") .get(mapDescription); database.close(); @@ -225,37 +189,33 @@ function getMapByMapDescription(mapDescription: string) { return map; } - function formatDateString(year: string, month: string, day: string) { - - return ("0000" + year).slice(-4) + "-" + - ("00" + month).slice(-2) + "-" + - ("00" + day).slice(-2); + return ( + ("0000" + year).slice(-4) + + "-" + + ("00" + month).slice(-2) + + "-" + + ("00" + day).slice(-2) + ); } - const cemeteryToMapName = { "00": "Crematorium", - "GC": "New Greenwood - Columbarium", - "HC": "Holy Sepulchre - Columbarium", - "HS": "Holy Sepulchre", - "MA": "Holy Sepulchre - Mausoleum", - "NG": "New Greenwood", - "NW": "Niche Wall", - "OG": "Old Greenwood", - "PG": "Pine Grove", - "UG": "New Greenwood - Urn Garden", - "WK": "West Korah" + GC: "New Greenwood - Columbarium", + HC: "Holy Sepulchre - Columbarium", + HS: "Holy Sepulchre", + MA: "Holy Sepulchre - Mausoleum", + NG: "New Greenwood", + NW: "Niche Wall", + OG: "Old Greenwood", + PG: "Pine Grove", + UG: "New Greenwood - Urn Garden", + WK: "West Korah" }; +const mapCache: Map = new Map(); -const mapCache: Map < string, recordTypes.Map > = new Map(); - - -function getMap(dataRow: { - cemetery: string; -}): recordTypes.Map { - +function getMap(dataRow: { cemetery: string }): recordTypes.Map { const mapCacheKey = dataRow.cemetery; /* @@ -272,22 +232,25 @@ function getMap(dataRow: { let map = getMapByMapDescription(mapCacheKey); if (!map) { - console.log("Creating map: " + dataRow.cemetery); - const mapId = addMap({ - mapName: cemeteryToMapName[dataRow.cemetery] || dataRow.cemetery, - mapDescription: dataRow.cemetery, - mapSVG: "", - mapLatitude: "", - mapLongitude: "", - mapAddress1: "", - mapAddress2: "", - mapCity: "Sault Ste. Marie", - mapProvince: "ON", - mapPostalCode: "", - mapPhoneNumber: "" - }, user); + const mapId = addMap( + { + mapName: + cemeteryToMapName[dataRow.cemetery] || dataRow.cemetery, + mapDescription: dataRow.cemetery, + mapSVG: "", + mapLatitude: "", + mapLongitude: "", + mapAddress1: "", + mapAddress2: "", + mapCity: "Sault Ste. Marie", + mapProvince: "ON", + mapPostalCode: "", + mapPhoneNumber: "" + }, + user + ); map = getMapFromDatabase(mapId); } @@ -297,23 +260,22 @@ function getMap(dataRow: { return map; } - -const feeCache: Map < string, number > = new Map(); - +const feeCache: Map = new Map(); function getFeeIdByFeeDescription(feeDescription: string) { - if (feeCache.keys.length === 0) { - const database = sqlite(databasePath, { readonly: true }); const records: { - feeId: number;feeDescription: string - } [] = database - .prepare("select feeId, feeDescription from Fees" + - " where feeDescription like 'CMPP_FEE_%'") + feeId: number; + feeDescription: string; + }[] = database + .prepare( + "select feeId, feeDescription from Fees" + + " where feeDescription like 'CMPP_FEE_%'" + ) .all(); for (const record of records) { @@ -326,7 +288,6 @@ function getFeeIdByFeeDescription(feeDescription: string) { return feeCache.get(feeDescription); } - function buildLotName(lotNamePieces: { cemetery: string; block: string; @@ -338,19 +299,23 @@ function buildLotName(lotNamePieces: { grave2: string; interment: string; }) { - return lotNamePieces.cemetery + "-" + + return ( + lotNamePieces.cemetery + + "-" + (lotNamePieces.block === "" ? "" : lotNamePieces.block + "-") + - (lotNamePieces.range1 === "0" && lotNamePieces.range2 === "" ? - "" : - (lotNamePieces.range1 + lotNamePieces.range2) + "-") + - (lotNamePieces.lot1 === "0" && lotNamePieces.lot2 === "" ? - "" : - lotNamePieces.lot1 + lotNamePieces.lot2 + "-") + - lotNamePieces.grave1 + lotNamePieces.grave2 + "-" + - lotNamePieces.interment; + (lotNamePieces.range1 === "0" && lotNamePieces.range2 === "" + ? "" + : lotNamePieces.range1 + lotNamePieces.range2 + "-") + + (lotNamePieces.lot1 === "0" && lotNamePieces.lot2 === "" + ? "" + : lotNamePieces.lot1 + lotNamePieces.lot2 + "-") + + lotNamePieces.grave1 + + lotNamePieces.grave2 + + "-" + + lotNamePieces.interment + ); } - const casketLotType = cacheFunctions.getLotTypesByLotType("Casket Grave"); const columbariumLotType = cacheFunctions.getLotTypesByLotType("Columbarium"); const crematoriumLotType = cacheFunctions.getLotTypesByLotType("Crematorium"); @@ -358,11 +323,7 @@ const mausoleumLotType = cacheFunctions.getLotTypesByLotType("Mausoleum"); const nicheWallLotType = cacheFunctions.getLotTypesByLotType("Niche Wall"); const urnGardenLotType = cacheFunctions.getLotTypesByLotType("Urn Garden"); - -function getLotType(dataRow: { - cemetery: string; -}) { - +function getLotType(dataRow: { cemetery: string }) { switch (dataRow.cemetery) { case "00": { return crematoriumLotType; @@ -385,27 +346,30 @@ function getLotType(dataRow: { return casketLotType; } - const availableLotStatus = cacheFunctions.getLotStatusByLotStatus("Available"); const reservedLotStatus = cacheFunctions.getLotStatusByLotStatus("Reserved"); const takenLotStatus = cacheFunctions.getLotStatusByLotStatus("Taken"); -const preneedOccupancyType = cacheFunctions.getOccupancyTypeByOccupancyType("Preneed"); -const deceasedOccupancyType = cacheFunctions.getOccupancyTypeByOccupancyType("Interment"); -const cremationOccupancyType = cacheFunctions.getOccupancyTypeByOccupancyType("Cremation"); - -const preneedOwnerLotOccupantType = cacheFunctions.getLotOccupantTypesByLotOccupantType("Preneed Owner"); -const deceasedLotOccupantType = cacheFunctions.getLotOccupantTypesByLotOccupantType("Deceased"); -const arrangerLotOccupantType = cacheFunctions.getLotOccupantTypesByLotOccupantType("Arranger"); +const preneedOccupancyType = + cacheFunctions.getOccupancyTypeByOccupancyType("Preneed"); +const deceasedOccupancyType = + cacheFunctions.getOccupancyTypeByOccupancyType("Interment"); +const cremationOccupancyType = + cacheFunctions.getOccupancyTypeByOccupancyType("Cremation"); +const preneedOwnerLotOccupantType = + cacheFunctions.getLotOccupantTypesByLotOccupantType("Preneed Owner"); +const deceasedLotOccupantType = + cacheFunctions.getLotOccupantTypesByLotOccupantType("Deceased"); +const arrangerLotOccupantType = + cacheFunctions.getLotOccupantTypesByLotOccupantType("Arranger"); function importFromMasterCSV() { - let masterRow: MasterRecord; const rawData = fs.readFileSync("./temp/CMMASTER.csv").toString(); - const cmmaster: papa.ParseResult < MasterRecord > = papa.parse(rawData, { + const cmmaster: papa.ParseResult = papa.parse(rawData, { delimiter: ",", header: true, skipEmptyLines: true @@ -417,7 +381,6 @@ function importFromMasterCSV() { try { for (masterRow of cmmaster.data) { - const map = getMap({ cemetery: masterRow.CM_CEMETERY }); @@ -441,88 +404,129 @@ function importFromMasterCSV() { let lotId: number; if (masterRow.CM_CEMETERY !== "00") { - lotId = addLot({ - lotName: lotName, - lotTypeId: lotType.lotTypeId, - lotStatusId: availableLotStatus.lotStatusId, - mapId: map.mapId, - mapKey: lotName, - lotLatitude: "", - lotLongitude: "" - }, user); + lotId = addLot( + { + lotName: lotName, + lotTypeId: lotType.lotTypeId, + lotStatusId: availableLotStatus.lotStatusId, + mapId: map.mapId, + mapKey: lotName, + lotLatitude: "", + lotLongitude: "" + }, + user + ); } let preneedOccupancyStartDateString: string; let preneedLotOccupancyId: number; if (masterRow.CM_PRENEED_ORDER) { - - preneedOccupancyStartDateString = formatDateString(masterRow.CM_PURCHASE_YR, + preneedOccupancyStartDateString = formatDateString( + masterRow.CM_PURCHASE_YR, masterRow.CM_PURCHASE_MON, - masterRow.CM_PURCHASE_DAY); + masterRow.CM_PURCHASE_DAY + ); let occupancyEndDateString = ""; - if (masterRow.CM_INTERMENT_YR !== "" && masterRow.CM_INTERMENT_YR !== "0") { - occupancyEndDateString = formatDateString(masterRow.CM_INTERMENT_YR, + if ( + masterRow.CM_INTERMENT_YR !== "" && + masterRow.CM_INTERMENT_YR !== "0" + ) { + occupancyEndDateString = formatDateString( + masterRow.CM_INTERMENT_YR, masterRow.CM_INTERMENT_MON, - masterRow.CM_INTERMENT_DAY); + masterRow.CM_INTERMENT_DAY + ); } // if purchase date unavailable - if (preneedOccupancyStartDateString === "0000-00-00" && occupancyEndDateString !== "") { + if ( + preneedOccupancyStartDateString === "0000-00-00" && + occupancyEndDateString !== "" + ) { preneedOccupancyStartDateString = occupancyEndDateString; } // if end date unavailable - if (preneedOccupancyStartDateString === "0000-00-00" && masterRow.CM_DEATH_YR !== "" && masterRow.CM_DEATH_YR !== "0") { - preneedOccupancyStartDateString = formatDateString(masterRow.CM_DEATH_YR, + if ( + preneedOccupancyStartDateString === "0000-00-00" && + masterRow.CM_DEATH_YR !== "" && + masterRow.CM_DEATH_YR !== "0" + ) { + preneedOccupancyStartDateString = formatDateString( + masterRow.CM_DEATH_YR, masterRow.CM_DEATH_MON, - masterRow.CM_DEATH_DAY); + masterRow.CM_DEATH_DAY + ); } - if (preneedOccupancyStartDateString === "" || preneedOccupancyStartDateString === "0000-00-00") { + if ( + preneedOccupancyStartDateString === "" || + preneedOccupancyStartDateString === "0000-00-00" + ) { preneedOccupancyStartDateString = "0001-01-01"; } - preneedLotOccupancyId = addLotOccupancy({ - occupancyTypeId: preneedOccupancyType.occupancyTypeId, - lotId, - occupancyStartDateString: preneedOccupancyStartDateString, - occupancyEndDateString, - occupancyTypeFieldIds: "" - }, user); + preneedLotOccupancyId = addLotOccupancy( + { + occupancyTypeId: preneedOccupancyType.occupancyTypeId, + lotId, + occupancyStartDateString: + preneedOccupancyStartDateString, + occupancyEndDateString, + occupancyTypeFieldIds: "" + }, + user + ); - const occupantPostalCode = ((masterRow.CM_POST1 || "") + " " + (masterRow.CM_POST2 || "")).trim(); + const occupantPostalCode = ( + (masterRow.CM_POST1 || "") + + " " + + (masterRow.CM_POST2 || "") + ).trim(); - addLotOccupancyOccupant({ - lotOccupancyId: preneedLotOccupancyId, - lotOccupantTypeId: preneedOwnerLotOccupantType.lotOccupantTypeId, - occupantName: masterRow.CM_PRENEED_OWNER, - occupantAddress1: masterRow.CM_ADDRESS, - occupantAddress2: "", - occupantCity: masterRow.CM_CITY, - occupantProvince: masterRow.CM_PROV, - occupantPostalCode, - occupantPhoneNumber: "" - }, user); + addLotOccupancyOccupant( + { + lotOccupancyId: preneedLotOccupancyId, + lotOccupantTypeId: + preneedOwnerLotOccupantType.lotOccupantTypeId, + occupantName: masterRow.CM_PRENEED_OWNER, + occupantAddress1: masterRow.CM_ADDRESS, + occupantAddress2: "", + occupantCity: masterRow.CM_CITY, + occupantProvince: masterRow.CM_PROV, + occupantPostalCode, + occupantPhoneNumber: "" + }, + user + ); if (masterRow.CM_REMARK1 !== "") { - addLotOccupancyComment({ - lotOccupancyId: preneedLotOccupancyId, - lotOccupancyCommentDateString: preneedOccupancyStartDateString, - lotOccupancyCommentTimeString: "00:00", - lotOccupancyComment: masterRow.CM_REMARK1 - }, user); + addLotOccupancyComment( + { + lotOccupancyId: preneedLotOccupancyId, + lotOccupancyCommentDateString: + preneedOccupancyStartDateString, + lotOccupancyCommentTimeString: "00:00", + lotOccupancyComment: masterRow.CM_REMARK1 + }, + user + ); } if (masterRow.CM_REMARK2 !== "") { - addLotOccupancyComment({ - lotOccupancyId: preneedLotOccupancyId, - lotOccupancyCommentDateString: preneedOccupancyStartDateString, - lotOccupancyCommentTimeString: "00:00", - lotOccupancyComment: masterRow.CM_REMARK2 - }, user); + addLotOccupancyComment( + { + lotOccupancyId: preneedLotOccupancyId, + lotOccupancyCommentDateString: + preneedOccupancyStartDateString, + lotOccupancyCommentTimeString: "00:00", + lotOccupancyComment: masterRow.CM_REMARK2 + }, + user + ); } if (occupancyEndDateString === "") { @@ -534,204 +538,304 @@ function importFromMasterCSV() { let deceasedLotOccupancyId: number; if (masterRow.CM_DECEASED_NAME) { - - deceasedOccupancyStartDateString = formatDateString(masterRow.CM_INTERMENT_YR, + deceasedOccupancyStartDateString = formatDateString( + masterRow.CM_INTERMENT_YR, masterRow.CM_INTERMENT_MON, - masterRow.CM_INTERMENT_DAY); + masterRow.CM_INTERMENT_DAY + ); const occupancyEndDateString = ""; // if interment date unavailable - if (deceasedOccupancyStartDateString === "0000-00-00" && masterRow.CM_DEATH_YR !== "" && masterRow.CM_DEATH_YR !== "0") { - deceasedOccupancyStartDateString = formatDateString(masterRow.CM_DEATH_YR, + if ( + deceasedOccupancyStartDateString === "0000-00-00" && + masterRow.CM_DEATH_YR !== "" && + masterRow.CM_DEATH_YR !== "0" + ) { + deceasedOccupancyStartDateString = formatDateString( + masterRow.CM_DEATH_YR, masterRow.CM_DEATH_MON, - masterRow.CM_DEATH_DAY); + masterRow.CM_DEATH_DAY + ); } - if (deceasedOccupancyStartDateString === "" || deceasedOccupancyStartDateString === "0000-00-00") { + if ( + deceasedOccupancyStartDateString === "" || + deceasedOccupancyStartDateString === "0000-00-00" + ) { deceasedOccupancyStartDateString = "0001-01-01"; } - deceasedLotOccupancyId = addLotOccupancy({ - occupancyTypeId: lotId ? deceasedOccupancyType.occupancyTypeId : cremationOccupancyType.occupancyTypeId, - lotId, - occupancyStartDateString: deceasedOccupancyStartDateString, - occupancyEndDateString, - occupancyTypeFieldIds: "" - }, user); + deceasedLotOccupancyId = addLotOccupancy( + { + occupancyTypeId: lotId + ? deceasedOccupancyType.occupancyTypeId + : cremationOccupancyType.occupancyTypeId, + lotId, + occupancyStartDateString: + deceasedOccupancyStartDateString, + occupancyEndDateString, + occupancyTypeFieldIds: "" + }, + user + ); - const deceasedPostalCode = ((masterRow.CM_POST1 || "") + " " + (masterRow.CM_POST2 || "")).trim(); + const deceasedPostalCode = ( + (masterRow.CM_POST1 || "") + + " " + + (masterRow.CM_POST2 || "") + ).trim(); - addLotOccupancyOccupant({ - lotOccupancyId: deceasedLotOccupancyId, - lotOccupantTypeId: deceasedLotOccupantType.lotOccupantTypeId, - occupantName: masterRow.CM_DECEASED_NAME, - occupantAddress1: masterRow.CM_ADDRESS, - occupantAddress2: "", - occupantCity: masterRow.CM_CITY, - occupantProvince: masterRow.CM_PROV, - occupantPostalCode: deceasedPostalCode, - occupantPhoneNumber: "" - }, user); + addLotOccupancyOccupant( + { + lotOccupancyId: deceasedLotOccupancyId, + lotOccupantTypeId: + deceasedLotOccupantType.lotOccupantTypeId, + occupantName: masterRow.CM_DECEASED_NAME, + occupantAddress1: masterRow.CM_ADDRESS, + occupantAddress2: "", + occupantCity: masterRow.CM_CITY, + occupantProvince: masterRow.CM_PROV, + occupantPostalCode: deceasedPostalCode, + occupantPhoneNumber: "" + }, + user + ); if (masterRow.CM_DEATH_YR !== "") { - - const lotOccupancyFieldValue = formatDateString(masterRow.CM_DEATH_YR, + const lotOccupancyFieldValue = formatDateString( + masterRow.CM_DEATH_YR, masterRow.CM_DEATH_MON, - masterRow.CM_DEATH_DAY); + masterRow.CM_DEATH_DAY + ); - addOrUpdateLotOccupancyField({ - lotOccupancyId: deceasedLotOccupancyId, - occupancyTypeFieldId: deceasedOccupancyType.occupancyTypeFields.find((occupancyTypeField) => { - return occupancyTypeField.occupancyTypeField === "Death Date" - }).occupancyTypeFieldId, - lotOccupancyFieldValue - }, user); + addOrUpdateLotOccupancyField( + { + lotOccupancyId: deceasedLotOccupancyId, + occupancyTypeFieldId: + deceasedOccupancyType.occupancyTypeFields.find( + (occupancyTypeField) => { + return ( + occupancyTypeField.occupancyTypeField === + "Death Date" + ); + } + ).occupancyTypeFieldId, + lotOccupancyFieldValue + }, + user + ); } if (masterRow.CM_AGE !== "") { - - addOrUpdateLotOccupancyField({ - lotOccupancyId: deceasedLotOccupancyId, - occupancyTypeFieldId: deceasedOccupancyType.occupancyTypeFields.find((occupancyTypeField) => { - return occupancyTypeField.occupancyTypeField === "Death Age" - }).occupancyTypeFieldId, - lotOccupancyFieldValue: masterRow.CM_AGE - }, user); + addOrUpdateLotOccupancyField( + { + lotOccupancyId: deceasedLotOccupancyId, + occupancyTypeFieldId: + deceasedOccupancyType.occupancyTypeFields.find( + (occupancyTypeField) => { + return ( + occupancyTypeField.occupancyTypeField === + "Death Age" + ); + } + ).occupancyTypeFieldId, + lotOccupancyFieldValue: masterRow.CM_AGE + }, + user + ); } if (masterRow.CM_PERIOD !== "") { - - addOrUpdateLotOccupancyField({ - lotOccupancyId: deceasedLotOccupancyId, - occupancyTypeFieldId: deceasedOccupancyType.occupancyTypeFields.find((occupancyTypeField) => { - return occupancyTypeField.occupancyTypeField === "Death Age Period" - }).occupancyTypeFieldId, - lotOccupancyFieldValue: masterRow.CM_PERIOD - }, user); + addOrUpdateLotOccupancyField( + { + lotOccupancyId: deceasedLotOccupancyId, + occupancyTypeFieldId: + deceasedOccupancyType.occupancyTypeFields.find( + (occupancyTypeField) => { + return ( + occupancyTypeField.occupancyTypeField === + "Death Age Period" + ); + } + ).occupancyTypeFieldId, + lotOccupancyFieldValue: masterRow.CM_PERIOD + }, + user + ); } if (masterRow.CM_FUNERAL_HOME !== "") { - - addOrUpdateLotOccupancyField({ - lotOccupancyId: deceasedLotOccupancyId, - occupancyTypeFieldId: deceasedOccupancyType.occupancyTypeFields.find((occupancyTypeField) => { - return occupancyTypeField.occupancyTypeField === "Funeral Home" - }).occupancyTypeFieldId, - lotOccupancyFieldValue: masterRow.CM_FUNERAL_HOME - }, user); + addOrUpdateLotOccupancyField( + { + lotOccupancyId: deceasedLotOccupancyId, + occupancyTypeFieldId: + deceasedOccupancyType.occupancyTypeFields.find( + (occupancyTypeField) => { + return ( + occupancyTypeField.occupancyTypeField === + "Funeral Home" + ); + } + ).occupancyTypeFieldId, + lotOccupancyFieldValue: masterRow.CM_FUNERAL_HOME + }, + user + ); } if (masterRow.CM_FUNERAL_YR !== "") { - - const lotOccupancyFieldValue = formatDateString(masterRow.CM_FUNERAL_YR, + const lotOccupancyFieldValue = formatDateString( + masterRow.CM_FUNERAL_YR, masterRow.CM_FUNERAL_MON, - masterRow.CM_FUNERAL_DAY); + masterRow.CM_FUNERAL_DAY + ); - addOrUpdateLotOccupancyField({ - lotOccupancyId: deceasedLotOccupancyId, - occupancyTypeFieldId: deceasedOccupancyType.occupancyTypeFields.find((occupancyTypeField) => { - return occupancyTypeField.occupancyTypeField === "Funeral Date" - }).occupancyTypeFieldId, - lotOccupancyFieldValue - }, user); + addOrUpdateLotOccupancyField( + { + lotOccupancyId: deceasedLotOccupancyId, + occupancyTypeFieldId: + deceasedOccupancyType.occupancyTypeFields.find( + (occupancyTypeField) => { + return ( + occupancyTypeField.occupancyTypeField === + "Funeral Date" + ); + } + ).occupancyTypeFieldId, + lotOccupancyFieldValue + }, + user + ); } if (masterRow.CM_CONTAINER_TYPE !== "") { - - addOrUpdateLotOccupancyField({ - lotOccupancyId: deceasedLotOccupancyId, - occupancyTypeFieldId: deceasedOccupancyType.occupancyTypeFields.find((occupancyTypeField) => { - return occupancyTypeField.occupancyTypeField === "Container Type" - }).occupancyTypeFieldId, - lotOccupancyFieldValue: masterRow.CM_CONTAINER_TYPE - }, user); + addOrUpdateLotOccupancyField( + { + lotOccupancyId: deceasedLotOccupancyId, + occupancyTypeFieldId: + deceasedOccupancyType.occupancyTypeFields.find( + (occupancyTypeField) => { + return ( + occupancyTypeField.occupancyTypeField === + "Container Type" + ); + } + ).occupancyTypeFieldId, + lotOccupancyFieldValue: masterRow.CM_CONTAINER_TYPE + }, + user + ); } if (masterRow.CM_COMMITTAL_TYPE !== "") { - let commitalType = masterRow.CM_COMMITTAL_TYPE; if (commitalType === "GS") { commitalType = "Graveside"; } - addOrUpdateLotOccupancyField({ - lotOccupancyId: deceasedLotOccupancyId, - occupancyTypeFieldId: deceasedOccupancyType.occupancyTypeFields.find((occupancyTypeField) => { - return occupancyTypeField.occupancyTypeField === "Committal Type" - }).occupancyTypeFieldId, - lotOccupancyFieldValue: commitalType - }, user); + addOrUpdateLotOccupancyField( + { + lotOccupancyId: deceasedLotOccupancyId, + occupancyTypeFieldId: + deceasedOccupancyType.occupancyTypeFields.find( + (occupancyTypeField) => { + return ( + occupancyTypeField.occupancyTypeField === + "Committal Type" + ); + } + ).occupancyTypeFieldId, + lotOccupancyFieldValue: commitalType + }, + user + ); } if (masterRow.CM_REMARK1 !== "") { - addLotOccupancyComment({ - lotOccupancyId: deceasedLotOccupancyId, - lotOccupancyCommentDateString: deceasedOccupancyStartDateString, - lotOccupancyCommentTimeString: "00:00", - lotOccupancyComment: masterRow.CM_REMARK1 - }, user); + addLotOccupancyComment( + { + lotOccupancyId: deceasedLotOccupancyId, + lotOccupancyCommentDateString: + deceasedOccupancyStartDateString, + lotOccupancyCommentTimeString: "00:00", + lotOccupancyComment: masterRow.CM_REMARK1 + }, + user + ); } if (masterRow.CM_REMARK2 !== "") { - addLotOccupancyComment({ - lotOccupancyId: deceasedLotOccupancyId, - lotOccupancyCommentDateString: deceasedOccupancyStartDateString, - lotOccupancyCommentTimeString: "00:00", - lotOccupancyComment: masterRow.CM_REMARK2 - }, user); + addLotOccupancyComment( + { + lotOccupancyId: deceasedLotOccupancyId, + lotOccupancyCommentDateString: + deceasedOccupancyStartDateString, + lotOccupancyCommentTimeString: "00:00", + lotOccupancyComment: masterRow.CM_REMARK2 + }, + user + ); } updateLotStatus(lotId, takenLotStatus.lotStatusId, user); } if (masterRow.CM_WORK_ORDER) { - - const workOrderId = addWorkOrder({ - workOrderNumber: masterRow.CM_WORK_ORDER, - workOrderTypeId: 1, - workOrderDescription: "", - workOrderOpenDateString: deceasedOccupancyStartDateString || preneedOccupancyStartDateString - }, user); + const workOrderId = addWorkOrder( + { + workOrderNumber: masterRow.CM_WORK_ORDER, + workOrderTypeId: 1, + workOrderDescription: "", + workOrderOpenDateString: + deceasedOccupancyStartDateString || + preneedOccupancyStartDateString + }, + user + ); if (lotId) { - addWorkOrderLot({ - workOrderId, - lotId - }, user); + addWorkOrderLot( + { + workOrderId, + lotId + }, + user + ); } if (deceasedLotOccupancyId) { - - addWorkOrderLotOccupancy({ - workOrderId, - lotOccupancyId: deceasedLotOccupancyId - }, user); - + addWorkOrderLotOccupancy( + { + workOrderId, + lotOccupancyId: deceasedLotOccupancyId + }, + user + ); } else if (preneedLotOccupancyId) { - - addWorkOrderLotOccupancy({ - workOrderId, - lotOccupancyId: preneedLotOccupancyId - }, user); + addWorkOrderLotOccupancy( + { + workOrderId, + lotOccupancyId: preneedLotOccupancyId + }, + user + ); } } } } catch (error) { - console.error(error) + console.error(error); console.log(masterRow); } } - function importFromPrepaidCSV() { - let prepaidRow: PrepaidRecord; const rawData = fs.readFileSync("./temp/CMPRPAID.csv").toString(); - const cmprpaid: papa.ParseResult < PrepaidRecord > = papa.parse(rawData, { + const cmprpaid: papa.ParseResult = papa.parse(rawData, { delimiter: ",", header: true, skipEmptyLines: true @@ -743,7 +847,6 @@ function importFromPrepaidCSV() { try { for (prepaidRow of cmprpaid.data) { - if (!prepaidRow.CMPP_PREPAID_FOR_NAME) { continue; } @@ -751,13 +854,12 @@ function importFromPrepaidCSV() { let cemetery = prepaidRow.CMPP_CEMETERY; if (cemetery && cemetery === ".m") { - cemetery = "HC" + cemetery = "HC"; } let lot: recordTypes.Lot; if (cemetery) { - const map = getMap({ cemetery }); @@ -774,31 +876,36 @@ function importFromPrepaidCSV() { interment: prepaidRow.CMPP_INTERMENT }); - const possibleLots = getLots({ - mapId: map.mapId, - lotName - }, { - limit: -1, - offset: 0 - }); + const possibleLots = getLots( + { + mapId: map.mapId, + lotName + }, + { + limit: -1, + offset: 0 + } + ); if (possibleLots.lots.length > 0) { lot = possibleLots.lots[0]; } else { - const lotType = getLotType({ cemetery }); - const lotId = addLot({ - lotName: lotName, - lotTypeId: lotType.lotTypeId, - lotStatusId: reservedLotStatus.lotStatusId, - mapId: map.mapId, - mapKey: lotName, - lotLatitude: "", - lotLongitude: "" - }, user); + const lotId = addLot( + { + lotName: lotName, + lotTypeId: lotType.lotTypeId, + lotStatusId: reservedLotStatus.lotStatusId, + mapId: map.mapId, + mapKey: lotName, + lotLatitude: "", + lotLongitude: "" + }, + user + ); lot = getLot(lotId); } @@ -808,142 +915,189 @@ function importFromPrepaidCSV() { updateLotStatus(lot.lotId, reservedLotStatus.lotStatusId, user); } - const occupancyStartDateString = formatDateString(prepaidRow.CMPP_PURCH_YR, + const occupancyStartDateString = formatDateString( + prepaidRow.CMPP_PURCH_YR, prepaidRow.CMPP_PURCH_MON, - prepaidRow.CMPP_PURCH_DAY); + prepaidRow.CMPP_PURCH_DAY + ); let lotOccupancyId: number; if (lot) { - const possibleLotOccupancies = getLotOccupancies({ - lotId: lot.lotId, - occupancyTypeId: preneedOccupancyType.occupancyTypeId, - occupantName: prepaidRow.CMPP_PREPAID_FOR_NAME, - occupancyStartDateString - }, { - includeOccupants: false, - limit: -1, - offset: 0 - }); + const possibleLotOccupancies = getLotOccupancies( + { + lotId: lot.lotId, + occupancyTypeId: preneedOccupancyType.occupancyTypeId, + occupantName: prepaidRow.CMPP_PREPAID_FOR_NAME, + occupancyStartDateString + }, + { + includeOccupants: false, + limit: -1, + offset: 0 + } + ); if (possibleLotOccupancies.lotOccupancies.length > 0) { - lotOccupancyId = possibleLotOccupancies.lotOccupancies[0].lotOccupancyId; + lotOccupancyId = + possibleLotOccupancies.lotOccupancies[0].lotOccupancyId; } } if (!lotOccupancyId) { - lotOccupancyId = addLotOccupancy({ - lotId: lot ? lot.lotId : "", - occupancyTypeId: preneedOccupancyType.occupancyTypeId, - occupancyStartDateString, - occupancyEndDateString: "" - }, user); + lotOccupancyId = addLotOccupancy( + { + lotId: lot ? lot.lotId : "", + occupancyTypeId: preneedOccupancyType.occupancyTypeId, + occupancyStartDateString, + occupancyEndDateString: "" + }, + user + ); } - addLotOccupancyOccupant({ - lotOccupancyId, - lotOccupantTypeId: preneedOwnerLotOccupantType.lotOccupantTypeId, - occupantName: prepaidRow.CMPP_PREPAID_FOR_NAME, - occupantAddress1: prepaidRow.CMPP_ADDRESS, - occupantAddress2: "", - occupantCity: prepaidRow.CMPP_CITY, - occupantProvince: prepaidRow.CMPP_PROV.slice(0, 2), - occupantPostalCode: prepaidRow.CMPP_POSTAL1 + " " + prepaidRow.CMPP_POSTAL2, - occupantPhoneNumber: "" - }, user); + addLotOccupancyOccupant( + { + lotOccupancyId, + lotOccupantTypeId: + preneedOwnerLotOccupantType.lotOccupantTypeId, + occupantName: prepaidRow.CMPP_PREPAID_FOR_NAME, + occupantAddress1: prepaidRow.CMPP_ADDRESS, + occupantAddress2: "", + occupantCity: prepaidRow.CMPP_CITY, + occupantProvince: prepaidRow.CMPP_PROV.slice(0, 2), + occupantPostalCode: + prepaidRow.CMPP_POSTAL1 + " " + prepaidRow.CMPP_POSTAL2, + occupantPhoneNumber: "" + }, + user + ); if (prepaidRow.CMPP_ARRANGED_BY_NAME) { - addLotOccupancyOccupant({ - lotOccupancyId, - lotOccupantTypeId: arrangerLotOccupantType.lotOccupantTypeId, - occupantName: prepaidRow.CMPP_ARRANGED_BY_NAME, - occupantAddress1: "", - occupantAddress2: "", - occupantCity: "", - occupantProvince: "", - occupantPostalCode: "", - occupantPhoneNumber: "" - }, user); + addLotOccupancyOccupant( + { + lotOccupancyId, + lotOccupantTypeId: + arrangerLotOccupantType.lotOccupantTypeId, + occupantName: prepaidRow.CMPP_ARRANGED_BY_NAME, + occupantAddress1: "", + occupantAddress2: "", + occupantCity: "", + occupantProvince: "", + occupantPostalCode: "", + occupantPhoneNumber: "" + }, + user + ); } if (prepaidRow.CMPP_FEE_GRAV_SD !== "0.0") { - addLotOccupancyFee({ - lotOccupancyId, - feeId: getFeeIdByFeeDescription("CMPP_FEE_GRAV_SD"), - quantity: 1, - feeAmount: prepaidRow.CMPP_FEE_GRAV_SD, - taxAmount: prepaidRow.CMPP_GST_GRAV_SD - }, user); + addLotOccupancyFee( + { + lotOccupancyId, + feeId: getFeeIdByFeeDescription("CMPP_FEE_GRAV_SD"), + quantity: 1, + feeAmount: prepaidRow.CMPP_FEE_GRAV_SD, + taxAmount: prepaidRow.CMPP_GST_GRAV_SD + }, + user + ); } if (prepaidRow.CMPP_FEE_GRAV_DD !== "0.0") { - addLotOccupancyFee({ - lotOccupancyId, - feeId: getFeeIdByFeeDescription("CMPP_FEE_GRAV_DD"), - quantity: 1, - feeAmount: prepaidRow.CMPP_FEE_GRAV_DD, - taxAmount: prepaidRow.CMPP_GST_GRAV_DD - }, user); + addLotOccupancyFee( + { + lotOccupancyId, + feeId: getFeeIdByFeeDescription("CMPP_FEE_GRAV_DD"), + quantity: 1, + feeAmount: prepaidRow.CMPP_FEE_GRAV_DD, + taxAmount: prepaidRow.CMPP_GST_GRAV_DD + }, + user + ); } if (prepaidRow.CMPP_FEE_CHAP_SD !== "0.0") { - addLotOccupancyFee({ - lotOccupancyId, - feeId: getFeeIdByFeeDescription("CMPP_FEE_CHAP_SD"), - quantity: 1, - feeAmount: prepaidRow.CMPP_FEE_CHAP_SD, - taxAmount: prepaidRow.CMPP_GST_CHAP_SD - }, user); + addLotOccupancyFee( + { + lotOccupancyId, + feeId: getFeeIdByFeeDescription("CMPP_FEE_CHAP_SD"), + quantity: 1, + feeAmount: prepaidRow.CMPP_FEE_CHAP_SD, + taxAmount: prepaidRow.CMPP_GST_CHAP_SD + }, + user + ); } if (prepaidRow.CMPP_FEE_CHAP_DD !== "0.0") { - addLotOccupancyFee({ - lotOccupancyId, - feeId: getFeeIdByFeeDescription("CMPP_FEE_CHAP_DD"), - quantity: 1, - feeAmount: prepaidRow.CMPP_FEE_CHAP_DD, - taxAmount: prepaidRow.CMPP_GST_CHAP_DD - }, user); + addLotOccupancyFee( + { + lotOccupancyId, + feeId: getFeeIdByFeeDescription("CMPP_FEE_CHAP_DD"), + quantity: 1, + feeAmount: prepaidRow.CMPP_FEE_CHAP_DD, + taxAmount: prepaidRow.CMPP_GST_CHAP_DD + }, + user + ); } if (prepaidRow.CMPP_FEE_ENTOMBMENT !== "0.0") { - addLotOccupancyFee({ - lotOccupancyId, - feeId: getFeeIdByFeeDescription("CMPP_FEE_ENTOMBMENT"), - quantity: 1, - feeAmount: prepaidRow.CMPP_FEE_ENTOMBMENT, - taxAmount: prepaidRow.CMPP_GST_ENTOMBMENT - }, user); + addLotOccupancyFee( + { + lotOccupancyId, + feeId: getFeeIdByFeeDescription("CMPP_FEE_ENTOMBMENT"), + quantity: 1, + feeAmount: prepaidRow.CMPP_FEE_ENTOMBMENT, + taxAmount: prepaidRow.CMPP_GST_ENTOMBMENT + }, + user + ); } if (prepaidRow.CMPP_FEE_CREM !== "0.0") { - addLotOccupancyFee({ - lotOccupancyId, - feeId: getFeeIdByFeeDescription("CMPP_FEE_CREM"), - quantity: 1, - feeAmount: prepaidRow.CMPP_FEE_CREM, - taxAmount: prepaidRow.CMPP_GST_CREM - }, user); + addLotOccupancyFee( + { + lotOccupancyId, + feeId: getFeeIdByFeeDescription("CMPP_FEE_CREM"), + quantity: 1, + feeAmount: prepaidRow.CMPP_FEE_CREM, + taxAmount: prepaidRow.CMPP_GST_CREM + }, + user + ); } if (prepaidRow.CMPP_FEE_NICHE !== "0.0") { - addLotOccupancyFee({ - lotOccupancyId, - feeId: getFeeIdByFeeDescription("CMPP_FEE_NICHE"), - quantity: 1, - feeAmount: prepaidRow.CMPP_FEE_NICHE, - taxAmount: prepaidRow.CMPP_GST_NICHE - }, user); + addLotOccupancyFee( + { + lotOccupancyId, + feeId: getFeeIdByFeeDescription("CMPP_FEE_NICHE"), + quantity: 1, + feeAmount: prepaidRow.CMPP_FEE_NICHE, + taxAmount: prepaidRow.CMPP_GST_NICHE + }, + user + ); } - if (prepaidRow.CMPP_FEE_DISINTERMENT !== "0.0" && prepaidRow.CMPP_FEE_DISINTERMENT !== "20202.02") { - addLotOccupancyFee({ - lotOccupancyId, - feeId: getFeeIdByFeeDescription("CMPP_FEE_DISINTERMENT"), - quantity: 1, - feeAmount: prepaidRow.CMPP_FEE_DISINTERMENT, - taxAmount: prepaidRow.CMPP_GST_DISINTERMENT - }, user); + if ( + prepaidRow.CMPP_FEE_DISINTERMENT !== "0.0" && + prepaidRow.CMPP_FEE_DISINTERMENT !== "20202.02" + ) { + addLotOccupancyFee( + { + lotOccupancyId, + feeId: getFeeIdByFeeDescription( + "CMPP_FEE_DISINTERMENT" + ), + quantity: 1, + feeAmount: prepaidRow.CMPP_FEE_DISINTERMENT, + taxAmount: prepaidRow.CMPP_GST_DISINTERMENT + }, + user + ); } const transactionAmount = @@ -961,35 +1115,50 @@ function importFromPrepaidCSV() { Number.parseFloat(prepaidRow.CMPP_GST_CREM) + Number.parseFloat(prepaidRow.CMPP_FEE_NICHE) + Number.parseFloat(prepaidRow.CMPP_GST_NICHE) + - Number.parseFloat(prepaidRow.CMPP_FEE_DISINTERMENT === "20202.02" ? "0" : prepaidRow.CMPP_FEE_DISINTERMENT) + - Number.parseFloat(prepaidRow.CMPP_GST_DISINTERMENT === "20202.02" ? "0" : prepaidRow.CMPP_GST_DISINTERMENT); + Number.parseFloat( + prepaidRow.CMPP_FEE_DISINTERMENT === "20202.02" + ? "0" + : prepaidRow.CMPP_FEE_DISINTERMENT + ) + + Number.parseFloat( + prepaidRow.CMPP_GST_DISINTERMENT === "20202.02" + ? "0" + : prepaidRow.CMPP_GST_DISINTERMENT + ); - addLotOccupancyTransaction({ - lotOccupancyId, - externalReceiptNumber: prepaidRow.CMPP_ORDER_NO, - transactionAmount, - transactionDateString: occupancyStartDateString, - transactionNote: "" - }, user); + addLotOccupancyTransaction( + { + lotOccupancyId, + externalReceiptNumber: prepaidRow.CMPP_ORDER_NO, + transactionAmount, + transactionDateString: occupancyStartDateString, + transactionNote: "" + }, + user + ); if (prepaidRow.CMPP_REMARK1) { - addLotOccupancyComment({ - lotOccupancyId, - lotOccupancyCommentDateString: occupancyStartDateString, - lotOccupancyComment: prepaidRow.CMPP_REMARK1 - }, user); + addLotOccupancyComment( + { + lotOccupancyId, + lotOccupancyCommentDateString: occupancyStartDateString, + lotOccupancyComment: prepaidRow.CMPP_REMARK1 + }, + user + ); } if (prepaidRow.CMPP_REMARK2) { - addLotOccupancyComment({ - lotOccupancyId, - lotOccupancyCommentDateString: occupancyStartDateString, - lotOccupancyComment: prepaidRow.CMPP_REMARK2 - }, user); + addLotOccupancyComment( + { + lotOccupancyId, + lotOccupancyCommentDateString: occupancyStartDateString, + lotOccupancyComment: prepaidRow.CMPP_REMARK2 + }, + user + ); } } - - } catch (error) { console.error(error); console.log(prepaidRow); @@ -999,4 +1168,4 @@ function importFromPrepaidCSV() { purgeTables(); // purgeConfigTables(); importFromMasterCSV(); -importFromPrepaidCSV(); \ No newline at end of file +importFromPrepaidCSV(); diff --git a/test/1_serverCypress.js b/test/1_serverCypress.js index 8efe692b..5160a48e 100644 --- a/test/1_serverCypress.js +++ b/test/1_serverCypress.js @@ -25,7 +25,8 @@ describe("lot-occupancy-system", () => { describe("Cypress tests", () => { it("should run Cypress tests", (done) => { let cypressCommand = "cypress run --config-file cypress.config.ts --browser chrome"; - if (process.env.CYPRESS_RECORD_KEY && process.env.CYPRESS_RECORD_KEY !== "") { + if (process.env.CYPRESS_RECORD_KEY && + process.env.CYPRESS_RECORD_KEY !== "") { cypressCommand += " --record"; } const childProcess = exec(cypressCommand); diff --git a/test/1_serverCypress.ts b/test/1_serverCypress.ts index b9f3aa8f..6c7ea1eb 100644 --- a/test/1_serverCypress.ts +++ b/test/1_serverCypress.ts @@ -2,28 +2,19 @@ import * as assert from "assert"; -import { - portNumber -} from "./_globals.js"; +import { portNumber } from "./_globals.js"; -import { - exec -} from "child_process"; +import { exec } from "child_process"; import * as http from "http"; -import { - app -} from "../app.js"; - +import { app } from "../app.js"; describe("lot-occupancy-system", () => { - const httpServer = http.createServer(app); let serverStarted = false; before(() => { - httpServer.listen(portNumber); httpServer.on("listening", () => { @@ -44,12 +35,14 @@ describe("lot-occupancy-system", () => { }); describe("Cypress tests", () => { - it("should run Cypress tests", (done) => { + let cypressCommand = + "cypress run --config-file cypress.config.ts --browser chrome"; - let cypressCommand = "cypress run --config-file cypress.config.ts --browser chrome"; - - if (process.env.CYPRESS_RECORD_KEY && process.env.CYPRESS_RECORD_KEY !== "") { + if ( + process.env.CYPRESS_RECORD_KEY && + process.env.CYPRESS_RECORD_KEY !== "" + ) { cypressCommand += " --record"; } @@ -69,4 +62,4 @@ describe("lot-occupancy-system", () => { }); }).timeout(30 * 60 * 60 * 1000); }); -}); \ No newline at end of file +}); diff --git a/test/_globals.ts b/test/_globals.ts index 78ec2469..2e05c828 100644 --- a/test/_globals.ts +++ b/test/_globals.ts @@ -1,20 +1,13 @@ -import type { - Request -} from "express"; - -import type { - Session -} from "express-session"; +import type { Request } from "express"; +import type { Session } from "express-session"; export const testView = "*testView"; export const testUpdate = "*testUpdate"; export const testAdmin = "*testAdmin"; - export const portNumber = 7000; - export const fakeViewOnlySession: Session = { id: "", cookie: undefined, @@ -27,7 +20,6 @@ export const fakeViewOnlySession: Session = { user: undefined }; - export const fakeAdminSession: Session = { id: "", cookie: undefined, @@ -40,7 +32,6 @@ export const fakeAdminSession: Session = { user: undefined }; - export const fakeRequest: Request = { // eslint-disable-next-line @typescript-eslint/no-empty-function async *[Symbol.asyncIterator]() {}, @@ -132,14 +123,10 @@ export const fakeRequest: Request = { xhr: undefined }; +export const fakeViewOnlyRequest = Object.assign({}, fakeRequest, { + session: fakeViewOnlySession +}); -export const fakeViewOnlyRequest = - Object.assign({}, fakeRequest, { - session: fakeViewOnlySession - }); - - -export const fakeAdminRequest = - Object.assign({}, fakeRequest, { - session: fakeAdminSession - }); \ No newline at end of file +export const fakeAdminRequest = Object.assign({}, fakeRequest, { + session: fakeAdminSession +}); diff --git a/test/version.ts b/test/version.ts index 8728be3c..9466e508 100644 --- a/test/version.ts +++ b/test/version.ts @@ -2,15 +2,11 @@ import * as assert from "assert"; import fs from "fs"; -import { - version -} from "../version.js"; - +import { version } from "../version.js"; describe("version", () => { - it("has a version that matches the package.json", () => { const packageJSON = JSON.parse(fs.readFileSync("package.json", "utf8")); assert.strictEqual(version, packageJSON.version); }); -}); \ No newline at end of file +}); diff --git a/types/configTypes.ts b/types/configTypes.ts index 429f87a9..8c0dae4c 100644 --- a/types/configTypes.ts +++ b/types/configTypes.ts @@ -1,71 +1,69 @@ export interface Config { - application ? : ConfigApplication; - session ? : ConfigSession; - reverseProxy ? : { + application?: ConfigApplication; + session?: ConfigSession; + reverseProxy?: { disableCompression: boolean; disableEtag: boolean; urlPrefix: string; }; - activeDirectory ? : ConfigActiveDirectory; - users ? : { - testing ? : string[]; - canLogin ? : string[]; - canUpdate ? : string[]; - isAdmin ? : string[]; + activeDirectory?: ConfigActiveDirectory; + users?: { + testing?: string[]; + canLogin?: string[]; + canUpdate?: string[]; + isAdmin?: string[]; }; - aliases ? : { - lot ? : string; - lots ? : string; - map ? : string; - maps ? : string; - occupancy ? : string; - occupancies ? : string; - occupant ? : string; - occupants ? : string; - externalReceiptNumber ? : string; + aliases?: { + lot?: string; + lots?: string; + map?: string; + maps?: string; + occupancy?: string; + occupancies?: string; + occupant?: string; + occupants?: string; + externalReceiptNumber?: string; }; - settings ? : { - fees ? : { - taxPercentageDefault ? : number; + settings?: { + fees?: { + taxPercentageDefault?: number; }; - map ? : { - mapCityDefault ? : string; - mapProvinceDefault ? : string; + map?: { + mapCityDefault?: string; + mapProvinceDefault?: string; }; - lot ? : { - lotNamePattern ? : RegExp; - lotNameSortNameFunction ? : (lotName: string) => string; + lot?: { + lotNamePattern?: RegExp; + lotNameSortNameFunction?: (lotName: string) => string; }; - lotOccupancy ? : { - lotIdIsRequired ? : boolean; - occupancyEndDateIsRequired ? : boolean; - occupantCityDefault ? : string; - occupantProvinceDefault ? : string; + lotOccupancy?: { + lotIdIsRequired?: boolean; + occupancyEndDateIsRequired?: boolean; + occupantCityDefault?: string; + occupantProvinceDefault?: string; }; }; } interface ConfigApplication { - applicationName ? : string; - backgroundURL ? : string; - logoURL ? : string; - httpPort ? : number; - userDomain ? : string; - useTestDatabases ? : boolean; + applicationName?: string; + backgroundURL?: string; + logoURL?: string; + httpPort?: number; + userDomain?: string; + useTestDatabases?: boolean; } - interface ConfigSession { - cookieName ? : string; - secret ? : string; - maxAgeMillis ? : number; - doKeepAlive ? : boolean; + cookieName?: string; + secret?: string; + maxAgeMillis?: number; + doKeepAlive?: boolean; } - export interface ConfigActiveDirectory { url: string; baseDN: string; username: string; password: string; -} \ No newline at end of file +} diff --git a/types/globalTypes.js b/types/globalTypes.js index c8ad2e54..cb0ff5c3 100644 --- a/types/globalTypes.js +++ b/types/globalTypes.js @@ -1,2 +1 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); +export {}; diff --git a/types/globalTypes.ts b/types/globalTypes.ts index 6b2becc9..bf00e63c 100644 --- a/types/globalTypes.ts +++ b/types/globalTypes.ts @@ -1,5 +1,9 @@ export interface LOS { - highlightMap: (mapContainerElement: HTMLElement, mapKey: string, contextualClass: "success" | "danger") => void; + highlightMap: ( + mapContainerElement: HTMLElement, + mapKey: string, + contextualClass: "success" | "danger" + ) => void; initializeUnlockFieldButtons: (containerElement: HTMLElement) => void; populateAliases: (containerElement: HTMLElement) => void; } diff --git a/types/recordTypes.js b/types/recordTypes.js index c8ad2e54..cb0ff5c3 100644 --- a/types/recordTypes.js +++ b/types/recordTypes.js @@ -1,2 +1 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); +export {}; diff --git a/types/recordTypes.ts b/types/recordTypes.ts index 0529a225..6d4bfa22 100644 --- a/types/recordTypes.ts +++ b/types/recordTypes.ts @@ -1,327 +1,303 @@ export interface Record { - recordCreate_userName ? : string; - recordCreate_timeMillis ? : number; - recordCreate_dateString ? : string; + recordCreate_userName?: string; + recordCreate_timeMillis?: number; + recordCreate_dateString?: string; - recordUpdate_userName ? : string; - recordUpdate_timeMillis ? : number; - recordUpdate_dateString ? : string; - recordUpdate_timeString ? : string; + recordUpdate_userName?: string; + recordUpdate_timeMillis?: number; + recordUpdate_dateString?: string; + recordUpdate_timeString?: string; - recordDelete_userName ? : string; - recordDelete_timeMillis ? : number; - recordDelete_dateString ? : string; + recordDelete_userName?: string; + recordDelete_timeMillis?: number; + recordDelete_dateString?: string; } - /* * LOT OCCUPANCY DB TYPES */ - export interface Map extends Record { - mapId ? : number; - mapName ? : string; - mapDescription ? : string; + mapId?: number; + mapName?: string; + mapDescription?: string; - mapLatitude ? : number; - mapLongitude ? : number; - mapSVG ? : string; + mapLatitude?: number; + mapLongitude?: number; + mapSVG?: string; - mapAddress1 ? : string; - mapAddress2 ? : string; - mapCity ? : string; - mapProvince ? : string; - mapPostalCode ? : string; - mapPhoneNumber ? : string; + mapAddress1?: string; + mapAddress2?: string; + mapCity?: string; + mapProvince?: string; + mapPostalCode?: string; + mapPhoneNumber?: string; - lotCount ? : number; + lotCount?: number; } - export interface LotType extends Record { - lotTypeId ? : number; - lotType ? : string; - orderNumber ? : number; - lotTypeFields ? : LotTypeField[]; + lotTypeId?: number; + lotType?: string; + orderNumber?: number; + lotTypeFields?: LotTypeField[]; } - export interface LotTypeField extends Record { - lotTypeFieldId ? : number; - lotTypeField ? : string; + lotTypeFieldId?: number; + lotTypeField?: string; - lotTypeId ? : number; + lotTypeId?: number; lotType: LotType; - lotTypeFieldValues ? : string; - isRequired ? : boolean; - pattern ? : string; - minimumLength ? : number; - maximumLength ? : number; + lotTypeFieldValues?: string; + isRequired?: boolean; + pattern?: string; + minimumLength?: number; + maximumLength?: number; - orderNumber ? : number; + orderNumber?: number; } - export interface LotStatus extends Record { - lotStatusId ? : number; - lotStatus ? : string; - orderNumber ? : number; + lotStatusId?: number; + lotStatus?: string; + orderNumber?: number; } - export interface Lot extends Record { - lotId ? : number; - lotName ? : string; + lotId?: number; + lotName?: string; - lotTypeId ? : number; - lotType ? : LotType | string; + lotTypeId?: number; + lotType?: LotType | string; - mapId ? : number; - mapName ? : string; - map ? : Map; - mapSVG ? : string; - mapKey ? : string; + mapId?: number; + mapName?: string; + map?: Map; + mapSVG?: string; + mapKey?: string; - lotLatitude ? : number; - lotLongitude ? : number; + lotLatitude?: number; + lotLongitude?: number; - lotStatusId ? : number; - lotStatus ? : LotStatus | string; + lotStatusId?: number; + lotStatus?: LotStatus | string; - lotOccupancyCount ? : number; - lotOccupancies ? : LotOccupancy[]; + lotOccupancyCount?: number; + lotOccupancies?: LotOccupancy[]; - lotComments ? : LotComment[]; + lotComments?: LotComment[]; } - export interface LotComment extends Record { - lotCommentId ? : number; - lotId ? : number; + lotCommentId?: number; + lotId?: number; - lotCommentDate ? : number; - lotCommentDateString ? : string; + lotCommentDate?: number; + lotCommentDateString?: string; - lotCommentTime ? : number; - lotCommentTimeString ? : string; + lotCommentTime?: number; + lotCommentTimeString?: string; - lotComment ? : string; + lotComment?: string; } - export interface OccupancyType extends Record { - occupancyTypeId ? : number; - occupancyType ? : string; - orderNumber ? : number; - occupancyTypeFields ? : OccupancyTypeField[]; + occupancyTypeId?: number; + occupancyType?: string; + orderNumber?: number; + occupancyTypeFields?: OccupancyTypeField[]; } - export interface OccupancyTypeField { - occupancyTypeFieldId ? : number; - occupancyTypeId ? : number; - occupancyTypeField ? : string; - occupancyTypeFieldValues ? : string; - isRequired ? : boolean; - pattern ? : string; - minimumLength ? : number; - maximumLength ? : number; - orderNumber ? : number; + occupancyTypeFieldId?: number; + occupancyTypeId?: number; + occupancyTypeField?: string; + occupancyTypeFieldValues?: string; + isRequired?: boolean; + pattern?: string; + minimumLength?: number; + maximumLength?: number; + orderNumber?: number; } - export interface LotOccupantType extends Record { - lotOccupantTypeId ? : number; - lotOccupantType ? : string; - orderNumber ? : number; + lotOccupantTypeId?: number; + lotOccupantType?: string; + orderNumber?: number; } - export interface FeeCategory extends Record { - feeCategoryId ? : number; - feeCategory ? : string; - fees ? : Fee[]; - orderNumber ? : number; + feeCategoryId?: number; + feeCategory?: string; + fees?: Fee[]; + orderNumber?: number; } - export interface Fee extends Record { - feeId ? : number; + feeId?: number; - feeCategoryId ? : number; - feeCategory ? : string; + feeCategoryId?: number; + feeCategory?: string; - feeName ? : string; - feeDescription ? : string; + feeName?: string; + feeDescription?: string; - occupancyTypeId ? : number; - occupancyType ? : string; + occupancyTypeId?: number; + occupancyType?: string; - lotTypeId ? : number; - lotType ? : string; + lotTypeId?: number; + lotType?: string; - includeQuantity ? : boolean; - quantityUnit ? : string; + includeQuantity?: boolean; + quantityUnit?: string; - feeAmount ? : number; - feeFunction ? : string; + feeAmount?: number; + feeFunction?: string; - taxAmount ? : number; - taxPercentage ? : number; + taxAmount?: number; + taxPercentage?: number; - isRequired ? : boolean; + isRequired?: boolean; - orderNumber ? : number; + orderNumber?: number; } - export interface LotOccupancyFee extends Fee, Record { - lotOccupancyId ? : number; + lotOccupancyId?: number; - feeId ? : number; - feeName ? : string; + feeId?: number; + feeName?: string; - quantity ? : number; - feeAmount ? : number; - taxAmount ? : number; + quantity?: number; + feeAmount?: number; + taxAmount?: number; } - export interface LotOccupancyTransaction extends Record { - lotOccupancyId ? : number; - transactionIndex ? : number; - transactionDate ? : number; - transactionDateString ? : string; - transactionTime ? : number; - transactionTimeString ? : string; - transactionAmount ? : number; - externalReceiptNumber ? : string; - transactionNote ? : string; + lotOccupancyId?: number; + transactionIndex?: number; + transactionDate?: number; + transactionDateString?: string; + transactionTime?: number; + transactionTimeString?: string; + transactionAmount?: number; + externalReceiptNumber?: string; + transactionNote?: string; } - export interface LotOccupancyOccupant extends Record { - lotOccupancyId ? : number; - lotOccupantIndex ? : number; + lotOccupancyId?: number; + lotOccupantIndex?: number; - lotOccupantTypeId ? : number; - lotOccupantType ? : string; + lotOccupantTypeId?: number; + lotOccupantType?: string; - occupantName ? : string; - occupantAddress1 ? : string; - occupantAddress2 ? : string; - occupantCity ? : string; - occupantProvince ? : string; - occupantPostalCode ? : string; - occupantPhoneNumber ? : string; + occupantName?: string; + occupantAddress1?: string; + occupantAddress2?: string; + occupantCity?: string; + occupantProvince?: string; + occupantPostalCode?: string; + occupantPhoneNumber?: string; } - export interface LotOccupancyComment extends Record { - lotOccupancyCommentId ? : number; - lotOccupancyId ? : number; + lotOccupancyCommentId?: number; + lotOccupancyId?: number; - lotOccupancyCommentDate ? : number; - lotOccupancyCommentDateString ? : string; + lotOccupancyCommentDate?: number; + lotOccupancyCommentDateString?: string; - lotOccupancyCommentTime ? : number; - lotOccupancyCommentTimeString ? : string; + lotOccupancyCommentTime?: number; + lotOccupancyCommentTimeString?: string; - lotOccupancyComment ? : string; + lotOccupancyComment?: string; } - export interface LotOccupancyField extends OccupancyTypeField, Record { - lotOccupancyId ? : number; - occupancyTypeFieldId ? : number; - lotOccupancyFieldValue ? : string; + lotOccupancyId?: number; + occupancyTypeFieldId?: number; + lotOccupancyFieldValue?: string; } - export interface LotOccupancy extends Record { - lotOccupancyId ? : number; + lotOccupancyId?: number; - occupancyTypeId ? : number; - occupancyType ? : string; + occupancyTypeId?: number; + occupancyType?: string; - lotId ? : number; - lotTypeId ? : number; - lotName ? : string; + lotId?: number; + lotTypeId?: number; + lotName?: string; - mapId ? : number; - mapName ? : string; + mapId?: number; + mapName?: string; - occupancyStartDate ? : number; - occupancyStartDateString ? : string; + occupancyStartDate?: number; + occupancyStartDateString?: string; - occupancyEndDate ? : number; - occupancyEndDateString ? : string; + occupancyEndDate?: number; + occupancyEndDateString?: string; - lotOccupancyFields ? : LotOccupancyField[]; - lotOccupancyComments ? : LotOccupancyComment[]; - lotOccupancyOccupants ? : LotOccupancyOccupant[]; - lotOccupancyFees ? : LotOccupancyFee[]; - lotOccupancyTransactions ? : LotOccupancyTransaction[]; + lotOccupancyFields?: LotOccupancyField[]; + lotOccupancyComments?: LotOccupancyComment[]; + lotOccupancyOccupants?: LotOccupancyOccupant[]; + lotOccupancyFees?: LotOccupancyFee[]; + lotOccupancyTransactions?: LotOccupancyTransaction[]; } - /* * WORK ORDERS */ - export interface WorkOrderType extends Record { - workOrderTypeId ? : number; - workOrderType ? : string; - orderNumber ? : number; + workOrderTypeId?: number; + workOrderType?: string; + orderNumber?: number; } - export interface WorkOrderComment extends Record { - workOrderCommentId ? : number; - workOrderId ? : number; + workOrderCommentId?: number; + workOrderId?: number; - workOrderCommentDate ? : number; - workOrderCommentDateString ? : string; + workOrderCommentDate?: number; + workOrderCommentDateString?: string; - workOrderCommentTime ? : number; - workOrderCommentTimeString ? : string; + workOrderCommentTime?: number; + workOrderCommentTimeString?: string; - workOrderComment ? : string; + workOrderComment?: string; } - export interface WorkOrder extends Record { - workOrderId ? : number; + workOrderId?: number; - workOrderTypeId ? : number; - workOrderType ? : string; + workOrderTypeId?: number; + workOrderType?: string; - workOrderNumber ? : string; - workOrderDescription ? : string; + workOrderNumber?: string; + workOrderDescription?: string; - workOrderOpenDate ? : number; - workOrderOpenDateString ? : string; + workOrderOpenDate?: number; + workOrderOpenDateString?: string; - workOrderCloseDate ? : number; - workOrderCloseDateString ? : string; + workOrderCloseDate?: number; + workOrderCloseDateString?: string; - workOrderComments ? : WorkOrderComment[]; - workOrderLots ? : Lot[]; - workOrderLotOccupancies ? : LotOccupancy[]; + workOrderComments?: WorkOrderComment[]; + workOrderLots?: Lot[]; + workOrderLotOccupancies?: LotOccupancy[]; } - /* * USER TYPES */ - export interface User { userName: string; - userProperties ? : UserProperties; + userProperties?: UserProperties; } export interface UserProperties { @@ -329,7 +305,6 @@ export interface UserProperties { isAdmin: boolean; } - declare module "express-session" { interface Session { user: User; @@ -338,4 +313,4 @@ declare module "express-session" { export interface PartialSession { user: User; -} \ No newline at end of file +} diff --git a/views/_menu-admin.ejs b/views/_menu-admin.ejs index ad128961..6e118791 100644 --- a/views/_menu-admin.ejs +++ b/views/_menu-admin.ejs @@ -9,6 +9,12 @@ Fee Management +
  • + " href="<%= urlPrefix %>/admin/occupancyTypes"> + + <%= configFunctions.getProperty("aliases.occupancy") %> Type Management + +
  • " href="<%= urlPrefix %>/admin/tables"> diff --git a/views/dashboard.ejs b/views/dashboard.ejs index 7ccaf9a3..1b62d4e1 100644 --- a/views/dashboard.ejs +++ b/views/dashboard.ejs @@ -145,6 +145,23 @@
  • +
    +
    +
    + +
    +
    +

    + <%= configFunctions.getProperty("aliases.occupancy") %> Type Management +

    +

    + Manage + <%= configFunctions.getProperty("aliases.occupancy").toLowerCase() %> types + and fields associated with them. +

    +
    +
    +