linting
parent
a8981e8154
commit
4f683e7432
|
|
@ -1,3 +1,3 @@
|
||||||
import type { Request, Response } from 'express';
|
import type { Request, Response, NextFunction } from 'express';
|
||||||
export declare function handler(request: Request, response: Response, next: any): Promise<void>;
|
export declare function handler(request: Request, response: Response, next: NextFunction): Promise<void>;
|
||||||
export default handler;
|
export default handler;
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ export async function handler(request, response, next) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const printConfig = getPdfPrintConfig(printName);
|
const printConfig = getPdfPrintConfig(printName);
|
||||||
if (!printConfig) {
|
if (printConfig === undefined) {
|
||||||
response.redirect(configFunctions.getProperty('reverseProxy.urlPrefix') +
|
response.redirect(configFunctions.getProperty('reverseProxy.urlPrefix') +
|
||||||
'/dashboard/?error=printConfigNotFound');
|
'/dashboard/?error=printConfigNotFound');
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import type { Request, Response } from 'express'
|
import type { Request, Response, NextFunction } from 'express'
|
||||||
|
|
||||||
import path from 'node:path'
|
import path from 'node:path'
|
||||||
import * as ejs from 'ejs'
|
import * as ejs from 'ejs'
|
||||||
|
|
@ -22,7 +22,7 @@ const attachmentOrInline = configFunctions.getProperty(
|
||||||
export async function handler(
|
export async function handler(
|
||||||
request: Request,
|
request: Request,
|
||||||
response: Response,
|
response: Response,
|
||||||
next
|
next: NextFunction
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const printName = request.params.printName
|
const printName = request.params.printName
|
||||||
|
|
||||||
|
|
@ -43,7 +43,7 @@ export async function handler(
|
||||||
|
|
||||||
const printConfig = getPdfPrintConfig(printName)
|
const printConfig = getPdfPrintConfig(printName)
|
||||||
|
|
||||||
if (!printConfig) {
|
if (printConfig === undefined) {
|
||||||
response.redirect(
|
response.redirect(
|
||||||
configFunctions.getProperty('reverseProxy.urlPrefix') +
|
configFunctions.getProperty('reverseProxy.urlPrefix') +
|
||||||
'/dashboard/?error=printConfigNotFound'
|
'/dashboard/?error=printConfigNotFound'
|
||||||
|
|
@ -58,7 +58,7 @@ export async function handler(
|
||||||
function pdfCallbackFunction(pdf: Buffer): void {
|
function pdfCallbackFunction(pdf: Buffer): void {
|
||||||
response.setHeader(
|
response.setHeader(
|
||||||
'Content-Disposition',
|
'Content-Disposition',
|
||||||
`${attachmentOrInline}; filename=${camelcase(printConfig.title)}.pdf`
|
`${attachmentOrInline}; filename=${camelcase(printConfig!.title)}.pdf`
|
||||||
)
|
)
|
||||||
|
|
||||||
response.setHeader('Content-Type', 'application/pdf')
|
response.setHeader('Content-Type', 'application/pdf')
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ export async function handler(request, response) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const printConfig = getScreenPrintConfig(printName);
|
const printConfig = getScreenPrintConfig(printName);
|
||||||
if (!printConfig) {
|
if (printConfig === undefined) {
|
||||||
response.redirect(configFunctions.getProperty('reverseProxy.urlPrefix') +
|
response.redirect(configFunctions.getProperty('reverseProxy.urlPrefix') +
|
||||||
'/dashboard/?error=printConfigNotFound');
|
'/dashboard/?error=printConfigNotFound');
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ export async function handler(
|
||||||
|
|
||||||
const printConfig = getScreenPrintConfig(printName)
|
const printConfig = getScreenPrintConfig(printName)
|
||||||
|
|
||||||
if (!printConfig) {
|
if (printConfig === undefined) {
|
||||||
response.redirect(
|
response.redirect(
|
||||||
configFunctions.getProperty('reverseProxy.urlPrefix') +
|
configFunctions.getProperty('reverseProxy.urlPrefix') +
|
||||||
'/dashboard/?error=printConfigNotFound'
|
'/dashboard/?error=printConfigNotFound'
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ export async function handler(request, response) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!rows) {
|
if (rows === undefined) {
|
||||||
response.status(404).json({
|
response.status(404).json({
|
||||||
success: false,
|
success: false,
|
||||||
message: 'Report Not Found'
|
message: 'Report Not Found'
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ export async function handler(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!rows) {
|
if (rows === undefined) {
|
||||||
response.status(404).json({
|
response.status(404).json({
|
||||||
success: false,
|
success: false,
|
||||||
message: 'Report Not Found'
|
message: 'Report Not Found'
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,8 @@ interface PrintConfig {
|
||||||
title: string;
|
title: string;
|
||||||
params: string[];
|
params: string[];
|
||||||
}
|
}
|
||||||
export declare function getScreenPrintConfig(printName: string): PrintConfig;
|
export declare function getScreenPrintConfig(printName: string): PrintConfig | undefined;
|
||||||
export declare function getPdfPrintConfig(printName: string): PrintConfig;
|
export declare function getPdfPrintConfig(printName: string): PrintConfig | undefined;
|
||||||
export declare function getPrintConfig(screenOrPdfPrintName: string): PrintConfig | undefined;
|
export declare function getPrintConfig(screenOrPdfPrintName: string): PrintConfig | undefined;
|
||||||
export declare function getReportData(printConfig: PrintConfig, requestQuery: Record<string, unknown>): Promise<Record<string, unknown>>;
|
export declare function getReportData(printConfig: PrintConfig, requestQuery: Record<string, unknown>): Promise<Record<string, unknown>>;
|
||||||
export {};
|
export {};
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ const screenPrintConfigs: Record<string, PrintConfig> = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getScreenPrintConfig(printName: string): PrintConfig {
|
export function getScreenPrintConfig(printName: string): PrintConfig | undefined {
|
||||||
return screenPrintConfigs[printName]
|
return screenPrintConfigs[printName]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -43,7 +43,7 @@ const pdfPrintConfigs: Record<string, PrintConfig> = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getPdfPrintConfig(printName: string): PrintConfig {
|
export function getPdfPrintConfig(printName: string): PrintConfig | undefined {
|
||||||
return pdfPrintConfigs[printName]
|
return pdfPrintConfigs[printName]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,26 +1,18 @@
|
||||||
import { getUserNameFromApiKey } from './functions.api.js';
|
import { getUserNameFromApiKey } from './functions.api.js';
|
||||||
import * as configFunctions from './functions.config.js';
|
import * as configFunctions from './functions.config.js';
|
||||||
export function userIsAdmin(request) {
|
export function userIsAdmin(request) {
|
||||||
const user = request.session?.user;
|
return request.session?.user?.userProperties?.isAdmin ?? false;
|
||||||
if (!user?.userProperties) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return user.userProperties.isAdmin;
|
|
||||||
}
|
}
|
||||||
export function userCanUpdate(request) {
|
export function userCanUpdate(request) {
|
||||||
const user = request.session?.user;
|
return request.session?.user?.userProperties?.canUpdate ?? false;
|
||||||
if (!user?.userProperties) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return user.userProperties.canUpdate;
|
|
||||||
}
|
}
|
||||||
export async function apiKeyIsValid(request) {
|
export async function apiKeyIsValid(request) {
|
||||||
const apiKey = request.params?.apiKey;
|
const apiKey = request.params?.apiKey;
|
||||||
if (!apiKey) {
|
if (apiKey === undefined) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const userName = await getUserNameFromApiKey(apiKey);
|
const userName = await getUserNameFromApiKey(apiKey);
|
||||||
if (!userName) {
|
if (userName === undefined) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const canLogin = configFunctions
|
const canLogin = configFunctions
|
||||||
|
|
|
||||||
|
|
@ -16,35 +16,23 @@ export interface APIRequest {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function userIsAdmin(request: UserRequest): boolean {
|
export function userIsAdmin(request: UserRequest): boolean {
|
||||||
const user = request.session?.user
|
return request.session?.user?.userProperties?.isAdmin ?? false
|
||||||
|
|
||||||
if (!user?.userProperties) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
return user.userProperties.isAdmin
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function userCanUpdate(request: UserRequest): boolean {
|
export function userCanUpdate(request: UserRequest): boolean {
|
||||||
const user = request.session?.user
|
return request.session?.user?.userProperties?.canUpdate ?? false
|
||||||
|
|
||||||
if (!user?.userProperties) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
return user.userProperties.canUpdate
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function apiKeyIsValid(request: APIRequest): Promise<boolean> {
|
export async function apiKeyIsValid(request: APIRequest): Promise<boolean> {
|
||||||
const apiKey = request.params?.apiKey
|
const apiKey = request.params?.apiKey
|
||||||
|
|
||||||
if (!apiKey) {
|
if (apiKey === undefined) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
const userName = await getUserNameFromApiKey(apiKey)
|
const userName = await getUserNameFromApiKey(apiKey)
|
||||||
|
|
||||||
if (!userName) {
|
if (userName === undefined) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -61,10 +61,10 @@ export async function moveFeeUpToTop(feeId) {
|
||||||
updateRecordOrderNumber('Fees', feeId, -1, database);
|
updateRecordOrderNumber('Fees', feeId, -1, database);
|
||||||
database
|
database
|
||||||
.prepare(`update Fees
|
.prepare(`update Fees
|
||||||
set orderNumber = orderNumber + 1
|
set orderNumber = orderNumber + 1
|
||||||
where recordDelete_timeMillis is null
|
where recordDelete_timeMillis is null
|
||||||
and feeCategoryId = ?
|
and feeCategoryId = ?
|
||||||
and orderNumber < ?`)
|
and orderNumber < ?`)
|
||||||
.run(currentFee.feeCategoryId, currentFee.orderNumber);
|
.run(currentFee.feeCategoryId, currentFee.orderNumber);
|
||||||
}
|
}
|
||||||
database.release();
|
database.release();
|
||||||
|
|
|
||||||
|
|
@ -107,10 +107,10 @@ export async function moveFeeUpToTop(feeId: number | string): Promise<boolean> {
|
||||||
database
|
database
|
||||||
.prepare(
|
.prepare(
|
||||||
`update Fees
|
`update Fees
|
||||||
set orderNumber = orderNumber + 1
|
set orderNumber = orderNumber + 1
|
||||||
where recordDelete_timeMillis is null
|
where recordDelete_timeMillis is null
|
||||||
and feeCategoryId = ?
|
and feeCategoryId = ?
|
||||||
and orderNumber < ?`
|
and orderNumber < ?`
|
||||||
)
|
)
|
||||||
.run(currentFee.feeCategoryId, currentFee.orderNumber)
|
.run(currentFee.feeCategoryId, currentFee.orderNumber)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,10 +34,10 @@ export async function moveLotTypeFieldDownToBottom(lotTypeFieldId) {
|
||||||
updateRecordOrderNumber('LotTypeFields', lotTypeFieldId, maxOrderNumber + 1, database);
|
updateRecordOrderNumber('LotTypeFields', lotTypeFieldId, maxOrderNumber + 1, database);
|
||||||
database
|
database
|
||||||
.prepare(`update LotTypeFields
|
.prepare(`update LotTypeFields
|
||||||
set orderNumber = orderNumber - 1
|
set orderNumber = orderNumber - 1
|
||||||
where recordDelete_timeMillis is null
|
where recordDelete_timeMillis is null
|
||||||
and lotTypeId = ?
|
and lotTypeId = ?
|
||||||
and orderNumber > ?`)
|
and orderNumber > ?`)
|
||||||
.run(currentField.lotTypeId, currentField.orderNumber);
|
.run(currentField.lotTypeId, currentField.orderNumber);
|
||||||
}
|
}
|
||||||
database.release();
|
database.release();
|
||||||
|
|
|
||||||
|
|
@ -73,10 +73,10 @@ export async function moveLotTypeFieldDownToBottom(
|
||||||
database
|
database
|
||||||
.prepare(
|
.prepare(
|
||||||
`update LotTypeFields
|
`update LotTypeFields
|
||||||
set orderNumber = orderNumber - 1
|
set orderNumber = orderNumber - 1
|
||||||
where recordDelete_timeMillis is null
|
where recordDelete_timeMillis is null
|
||||||
and lotTypeId = ?
|
and lotTypeId = ?
|
||||||
and orderNumber > ?`
|
and orderNumber > ?`
|
||||||
)
|
)
|
||||||
.run(currentField.lotTypeId, currentField.orderNumber)
|
.run(currentField.lotTypeId, currentField.orderNumber)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,23 +26,23 @@ export async function moveOccupancyTypePrintDownToBottom(occupancyTypeId, printE
|
||||||
.get(occupancyTypeId, printEJS).orderNumber;
|
.get(occupancyTypeId, printEJS).orderNumber;
|
||||||
const maxOrderNumber = database
|
const maxOrderNumber = database
|
||||||
.prepare(`select max(orderNumber) as maxOrderNumber
|
.prepare(`select max(orderNumber) as maxOrderNumber
|
||||||
from OccupancyTypePrints
|
from OccupancyTypePrints
|
||||||
where recordDelete_timeMillis is null
|
where recordDelete_timeMillis is null
|
||||||
and occupancyTypeId = ?`)
|
and occupancyTypeId = ?`)
|
||||||
.get(occupancyTypeId).maxOrderNumber;
|
.get(occupancyTypeId).maxOrderNumber;
|
||||||
if (currentOrderNumber !== maxOrderNumber) {
|
if (currentOrderNumber !== maxOrderNumber) {
|
||||||
database
|
database
|
||||||
.prepare(`update OccupancyTypePrints
|
.prepare(`update OccupancyTypePrints
|
||||||
set orderNumber = ? + 1
|
set orderNumber = ? + 1
|
||||||
where occupancyTypeId = ?
|
where occupancyTypeId = ?
|
||||||
and printEJS = ?`)
|
and printEJS = ?`)
|
||||||
.run(maxOrderNumber, occupancyTypeId, printEJS);
|
.run(maxOrderNumber, occupancyTypeId, printEJS);
|
||||||
database
|
database
|
||||||
.prepare(`update OccupancyTypeFields
|
.prepare(`update OccupancyTypeFields
|
||||||
set orderNumber = orderNumber - 1
|
set orderNumber = orderNumber - 1
|
||||||
where recordDelete_timeMillis is null
|
where recordDelete_timeMillis is null
|
||||||
and occupancyTypeId = ?
|
and occupancyTypeId = ?
|
||||||
and orderNumber > ?`)
|
and orderNumber > ?`)
|
||||||
.run(occupancyTypeId, currentOrderNumber);
|
.run(occupancyTypeId, currentOrderNumber);
|
||||||
}
|
}
|
||||||
database.release();
|
database.release();
|
||||||
|
|
|
||||||
|
|
@ -52,9 +52,9 @@ export async function moveOccupancyTypePrintDownToBottom(
|
||||||
const maxOrderNumber: number = database
|
const maxOrderNumber: number = database
|
||||||
.prepare(
|
.prepare(
|
||||||
`select max(orderNumber) as maxOrderNumber
|
`select max(orderNumber) as maxOrderNumber
|
||||||
from OccupancyTypePrints
|
from OccupancyTypePrints
|
||||||
where recordDelete_timeMillis is null
|
where recordDelete_timeMillis is null
|
||||||
and occupancyTypeId = ?`
|
and occupancyTypeId = ?`
|
||||||
)
|
)
|
||||||
.get(occupancyTypeId).maxOrderNumber
|
.get(occupancyTypeId).maxOrderNumber
|
||||||
|
|
||||||
|
|
@ -62,19 +62,19 @@ export async function moveOccupancyTypePrintDownToBottom(
|
||||||
database
|
database
|
||||||
.prepare(
|
.prepare(
|
||||||
`update OccupancyTypePrints
|
`update OccupancyTypePrints
|
||||||
set orderNumber = ? + 1
|
set orderNumber = ? + 1
|
||||||
where occupancyTypeId = ?
|
where occupancyTypeId = ?
|
||||||
and printEJS = ?`
|
and printEJS = ?`
|
||||||
)
|
)
|
||||||
.run(maxOrderNumber, occupancyTypeId, printEJS)
|
.run(maxOrderNumber, occupancyTypeId, printEJS)
|
||||||
|
|
||||||
database
|
database
|
||||||
.prepare(
|
.prepare(
|
||||||
`update OccupancyTypeFields
|
`update OccupancyTypeFields
|
||||||
set orderNumber = orderNumber - 1
|
set orderNumber = orderNumber - 1
|
||||||
where recordDelete_timeMillis is null
|
where recordDelete_timeMillis is null
|
||||||
and occupancyTypeId = ?
|
and occupancyTypeId = ?
|
||||||
and orderNumber > ?`
|
and orderNumber > ?`
|
||||||
)
|
)
|
||||||
.run(occupancyTypeId, currentOrderNumber)
|
.run(occupancyTypeId, currentOrderNumber)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,16 +31,16 @@ export async function moveOccupancyTypePrintUpToTop(occupancyTypeId, printEJS) {
|
||||||
if (currentOrderNumber > 0) {
|
if (currentOrderNumber > 0) {
|
||||||
database
|
database
|
||||||
.prepare(`update OccupancyTypePrints
|
.prepare(`update OccupancyTypePrints
|
||||||
set orderNumber = -1
|
set orderNumber = -1
|
||||||
where occupancyTypeId = ?
|
where occupancyTypeId = ?
|
||||||
and printEJS = ?`)
|
and printEJS = ?`)
|
||||||
.run(occupancyTypeId, printEJS);
|
.run(occupancyTypeId, printEJS);
|
||||||
database
|
database
|
||||||
.prepare(`update OccupancyTypePrints
|
.prepare(`update OccupancyTypePrints
|
||||||
set orderNumber = orderNumber + 1
|
set orderNumber = orderNumber + 1
|
||||||
where recordDelete_timeMillis is null
|
where recordDelete_timeMillis is null
|
||||||
and occupancyTypeId = ?
|
and occupancyTypeId = ?
|
||||||
and orderNumber < ?`)
|
and orderNumber < ?`)
|
||||||
.run(occupancyTypeId, currentOrderNumber);
|
.run(occupancyTypeId, currentOrderNumber);
|
||||||
}
|
}
|
||||||
database.release();
|
database.release();
|
||||||
|
|
|
||||||
|
|
@ -58,19 +58,19 @@ export async function moveOccupancyTypePrintUpToTop(
|
||||||
database
|
database
|
||||||
.prepare(
|
.prepare(
|
||||||
`update OccupancyTypePrints
|
`update OccupancyTypePrints
|
||||||
set orderNumber = -1
|
set orderNumber = -1
|
||||||
where occupancyTypeId = ?
|
where occupancyTypeId = ?
|
||||||
and printEJS = ?`
|
and printEJS = ?`
|
||||||
)
|
)
|
||||||
.run(occupancyTypeId, printEJS)
|
.run(occupancyTypeId, printEJS)
|
||||||
|
|
||||||
database
|
database
|
||||||
.prepare(
|
.prepare(
|
||||||
`update OccupancyTypePrints
|
`update OccupancyTypePrints
|
||||||
set orderNumber = orderNumber + 1
|
set orderNumber = orderNumber + 1
|
||||||
where recordDelete_timeMillis is null
|
where recordDelete_timeMillis is null
|
||||||
and occupancyTypeId = ?
|
and occupancyTypeId = ?
|
||||||
and orderNumber < ?`
|
and orderNumber < ?`
|
||||||
)
|
)
|
||||||
.run(occupancyTypeId, currentOrderNumber)
|
.run(occupancyTypeId, currentOrderNumber)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,8 +12,8 @@ recordIdColumns.set('WorkOrderTypes', 'workOrderTypeId');
|
||||||
function getCurrentOrderNumber(recordTable, recordId, database) {
|
function getCurrentOrderNumber(recordTable, recordId, database) {
|
||||||
const currentOrderNumber = database
|
const currentOrderNumber = database
|
||||||
.prepare(`select orderNumber
|
.prepare(`select orderNumber
|
||||||
from ${recordTable}
|
from ${recordTable}
|
||||||
where ${recordIdColumns.get(recordTable)} = ?`)
|
where ${recordIdColumns.get(recordTable)} = ?`)
|
||||||
.get(recordId).orderNumber;
|
.get(recordId).orderNumber;
|
||||||
return currentOrderNumber;
|
return currentOrderNumber;
|
||||||
}
|
}
|
||||||
|
|
@ -43,9 +43,9 @@ export async function moveRecordDownToBottom(recordTable, recordId) {
|
||||||
updateRecordOrderNumber(recordTable, recordId, maxOrderNumber + 1, database);
|
updateRecordOrderNumber(recordTable, recordId, maxOrderNumber + 1, database);
|
||||||
database
|
database
|
||||||
.prepare(`update ${recordTable}
|
.prepare(`update ${recordTable}
|
||||||
set orderNumber = orderNumber - 1
|
set orderNumber = orderNumber - 1
|
||||||
where recordDelete_timeMillis is null
|
where recordDelete_timeMillis is null
|
||||||
and orderNumber > ?`)
|
and orderNumber > ?`)
|
||||||
.run(currentOrderNumber);
|
.run(currentOrderNumber);
|
||||||
}
|
}
|
||||||
database.release();
|
database.release();
|
||||||
|
|
@ -77,9 +77,9 @@ export async function moveRecordUpToTop(recordTable, recordId) {
|
||||||
updateRecordOrderNumber(recordTable, recordId, -1, database);
|
updateRecordOrderNumber(recordTable, recordId, -1, database);
|
||||||
database
|
database
|
||||||
.prepare(`update ${recordTable}
|
.prepare(`update ${recordTable}
|
||||||
set orderNumber = orderNumber + 1
|
set orderNumber = orderNumber + 1
|
||||||
where recordDelete_timeMillis is null
|
where recordDelete_timeMillis is null
|
||||||
and orderNumber < ?`)
|
and orderNumber < ?`)
|
||||||
.run(currentOrderNumber);
|
.run(currentOrderNumber);
|
||||||
}
|
}
|
||||||
database.release();
|
database.release();
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ type RecordTable =
|
||||||
| 'WorkOrderMilestoneTypes'
|
| 'WorkOrderMilestoneTypes'
|
||||||
| 'WorkOrderTypes'
|
| 'WorkOrderTypes'
|
||||||
|
|
||||||
const recordIdColumns: Map<RecordTable, string> = new Map()
|
const recordIdColumns = new Map<RecordTable, string>()
|
||||||
recordIdColumns.set('FeeCategories', 'feeCategoryId')
|
recordIdColumns.set('FeeCategories', 'feeCategoryId')
|
||||||
recordIdColumns.set('LotOccupantTypes', 'lotOccupantTypeId')
|
recordIdColumns.set('LotOccupantTypes', 'lotOccupantTypeId')
|
||||||
recordIdColumns.set('LotStatuses', 'lotStatusId')
|
recordIdColumns.set('LotStatuses', 'lotStatusId')
|
||||||
|
|
@ -30,8 +30,8 @@ function getCurrentOrderNumber(
|
||||||
const currentOrderNumber: number = database
|
const currentOrderNumber: number = database
|
||||||
.prepare(
|
.prepare(
|
||||||
`select orderNumber
|
`select orderNumber
|
||||||
from ${recordTable}
|
from ${recordTable}
|
||||||
where ${recordIdColumns.get(recordTable)!} = ?`
|
where ${recordIdColumns.get(recordTable)!} = ?`
|
||||||
)
|
)
|
||||||
.get(recordId).orderNumber
|
.get(recordId).orderNumber
|
||||||
|
|
||||||
|
|
@ -99,9 +99,9 @@ export async function moveRecordDownToBottom(
|
||||||
database
|
database
|
||||||
.prepare(
|
.prepare(
|
||||||
`update ${recordTable}
|
`update ${recordTable}
|
||||||
set orderNumber = orderNumber - 1
|
set orderNumber = orderNumber - 1
|
||||||
where recordDelete_timeMillis is null
|
where recordDelete_timeMillis is null
|
||||||
and orderNumber > ?`
|
and orderNumber > ?`
|
||||||
)
|
)
|
||||||
.run(currentOrderNumber)
|
.run(currentOrderNumber)
|
||||||
}
|
}
|
||||||
|
|
@ -171,9 +171,9 @@ export async function moveRecordUpToTop(
|
||||||
database
|
database
|
||||||
.prepare(
|
.prepare(
|
||||||
`update ${recordTable}
|
`update ${recordTable}
|
||||||
set orderNumber = orderNumber + 1
|
set orderNumber = orderNumber + 1
|
||||||
where recordDelete_timeMillis is null
|
where recordDelete_timeMillis is null
|
||||||
and orderNumber < ?`
|
and orderNumber < ?`
|
||||||
)
|
)
|
||||||
.run(currentOrderNumber)
|
.run(currentOrderNumber)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,13 +22,13 @@ export async function updateLot(lotForm, requestSession) {
|
||||||
const lotTypeFieldIds = (lotForm.lotTypeFieldIds ?? '').split(',');
|
const lotTypeFieldIds = (lotForm.lotTypeFieldIds ?? '').split(',');
|
||||||
for (const lotTypeFieldId of lotTypeFieldIds) {
|
for (const lotTypeFieldId of lotTypeFieldIds) {
|
||||||
const lotFieldValue = lotForm['lotFieldValue_' + lotTypeFieldId];
|
const lotFieldValue = lotForm['lotFieldValue_' + lotTypeFieldId];
|
||||||
await (lotFieldValue && lotFieldValue !== ''
|
await ((lotFieldValue ?? '') === ''
|
||||||
? addOrUpdateLotField({
|
? deleteLotField(lotForm.lotId, lotTypeFieldId, requestSession, database)
|
||||||
|
: addOrUpdateLotField({
|
||||||
lotId: lotForm.lotId,
|
lotId: lotForm.lotId,
|
||||||
lotTypeFieldId,
|
lotTypeFieldId,
|
||||||
lotFieldValue
|
lotFieldValue: lotFieldValue
|
||||||
}, requestSession, database)
|
}, requestSession, database));
|
||||||
: deleteLotField(lotForm.lotId, lotTypeFieldId, requestSession, database));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
database.release();
|
database.release();
|
||||||
|
|
|
||||||
|
|
@ -62,21 +62,23 @@ export async function updateLot(
|
||||||
const lotTypeFieldIds = (lotForm.lotTypeFieldIds ?? '').split(',')
|
const lotTypeFieldIds = (lotForm.lotTypeFieldIds ?? '').split(',')
|
||||||
|
|
||||||
for (const lotTypeFieldId of lotTypeFieldIds) {
|
for (const lotTypeFieldId of lotTypeFieldIds) {
|
||||||
const lotFieldValue = lotForm['lotFieldValue_' + lotTypeFieldId] as string
|
const lotFieldValue = lotForm['lotFieldValue_' + lotTypeFieldId] as
|
||||||
|
| string
|
||||||
|
| undefined
|
||||||
|
|
||||||
await (lotFieldValue && lotFieldValue !== ''
|
await ((lotFieldValue ?? '') === ''
|
||||||
? addOrUpdateLotField(
|
? deleteLotField(
|
||||||
{
|
lotForm.lotId,
|
||||||
lotId: lotForm.lotId,
|
lotTypeFieldId,
|
||||||
lotTypeFieldId,
|
|
||||||
lotFieldValue
|
|
||||||
},
|
|
||||||
requestSession,
|
requestSession,
|
||||||
database
|
database
|
||||||
)
|
)
|
||||||
: deleteLotField(
|
: addOrUpdateLotField(
|
||||||
lotForm.lotId,
|
{
|
||||||
lotTypeFieldId,
|
lotId: lotForm.lotId,
|
||||||
|
lotTypeFieldId,
|
||||||
|
lotFieldValue: lotFieldValue!
|
||||||
|
},
|
||||||
requestSession,
|
requestSession,
|
||||||
database
|
database
|
||||||
))
|
))
|
||||||
|
|
|
||||||
|
|
@ -22,13 +22,13 @@ export async function updateLotOccupancy(lotOccupancyForm, requestSession) {
|
||||||
const occupancyTypeFieldIds = (lotOccupancyForm.occupancyTypeFieldIds ?? '').split(',');
|
const occupancyTypeFieldIds = (lotOccupancyForm.occupancyTypeFieldIds ?? '').split(',');
|
||||||
for (const occupancyTypeFieldId of occupancyTypeFieldIds) {
|
for (const occupancyTypeFieldId of occupancyTypeFieldIds) {
|
||||||
const lotOccupancyFieldValue = lotOccupancyForm['lotOccupancyFieldValue_' + occupancyTypeFieldId];
|
const lotOccupancyFieldValue = lotOccupancyForm['lotOccupancyFieldValue_' + occupancyTypeFieldId];
|
||||||
await (lotOccupancyFieldValue && lotOccupancyFieldValue !== ''
|
await ((lotOccupancyFieldValue ?? '') === ''
|
||||||
? addOrUpdateLotOccupancyField({
|
? deleteLotOccupancyField(lotOccupancyForm.lotOccupancyId, occupancyTypeFieldId, requestSession, database)
|
||||||
|
: addOrUpdateLotOccupancyField({
|
||||||
lotOccupancyId: lotOccupancyForm.lotOccupancyId,
|
lotOccupancyId: lotOccupancyForm.lotOccupancyId,
|
||||||
occupancyTypeFieldId,
|
occupancyTypeFieldId,
|
||||||
lotOccupancyFieldValue
|
lotOccupancyFieldValue
|
||||||
}, requestSession, database)
|
}, requestSession, database));
|
||||||
: deleteLotOccupancyField(lotOccupancyForm.lotOccupancyId, occupancyTypeFieldId, requestSession, database));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
database.release();
|
database.release();
|
||||||
|
|
|
||||||
|
|
@ -64,8 +64,14 @@ export async function updateLotOccupancy(
|
||||||
'lotOccupancyFieldValue_' + occupancyTypeFieldId
|
'lotOccupancyFieldValue_' + occupancyTypeFieldId
|
||||||
] as string
|
] as string
|
||||||
|
|
||||||
await (lotOccupancyFieldValue && lotOccupancyFieldValue !== ''
|
await ((lotOccupancyFieldValue ?? '') === ''
|
||||||
? addOrUpdateLotOccupancyField(
|
? deleteLotOccupancyField(
|
||||||
|
lotOccupancyForm.lotOccupancyId,
|
||||||
|
occupancyTypeFieldId,
|
||||||
|
requestSession,
|
||||||
|
database
|
||||||
|
)
|
||||||
|
: addOrUpdateLotOccupancyField(
|
||||||
{
|
{
|
||||||
lotOccupancyId: lotOccupancyForm.lotOccupancyId,
|
lotOccupancyId: lotOccupancyForm.lotOccupancyId,
|
||||||
occupancyTypeFieldId,
|
occupancyTypeFieldId,
|
||||||
|
|
@ -73,12 +79,6 @@ export async function updateLotOccupancy(
|
||||||
},
|
},
|
||||||
requestSession,
|
requestSession,
|
||||||
database
|
database
|
||||||
)
|
|
||||||
: deleteLotOccupancyField(
|
|
||||||
lotOccupancyForm.lotOccupancyId,
|
|
||||||
occupancyTypeFieldId,
|
|
||||||
requestSession,
|
|
||||||
database
|
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ type RecordTable =
|
||||||
| 'WorkOrderMilestoneTypes'
|
| 'WorkOrderMilestoneTypes'
|
||||||
| 'WorkOrderTypes'
|
| 'WorkOrderTypes'
|
||||||
|
|
||||||
const recordNameIdColumns: Map<RecordTable, string[]> = new Map()
|
const recordNameIdColumns = new Map<RecordTable, string[]>()
|
||||||
recordNameIdColumns.set('FeeCategories', ['feeCategory', 'feeCategoryId'])
|
recordNameIdColumns.set('FeeCategories', ['feeCategory', 'feeCategoryId'])
|
||||||
recordNameIdColumns.set('LotStatuses', ['lotStatus', 'lotStatusId'])
|
recordNameIdColumns.set('LotStatuses', ['lotStatus', 'lotStatusId'])
|
||||||
recordNameIdColumns.set('LotTypes', ['lotType', 'lotTypeId'])
|
recordNameIdColumns.set('LotTypes', ['lotType', 'lotTypeId'])
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ type RecordTable =
|
||||||
| 'WorkOrderMilestoneTypes'
|
| 'WorkOrderMilestoneTypes'
|
||||||
| 'WorkOrderTypes'
|
| 'WorkOrderTypes'
|
||||||
|
|
||||||
const recordIdColumns: Map<RecordTable, string> = new Map()
|
const recordIdColumns = new Map<RecordTable, string>()
|
||||||
recordIdColumns.set('FeeCategories', 'feeCategoryId')
|
recordIdColumns.set('FeeCategories', 'feeCategoryId')
|
||||||
recordIdColumns.set('Fees', 'feeId')
|
recordIdColumns.set('Fees', 'feeId')
|
||||||
recordIdColumns.set('LotOccupantTypes', 'lotOccupantTypeId')
|
recordIdColumns.set('LotOccupantTypes', 'lotOccupantTypeId')
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue