filter prints by occupancy type
parent
aa8c760fdf
commit
3af3064880
|
|
@ -1,4 +1,4 @@
|
|||
import { getLotOccupantTypes, getLotStatuses, getLotTypes, getOccupancyTypes, getWorkOrderTypes } from "../../helpers/functions.cache.js";
|
||||
import { getLotOccupantTypes, getLotStatuses, getLotTypes, getOccupancyTypePrintsById, getOccupancyTypes, getWorkOrderTypes } from "../../helpers/functions.cache.js";
|
||||
import * as configFunctions from "../../helpers/functions.config.js";
|
||||
import { getLotOccupancy } from "../../helpers/lotOccupancyDB/getLotOccupancy.js";
|
||||
import { getMaps } from "../../helpers/lotOccupancyDB/getMaps.js";
|
||||
|
|
@ -8,6 +8,7 @@ export const handler = (request, response) => {
|
|||
return response.redirect(configFunctions.getProperty("reverseProxy.urlPrefix") +
|
||||
"/lotOccupancies/?error=lotOccupancyIdNotFound");
|
||||
}
|
||||
const occupancyTypePrints = getOccupancyTypePrintsById(lotOccupancy.occupancyTypeId);
|
||||
const occupancyTypes = getOccupancyTypes();
|
||||
const lotOccupantTypes = getLotOccupantTypes();
|
||||
const lotTypes = getLotTypes();
|
||||
|
|
@ -20,6 +21,7 @@ export const handler = (request, response) => {
|
|||
configFunctions.getProperty("aliases.occupancy") +
|
||||
" Update",
|
||||
lotOccupancy,
|
||||
occupancyTypePrints,
|
||||
occupancyTypes,
|
||||
lotOccupantTypes,
|
||||
lotTypes,
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import {
|
|||
getLotOccupantTypes,
|
||||
getLotStatuses,
|
||||
getLotTypes,
|
||||
getOccupancyTypePrintsById,
|
||||
getOccupancyTypes,
|
||||
getWorkOrderTypes
|
||||
} from "../../helpers/functions.cache.js";
|
||||
|
|
@ -23,6 +24,8 @@ export const handler: RequestHandler = (request, response) => {
|
|||
);
|
||||
}
|
||||
|
||||
const occupancyTypePrints = getOccupancyTypePrintsById(lotOccupancy.occupancyTypeId);
|
||||
|
||||
const occupancyTypes = getOccupancyTypes();
|
||||
const lotOccupantTypes = getLotOccupantTypes();
|
||||
const lotTypes = getLotTypes();
|
||||
|
|
@ -37,6 +40,7 @@ export const handler: RequestHandler = (request, response) => {
|
|||
configFunctions.getProperty("aliases.occupancy") +
|
||||
" Update",
|
||||
lotOccupancy,
|
||||
occupancyTypePrints,
|
||||
|
||||
occupancyTypes,
|
||||
lotOccupantTypes,
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import { getOccupancyTypePrintsById } from "../../helpers/functions.cache.js";
|
||||
import * as configFunctions from "../../helpers/functions.config.js";
|
||||
import { getLotOccupancy } from "../../helpers/lotOccupancyDB/getLotOccupancy.js";
|
||||
export const handler = (request, response) => {
|
||||
|
|
@ -6,12 +7,14 @@ export const handler = (request, response) => {
|
|||
return response.redirect(configFunctions.getProperty("reverseProxy.urlPrefix") +
|
||||
"/lotOccupancies/?error=lotOccupancyIdNotFound");
|
||||
}
|
||||
const occupancyTypePrints = getOccupancyTypePrintsById(lotOccupancy.occupancyTypeId);
|
||||
return response.render("lotOccupancy-view", {
|
||||
headTitle: configFunctions.getProperty("aliases.lot") +
|
||||
" " +
|
||||
configFunctions.getProperty("aliases.occupancy") +
|
||||
" View",
|
||||
lotOccupancy
|
||||
lotOccupancy,
|
||||
occupancyTypePrints
|
||||
});
|
||||
};
|
||||
export default handler;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import type { RequestHandler } from "express";
|
||||
import { getOccupancyTypePrintsById } from "../../helpers/functions.cache.js";
|
||||
|
||||
import * as configFunctions from "../../helpers/functions.config.js";
|
||||
|
||||
|
|
@ -14,13 +15,16 @@ export const handler: RequestHandler = (request, response) => {
|
|||
);
|
||||
}
|
||||
|
||||
const occupancyTypePrints = getOccupancyTypePrintsById(lotOccupancy.occupancyTypeId);
|
||||
|
||||
return response.render("lotOccupancy-view", {
|
||||
headTitle:
|
||||
configFunctions.getProperty("aliases.lot") +
|
||||
" " +
|
||||
configFunctions.getProperty("aliases.occupancy") +
|
||||
" View",
|
||||
lotOccupancy
|
||||
lotOccupancy,
|
||||
occupancyTypePrints
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ export declare function getOccupancyTypes(): recordTypes.OccupancyType[];
|
|||
export declare function getAllOccupancyTypeFields(): recordTypes.OccupancyTypeField[];
|
||||
export declare function getOccupancyTypeById(occupancyTypeId: number): recordTypes.OccupancyType;
|
||||
export declare function getOccupancyTypeByOccupancyType(occupancyTypeString: string): recordTypes.OccupancyType;
|
||||
export declare function getOccupancyTypePrintsById(occupancyTypeId: number): string[];
|
||||
export declare function clearOccupancyTypesCache(): void;
|
||||
export declare function getWorkOrderTypes(): recordTypes.WorkOrderType[];
|
||||
export declare function clearWorkOrderTypesCache(): void;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import * as configFunctions from "./functions.config.js";
|
||||
import { getLotOccupantTypes as getLotOccupantTypesFromDatabase } from "./lotOccupancyDB/getLotOccupantTypes.js";
|
||||
import { getLotStatuses as getLotStatusesFromDatabase } from "./lotOccupancyDB/getLotStatuses.js";
|
||||
import { getLotTypes as getLotTypesFromDatabase } from "./lotOccupancyDB/getLotTypes.js";
|
||||
|
|
@ -101,6 +102,16 @@ export function getOccupancyTypeByOccupancyType(occupancyTypeString) {
|
|||
return currentOccupancyType.occupancyType.toLowerCase() === occupancyTypeLowerCase;
|
||||
});
|
||||
}
|
||||
export function getOccupancyTypePrintsById(occupancyTypeId) {
|
||||
const occupancyType = getOccupancyTypeById(occupancyTypeId);
|
||||
if (!occupancyType || occupancyType.occupancyTypePrints.length === 0) {
|
||||
return [];
|
||||
}
|
||||
if (occupancyType.occupancyTypePrints.includes("*")) {
|
||||
return configFunctions.getProperty("settings.lotOccupancy.prints");
|
||||
}
|
||||
return occupancyType.occupancyTypePrints;
|
||||
}
|
||||
export function clearOccupancyTypesCache() {
|
||||
occupancyTypes = undefined;
|
||||
allOccupancyTypeFields = undefined;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
import * as configFunctions from "./functions.config.js";
|
||||
|
||||
import { getLotOccupantTypes as getLotOccupantTypesFromDatabase } from "./lotOccupancyDB/getLotOccupantTypes.js";
|
||||
|
||||
import { getLotStatuses as getLotStatusesFromDatabase } from "./lotOccupancyDB/getLotStatuses.js";
|
||||
|
|
@ -161,6 +163,21 @@ export function getOccupancyTypeByOccupancyType(occupancyTypeString: string) {
|
|||
});
|
||||
}
|
||||
|
||||
export function getOccupancyTypePrintsById(occupancyTypeId: number): string[] {
|
||||
|
||||
const occupancyType = getOccupancyTypeById(occupancyTypeId);
|
||||
|
||||
if (!occupancyType || occupancyType.occupancyTypePrints.length === 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
if (occupancyType.occupancyTypePrints.includes("*")) {
|
||||
return configFunctions.getProperty("settings.lotOccupancy.prints");
|
||||
}
|
||||
|
||||
return occupancyType.occupancyTypePrints;
|
||||
}
|
||||
|
||||
export function clearOccupancyTypesCache() {
|
||||
occupancyTypes = undefined;
|
||||
allOccupancyTypeFields = undefined;
|
||||
|
|
|
|||
|
|
@ -24,7 +24,8 @@ export const initializeDatabase = () => {
|
|||
")")
|
||||
.run();
|
||||
lotOccupancyDB
|
||||
.prepare("create index if not exists idx_lottypes_ordernumber" + " on LotTypes (orderNumber, lotType)")
|
||||
.prepare("create index if not exists idx_lottypes_ordernumber" +
|
||||
" on LotTypes (orderNumber, lotType)")
|
||||
.run();
|
||||
lotOccupancyDB
|
||||
.prepare("create table if not exists LotTypeFields (" +
|
||||
|
|
@ -55,7 +56,8 @@ export const initializeDatabase = () => {
|
|||
")")
|
||||
.run();
|
||||
lotOccupancyDB
|
||||
.prepare("create index if not exists idx_lotstatuses_ordernumber" + " on LotStatuses (orderNumber, lotStatus)")
|
||||
.prepare("create index if not exists idx_lotstatuses_ordernumber" +
|
||||
" on LotStatuses (orderNumber, lotStatus)")
|
||||
.run();
|
||||
lotOccupancyDB
|
||||
.prepare("create table if not exists Maps (" +
|
||||
|
|
@ -151,6 +153,21 @@ export const initializeDatabase = () => {
|
|||
.prepare("create index if not exists idx_occupancytypefields_ordernumber" +
|
||||
" on OccupancyTypeFields (occupancyTypeId, orderNumber, occupancyTypeField)")
|
||||
.run();
|
||||
lotOccupancyDB
|
||||
.prepare("create table if not exists OccupancyTypePrints (" +
|
||||
"occupancyTypeId integer not null," +
|
||||
" printEJS varchar(100) not null," +
|
||||
" orderNumber smallint not null default 0," +
|
||||
recordColumns +
|
||||
"," +
|
||||
" primary key (occupancyTypeId, printEJS)," +
|
||||
" foreign key (occupancyTypeId) references OccupancyTypes (occupancyTypeId)" +
|
||||
")")
|
||||
.run();
|
||||
lotOccupancyDB
|
||||
.prepare("create index if not exists idx_occupancytypeprints_ordernumber" +
|
||||
" on OccupancyTypePrints (occupancyTypeId, orderNumber, printEJS)")
|
||||
.run();
|
||||
lotOccupancyDB
|
||||
.prepare("create table if not exists LotOccupantTypes (" +
|
||||
"lotOccupantTypeId integer not null primary key autoincrement," +
|
||||
|
|
@ -258,7 +275,8 @@ export const initializeDatabase = () => {
|
|||
")")
|
||||
.run();
|
||||
lotOccupancyDB
|
||||
.prepare("create index if not exists idx_fees_ordernumber" + " on Fees (orderNumber, feeName)")
|
||||
.prepare("create index if not exists idx_fees_ordernumber" +
|
||||
" on Fees (orderNumber, feeName)")
|
||||
.run();
|
||||
lotOccupancyDB
|
||||
.prepare("create table if not exists LotOccupancyFees (" +
|
||||
|
|
|
|||
|
|
@ -17,7 +17,9 @@ export const initializeDatabase = (): boolean => {
|
|||
const lotOccupancyDB = sqlite(databasePath);
|
||||
|
||||
const row = lotOccupancyDB
|
||||
.prepare("select name from sqlite_master where type = 'table' and name = 'WorkOrderMilestones'")
|
||||
.prepare(
|
||||
"select name from sqlite_master where type = 'table' and name = 'WorkOrderMilestones'"
|
||||
)
|
||||
.get();
|
||||
|
||||
if (!row) {
|
||||
|
|
@ -37,7 +39,10 @@ export const initializeDatabase = (): boolean => {
|
|||
.run();
|
||||
|
||||
lotOccupancyDB
|
||||
.prepare("create index if not exists idx_lottypes_ordernumber" + " on LotTypes (orderNumber, lotType)")
|
||||
.prepare(
|
||||
"create index if not exists idx_lottypes_ordernumber" +
|
||||
" on LotTypes (orderNumber, lotType)"
|
||||
)
|
||||
.run();
|
||||
|
||||
lotOccupancyDB
|
||||
|
|
@ -79,7 +84,8 @@ export const initializeDatabase = (): boolean => {
|
|||
|
||||
lotOccupancyDB
|
||||
.prepare(
|
||||
"create index if not exists idx_lotstatuses_ordernumber" + " on LotStatuses (orderNumber, lotStatus)"
|
||||
"create index if not exists idx_lotstatuses_ordernumber" +
|
||||
" on LotStatuses (orderNumber, lotStatus)"
|
||||
)
|
||||
.run();
|
||||
|
||||
|
|
@ -208,6 +214,27 @@ export const initializeDatabase = (): boolean => {
|
|||
)
|
||||
.run();
|
||||
|
||||
lotOccupancyDB
|
||||
.prepare(
|
||||
"create table if not exists OccupancyTypePrints (" +
|
||||
"occupancyTypeId integer not null," +
|
||||
" printEJS varchar(100) not null," +
|
||||
" orderNumber smallint not null default 0," +
|
||||
recordColumns +
|
||||
"," +
|
||||
" primary key (occupancyTypeId, printEJS)," +
|
||||
" foreign key (occupancyTypeId) references OccupancyTypes (occupancyTypeId)" +
|
||||
")"
|
||||
)
|
||||
.run();
|
||||
|
||||
lotOccupancyDB
|
||||
.prepare(
|
||||
"create index if not exists idx_occupancytypeprints_ordernumber" +
|
||||
" on OccupancyTypePrints (occupancyTypeId, orderNumber, printEJS)"
|
||||
)
|
||||
.run();
|
||||
|
||||
lotOccupancyDB
|
||||
.prepare(
|
||||
"create table if not exists LotOccupantTypes (" +
|
||||
|
|
@ -344,7 +371,10 @@ export const initializeDatabase = (): boolean => {
|
|||
.run();
|
||||
|
||||
lotOccupancyDB
|
||||
.prepare("create index if not exists idx_fees_ordernumber" + " on Fees (orderNumber, feeName)")
|
||||
.prepare(
|
||||
"create index if not exists idx_fees_ordernumber" +
|
||||
" on Fees (orderNumber, feeName)"
|
||||
)
|
||||
.run();
|
||||
|
||||
lotOccupancyDB
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
import sqlite from "better-sqlite3";
|
||||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
||||
import { dateIntegerToString, dateStringToInteger, dateToInteger } from "@cityssm/expressjs-server-js/dateTimeFns.js";
|
||||
import * as configFunctions from "../functions.config.js";
|
||||
import { getOccupancyTypeById } from "../functions.cache.js";
|
||||
import { getLotOccupancyOccupants } from "./getLotOccupancyOccupants.js";
|
||||
const buildWhereClause = (filters) => {
|
||||
let sqlWhereClause = " where o.recordDelete_timeMillis is null";
|
||||
|
|
@ -123,15 +125,21 @@ export const getLotOccupancies = (filters, options, connectedDatabase) => {
|
|||
" left join Maps m on l.mapId = m.mapId" +
|
||||
sqlWhereClause +
|
||||
" order by o.occupancyStartDate desc, ifnull(o.occupancyEndDate, 99999999) desc, l.lotName, o.lotId" +
|
||||
(options.limit !== -1
|
||||
? " limit " + options.limit + " offset " + options.offset
|
||||
: ""))
|
||||
(options.limit === -1
|
||||
? ""
|
||||
: " limit " + options.limit + " offset " + options.offset))
|
||||
.all(sqlParameters);
|
||||
if (options.limit === -1) {
|
||||
count = lotOccupancies.length;
|
||||
}
|
||||
if (options.includeOccupants) {
|
||||
for (const lotOccupancy of lotOccupancies) {
|
||||
for (const lotOccupancy of lotOccupancies) {
|
||||
const occupancyType = getOccupancyTypeById(lotOccupancy.occupancyTypeId);
|
||||
if (occupancyType) {
|
||||
lotOccupancy.printEJS = occupancyType.occupancyTypePrints.includes("*")
|
||||
? configFunctions.getProperty("settings.lotOccupancy.prints")[0]
|
||||
: occupancyType.occupancyTypePrints[0];
|
||||
}
|
||||
if (options.includeOccupants) {
|
||||
lotOccupancy.lotOccupancyOccupants = getLotOccupancyOccupants(lotOccupancy.lotOccupancyId, database);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,9 @@ import {
|
|||
dateToInteger
|
||||
} from "@cityssm/expressjs-server-js/dateTimeFns.js";
|
||||
|
||||
import * as configFunctions from "../functions.config.js";
|
||||
|
||||
import { getOccupancyTypeById } from "../functions.cache.js";
|
||||
import { getLotOccupancyOccupants } from "./getLotOccupancyOccupants.js";
|
||||
|
||||
import type * as recordTypes from "../../types/recordTypes";
|
||||
|
|
@ -190,9 +193,9 @@ export const getLotOccupancies = (
|
|||
" left join Maps m on l.mapId = m.mapId" +
|
||||
sqlWhereClause +
|
||||
" order by o.occupancyStartDate desc, ifnull(o.occupancyEndDate, 99999999) desc, l.lotName, o.lotId" +
|
||||
(options.limit !== -1
|
||||
? " limit " + options.limit + " offset " + options.offset
|
||||
: "")
|
||||
(options.limit === -1
|
||||
? ""
|
||||
: " limit " + options.limit + " offset " + options.offset)
|
||||
)
|
||||
.all(sqlParameters);
|
||||
|
||||
|
|
@ -200,8 +203,16 @@ export const getLotOccupancies = (
|
|||
count = lotOccupancies.length;
|
||||
}
|
||||
|
||||
if (options.includeOccupants) {
|
||||
for (const lotOccupancy of lotOccupancies) {
|
||||
for (const lotOccupancy of lotOccupancies) {
|
||||
const occupancyType = getOccupancyTypeById(lotOccupancy.occupancyTypeId);
|
||||
|
||||
if (occupancyType) {
|
||||
lotOccupancy.printEJS = occupancyType.occupancyTypePrints.includes("*")
|
||||
? configFunctions.getProperty("settings.lotOccupancy.prints")[0]
|
||||
: occupancyType.occupancyTypePrints[0];
|
||||
}
|
||||
|
||||
if (options.includeOccupants) {
|
||||
lotOccupancy.lotOccupancyOccupants = getLotOccupancyOccupants(
|
||||
lotOccupancy.lotOccupancyId as number,
|
||||
database
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
import sqlite from "better-sqlite3";
|
||||
export declare const getOccupancyTypePrints: (occupancyTypeId: number, connectedDatabase?: sqlite.Database) => string[];
|
||||
export default getOccupancyTypePrints;
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
import sqlite from "better-sqlite3";
|
||||
import * as configFunctions from "../functions.config.js";
|
||||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
||||
const availablePrints = configFunctions.getProperty("settings.lotOccupancy.prints");
|
||||
const userFunction_configContainsPrintEJS = (printEJS) => {
|
||||
if (printEJS === "*" || availablePrints.includes(printEJS)) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
};
|
||||
export const getOccupancyTypePrints = (occupancyTypeId, connectedDatabase) => {
|
||||
const database = connectedDatabase || sqlite(databasePath);
|
||||
database.function("userFn_configContainsPrintEJS", userFunction_configContainsPrintEJS);
|
||||
const results = database
|
||||
.prepare("select printEJS, orderNumber" +
|
||||
" from OccupancyTypePrints" +
|
||||
" where recordDelete_timeMillis is null" +
|
||||
" and occupancyTypeId = ?" +
|
||||
" and userFn_configContainsPrintEJS(printEJS) = 1" +
|
||||
" order by orderNumber, printEJS")
|
||||
.all(occupancyTypeId);
|
||||
let expectedOrderNumber = -1;
|
||||
const prints = [];
|
||||
for (const result of results) {
|
||||
expectedOrderNumber += 1;
|
||||
if (result.orderNumber !== expectedOrderNumber) {
|
||||
database
|
||||
.prepare("update OccupancyTypeFields" +
|
||||
" set orderNumber = ?" +
|
||||
" where occupancyTypeId = ?" +
|
||||
" and printEJS = ?")
|
||||
.run(expectedOrderNumber, occupancyTypeId, result.printEJS);
|
||||
}
|
||||
prints.push(result.printEJS);
|
||||
}
|
||||
if (!connectedDatabase) {
|
||||
database.close();
|
||||
}
|
||||
return prints;
|
||||
};
|
||||
export default getOccupancyTypePrints;
|
||||
|
|
@ -0,0 +1,63 @@
|
|||
import sqlite from "better-sqlite3";
|
||||
|
||||
import * as configFunctions from "../functions.config.js";
|
||||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
||||
|
||||
const availablePrints = configFunctions.getProperty("settings.lotOccupancy.prints");
|
||||
|
||||
const userFunction_configContainsPrintEJS = (printEJS: string): number => {
|
||||
if (printEJS === "*" || availablePrints.includes(printEJS)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
};
|
||||
|
||||
export const getOccupancyTypePrints = (
|
||||
occupancyTypeId: number,
|
||||
connectedDatabase?: sqlite.Database
|
||||
): string[] => {
|
||||
const database = connectedDatabase || sqlite(databasePath);
|
||||
|
||||
database.function("userFn_configContainsPrintEJS", userFunction_configContainsPrintEJS);
|
||||
|
||||
const results: { printEJS: string; orderNumber: number }[] = database
|
||||
.prepare(
|
||||
"select printEJS, orderNumber" +
|
||||
" from OccupancyTypePrints" +
|
||||
" where recordDelete_timeMillis is null" +
|
||||
" and occupancyTypeId = ?" +
|
||||
" and userFn_configContainsPrintEJS(printEJS) = 1" +
|
||||
" order by orderNumber, printEJS"
|
||||
)
|
||||
.all(occupancyTypeId);
|
||||
|
||||
let expectedOrderNumber = -1;
|
||||
|
||||
const prints = [];
|
||||
|
||||
for (const result of results) {
|
||||
expectedOrderNumber += 1;
|
||||
|
||||
if (result.orderNumber !== expectedOrderNumber) {
|
||||
database
|
||||
.prepare(
|
||||
"update OccupancyTypeFields" +
|
||||
" set orderNumber = ?" +
|
||||
" where occupancyTypeId = ?" +
|
||||
" and printEJS = ?"
|
||||
)
|
||||
.run(expectedOrderNumber, occupancyTypeId, result.printEJS);
|
||||
}
|
||||
|
||||
prints.push(result.printEJS);
|
||||
}
|
||||
|
||||
if (!connectedDatabase) {
|
||||
database.close();
|
||||
}
|
||||
|
||||
return prints;
|
||||
};
|
||||
|
||||
export default getOccupancyTypePrints;
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
import sqlite from "better-sqlite3";
|
||||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
||||
import { getOccupancyTypeFields } from "./getOccupancyTypeFields.js";
|
||||
import { getOccupancyTypePrints } from "./getOccupancyTypePrints.js";
|
||||
export const getOccupancyTypes = () => {
|
||||
const database = sqlite(databasePath);
|
||||
const occupancyTypes = database
|
||||
|
|
@ -19,6 +20,7 @@ export const getOccupancyTypes = () => {
|
|||
occupancyType.orderNumber = expectedTypeOrderNumber;
|
||||
}
|
||||
occupancyType.occupancyTypeFields = getOccupancyTypeFields(occupancyType.occupancyTypeId, database);
|
||||
occupancyType.occupancyTypePrints = getOccupancyTypePrints(occupancyType.occupancyTypeId, database);
|
||||
let expectedFieldOrderNumber = -1;
|
||||
for (const occupancyTypeField of occupancyType.occupancyTypeFields) {
|
||||
expectedFieldOrderNumber += 1;
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import sqlite from "better-sqlite3";
|
|||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
||||
|
||||
import { getOccupancyTypeFields } from "./getOccupancyTypeFields.js";
|
||||
import { getOccupancyTypePrints } from "./getOccupancyTypePrints.js";
|
||||
|
||||
import type * as recordTypes from "../../types/recordTypes";
|
||||
|
||||
|
|
@ -38,6 +39,11 @@ export const getOccupancyTypes = (): recordTypes.OccupancyType[] => {
|
|||
database
|
||||
);
|
||||
|
||||
occupancyType.occupancyTypePrints = getOccupancyTypePrints(
|
||||
occupancyType.occupancyTypeId,
|
||||
database
|
||||
);
|
||||
|
||||
let expectedFieldOrderNumber = -1;
|
||||
|
||||
for (const occupancyTypeField of occupancyType.occupancyTypeFields) {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
(() => {
|
||||
const los = exports.los;
|
||||
const lotOccupancyPrints = exports.lotOccupancyPrints;
|
||||
const searchFilterFormElement = document.querySelector("#form--searchFilters");
|
||||
const searchResultsContainerElement = document.querySelector("#container--searchResults");
|
||||
const limit = Number.parseInt(document.querySelector("#searchFilter--limit").value, 10);
|
||||
|
|
@ -111,19 +110,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|||
: '<span class="has-text-grey">(No End Date)</span>') +
|
||||
"</td>") +
|
||||
("<td>" + occupantsHTML + "</td>") +
|
||||
(lotOccupancyPrints.length > 0
|
||||
? "<td>" +
|
||||
'<a class="button is-small" data-tooltip="Print" href="' +
|
||||
"<td>" +
|
||||
(lotOccupancy.printEJS
|
||||
? '<a class="button is-small" data-tooltip="Print" href="' +
|
||||
los.urlPrefix +
|
||||
"/print/" +
|
||||
lotOccupancyPrints[0] +
|
||||
lotOccupancy.printEJS +
|
||||
"/?lotOccupancyId=" +
|
||||
lotOccupancy.lotOccupancyId +
|
||||
'" target="_blank">' +
|
||||
'<i class="fas fa-print" aria-label="Print"></i>' +
|
||||
"</a>" +
|
||||
"</td>"
|
||||
"</a>"
|
||||
: "") +
|
||||
"</td>" +
|
||||
"</tr>");
|
||||
}
|
||||
searchResultsContainerElement.innerHTML =
|
||||
|
|
@ -135,9 +134,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|||
("<th>" + cityssm.escapeHTML(exports.aliases.occupancyStartDate) + "</th>") +
|
||||
"<th>End Date</th>" +
|
||||
("<th>" + cityssm.escapeHTML(exports.aliases.occupants) + "</th>") +
|
||||
(lotOccupancyPrints.length > 0
|
||||
? '<th class="has-width-1"><span class="is-sr-only">Print</span></th>'
|
||||
: "") +
|
||||
'<th class="has-width-1"><span class="is-sr-only">Print</span></th>' +
|
||||
"</tr></thead>" +
|
||||
"<table>" +
|
||||
'<div class="level">' +
|
||||
|
|
|
|||
|
|
@ -10,8 +10,6 @@ declare const cityssm: cityssmGlobal;
|
|||
(() => {
|
||||
const los = exports.los as globalTypes.LOS;
|
||||
|
||||
const lotOccupancyPrints: string[] = exports.lotOccupancyPrints;
|
||||
|
||||
const searchFilterFormElement = document.querySelector(
|
||||
"#form--searchFilters"
|
||||
) as HTMLFormElement;
|
||||
|
|
@ -145,19 +143,19 @@ declare const cityssm: cityssmGlobal;
|
|||
: '<span class="has-text-grey">(No End Date)</span>') +
|
||||
"</td>") +
|
||||
("<td>" + occupantsHTML + "</td>") +
|
||||
(lotOccupancyPrints.length > 0
|
||||
? "<td>" +
|
||||
'<a class="button is-small" data-tooltip="Print" href="' +
|
||||
"<td>" +
|
||||
(lotOccupancy.printEJS
|
||||
? '<a class="button is-small" data-tooltip="Print" href="' +
|
||||
los.urlPrefix +
|
||||
"/print/" +
|
||||
lotOccupancyPrints[0] +
|
||||
lotOccupancy.printEJS +
|
||||
"/?lotOccupancyId=" +
|
||||
lotOccupancy.lotOccupancyId +
|
||||
'" target="_blank">' +
|
||||
'<i class="fas fa-print" aria-label="Print"></i>' +
|
||||
"</a>" +
|
||||
"</td>"
|
||||
"</a>"
|
||||
: "") +
|
||||
"</td>" +
|
||||
"</tr>"
|
||||
);
|
||||
}
|
||||
|
|
@ -171,9 +169,7 @@ declare const cityssm: cityssmGlobal;
|
|||
("<th>" + cityssm.escapeHTML(exports.aliases.occupancyStartDate) + "</th>") +
|
||||
"<th>End Date</th>" +
|
||||
("<th>" + cityssm.escapeHTML(exports.aliases.occupants) + "</th>") +
|
||||
(lotOccupancyPrints.length > 0
|
||||
? '<th class="has-width-1"><span class="is-sr-only">Print</span></th>'
|
||||
: "") +
|
||||
'<th class="has-width-1"><span class="is-sr-only">Print</span></th>' +
|
||||
"</tr></thead>" +
|
||||
"<table>" +
|
||||
'<div class="level">' +
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),(()=>{const t=exports.los,a=exports.lotOccupancyPrints,e=document.querySelector("#form--searchFilters"),s=document.querySelector("#container--searchResults"),c=Number.parseInt(document.querySelector("#searchFilter--limit").value,10),i=document.querySelector("#searchFilter--offset"),o=()=>{const o=Number.parseInt(i.value,10);s.innerHTML='<div class="has-text-grey has-text-centered"><i class="fas fa-5x fa-circle-notch fa-spin" aria-hidden="true"></i><br />Loading '+exports.aliases.occupancies+"...</div>",cityssm.postJSON(t.urlPrefix+"/lotOccupancies/doSearchLotOccupancies",e,e=>{if(0===e.lotOccupancies.length)return void(s.innerHTML='<div class="message is-info"><p class="message-body">There are no '+cityssm.escapeHTML(exports.aliases.occupancy.toLowerCase())+" records that meet the search criteria.</p></div>");const i=document.createElement("tbody"),r=cityssm.dateToString(new Date);for(const s of e.lotOccupancies){let e="";e=s.occupancyStartDateString<=r&&(""===s.occupancyEndDateString||s.occupancyEndDateString>=r)?'<span class="has-tooltip-right" data-tooltip="Current '+exports.aliases.occupancy+'"><i class="fas fa-play" aria-label="Current '+exports.aliases.occupancy+'"></i></span>':s.occupancyStartDateString>r?'<span class="has-tooltip-right" data-tooltip="Future '+exports.aliases.occupancy+'"><i class="fas fa-fast-forward" aria-label="Future '+exports.aliases.occupancy+'"></i></span>':'<span class="has-tooltip-right" data-tooltip="Past '+exports.aliases.occupancy+'"><i class="fas fa-stop" aria-label="Past '+exports.aliases.occupancy+'"></i></span>';let c="";for(const t of s.lotOccupancyOccupants)c+='<span class="has-tooltip-left" data-tooltip="'+cityssm.escapeHTML(t.lotOccupantType||"")+'"><i class="fas fa-fw fa-'+cityssm.escapeHTML(t.fontAwesomeIconClass||"user")+'" aria-hidden="true"></i> '+cityssm.escapeHTML(t.occupantName||"")+"</span><br />";i.insertAdjacentHTML("beforeend",'<tr><td class="has-width-1">'+e+'</td><td><a class="has-text-weight-bold" href="'+t.urlPrefix+"/lotOccupancies/"+s.lotOccupancyId+'">'+cityssm.escapeHTML(s.occupancyType)+"</a></td><td>"+(s.lotName?'<a class="has-tooltip-right" data-tooltip="'+cityssm.escapeHTML(s.lotType||"")+'" href="'+t.urlPrefix+"/lots/"+s.lotId+'">'+cityssm.escapeHTML(s.lotName)+"</a>":'<span class="has-text-grey">(No '+cityssm.escapeHTML(exports.aliases.lot)+")</span>")+'<br /><span class="is-size-7">'+cityssm.escapeHTML(s.mapName||"")+"</span></td><td>"+s.occupancyStartDateString+"</td><td>"+(s.occupancyEndDate?s.occupancyEndDateString:'<span class="has-text-grey">(No End Date)</span>')+"</td><td>"+c+"</td>"+(a.length>0?'<td><a class="button is-small" data-tooltip="Print" href="'+t.urlPrefix+"/print/"+a[0]+"/?lotOccupancyId="+s.lotOccupancyId+'" target="_blank"><i class="fas fa-print" aria-label="Print"></i></a></td>':"")+"</tr>")}s.innerHTML='<table class="table is-fullwidth is-striped is-hoverable has-sticky-header"><thead><tr><th class="has-width-1"></th><th>'+cityssm.escapeHTML(exports.aliases.occupancy)+" Type</th><th>"+cityssm.escapeHTML(exports.aliases.lot)+"</th><th>"+cityssm.escapeHTML(exports.aliases.occupancyStartDate)+"</th><th>End Date</th><th>"+cityssm.escapeHTML(exports.aliases.occupants)+"</th>"+(a.length>0?'<th class="has-width-1"><span class="is-sr-only">Print</span></th>':"")+'</tr></thead><table><div class="level"><div class="level-left"><div class="level-item has-text-weight-bold">Displaying '+(o+1).toString()+" to "+Math.min(e.count,c+o)+" of "+e.count+'</div></div><div class="level-right">'+(o>0?'<div class="level-item"><button class="button is-rounded is-link is-outlined" data-page="previous" type="button" title="Previous"><i class="fas fa-arrow-left" aria-hidden="true"></i></button></div>':"")+(c+o<e.count?'<div class="level-item"><button class="button is-rounded is-link" data-page="next" type="button" title="Next"><span>Next</span><span class="icon"><i class="fas fa-arrow-right" aria-hidden="true"></i></span></button></div>':"")+"</div></div>",s.querySelector("table").append(i),o>0&&s.querySelector("button[data-page='previous']").addEventListener("click",l),c+o<e.count&&s.querySelector("button[data-page='next']").addEventListener("click",n)})},r=()=>{i.value="0",o()},l=()=>{i.value=Math.max(Number.parseInt(i.value,10)-c,0).toString(),o()},n=()=>{i.value=(Number.parseInt(i.value,10)+c).toString(),o()},p=e.querySelectorAll("input, select");for(const t of p)t.addEventListener("change",r);e.addEventListener("submit",t=>{t.preventDefault(),r()}),o()})();
|
||||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),(()=>{const t=exports.los,a=document.querySelector("#form--searchFilters"),e=document.querySelector("#container--searchResults"),s=Number.parseInt(document.querySelector("#searchFilter--limit").value,10),c=document.querySelector("#searchFilter--offset"),i=()=>{const i=Number.parseInt(c.value,10);e.innerHTML='<div class="has-text-grey has-text-centered"><i class="fas fa-5x fa-circle-notch fa-spin" aria-hidden="true"></i><br />Loading '+exports.aliases.occupancies+"...</div>",cityssm.postJSON(t.urlPrefix+"/lotOccupancies/doSearchLotOccupancies",a,a=>{if(0===a.lotOccupancies.length)return void(e.innerHTML='<div class="message is-info"><p class="message-body">There are no '+cityssm.escapeHTML(exports.aliases.occupancy.toLowerCase())+" records that meet the search criteria.</p></div>");const c=document.createElement("tbody"),r=cityssm.dateToString(new Date);for(const e of a.lotOccupancies){let a="";a=e.occupancyStartDateString<=r&&(""===e.occupancyEndDateString||e.occupancyEndDateString>=r)?'<span class="has-tooltip-right" data-tooltip="Current '+exports.aliases.occupancy+'"><i class="fas fa-play" aria-label="Current '+exports.aliases.occupancy+'"></i></span>':e.occupancyStartDateString>r?'<span class="has-tooltip-right" data-tooltip="Future '+exports.aliases.occupancy+'"><i class="fas fa-fast-forward" aria-label="Future '+exports.aliases.occupancy+'"></i></span>':'<span class="has-tooltip-right" data-tooltip="Past '+exports.aliases.occupancy+'"><i class="fas fa-stop" aria-label="Past '+exports.aliases.occupancy+'"></i></span>';let s="";for(const t of e.lotOccupancyOccupants)s+='<span class="has-tooltip-left" data-tooltip="'+cityssm.escapeHTML(t.lotOccupantType||"")+'"><i class="fas fa-fw fa-'+cityssm.escapeHTML(t.fontAwesomeIconClass||"user")+'" aria-hidden="true"></i> '+cityssm.escapeHTML(t.occupantName||"")+"</span><br />";c.insertAdjacentHTML("beforeend",'<tr><td class="has-width-1">'+a+'</td><td><a class="has-text-weight-bold" href="'+t.urlPrefix+"/lotOccupancies/"+e.lotOccupancyId+'">'+cityssm.escapeHTML(e.occupancyType)+"</a></td><td>"+(e.lotName?'<a class="has-tooltip-right" data-tooltip="'+cityssm.escapeHTML(e.lotType||"")+'" href="'+t.urlPrefix+"/lots/"+e.lotId+'">'+cityssm.escapeHTML(e.lotName)+"</a>":'<span class="has-text-grey">(No '+cityssm.escapeHTML(exports.aliases.lot)+")</span>")+'<br /><span class="is-size-7">'+cityssm.escapeHTML(e.mapName||"")+"</span></td><td>"+e.occupancyStartDateString+"</td><td>"+(e.occupancyEndDate?e.occupancyEndDateString:'<span class="has-text-grey">(No End Date)</span>')+"</td><td>"+s+"</td><td>"+(e.printEJS?'<a class="button is-small" data-tooltip="Print" href="'+t.urlPrefix+"/print/"+e.printEJS+"/?lotOccupancyId="+e.lotOccupancyId+'" target="_blank"><i class="fas fa-print" aria-label="Print"></i></a>':"")+"</td></tr>")}e.innerHTML='<table class="table is-fullwidth is-striped is-hoverable has-sticky-header"><thead><tr><th class="has-width-1"></th><th>'+cityssm.escapeHTML(exports.aliases.occupancy)+" Type</th><th>"+cityssm.escapeHTML(exports.aliases.lot)+"</th><th>"+cityssm.escapeHTML(exports.aliases.occupancyStartDate)+"</th><th>End Date</th><th>"+cityssm.escapeHTML(exports.aliases.occupants)+'</th><th class="has-width-1"><span class="is-sr-only">Print</span></th></tr></thead><table><div class="level"><div class="level-left"><div class="level-item has-text-weight-bold">Displaying '+(i+1).toString()+" to "+Math.min(a.count,s+i)+" of "+a.count+'</div></div><div class="level-right">'+(i>0?'<div class="level-item"><button class="button is-rounded is-link is-outlined" data-page="previous" type="button" title="Previous"><i class="fas fa-arrow-left" aria-hidden="true"></i></button></div>':"")+(s+i<a.count?'<div class="level-item"><button class="button is-rounded is-link" data-page="next" type="button" title="Next"><span>Next</span><span class="icon"><i class="fas fa-arrow-right" aria-hidden="true"></i></span></button></div>':"")+"</div></div>",e.querySelector("table").append(c),i>0&&e.querySelector("button[data-page='previous']").addEventListener("click",o),s+i<a.count&&e.querySelector("button[data-page='next']").addEventListener("click",n)})},r=()=>{c.value="0",i()},o=()=>{c.value=Math.max(Number.parseInt(c.value,10)-s,0).toString(),i()},n=()=>{c.value=(Number.parseInt(c.value,10)+s).toString(),i()},l=a.querySelectorAll("input, select");for(const t of l)t.addEventListener("change",r);a.addEventListener("submit",t=>{t.preventDefault(),r()}),i()})();
|
||||
|
|
@ -80,6 +80,7 @@ export interface OccupancyType extends Record {
|
|||
occupancyType: string;
|
||||
orderNumber?: number;
|
||||
occupancyTypeFields?: OccupancyTypeField[];
|
||||
occupancyTypePrints?: string[];
|
||||
}
|
||||
export interface OccupancyTypeField {
|
||||
occupancyTypeFieldId?: number;
|
||||
|
|
@ -178,6 +179,7 @@ export interface LotOccupancy extends Record {
|
|||
lotOccupancyId?: number;
|
||||
occupancyTypeId?: number;
|
||||
occupancyType?: string;
|
||||
printEJS?: string;
|
||||
lotId?: number;
|
||||
lotTypeId?: number;
|
||||
lotType?: string;
|
||||
|
|
|
|||
|
|
@ -108,6 +108,7 @@ export interface OccupancyType extends Record {
|
|||
occupancyType: string;
|
||||
orderNumber?: number;
|
||||
occupancyTypeFields?: OccupancyTypeField[];
|
||||
occupancyTypePrints?: string[];
|
||||
}
|
||||
|
||||
export interface OccupancyTypeField {
|
||||
|
|
@ -236,6 +237,7 @@ export interface LotOccupancy extends Record {
|
|||
|
||||
occupancyTypeId?: number;
|
||||
occupancyType?: string;
|
||||
printEJS?: string;
|
||||
|
||||
lotId?: number;
|
||||
lotTypeId?: number;
|
||||
|
|
|
|||
|
|
@ -46,10 +46,10 @@
|
|||
</h1>
|
||||
</div>
|
||||
</div>
|
||||
<% if (configFunctions.getProperty("settings.lotOccupancy.prints").length > 0) { %>
|
||||
<% if (occupancyTypePrints.length > 0) { %>
|
||||
<div class="level-right is-hidden-print">
|
||||
<div class="level-item is-justify-content-right">
|
||||
<% if (configFunctions.getProperty("settings.lotOccupancy.prints").length === 1) { %>
|
||||
<% if (occupancyTypePrints.length === 1) { %>
|
||||
<a class="button is-link" href="<%= urlPrefix %>/print/<%= configFunctions.getProperty("settings.lotOccupancy.prints")[0] %>/?lotOccupancyId=<%= lotOccupancy.lotOccupancyId %>" target="_blank">
|
||||
<span class="icon is-small"><i class="fas fa-print" aria-hidden="true"></i></span>
|
||||
<span>Print</span>
|
||||
|
|
@ -65,7 +65,7 @@
|
|||
</div>
|
||||
<div class="dropdown-menu">
|
||||
<div class="dropdown-content">
|
||||
<% for (const printName of configFunctions.getProperty("settings.lotOccupancy.prints")) { %>
|
||||
<% for (const printName of occupancyTypePrints) { %>
|
||||
<% const printConfig = printFunctions.getPrintConfig(printName); %>
|
||||
<% if (printConfig) { %>
|
||||
<a class="dropdown-item" href="<%= urlPrefix %>/print/<%= printName %>/?lotOccupancyId=<%= lotOccupancy.lotOccupancyId %>" target="_blank">
|
||||
|
|
|
|||
|
|
@ -151,9 +151,6 @@
|
|||
|
||||
<%- include('_footerA'); -%>
|
||||
|
||||
<script>
|
||||
exports.lotOccupancyPrints = <%- JSON.stringify(configFunctions.getProperty("settings.lotOccupancy.prints")) %>;
|
||||
</script>
|
||||
<script src="<%= urlPrefix %>/javascripts/lotOccupancySearch.min.js"></script>
|
||||
|
||||
<%- include('_footerB'); -%>
|
||||
|
|
|
|||
|
|
@ -31,11 +31,11 @@
|
|||
</h1>
|
||||
</div>
|
||||
</div>
|
||||
<% if (configFunctions.getProperty("settings.lotOccupancy.prints").length > 0) { %>
|
||||
<% if (occupancyTypePrints.length > 0) { %>
|
||||
<div class="level-right is-hidden-print">
|
||||
<div class="level-item is-justify-content-right">
|
||||
<% if (configFunctions.getProperty("settings.lotOccupancy.prints").length === 1) { %>
|
||||
<a class="button is-link" href="<%= urlPrefix %>/print/<%= configFunctions.getProperty("settings.lotOccupancy.prints")[0] %>/?lotOccupancyId=<%= lotOccupancy.lotOccupancyId %>" target="_blank">
|
||||
<% if (occupancyTypePrints.length === 1) { %>
|
||||
<a class="button is-link" href="<%= urlPrefix %>/print/<%= occupancyTypePrints[0] %>/?lotOccupancyId=<%= lotOccupancy.lotOccupancyId %>" target="_blank">
|
||||
<span class="icon is-small"><i class="fas fa-print" aria-hidden="true"></i></span>
|
||||
<span>Print</span>
|
||||
</a>
|
||||
|
|
@ -50,7 +50,7 @@
|
|||
</div>
|
||||
<div class="dropdown-menu">
|
||||
<div class="dropdown-content">
|
||||
<% for (const printName of configFunctions.getProperty("settings.lotOccupancy.prints")) { %>
|
||||
<% for (const printName of occupancyTypePrints) { %>
|
||||
<% const printConfig = printFunctions.getPrintConfig(printName); %>
|
||||
<% if (printConfig) { %>
|
||||
<a class="dropdown-item" href="<%= urlPrefix %>/print/<%= printName %>/?lotOccupancyId=<%= lotOccupancy.lotOccupancyId %>" target="_blank">
|
||||
|
|
|
|||
Loading…
Reference in New Issue