prepare to accommodate multiple print styles
parent
81683d0420
commit
d100efc9bc
17
app.js
17
app.js
|
|
@ -10,13 +10,15 @@ import FileStore from "session-file-store";
|
||||||
import routerLogin from "./routes/login.js";
|
import routerLogin from "./routes/login.js";
|
||||||
import routerDashboard from "./routes/dashboard.js";
|
import routerDashboard from "./routes/dashboard.js";
|
||||||
import routerApi from "./routes/api.js";
|
import routerApi from "./routes/api.js";
|
||||||
import routerLots from "./routes/lots.js";
|
import routerPrint from "./routes/print.js";
|
||||||
import routerMaps from "./routes/maps.js";
|
import routerMaps from "./routes/maps.js";
|
||||||
|
import routerLots from "./routes/lots.js";
|
||||||
import routerLotOccupancies from "./routes/lotOccupancies.js";
|
import routerLotOccupancies from "./routes/lotOccupancies.js";
|
||||||
import routerWorkOrders from "./routes/workOrders.js";
|
import routerWorkOrders from "./routes/workOrders.js";
|
||||||
import routerReports from "./routes/reports.js";
|
import routerReports from "./routes/reports.js";
|
||||||
import routerAdmin from "./routes/admin.js";
|
import routerAdmin from "./routes/admin.js";
|
||||||
import * as configFunctions from "./helpers/functions.config.js";
|
import * as configFunctions from "./helpers/functions.config.js";
|
||||||
|
import * as printFunctions from "./helpers/functions.print.js";
|
||||||
import * as dateTimeFns from "@cityssm/expressjs-server-js/dateTimeFns.js";
|
import * as dateTimeFns from "@cityssm/expressjs-server-js/dateTimeFns.js";
|
||||||
import * as stringFns from "@cityssm/expressjs-server-js/stringFns.js";
|
import * as stringFns from "@cityssm/expressjs-server-js/stringFns.js";
|
||||||
import * as htmlFns from "@cityssm/expressjs-server-js/htmlFns.js";
|
import * as htmlFns from "@cityssm/expressjs-server-js/htmlFns.js";
|
||||||
|
|
@ -102,6 +104,7 @@ app.use((request, response, next) => {
|
||||||
response.locals.user = request.session.user;
|
response.locals.user = request.session.user;
|
||||||
response.locals.csrfToken = request.csrfToken();
|
response.locals.csrfToken = request.csrfToken();
|
||||||
response.locals.configFunctions = configFunctions;
|
response.locals.configFunctions = configFunctions;
|
||||||
|
response.locals.printFunctions = printFunctions;
|
||||||
response.locals.dateTimeFunctions = dateTimeFns;
|
response.locals.dateTimeFunctions = dateTimeFns;
|
||||||
response.locals.stringFunctions = stringFns;
|
response.locals.stringFunctions = stringFns;
|
||||||
response.locals.htmlFunctions = htmlFns;
|
response.locals.htmlFunctions = htmlFns;
|
||||||
|
|
@ -113,8 +116,9 @@ app.get(urlPrefix + "/", sessionChecker, (_request, response) => {
|
||||||
});
|
});
|
||||||
app.use(urlPrefix + "/dashboard", sessionChecker, routerDashboard);
|
app.use(urlPrefix + "/dashboard", sessionChecker, routerDashboard);
|
||||||
app.use(urlPrefix + "/api/:apiKey", apiGetHandler, routerApi);
|
app.use(urlPrefix + "/api/:apiKey", apiGetHandler, routerApi);
|
||||||
app.use(urlPrefix + "/lots", sessionChecker, routerLots);
|
app.use(urlPrefix + "/print", sessionChecker, routerPrint);
|
||||||
app.use(urlPrefix + "/maps", sessionChecker, routerMaps);
|
app.use(urlPrefix + "/maps", sessionChecker, routerMaps);
|
||||||
|
app.use(urlPrefix + "/lots", sessionChecker, routerLots);
|
||||||
app.use(urlPrefix + "/lotOccupancies", sessionChecker, routerLotOccupancies);
|
app.use(urlPrefix + "/lotOccupancies", sessionChecker, routerLotOccupancies);
|
||||||
app.use(urlPrefix + "/workOrders", sessionChecker, routerWorkOrders);
|
app.use(urlPrefix + "/workOrders", sessionChecker, routerWorkOrders);
|
||||||
app.use(urlPrefix + "/reports", sessionChecker, routerReports);
|
app.use(urlPrefix + "/reports", sessionChecker, routerReports);
|
||||||
|
|
@ -135,13 +139,6 @@ app.get(urlPrefix + "/logout", (request, response) => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
app.use((_request, _response, next) => {
|
app.use((_request, _response, next) => {
|
||||||
next(createError(404));
|
next(createError(404, "File not found."));
|
||||||
});
|
|
||||||
app.use((error, request, response) => {
|
|
||||||
response.locals.message = error.message;
|
|
||||||
response.locals.error =
|
|
||||||
request.app.get("env") === "development" ? error : {};
|
|
||||||
response.status(error.status || 500);
|
|
||||||
response.render("error");
|
|
||||||
});
|
});
|
||||||
export default app;
|
export default app;
|
||||||
|
|
|
||||||
57
app.ts
57
app.ts
|
|
@ -13,14 +13,16 @@ import FileStore from "session-file-store";
|
||||||
import routerLogin from "./routes/login.js";
|
import routerLogin from "./routes/login.js";
|
||||||
import routerDashboard from "./routes/dashboard.js";
|
import routerDashboard from "./routes/dashboard.js";
|
||||||
import routerApi from "./routes/api.js";
|
import routerApi from "./routes/api.js";
|
||||||
import routerLots from "./routes/lots.js";
|
import routerPrint from "./routes/print.js";
|
||||||
import routerMaps from "./routes/maps.js";
|
import routerMaps from "./routes/maps.js";
|
||||||
|
import routerLots from "./routes/lots.js";
|
||||||
import routerLotOccupancies from "./routes/lotOccupancies.js";
|
import routerLotOccupancies from "./routes/lotOccupancies.js";
|
||||||
import routerWorkOrders from "./routes/workOrders.js";
|
import routerWorkOrders from "./routes/workOrders.js";
|
||||||
import routerReports from "./routes/reports.js";
|
import routerReports from "./routes/reports.js";
|
||||||
import routerAdmin from "./routes/admin.js";
|
import routerAdmin from "./routes/admin.js";
|
||||||
|
|
||||||
import * as configFunctions from "./helpers/functions.config.js";
|
import * as configFunctions from "./helpers/functions.config.js";
|
||||||
|
import * as printFunctions from "./helpers/functions.print.js";
|
||||||
import * as dateTimeFns from "@cityssm/expressjs-server-js/dateTimeFns.js";
|
import * as dateTimeFns from "@cityssm/expressjs-server-js/dateTimeFns.js";
|
||||||
import * as stringFns from "@cityssm/expressjs-server-js/stringFns.js";
|
import * as stringFns from "@cityssm/expressjs-server-js/stringFns.js";
|
||||||
import * as htmlFns from "@cityssm/expressjs-server-js/htmlFns.js";
|
import * as htmlFns from "@cityssm/expressjs-server-js/htmlFns.js";
|
||||||
|
|
@ -54,7 +56,6 @@ if (!configFunctions.getProperty("reverseProxy.disableEtag")) {
|
||||||
app.set("etag", false);
|
app.set("etag", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// View engine setup
|
// View engine setup
|
||||||
app.set("views", path.join(__dirname, "views"));
|
app.set("views", path.join(__dirname, "views"));
|
||||||
app.set("view engine", "ejs");
|
app.set("view engine", "ejs");
|
||||||
|
|
@ -123,27 +124,18 @@ app.use(
|
||||||
|
|
||||||
app.use(
|
app.use(
|
||||||
urlPrefix + "/lib/fa",
|
urlPrefix + "/lib/fa",
|
||||||
express.static(
|
express.static(path.join("node_modules", "@fortawesome", "fontawesome-free"))
|
||||||
path.join("node_modules", "@fortawesome", "fontawesome-free")
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
app.use(
|
app.use(urlPrefix + "/lib/leaflet", express.static(path.join("node_modules", "leaflet", "dist")));
|
||||||
urlPrefix + "/lib/leaflet",
|
|
||||||
express.static(path.join("node_modules", "leaflet", "dist"))
|
|
||||||
);
|
|
||||||
|
|
||||||
app.use(
|
app.use(urlPrefix + "/lib/randomcolor", express.static(path.join("node_modules", "randomcolor")));
|
||||||
urlPrefix + "/lib/randomcolor",
|
|
||||||
express.static(path.join("node_modules", "randomcolor"))
|
|
||||||
);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* SESSION MANAGEMENT
|
* SESSION MANAGEMENT
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const sessionCookieName: string =
|
const sessionCookieName: string = configFunctions.getProperty("session.cookieName");
|
||||||
configFunctions.getProperty("session.cookieName");
|
|
||||||
|
|
||||||
const FileStoreSession = FileStore(session);
|
const FileStoreSession = FileStore(session);
|
||||||
|
|
||||||
|
|
@ -188,9 +180,7 @@ const sessionChecker = (
|
||||||
|
|
||||||
const redirectUrl = getSafeRedirectURL(request.originalUrl);
|
const redirectUrl = getSafeRedirectURL(request.originalUrl);
|
||||||
|
|
||||||
return response.redirect(
|
return response.redirect(`${urlPrefix}/login?redirect=${redirectUrl}`);
|
||||||
`${urlPrefix}/login?redirect=${redirectUrl}`
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -206,13 +196,12 @@ app.use((request, response, next) => {
|
||||||
response.locals.csrfToken = request.csrfToken();
|
response.locals.csrfToken = request.csrfToken();
|
||||||
|
|
||||||
response.locals.configFunctions = configFunctions;
|
response.locals.configFunctions = configFunctions;
|
||||||
|
response.locals.printFunctions = printFunctions;
|
||||||
response.locals.dateTimeFunctions = dateTimeFns;
|
response.locals.dateTimeFunctions = dateTimeFns;
|
||||||
response.locals.stringFunctions = stringFns;
|
response.locals.stringFunctions = stringFns;
|
||||||
response.locals.htmlFunctions = htmlFns;
|
response.locals.htmlFunctions = htmlFns;
|
||||||
|
|
||||||
response.locals.urlPrefix = configFunctions.getProperty(
|
response.locals.urlPrefix = configFunctions.getProperty("reverseProxy.urlPrefix");
|
||||||
"reverseProxy.urlPrefix"
|
|
||||||
);
|
|
||||||
|
|
||||||
next();
|
next();
|
||||||
});
|
});
|
||||||
|
|
@ -225,8 +214,9 @@ app.use(urlPrefix + "/dashboard", sessionChecker, routerDashboard);
|
||||||
|
|
||||||
app.use(urlPrefix + "/api/:apiKey", apiGetHandler, routerApi);
|
app.use(urlPrefix + "/api/:apiKey", apiGetHandler, routerApi);
|
||||||
|
|
||||||
app.use(urlPrefix + "/lots", sessionChecker, routerLots);
|
app.use(urlPrefix + "/print", sessionChecker, routerPrint);
|
||||||
app.use(urlPrefix + "/maps", sessionChecker, routerMaps);
|
app.use(urlPrefix + "/maps", sessionChecker, routerMaps);
|
||||||
|
app.use(urlPrefix + "/lots", sessionChecker, routerLots);
|
||||||
app.use(urlPrefix + "/lotOccupancies", sessionChecker, routerLotOccupancies);
|
app.use(urlPrefix + "/lotOccupancies", sessionChecker, routerLotOccupancies);
|
||||||
app.use(urlPrefix + "/workOrders", sessionChecker, routerWorkOrders);
|
app.use(urlPrefix + "/workOrders", sessionChecker, routerWorkOrders);
|
||||||
|
|
||||||
|
|
@ -253,28 +243,7 @@ app.get(urlPrefix + "/logout", (request, response) => {
|
||||||
|
|
||||||
// Catch 404 and forward to error handler
|
// Catch 404 and forward to error handler
|
||||||
app.use((_request, _response, next) => {
|
app.use((_request, _response, next) => {
|
||||||
next(createError(404));
|
next(createError(404, "File not found."));
|
||||||
});
|
});
|
||||||
|
|
||||||
// Error handler
|
|
||||||
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 : {};
|
|
||||||
|
|
||||||
// Render the error page
|
|
||||||
response.status(error.status || 500);
|
|
||||||
response.render("error");
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
export default app;
|
export default app;
|
||||||
|
|
|
||||||
|
|
@ -1,17 +0,0 @@
|
||||||
import * as configFunctions from "../../helpers/functions.config.js";
|
|
||||||
import { getLotOccupancy } from "../../helpers/lotOccupancyDB/getLotOccupancy.js";
|
|
||||||
export const handler = (request, response) => {
|
|
||||||
const lotOccupancy = getLotOccupancy(request.params.lotOccupancyId);
|
|
||||||
if (!lotOccupancy) {
|
|
||||||
return response.redirect(configFunctions.getProperty("reverseProxy.urlPrefix") +
|
|
||||||
"/lotOccupancies/?error=lotOccupancyIdNotFound");
|
|
||||||
}
|
|
||||||
return response.render("lotOccupancy-print", {
|
|
||||||
headTitle: configFunctions.getProperty("aliases.lot") +
|
|
||||||
" " +
|
|
||||||
configFunctions.getProperty("aliases.occupancy") +
|
|
||||||
" Print",
|
|
||||||
lotOccupancy
|
|
||||||
});
|
|
||||||
};
|
|
||||||
export default handler;
|
|
||||||
|
|
@ -1,27 +0,0 @@
|
||||||
import type { RequestHandler } from "express";
|
|
||||||
|
|
||||||
import * as configFunctions from "../../helpers/functions.config.js";
|
|
||||||
|
|
||||||
import { getLotOccupancy } from "../../helpers/lotOccupancyDB/getLotOccupancy.js";
|
|
||||||
|
|
||||||
export const handler: RequestHandler = (request, response) => {
|
|
||||||
const lotOccupancy = getLotOccupancy(request.params.lotOccupancyId);
|
|
||||||
|
|
||||||
if (!lotOccupancy) {
|
|
||||||
return response.redirect(
|
|
||||||
configFunctions.getProperty("reverseProxy.urlPrefix") +
|
|
||||||
"/lotOccupancies/?error=lotOccupancyIdNotFound"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return response.render("lotOccupancy-print", {
|
|
||||||
headTitle:
|
|
||||||
configFunctions.getProperty("aliases.lot") +
|
|
||||||
" " +
|
|
||||||
configFunctions.getProperty("aliases.occupancy") +
|
|
||||||
" Print",
|
|
||||||
lotOccupancy
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
export default handler;
|
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
import * as configFunctions from "../../helpers/functions.config.js";
|
||||||
|
import { getScreenPrintConfig } from "../../helpers/functions.print.js";
|
||||||
|
import { getLotOccupancy } from "../../helpers/lotOccupancyDB/getLotOccupancy.js";
|
||||||
|
export const handler = (request, response) => {
|
||||||
|
const printName = request.params.printName;
|
||||||
|
const printConfig = getScreenPrintConfig(printName);
|
||||||
|
if (!printConfig) {
|
||||||
|
return response.redirect(configFunctions.getProperty("reverseProxy.urlPrefix") +
|
||||||
|
"/dashboard/?error=printConfigNotFound");
|
||||||
|
}
|
||||||
|
const reportData = {
|
||||||
|
headTitle: printConfig.title
|
||||||
|
};
|
||||||
|
if (printConfig.params.includes("lotOccupancyId") &&
|
||||||
|
typeof request.query.lotOccupancyId === "string") {
|
||||||
|
reportData.lotOccupancy = getLotOccupancy(request.query.lotOccupancyId);
|
||||||
|
}
|
||||||
|
return response.render("print/screen/" + printName, reportData);
|
||||||
|
};
|
||||||
|
export default handler;
|
||||||
|
|
@ -0,0 +1,34 @@
|
||||||
|
import type { RequestHandler } from "express";
|
||||||
|
|
||||||
|
import * as configFunctions from "../../helpers/functions.config.js";
|
||||||
|
import { getScreenPrintConfig } from "../../helpers/functions.print.js";
|
||||||
|
|
||||||
|
import { getLotOccupancy } from "../../helpers/lotOccupancyDB/getLotOccupancy.js";
|
||||||
|
|
||||||
|
export const handler: RequestHandler = (request, response) => {
|
||||||
|
const printName = request.params.printName;
|
||||||
|
|
||||||
|
const printConfig = getScreenPrintConfig(printName);
|
||||||
|
|
||||||
|
if (!printConfig) {
|
||||||
|
return response.redirect(
|
||||||
|
configFunctions.getProperty("reverseProxy.urlPrefix") +
|
||||||
|
"/dashboard/?error=printConfigNotFound"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const reportData: { [dataName: string]: unknown } = {
|
||||||
|
headTitle: printConfig.title
|
||||||
|
};
|
||||||
|
|
||||||
|
if (
|
||||||
|
printConfig.params.includes("lotOccupancyId") &&
|
||||||
|
typeof request.query.lotOccupancyId === "string"
|
||||||
|
) {
|
||||||
|
reportData.lotOccupancy = getLotOccupancy(request.query.lotOccupancyId);
|
||||||
|
}
|
||||||
|
|
||||||
|
return response.render("print/screen/" + printName, reportData);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default handler;
|
||||||
|
|
@ -32,6 +32,7 @@ export declare function getProperty(propertyName: "settings.lot.lotNameSortNameF
|
||||||
export declare function getProperty(propertyName: "settings.lotOccupancy.occupancyEndDateIsRequired"): boolean;
|
export declare function getProperty(propertyName: "settings.lotOccupancy.occupancyEndDateIsRequired"): boolean;
|
||||||
export declare function getProperty(propertyName: "settings.lotOccupancy.occupantCityDefault"): string;
|
export declare function getProperty(propertyName: "settings.lotOccupancy.occupantCityDefault"): string;
|
||||||
export declare function getProperty(propertyName: "settings.lotOccupancy.occupantProvinceDefault"): string;
|
export declare function getProperty(propertyName: "settings.lotOccupancy.occupantProvinceDefault"): string;
|
||||||
|
export declare function getProperty(propertyName: "settings.lotOccupancy.prints"): string[];
|
||||||
export declare function getProperty(propertyName: "settings.fees.taxPercentageDefault"): number;
|
export declare function getProperty(propertyName: "settings.fees.taxPercentageDefault"): number;
|
||||||
export declare function getProperty(propertyName: "settings.workOrders.workOrderNumberLength"): number;
|
export declare function getProperty(propertyName: "settings.workOrders.workOrderNumberLength"): number;
|
||||||
export declare function getProperty(propertyName: "settings.workOrders.workOrderMilestoneDateRecentBeforeDays"): number;
|
export declare function getProperty(propertyName: "settings.workOrders.workOrderMilestoneDateRecentBeforeDays"): number;
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ configFallbackValues.set("settings.lot.lotNameSortNameFunction", (lotName) => lo
|
||||||
configFallbackValues.set("settings.lotOccupancy.occupancyEndDateIsRequired", true);
|
configFallbackValues.set("settings.lotOccupancy.occupancyEndDateIsRequired", true);
|
||||||
configFallbackValues.set("settings.lotOccupancy.occupantCityDefault", "");
|
configFallbackValues.set("settings.lotOccupancy.occupantCityDefault", "");
|
||||||
configFallbackValues.set("settings.lotOccupancy.occupantProvinceDefault", "");
|
configFallbackValues.set("settings.lotOccupancy.occupantProvinceDefault", "");
|
||||||
|
configFallbackValues.set("settings.lotOccupancy.prints", ["screen/lotOccupancy"]);
|
||||||
configFallbackValues.set("settings.fees.taxPercentageDefault", 0);
|
configFallbackValues.set("settings.fees.taxPercentageDefault", 0);
|
||||||
configFallbackValues.set("settings.workOrders.workOrderNumberLength", 6);
|
configFallbackValues.set("settings.workOrders.workOrderNumberLength", 6);
|
||||||
configFallbackValues.set("settings.workOrders.workOrderMilestoneDateRecentBeforeDays", 5);
|
configFallbackValues.set("settings.workOrders.workOrderMilestoneDateRecentBeforeDays", 5);
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,7 @@ configFallbackValues.set("settings.lot.lotNameSortNameFunction", (lotName: strin
|
||||||
configFallbackValues.set("settings.lotOccupancy.occupancyEndDateIsRequired", true);
|
configFallbackValues.set("settings.lotOccupancy.occupancyEndDateIsRequired", true);
|
||||||
configFallbackValues.set("settings.lotOccupancy.occupantCityDefault", "");
|
configFallbackValues.set("settings.lotOccupancy.occupantCityDefault", "");
|
||||||
configFallbackValues.set("settings.lotOccupancy.occupantProvinceDefault", "");
|
configFallbackValues.set("settings.lotOccupancy.occupantProvinceDefault", "");
|
||||||
|
configFallbackValues.set("settings.lotOccupancy.prints", ["screen/lotOccupancy"]);
|
||||||
|
|
||||||
configFallbackValues.set("settings.fees.taxPercentageDefault", 0);
|
configFallbackValues.set("settings.fees.taxPercentageDefault", 0);
|
||||||
|
|
||||||
|
|
@ -112,8 +113,8 @@ export function getProperty(
|
||||||
): boolean;
|
): boolean;
|
||||||
|
|
||||||
export function getProperty(propertyName: "settings.lotOccupancy.occupantCityDefault"): string;
|
export function getProperty(propertyName: "settings.lotOccupancy.occupantCityDefault"): string;
|
||||||
|
|
||||||
export function getProperty(propertyName: "settings.lotOccupancy.occupantProvinceDefault"): string;
|
export function getProperty(propertyName: "settings.lotOccupancy.occupantProvinceDefault"): string;
|
||||||
|
export function getProperty(propertyName: "settings.lotOccupancy.prints"): string[];
|
||||||
|
|
||||||
export function getProperty(propertyName: "settings.fees.taxPercentageDefault"): number;
|
export function getProperty(propertyName: "settings.fees.taxPercentageDefault"): number;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
interface PrintConfig {
|
||||||
|
title: string;
|
||||||
|
params: string[];
|
||||||
|
}
|
||||||
|
export declare const getScreenPrintConfig: (printName: string) => PrintConfig;
|
||||||
|
export declare const getPrintConfig: (screenOrPdf_printName: string) => PrintConfig;
|
||||||
|
export {};
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
import * as configFunctions from "./functions.config.js";
|
||||||
|
const screenPrintConfigs = {
|
||||||
|
lotOccupancy: {
|
||||||
|
title: configFunctions.getProperty("aliases.lot") +
|
||||||
|
" " +
|
||||||
|
configFunctions.getProperty("aliases.occupancy") +
|
||||||
|
" Print",
|
||||||
|
params: ["lotOccupancyId"]
|
||||||
|
}
|
||||||
|
};
|
||||||
|
export const getScreenPrintConfig = (printName) => {
|
||||||
|
return screenPrintConfigs[printName];
|
||||||
|
};
|
||||||
|
export const getPrintConfig = (screenOrPdf_printName) => {
|
||||||
|
const printNameSplit = screenOrPdf_printName.split("/");
|
||||||
|
switch (printNameSplit[0]) {
|
||||||
|
case "screen":
|
||||||
|
return getScreenPrintConfig(printNameSplit[1]);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
import * as configFunctions from "./functions.config.js";
|
||||||
|
|
||||||
|
interface PrintConfig {
|
||||||
|
title: string;
|
||||||
|
params: string[];
|
||||||
|
}
|
||||||
|
|
||||||
|
const screenPrintConfigs = {
|
||||||
|
lotOccupancy: {
|
||||||
|
title:
|
||||||
|
configFunctions.getProperty("aliases.lot") +
|
||||||
|
" " +
|
||||||
|
configFunctions.getProperty("aliases.occupancy") +
|
||||||
|
" Print",
|
||||||
|
params: ["lotOccupancyId"]
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getScreenPrintConfig = (printName: string): PrintConfig => {
|
||||||
|
return screenPrintConfigs[printName];
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getPrintConfig = (screenOrPdf_printName: string): PrintConfig => {
|
||||||
|
const printNameSplit = screenOrPdf_printName.split("/");
|
||||||
|
|
||||||
|
switch (printNameSplit[0]) {
|
||||||
|
case "screen":
|
||||||
|
return getScreenPrintConfig(printNameSplit[1]);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
@ -2,7 +2,6 @@ import { Router } from "express";
|
||||||
import handler_search from "../handlers/lotOccupancies-get/search.js";
|
import handler_search from "../handlers/lotOccupancies-get/search.js";
|
||||||
import handler_doSearchLotOccupancies from "../handlers/lotOccupancies-post/doSearchLotOccupancies.js";
|
import handler_doSearchLotOccupancies from "../handlers/lotOccupancies-post/doSearchLotOccupancies.js";
|
||||||
import handler_view from "../handlers/lotOccupancies-get/view.js";
|
import handler_view from "../handlers/lotOccupancies-get/view.js";
|
||||||
import handler_print from "../handlers/lotOccupancies-get/print.js";
|
|
||||||
import handler_new from "../handlers/lotOccupancies-get/new.js";
|
import handler_new from "../handlers/lotOccupancies-get/new.js";
|
||||||
import handler_doGetOccupancyTypeFields from "../handlers/lotOccupancies-post/doGetOccupancyTypeFields.js";
|
import handler_doGetOccupancyTypeFields from "../handlers/lotOccupancies-post/doGetOccupancyTypeFields.js";
|
||||||
import handler_doCreateLotOccupancy from "../handlers/lotOccupancies-post/doCreateLotOccupancy.js";
|
import handler_doCreateLotOccupancy from "../handlers/lotOccupancies-post/doCreateLotOccupancy.js";
|
||||||
|
|
@ -28,7 +27,6 @@ router.get("/new", permissionHandlers.updateGetHandler, handler_new);
|
||||||
router.post("/doGetOccupancyTypeFields", permissionHandlers.updatePostHandler, handler_doGetOccupancyTypeFields);
|
router.post("/doGetOccupancyTypeFields", permissionHandlers.updatePostHandler, handler_doGetOccupancyTypeFields);
|
||||||
router.post("/doCreateLotOccupancy", permissionHandlers.updatePostHandler, handler_doCreateLotOccupancy);
|
router.post("/doCreateLotOccupancy", permissionHandlers.updatePostHandler, handler_doCreateLotOccupancy);
|
||||||
router.get("/:lotOccupancyId", handler_view);
|
router.get("/:lotOccupancyId", handler_view);
|
||||||
router.get("/:lotOccupancyId/print", handler_print);
|
|
||||||
router.get("/:lotOccupancyId/edit", permissionHandlers.updateGetHandler, handler_edit);
|
router.get("/:lotOccupancyId/edit", permissionHandlers.updateGetHandler, handler_edit);
|
||||||
router.post("/doUpdateLotOccupancy", permissionHandlers.updatePostHandler, handler_doUpdateLotOccupancy);
|
router.post("/doUpdateLotOccupancy", permissionHandlers.updatePostHandler, handler_doUpdateLotOccupancy);
|
||||||
router.post("/doDeleteLotOccupancy", permissionHandlers.updatePostHandler, handler_doDeleteLotOccupancy);
|
router.post("/doDeleteLotOccupancy", permissionHandlers.updatePostHandler, handler_doDeleteLotOccupancy);
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@ import handler_search from "../handlers/lotOccupancies-get/search.js";
|
||||||
import handler_doSearchLotOccupancies from "../handlers/lotOccupancies-post/doSearchLotOccupancies.js";
|
import handler_doSearchLotOccupancies from "../handlers/lotOccupancies-post/doSearchLotOccupancies.js";
|
||||||
|
|
||||||
import handler_view from "../handlers/lotOccupancies-get/view.js";
|
import handler_view from "../handlers/lotOccupancies-get/view.js";
|
||||||
import handler_print from "../handlers/lotOccupancies-get/print.js";
|
|
||||||
|
|
||||||
import handler_new from "../handlers/lotOccupancies-get/new.js";
|
import handler_new from "../handlers/lotOccupancies-get/new.js";
|
||||||
import handler_doGetOccupancyTypeFields from "../handlers/lotOccupancies-post/doGetOccupancyTypeFields.js";
|
import handler_doGetOccupancyTypeFields from "../handlers/lotOccupancies-post/doGetOccupancyTypeFields.js";
|
||||||
|
|
@ -59,8 +58,6 @@ router.post(
|
||||||
|
|
||||||
router.get("/:lotOccupancyId", handler_view);
|
router.get("/:lotOccupancyId", handler_view);
|
||||||
|
|
||||||
router.get("/:lotOccupancyId/print", handler_print);
|
|
||||||
|
|
||||||
// Edit
|
// Edit
|
||||||
|
|
||||||
router.get(
|
router.get(
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
export declare const router: import("express-serve-static-core").Router;
|
||||||
|
export default router;
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
import { Router } from "express";
|
||||||
|
import handler_screen from "../handlers/print-get/screen.js";
|
||||||
|
export const router = Router();
|
||||||
|
router.get("/screen/:printName", handler_screen);
|
||||||
|
export default router;
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
import { Router } from "express";
|
||||||
|
|
||||||
|
import handler_screen from "../handlers/print-get/screen.js";
|
||||||
|
|
||||||
|
export const router = Router();
|
||||||
|
|
||||||
|
router.get("/screen/:printName", handler_screen);
|
||||||
|
|
||||||
|
export default router;
|
||||||
|
|
@ -41,6 +41,7 @@ export interface Config {
|
||||||
occupancyEndDateIsRequired?: boolean;
|
occupancyEndDateIsRequired?: boolean;
|
||||||
occupantCityDefault?: string;
|
occupantCityDefault?: string;
|
||||||
occupantProvinceDefault?: string;
|
occupantProvinceDefault?: string;
|
||||||
|
prints?: string[];
|
||||||
};
|
};
|
||||||
workOrders?: {
|
workOrders?: {
|
||||||
workOrderNumberLength?: number;
|
workOrderNumberLength?: number;
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,7 @@ export interface Config {
|
||||||
occupancyEndDateIsRequired?: boolean;
|
occupancyEndDateIsRequired?: boolean;
|
||||||
occupantCityDefault?: string;
|
occupantCityDefault?: string;
|
||||||
occupantProvinceDefault?: string;
|
occupantProvinceDefault?: string;
|
||||||
|
prints?: string[];
|
||||||
};
|
};
|
||||||
workOrders?: {
|
workOrders?: {
|
||||||
workOrderNumberLength?: number;
|
workOrderNumberLength?: number;
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1 @@
|
||||||
"use strict";
|
export {};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
|
|
|
||||||
|
|
@ -46,16 +46,41 @@
|
||||||
</h1>
|
</h1>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="level-right">
|
<% if (configFunctions.getProperty("settings.lotOccupancy.prints").length > 0) { %>
|
||||||
|
<div class="level-right is-hidden-print">
|
||||||
<div class="level-item is-justify-content-right">
|
<div class="level-item is-justify-content-right">
|
||||||
<a class="button is-link is-hidden-print" href="<%= urlPrefix %>/lotOccupancies/<%= lotOccupancy.lotOccupancyId %>/print" target="_blank">
|
<% if (configFunctions.getProperty("settings.lotOccupancy.prints").length === 1) { %>
|
||||||
|
<a class="button is-link" href="<%= urlPrefix %>/print/screen/lotOccupancy/?lotOccupancyId=<%= lotOccupancy.lotOccupancyId %>" target="_blank">
|
||||||
<span class="icon is-small"><i class="fas fa-print" aria-hidden="true"></i></span>
|
<span class="icon is-small"><i class="fas fa-print" aria-hidden="true"></i></span>
|
||||||
<span>Print</span>
|
<span>Print</span>
|
||||||
</a>
|
</a>
|
||||||
|
<% } else { %>
|
||||||
|
<div class="dropdown is-right">
|
||||||
|
<div class="dropdown-trigger">
|
||||||
|
<button class="button is-link" type="button">
|
||||||
|
<span class="icon is-small"><i class="fas fa-print" aria-hidden="true"></i></span>
|
||||||
|
<span>Print</span>
|
||||||
|
<span class="icon is-small"><i class="fas fa-caret-down" aria-hidden="true"></i></span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="dropdown-menu">
|
||||||
|
<div class="dropdown-content">
|
||||||
|
<% for (const printName of configFunctions.getProperty("settings.lotOccupancy.prints")) { %>
|
||||||
|
<% const printConfig = printFunctions.getPrintConfig(printName); %>
|
||||||
|
<a class="dropdown-item" href="<%= urlPrefix %>/print/<%= printName %>/?lotOccupancyId=<%= lotOccupancy.lotOccupancyId %>">
|
||||||
|
<span class="icon is-small"><i class="fas fa-print" aria-hidden="true"></i></span>
|
||||||
|
<span><%= printConfig.title %></span>
|
||||||
|
</a>
|
||||||
|
<% } %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<% } %>
|
<% } %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<% } %>
|
||||||
|
</div>
|
||||||
|
<% } %>
|
||||||
|
|
||||||
<form id="form--lotOccupancy">
|
<form id="form--lotOccupancy">
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,15 +31,40 @@
|
||||||
</h1>
|
</h1>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="level-right">
|
<% if (configFunctions.getProperty("settings.lotOccupancy.prints").length > 0) { %>
|
||||||
|
<div class="level-right is-hidden-print">
|
||||||
<div class="level-item is-justify-content-right">
|
<div class="level-item is-justify-content-right">
|
||||||
<a class="button is-link is-hidden-print" href="<%= urlPrefix %>/lotOccupancies/<%= lotOccupancy.lotOccupancyId %>/print" target="_blank">
|
<% if (configFunctions.getProperty("settings.lotOccupancy.prints").length === 1) { %>
|
||||||
|
<a class="button is-link" href="<%= urlPrefix %>/print/screen/lotOccupancy/?lotOccupancyId=<%= lotOccupancy.lotOccupancyId %>" target="_blank">
|
||||||
<span class="icon is-small"><i class="fas fa-print" aria-hidden="true"></i></span>
|
<span class="icon is-small"><i class="fas fa-print" aria-hidden="true"></i></span>
|
||||||
<span>Print</span>
|
<span>Print</span>
|
||||||
</a>
|
</a>
|
||||||
|
<% } else { %>
|
||||||
|
<div class="dropdown is-right">
|
||||||
|
<div class="dropdown-trigger">
|
||||||
|
<button class="button is-link" type="button">
|
||||||
|
<span class="icon is-small"><i class="fas fa-print" aria-hidden="true"></i></span>
|
||||||
|
<span>Print</span>
|
||||||
|
<span class="icon is-small"><i class="fas fa-caret-down" aria-hidden="true"></i></span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="dropdown-menu">
|
||||||
|
<div class="dropdown-content">
|
||||||
|
<% for (const printName of configFunctions.getProperty("settings.lotOccupancy.prints")) { %>
|
||||||
|
<% const printConfig = printFunctions.getPrintConfig(printName); %>
|
||||||
|
<a class="dropdown-item" href="<%= urlPrefix %>/print/<%= printName %>/?lotOccupancyId=<%= lotOccupancy.lotOccupancyId %>">
|
||||||
|
<span class="icon is-small"><i class="fas fa-print" aria-hidden="true"></i></span>
|
||||||
|
<span><%= printConfig.title %></span>
|
||||||
|
</a>
|
||||||
|
<% } %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<% } %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<% } %>
|
||||||
|
</div>
|
||||||
|
|
||||||
<% if (user.userProperties.canUpdate) { %>
|
<% if (user.userProperties.canUpdate) { %>
|
||||||
<div class="fixed-container is-fixed-bottom-right mx-4 my-4 has-text-right is-hidden-print">
|
<div class="fixed-container is-fixed-bottom-right mx-4 my-4 has-text-right is-hidden-print">
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue