code cleanup
parent
4a529fad3c
commit
92458596c8
|
|
@ -1,7 +1,4 @@
|
|||
/* eslint-disable unicorn/filename-case, promise/catch-or-return, promise/always-return */
|
||||
|
||||
import { testAdmin } from '../../../test/_globals.js'
|
||||
|
||||
import { logout, login } from '../../support/index.js'
|
||||
|
||||
describe('Admin - Config Table Management', () => {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import * as configFunctions from '../../../helpers/functions.config.js';
|
||||
import { testUpdate } from '../../../test/_globals.js';
|
||||
import { logout, login } from '../../support/index.js';
|
||||
import * as configFunctions from '../../../helpers/functions.config.js';
|
||||
describe('Update - Maps', () => {
|
||||
beforeEach('Loads page', () => {
|
||||
logout();
|
||||
|
|
|
|||
|
|
@ -1,12 +1,10 @@
|
|||
// eslint-disable-next-line eslint-comments/disable-enable-pair
|
||||
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
||||
|
||||
import { testUpdate } from '../../../test/_globals.js'
|
||||
|
||||
import { logout, login } from '../../support/index.js'
|
||||
|
||||
import * as configFunctions from '../../../helpers/functions.config.js'
|
||||
|
||||
import type * as recordTypes from '../../../types/recordTypes'
|
||||
import { testUpdate } from '../../../test/_globals.js'
|
||||
import type { MapRecord } from '../../../types/recordTypes.js'
|
||||
import { logout, login } from '../../support/index.js'
|
||||
|
||||
describe('Update - Maps', () => {
|
||||
beforeEach('Loads page', () => {
|
||||
|
|
@ -33,7 +31,7 @@ describe('Update - Maps', () => {
|
|||
cy.log('Populate the fields')
|
||||
|
||||
// eslint-disable-next-line promise/catch-or-return, promise/always-return
|
||||
cy.fixture('map.json').then((mapJSON: recordTypes.Map) => {
|
||||
cy.fixture('map.json').then((mapJSON: MapRecord) => {
|
||||
cy.get("input[name='mapName']").clear().type(mapJSON.mapName!)
|
||||
cy.get("textarea[name='mapDescription']")
|
||||
.clear()
|
||||
|
|
@ -77,7 +75,7 @@ describe('Update - Maps', () => {
|
|||
.should('contain', '/edit')
|
||||
|
||||
// eslint-disable-next-line promise/catch-or-return, promise/always-return
|
||||
cy.fixture('map.json').then((mapJSON: recordTypes.Map) => {
|
||||
cy.fixture('map.json').then((mapJSON: MapRecord) => {
|
||||
cy.get("input[name='mapName']").should('have.value', mapJSON.mapName)
|
||||
cy.get("textarea[name='mapDescription']").should(
|
||||
'have.value',
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import * as cacheFunctions from '../../helpers/functions.cache.js';
|
||||
import * as configFunctions from '../../helpers/functions.config.js';
|
||||
import { getLot } from '../../helpers/lotOccupancyDB/getLot.js';
|
||||
import { getMaps } from '../../helpers/lotOccupancyDB/getMaps.js';
|
||||
import * as cacheFunctions from '../../helpers/functions.cache.js';
|
||||
export async function handler(request, response) {
|
||||
const lot = await getLot(request.params.lotId);
|
||||
if (lot === undefined) {
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
import type { Request, Response } from 'express'
|
||||
|
||||
import * as cacheFunctions from '../../helpers/functions.cache.js'
|
||||
import * as configFunctions from '../../helpers/functions.config.js'
|
||||
|
||||
import { getLot } from '../../helpers/lotOccupancyDB/getLot.js'
|
||||
import { getMaps } from '../../helpers/lotOccupancyDB/getMaps.js'
|
||||
import * as cacheFunctions from '../../helpers/functions.cache.js'
|
||||
|
||||
export async function handler(
|
||||
request: Request,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import * as cacheFunctions from '../../helpers/functions.cache.js';
|
||||
import * as configFunctions from '../../helpers/functions.config.js';
|
||||
import { getMaps } from '../../helpers/lotOccupancyDB/getMaps.js';
|
||||
import * as cacheFunctions from '../../helpers/functions.cache.js';
|
||||
export async function handler(request, response) {
|
||||
const lot = {
|
||||
lotId: -1,
|
||||
|
|
|
|||
|
|
@ -1,17 +1,15 @@
|
|||
import type { Request, Response } from 'express'
|
||||
|
||||
import * as configFunctions from '../../helpers/functions.config.js'
|
||||
|
||||
import { getMaps } from '../../helpers/lotOccupancyDB/getMaps.js'
|
||||
import * as cacheFunctions from '../../helpers/functions.cache.js'
|
||||
|
||||
import type * as recordTypes from '../../types/recordTypes'
|
||||
import * as configFunctions from '../../helpers/functions.config.js'
|
||||
import { getMaps } from '../../helpers/lotOccupancyDB/getMaps.js'
|
||||
import type { Lot } from '../../types/recordTypes.js'
|
||||
|
||||
export async function handler(
|
||||
request: Request,
|
||||
response: Response
|
||||
): Promise<void> {
|
||||
const lot: recordTypes.Lot = {
|
||||
const lot: Lot = {
|
||||
lotId: -1,
|
||||
lotOccupancies: []
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import type { Request, Response } from 'express'
|
||||
|
||||
import * as configFunctions from '../../helpers/functions.config.js'
|
||||
|
||||
import { getNextLotId } from '../../helpers/functions.lots.js'
|
||||
|
||||
export async function handler(
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import type { Request, Response } from 'express'
|
||||
|
||||
import * as configFunctions from '../../helpers/functions.config.js'
|
||||
|
||||
import { getPreviousLotId } from '../../helpers/functions.lots.js'
|
||||
|
||||
export async function handler(
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { getLotTypes, getLotStatuses } from '../../helpers/functions.cache.js';
|
||||
import * as configFunctions from '../../helpers/functions.config.js';
|
||||
import { getMaps } from '../../helpers/lotOccupancyDB/getMaps.js';
|
||||
import { getLotTypes, getLotStatuses } from '../../helpers/functions.cache.js';
|
||||
export async function handler(request, response) {
|
||||
const maps = await getMaps();
|
||||
const lotTypes = await getLotTypes();
|
||||
|
|
|
|||
|
|
@ -1,10 +1,8 @@
|
|||
import type { Request, Response } from 'express'
|
||||
|
||||
import * as configFunctions from '../../helpers/functions.config.js'
|
||||
|
||||
import { getMaps } from '../../helpers/lotOccupancyDB/getMaps.js'
|
||||
|
||||
import { getLotTypes, getLotStatuses } from '../../helpers/functions.cache.js'
|
||||
import * as configFunctions from '../../helpers/functions.config.js'
|
||||
import { getMaps } from '../../helpers/lotOccupancyDB/getMaps.js'
|
||||
|
||||
export async function handler(
|
||||
request: Request,
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import type { Request, Response } from 'express'
|
|||
|
||||
import * as configFunctions from '../../helpers/functions.config.js'
|
||||
import { getNextLotId, getPreviousLotId } from '../../helpers/functions.lots.js'
|
||||
|
||||
import { getLot } from '../../helpers/lotOccupancyDB/getLot.js'
|
||||
|
||||
export async function handler(
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import * as configFunctions from '../../helpers/functions.config.js';
|
||||
import { getMap } from '../../helpers/lotOccupancyDB/getMap.js';
|
||||
import { getMapSVGs } from '../../helpers/functions.map.js';
|
||||
import { getLotTypeSummary } from '../../helpers/lotOccupancyDB/getLotTypeSummary.js';
|
||||
import { getLotStatusSummary } from '../../helpers/lotOccupancyDB/getLotStatusSummary.js';
|
||||
import { getLotTypeSummary } from '../../helpers/lotOccupancyDB/getLotTypeSummary.js';
|
||||
import { getMap } from '../../helpers/lotOccupancyDB/getMap.js';
|
||||
export async function handler(request, response) {
|
||||
const map = await getMap(request.params.mapId);
|
||||
if (map === undefined) {
|
||||
|
|
|
|||
|
|
@ -1,12 +1,10 @@
|
|||
import type { Request, Response } from 'express'
|
||||
|
||||
import * as configFunctions from '../../helpers/functions.config.js'
|
||||
|
||||
import { getMap } from '../../helpers/lotOccupancyDB/getMap.js'
|
||||
|
||||
import { getMapSVGs } from '../../helpers/functions.map.js'
|
||||
import { getLotTypeSummary } from '../../helpers/lotOccupancyDB/getLotTypeSummary.js'
|
||||
import { getLotStatusSummary } from '../../helpers/lotOccupancyDB/getLotStatusSummary.js'
|
||||
import { getLotTypeSummary } from '../../helpers/lotOccupancyDB/getLotTypeSummary.js'
|
||||
import { getMap } from '../../helpers/lotOccupancyDB/getMap.js'
|
||||
|
||||
export async function handler(
|
||||
request: Request,
|
||||
|
|
|
|||
|
|
@ -1,16 +1,14 @@
|
|||
import type { Request, Response } from 'express'
|
||||
|
||||
import * as configFunctions from '../../helpers/functions.config.js'
|
||||
|
||||
import { getMapSVGs } from '../../helpers/functions.map.js'
|
||||
|
||||
import * as recordTypes from '../../types/recordTypes'
|
||||
import type { MapRecord } from '../../types/recordTypes.js'
|
||||
|
||||
export async function handler(
|
||||
_request: Request,
|
||||
response: Response
|
||||
): Promise<void> {
|
||||
const map: recordTypes.Map = {
|
||||
const map: MapRecord = {
|
||||
mapCity: configFunctions.getProperty('settings.map.mapCityDefault'),
|
||||
mapProvince: configFunctions.getProperty('settings.map.mapProvinceDefault')
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import type { Request, Response } from 'express'
|
||||
|
||||
import * as configFunctions from '../../helpers/functions.config.js'
|
||||
|
||||
import { getNextMapId } from '../../helpers/lotOccupancyDB/getNextMapId.js'
|
||||
|
||||
export async function handler(
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import type { Request, Response } from 'express'
|
||||
|
||||
import * as configFunctions from '../../helpers/functions.config.js'
|
||||
|
||||
import { getPreviousMapId } from '../../helpers/lotOccupancyDB/getPreviousMapId.js'
|
||||
|
||||
export async function handler(
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import type { Request, Response } from 'express'
|
||||
|
||||
import * as configFunctions from '../../helpers/functions.config.js'
|
||||
|
||||
import { getMaps } from '../../helpers/lotOccupancyDB/getMaps.js'
|
||||
|
||||
export async function handler(_request: Request, response: Response): Promise<void> {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import * as configFunctions from '../../helpers/functions.config.js';
|
||||
import { getMap } from '../../helpers/lotOccupancyDB/getMap.js';
|
||||
import { getLotStatusSummary } from '../../helpers/lotOccupancyDB/getLotStatusSummary.js';
|
||||
import { getLotTypeSummary } from '../../helpers/lotOccupancyDB/getLotTypeSummary.js';
|
||||
import { getMap } from '../../helpers/lotOccupancyDB/getMap.js';
|
||||
export async function handler(request, response) {
|
||||
const map = await getMap(request.params.mapId);
|
||||
if (map === undefined) {
|
||||
|
|
|
|||
|
|
@ -1,12 +1,14 @@
|
|||
import type { Request, Response } from 'express'
|
||||
|
||||
import * as configFunctions from '../../helpers/functions.config.js'
|
||||
|
||||
import { getMap } from '../../helpers/lotOccupancyDB/getMap.js'
|
||||
import { getLotStatusSummary } from '../../helpers/lotOccupancyDB/getLotStatusSummary.js'
|
||||
import { getLotTypeSummary } from '../../helpers/lotOccupancyDB/getLotTypeSummary.js'
|
||||
import { getMap } from '../../helpers/lotOccupancyDB/getMap.js'
|
||||
|
||||
export async function handler(request: Request, response: Response): Promise<void> {
|
||||
export async function handler(
|
||||
request: Request,
|
||||
response: Response
|
||||
): Promise<void> {
|
||||
const map = await getMap(request.params.mapId)
|
||||
|
||||
if (map === undefined) {
|
||||
|
|
|
|||
|
|
@ -5,9 +5,7 @@ import {
|
|||
getWorkOrderMilestoneTypes,
|
||||
getWorkOrderTypes
|
||||
} from '../../helpers/functions.cache.js'
|
||||
|
||||
import * as configFunctions from '../../helpers/functions.config.js'
|
||||
|
||||
import { getWorkOrder } from '../../helpers/lotOccupancyDB/getWorkOrder.js'
|
||||
|
||||
export async function handler(
|
||||
|
|
|
|||
|
|
@ -1,12 +1,8 @@
|
|||
import {
|
||||
dateToInteger,
|
||||
dateToString
|
||||
} from '@cityssm/utils-datetime'
|
||||
import { dateToInteger, dateToString } from '@cityssm/utils-datetime'
|
||||
import type { Request, Response } from 'express'
|
||||
|
||||
import { getWorkOrderTypes } from '../../helpers/functions.cache.js'
|
||||
|
||||
import type * as recordTypes from '../../types/recordTypes'
|
||||
import type { WorkOrder } from '../../types/recordTypes.js'
|
||||
|
||||
export async function handler(
|
||||
request: Request,
|
||||
|
|
@ -14,7 +10,7 @@ export async function handler(
|
|||
): Promise<void> {
|
||||
const currentDate = new Date()
|
||||
|
||||
const workOrder: recordTypes.WorkOrder = {
|
||||
const workOrder: WorkOrder = {
|
||||
workOrderOpenDate: dateToInteger(currentDate),
|
||||
workOrderOpenDateString: dateToString(currentDate)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
import type * as recordTypes from '../../types/recordTypes';
|
||||
export declare function getMap(mapId: number | string): Promise<recordTypes.Map | undefined>;
|
||||
import type { MapRecord } from '../../types/recordTypes.js';
|
||||
export declare function getMap(mapId: number | string): Promise<MapRecord | undefined>;
|
||||
export default getMap;
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
import { acquireConnection } from './pool.js'
|
||||
import type { MapRecord } from '../../types/recordTypes.js'
|
||||
|
||||
import type * as recordTypes from '../../types/recordTypes'
|
||||
import { acquireConnection } from './pool.js'
|
||||
|
||||
export async function getMap(
|
||||
mapId: number | string
|
||||
): Promise<recordTypes.Map | undefined> {
|
||||
): Promise<MapRecord | undefined> {
|
||||
const database = await acquireConnection()
|
||||
|
||||
const map = database
|
||||
|
|
@ -29,7 +29,7 @@ export async function getMap(
|
|||
m.recordUpdate_userName, m.recordUpdate_timeMillis,
|
||||
m.recordDelete_userName, m.recordDelete_timeMillis`
|
||||
)
|
||||
.get(mapId) as recordTypes.Map | undefined
|
||||
.get(mapId) as MapRecord | undefined
|
||||
|
||||
database.release()
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
import type * as recordTypes from '../../types/recordTypes';
|
||||
export declare function getMaps(): Promise<recordTypes.Map[]>;
|
||||
import type { MapRecord } from '../../types/recordTypes.js';
|
||||
export declare function getMaps(): Promise<MapRecord[]>;
|
||||
export default getMaps;
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import type { MapRecord } from '../../types/recordTypes.js'
|
||||
|
||||
import { acquireConnection } from './pool.js'
|
||||
|
||||
import type * as recordTypes from '../../types/recordTypes'
|
||||
|
||||
export async function getMaps(): Promise<recordTypes.Map[]> {
|
||||
export async function getMaps(): Promise<MapRecord[]> {
|
||||
const database = await acquireConnection()
|
||||
|
||||
const maps = database
|
||||
|
|
@ -20,7 +20,7 @@ export async function getMaps(): Promise<recordTypes.Map[]> {
|
|||
) l on m.mapId = l.mapId
|
||||
where m.recordDelete_timeMillis is null order by m.mapName, m.mapId`
|
||||
)
|
||||
.all() as recordTypes.Map[]
|
||||
.all() as MapRecord[]
|
||||
|
||||
database.release()
|
||||
|
||||
|
|
|
|||
|
|
@ -661,7 +661,7 @@ declare const bulmaJS: BulmaJS
|
|||
'#lotCreate--mapId'
|
||||
) as HTMLSelectElement
|
||||
|
||||
for (const map of exports.maps as recordTypes.Map[]) {
|
||||
for (const map of exports.maps as recordTypes.MapRecord[]) {
|
||||
const optionElement = document.createElement('option')
|
||||
optionElement.value = map.mapId!.toString()
|
||||
optionElement.textContent =
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ declare const cityssm: cityssmGlobal
|
|||
;(() => {
|
||||
const los = exports.los as globalTypes.LOS
|
||||
|
||||
const maps: recordTypes.Map[] = exports.maps
|
||||
const maps: recordTypes.MapRecord[] = exports.maps
|
||||
|
||||
const searchFilterElement = document.querySelector(
|
||||
'#searchFilter--map'
|
||||
|
|
|
|||
|
|
@ -232,14 +232,14 @@ function purgeConfigTables(): void {
|
|||
console.timeEnd('purgeConfigTables')
|
||||
}
|
||||
|
||||
function getMapByMapDescription(mapDescription: string): recordTypes.Map {
|
||||
function getMapByMapDescription(mapDescription: string): recordTypes.MapRecord {
|
||||
const database = sqlite(databasePath, {
|
||||
readonly: true
|
||||
})
|
||||
|
||||
const map: recordTypes.Map = database
|
||||
const map = database
|
||||
.prepare('select * from Maps where mapDescription = ?')
|
||||
.get(mapDescription)
|
||||
.get(mapDescription) as recordTypes.MapRecord
|
||||
|
||||
database.close()
|
||||
|
||||
|
|
@ -274,9 +274,9 @@ const cemeteryToMapName = {
|
|||
WK: 'West Korah'
|
||||
}
|
||||
|
||||
const mapCache = new Map<string, recordTypes.Map>()
|
||||
const mapCache = new Map<string, recordTypes.MapRecord>()
|
||||
|
||||
async function getMap(dataRow: { cemetery: string }): Promise<recordTypes.Map> {
|
||||
async function getMap(dataRow: { cemetery: string }): Promise<recordTypes.MapRecord> {
|
||||
const mapCacheKey = dataRow.cemetery
|
||||
|
||||
/*
|
||||
|
|
@ -312,7 +312,7 @@ async function getMap(dataRow: { cemetery: string }): Promise<recordTypes.Map> {
|
|||
user
|
||||
)
|
||||
|
||||
map = (await getMapFromDatabase(mapId)) as recordTypes.Map
|
||||
map = (await getMapFromDatabase(mapId)) as recordTypes.MapRecord
|
||||
}
|
||||
|
||||
mapCache.set(mapCacheKey, map)
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ export interface Record {
|
|||
recordDelete_timeMillis?: number;
|
||||
recordDelete_dateString?: string;
|
||||
}
|
||||
export interface Map extends Record {
|
||||
export interface MapRecord extends Record {
|
||||
mapId?: number;
|
||||
mapName?: string;
|
||||
mapDescription?: string;
|
||||
|
|
@ -55,7 +55,7 @@ export interface Lot extends Record {
|
|||
lotType?: string;
|
||||
mapId?: number;
|
||||
mapName?: string;
|
||||
map?: Map;
|
||||
map?: MapRecord;
|
||||
mapSVG?: string;
|
||||
mapKey?: string;
|
||||
lotLatitude?: number;
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ export interface Record {
|
|||
* LOT OCCUPANCY DB TYPES
|
||||
*/
|
||||
|
||||
export interface Map extends Record {
|
||||
export interface MapRecord extends Record {
|
||||
mapId?: number
|
||||
mapName?: string
|
||||
mapDescription?: string
|
||||
|
|
@ -74,7 +74,7 @@ export interface Lot extends Record {
|
|||
|
||||
mapId?: number
|
||||
mapName?: string
|
||||
map?: Map
|
||||
map?: MapRecord
|
||||
mapSVG?: string
|
||||
mapKey?: string
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue