development

deepsource-autofix-76c6eb20
Dan Gowans 2022-07-22 16:24:48 -04:00
parent eb7c666b52
commit b4127304d1
30 changed files with 8702 additions and 2758 deletions

View File

@ -1,11 +1,12 @@
import { getLots } from "../../helpers/lotOccupancyDB/getLots.js";
export const handler = async (request, response) => {
const lots = getLots(request.body, {
const result = getLots(request.body, {
limit: request.body.limit,
offset: request.body.offset
});
response.json({
lots
count: result.count,
lots: result.lots
});
};
export default handler;

View File

@ -5,13 +5,14 @@ import { getLots } from "../../helpers/lotOccupancyDB/getLots.js";
export const handler: RequestHandler = async (request, response) => {
const lots = getLots(request.body, {
const result = getLots(request.body, {
limit: request.body.limit,
offset: request.body.offset
});
response.json({
lots
count: result.count,
lots: result.lots
});
};

View File

@ -10,4 +10,4 @@ export declare function getLotTypeById(lotTypeId: number): recordTypes.LotType;
export declare function getLotTypesByLotType(lotType: string): recordTypes.LotType;
export declare function getOccupancyTypes(): recordTypes.OccupancyType[];
export declare function getOccupancyTypeById(occupancyTypeId: number): recordTypes.OccupancyType;
export declare function getOccupancyTypeByOccupancyType(occupancyType: string): recordTypes.OccupancyType;
export declare function getOccupancyTypeByOccupancyType(occupancyTypeString: string): recordTypes.OccupancyType;

View File

@ -2,6 +2,7 @@ import { getLotOccupantTypes as getLotOccupantTypesFromDatabase } from "./lotOcc
import { getLotStatuses as getLotStatusesFromDatabase } from "./lotOccupancyDB/getLotStatuses.js";
import { getLotTypes as getLotTypesFromDatabase } from "./lotOccupancyDB/getLotTypes.js";
import { getOccupancyTypes as getOccupancyTypesFromDatabase } from "./lotOccupancyDB/getOccupancyTypes.js";
import getOccupancyType from "./lotOccupancyDB/getOccupancyType.js";
let lotOccupantTypes;
export function getLotOccupantTypes() {
if (!lotOccupantTypes) {
@ -63,6 +64,7 @@ export function getLotTypesByLotType(lotType) {
});
}
let occupancyTypes;
const occupancyTypeMap = new Map();
export function getOccupancyTypes() {
if (!occupancyTypes) {
occupancyTypes = getOccupancyTypesFromDatabase();
@ -70,15 +72,20 @@ export function getOccupancyTypes() {
return occupancyTypes;
}
export function getOccupancyTypeById(occupancyTypeId) {
const cachedOccupancyTypes = getOccupancyTypes();
return cachedOccupancyTypes.find((currentOccupancyType) => {
return currentOccupancyType.occupancyTypeId === occupancyTypeId;
});
if (!occupancyTypeMap.has(occupancyTypeId)) {
const occupancyType = getOccupancyType(occupancyTypeId);
occupancyTypeMap.set(occupancyTypeId, occupancyType);
}
return occupancyTypeMap.get(occupancyTypeId);
}
export function getOccupancyTypeByOccupancyType(occupancyType) {
export function getOccupancyTypeByOccupancyType(occupancyTypeString) {
const cachedOccupancyTypes = getOccupancyTypes();
const occupancyTypeLowerCase = occupancyType.toLowerCase();
return cachedOccupancyTypes.find((currentOccupancyType) => {
const occupancyTypeLowerCase = occupancyTypeString.toLowerCase();
let occupancyType = cachedOccupancyTypes.find((currentOccupancyType) => {
return currentOccupancyType.occupancyType.toLowerCase() === occupancyTypeLowerCase;
});
if (occupancyType) {
occupancyType = getOccupancyTypeById(occupancyType.occupancyTypeId);
}
return occupancyType;
}

View File

@ -4,6 +4,7 @@ import { getLotTypes as getLotTypesFromDatabase } from "./lotOccupancyDB/getLotT
import { getOccupancyTypes as getOccupancyTypesFromDatabase } from "./lotOccupancyDB/getOccupancyTypes.js";
import type * as recordTypes from "../types/recordTypes";
import getOccupancyType from "./lotOccupancyDB/getOccupancyType.js";
/*
* Lot Occupant Types
@ -116,6 +117,7 @@ export function getLotTypesByLotType(lotType: string) {
*/
let occupancyTypes: recordTypes.OccupancyType[];
const occupancyTypeMap = new Map<number, recordTypes.OccupancyType>();
export function getOccupancyTypes () {
@ -128,20 +130,29 @@ export function getOccupancyTypes () {
export function getOccupancyTypeById (occupancyTypeId: number) {
const cachedOccupancyTypes = getOccupancyTypes();
if (!occupancyTypeMap.has(occupancyTypeId)) {
return cachedOccupancyTypes.find((currentOccupancyType) => {
return currentOccupancyType.occupancyTypeId === occupancyTypeId;
});
const occupancyType = getOccupancyType(occupancyTypeId);
occupancyTypeMap.set(occupancyTypeId, occupancyType);
}
return occupancyTypeMap.get(occupancyTypeId);
}
export function getOccupancyTypeByOccupancyType (occupancyType: string) {
export function getOccupancyTypeByOccupancyType (occupancyTypeString: string) {
const cachedOccupancyTypes = getOccupancyTypes();
const occupancyTypeLowerCase = occupancyType.toLowerCase();
const occupancyTypeLowerCase = occupancyTypeString.toLowerCase();
return cachedOccupancyTypes.find((currentOccupancyType) => {
let occupancyType = cachedOccupancyTypes.find((currentOccupancyType) => {
return currentOccupancyType.occupancyType.toLowerCase() === occupancyTypeLowerCase;
});
// get object with related fields
if (occupancyType) {
occupancyType = getOccupancyTypeById(occupancyType.occupancyTypeId);
}
return occupancyType;
}

View File

@ -0,0 +1,13 @@
import type * as recordTypes from "../../types/recordTypes";
interface GetLotOccupanciesFilters {
lotId?: number | string;
}
interface GetLotOccupanciesOptions {
limit: number;
offset: number;
}
export declare const getLotOccupancies: (filters: GetLotOccupanciesFilters, options?: GetLotOccupanciesOptions) => {
count: number;
lotOccupancies: recordTypes.LotOccupancy[];
};
export default getLotOccupancies;

View File

@ -0,0 +1,44 @@
import sqlite from "better-sqlite3";
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
export const getLotOccupancies = (filters, options) => {
const database = sqlite(databasePath, {
readonly: true
});
let sqlWhereClause = " where o.recordDelete_timeMillis is null";
const sqlParameters = [];
if (filters.lotId) {
sqlWhereClause += " and o.lotId = ?";
sqlParameters.push(filters.lotId);
}
const count = database.prepare("select count(*) as recordCount" +
" from LotOccupancies o" +
sqlWhereClause)
.get(sqlParameters)
.recordCount;
let lotOccupancies = [];
if (count > 0) {
lotOccupancies = database
.prepare("select o.lotOccupancyId," +
" o.occupancyTypeId, t.occupancyType," +
" o.lotId, l.lotName," +
" o.occupantId, n.occupantName," +
" o.occupancyStartDate," +
" o.occupancyEndDate" +
" from LotOccupancies o" +
" left join OccupancyTypes t on o.occupancyTypeId = t.occupancyTypeId" +
" left join Lots l on o.lotId = l.lotId" +
" left join Occupants n on o.occupantId = n.occupantId" +
sqlWhereClause +
" order by o.occupancyStartDate, o.occupancyEndDate, l.lotName, o.lotId" +
(options ?
" limit " + options.limit + " offset " + options.offset :
""))
.all(sqlParameters);
}
database.close();
return {
count,
lotOccupancies
};
};
export default getLotOccupancies;

View File

@ -0,0 +1,75 @@
import sqlite from "better-sqlite3";
import {
lotOccupancyDB as databasePath
} from "../../data/databasePaths.js";
import type * as recordTypes from "../../types/recordTypes";
interface GetLotOccupanciesFilters {
lotId ? : number | string;
}
interface GetLotOccupanciesOptions {
limit: number;
offset: number;
}
export const getLotOccupancies = (filters: GetLotOccupanciesFilters, options ? : GetLotOccupanciesOptions): {
count: number;
lotOccupancies: recordTypes.LotOccupancy[];
} => {
const database = sqlite(databasePath, {
readonly: true
});
let sqlWhereClause = " where o.recordDelete_timeMillis is null";
const sqlParameters = [];
if (filters.lotId) {
sqlWhereClause += " and o.lotId = ?";
sqlParameters.push(filters.lotId);
}
const count: number = database.prepare("select count(*) as recordCount" +
" from LotOccupancies o" +
sqlWhereClause)
.get(sqlParameters)
.recordCount;
let lotOccupancies: recordTypes.LotOccupancy[] = [];
if (count > 0) {
lotOccupancies = database
.prepare("select o.lotOccupancyId," +
" o.occupancyTypeId, t.occupancyType," +
" o.lotId, l.lotName," +
" o.occupantId, n.occupantName," +
" o.occupancyStartDate," +
" o.occupancyEndDate" +
" from LotOccupancies o" +
" left join OccupancyTypes t on o.occupancyTypeId = t.occupancyTypeId" +
" left join Lots l on o.lotId = l.lotId" +
" left join Occupants n on o.occupantId = n.occupantId" +
sqlWhereClause +
" order by o.occupancyStartDate, o.occupancyEndDate, l.lotName, o.lotId" +
(options ?
" limit " + options.limit + " offset " + options.offset :
""))
.all(sqlParameters);
}
database.close();
return {
count,
lotOccupancies
};
};
export default getLotOccupancies;

View File

@ -9,5 +9,8 @@ interface GetLotsOptions {
limit: number;
offset: number;
}
export declare const getLots: (filters?: GetLotsFilters, options?: GetLotsOptions) => recordTypes.Lot[];
export declare const getLots: (filters?: GetLotsFilters, options?: GetLotsOptions) => {
count: number;
lots: recordTypes.Lot[];
};
export default getLots;

View File

@ -5,7 +5,7 @@ export const getLots = (filters, options) => {
const database = sqlite(databasePath, {
readonly: true
});
let sqlWhereClause = "";
let sqlWhereClause = " where l.recordDelete_timeMillis is null";
const sqlParameters = [];
if (filters.lotName) {
const lotNamePieces = filters.lotName.toLowerCase().split(" ");
@ -26,33 +26,43 @@ export const getLots = (filters, options) => {
sqlWhereClause += " and l.lotStatusId = ?";
sqlParameters.push(filters.lotStatusId);
}
const currentDate = dateToInteger(new Date());
const lots = database
.prepare("select l.lotId, l.lotName," +
" t.lotType," +
" l.mapId, m.mapName, l.mapKey," +
" s.lotStatus," +
" ifnull(o.lotOccupancyCount, 0) as lotOccupancyCount" +
const count = database.prepare("select count(*) as recordCount" +
" from Lots l" +
" left join LotTypes t on l.lotTypeId = t.lotTypeId" +
" left join LotStatuses s on l.lotStatusId = s.lotStatusId" +
" left join Maps m on l.mapId = m.mapId" +
(" left join (" +
"select lotId, count(lotOccupancyId) as lotOccupancyCount" +
" from LotOccupancies" +
" where recordDelete_timeMillis is null" +
" and occupancyStartDate <= " + currentDate +
" and (occupancyEndDate is null or occupancyEndDate >= " + currentDate + ")" +
" group by lotId" +
") o on l.lotId = o.lotId") +
" where l.recordDelete_timeMillis is null" +
sqlWhereClause +
" order by l.lotName" +
(options ?
" limit " + options.limit + " offset " + options.offset :
""))
.all(sqlParameters);
sqlWhereClause)
.get(sqlParameters)
.recordCount;
let lots = [];
if (count > 0) {
const currentDate = dateToInteger(new Date());
lots = database
.prepare("select l.lotId, l.lotName," +
" t.lotType," +
" l.mapId, m.mapName, l.mapKey," +
" s.lotStatus," +
" ifnull(o.lotOccupancyCount, 0) as lotOccupancyCount" +
" from Lots l" +
" left join LotTypes t on l.lotTypeId = t.lotTypeId" +
" left join LotStatuses s on l.lotStatusId = s.lotStatusId" +
" left join Maps m on l.mapId = m.mapId" +
(" left join (" +
"select lotId, count(lotOccupancyId) as lotOccupancyCount" +
" from LotOccupancies" +
" where recordDelete_timeMillis is null" +
" and occupancyStartDate <= " + currentDate +
" and (occupancyEndDate is null or occupancyEndDate >= " + currentDate + ")" +
" group by lotId" +
") o on l.lotId = o.lotId") +
sqlWhereClause +
" order by l.lotName" +
(options ?
" limit " + options.limit + " offset " + options.offset :
""))
.all(sqlParameters);
}
database.close();
return lots;
return {
count,
lots
};
};
export default getLots;

View File

@ -10,7 +10,7 @@ import type * as recordTypes from "../../types/recordTypes";
interface GetLotsFilters {
lotName?: string;
lotName ? : string;
mapId ? : number | string;
lotTypeId ? : number | string;
lotStatusId ? : number | string;
@ -22,13 +22,16 @@ interface GetLotsOptions {
}
export const getLots = (filters ? : GetLotsFilters, options ? : GetLotsOptions): recordTypes.Lot[] => {
export const getLots = (filters ? : GetLotsFilters, options ? : GetLotsOptions): {
count: number;
lots: recordTypes.Lot[];
} => {
const database = sqlite(databasePath, {
readonly: true
});
let sqlWhereClause = "";
let sqlWhereClause = " where l.recordDelete_timeMillis is null";
const sqlParameters = [];
if (filters.lotName) {
@ -54,37 +57,50 @@ export const getLots = (filters ? : GetLotsFilters, options ? : GetLotsOptions):
sqlParameters.push(filters.lotStatusId);
}
const currentDate = dateToInteger(new Date());
const lots: recordTypes.Lot[] = database
.prepare("select l.lotId, l.lotName," +
" t.lotType," +
" l.mapId, m.mapName, l.mapKey," +
" s.lotStatus," +
" ifnull(o.lotOccupancyCount, 0) as lotOccupancyCount" +
const count: number = database.prepare("select count(*) as recordCount" +
" from Lots l" +
" left join LotTypes t on l.lotTypeId = t.lotTypeId" +
" left join LotStatuses s on l.lotStatusId = s.lotStatusId" +
" left join Maps m on l.mapId = m.mapId" +
(" left join (" +
"select lotId, count(lotOccupancyId) as lotOccupancyCount" +
" from LotOccupancies" +
" where recordDelete_timeMillis is null" +
" and occupancyStartDate <= " + currentDate +
" and (occupancyEndDate is null or occupancyEndDate >= " + currentDate + ")" +
" group by lotId" +
") o on l.lotId = o.lotId") +
" where l.recordDelete_timeMillis is null" +
sqlWhereClause +
" order by l.lotName" +
(options ?
" limit " + options.limit + " offset " + options.offset :
""))
.all(sqlParameters);
sqlWhereClause)
.get(sqlParameters)
.recordCount;
let lots: recordTypes.Lot[] = [];
if (count > 0) {
const currentDate = dateToInteger(new Date());
lots = database
.prepare("select l.lotId, l.lotName," +
" t.lotType," +
" l.mapId, m.mapName, l.mapKey," +
" s.lotStatus," +
" ifnull(o.lotOccupancyCount, 0) as lotOccupancyCount" +
" from Lots l" +
" left join LotTypes t on l.lotTypeId = t.lotTypeId" +
" left join LotStatuses s on l.lotStatusId = s.lotStatusId" +
" left join Maps m on l.mapId = m.mapId" +
(" left join (" +
"select lotId, count(lotOccupancyId) as lotOccupancyCount" +
" from LotOccupancies" +
" where recordDelete_timeMillis is null" +
" and occupancyStartDate <= " + currentDate +
" and (occupancyEndDate is null or occupancyEndDate >= " + currentDate + ")" +
" group by lotId" +
") o on l.lotId = o.lotId") +
sqlWhereClause +
" order by l.lotName" +
(options ?
" limit " + options.limit + " offset " + options.offset :
""))
.all(sqlParameters);
}
database.close();
return lots;
return {
count,
lots
};
};

View File

@ -0,0 +1,3 @@
import type * as recordTypes from "../../types/recordTypes";
export declare const getOccupancyType: (occupancyTypeId: number | string) => recordTypes.OccupancyType;
export default getOccupancyType;

View File

@ -0,0 +1,21 @@
import sqlite from "better-sqlite3";
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
export const getOccupancyType = (occupancyTypeId) => {
const database = sqlite(databasePath, {
readonly: true
});
const occupancyType = database
.prepare("select * from OccupancyTypes" +
" where occupancyTypeId = ?")
.get(occupancyTypeId);
if (occupancyType) {
occupancyType.occupancyTypeFields = database.prepare("select * from OccupancyTypeFields" +
" where recordDelete_timeMillis is null" +
" and occupancyTypeId = ?" +
" order by orderNumber, occupancyTypeField")
.all(occupancyTypeId);
}
database.close();
return occupancyType;
};
export default getOccupancyType;

View File

@ -0,0 +1,33 @@
import sqlite from "better-sqlite3";
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
import type * as recordTypes from "../../types/recordTypes";
export const getOccupancyType = (occupancyTypeId: number | string): recordTypes.OccupancyType => {
const database = sqlite(databasePath, {
readonly: true
});
const occupancyType: recordTypes.OccupancyType = database
.prepare("select * from OccupancyTypes" +
" where occupancyTypeId = ?")
.get(occupancyTypeId);
if (occupancyType) {
occupancyType.occupancyTypeFields = database.prepare("select * from OccupancyTypeFields" +
" where recordDelete_timeMillis is null" +
" and occupancyTypeId = ?" +
" order by orderNumber, occupancyTypeField")
.all(occupancyTypeId);
}
database.close();
return occupancyType;
};
export default getOccupancyType;

View File

@ -106,4 +106,8 @@ fieldset:enabled .is-hidden-enabled {
fill: $success-light;
}
}
text {
user-select: none;
}
}

View File

@ -4,7 +4,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
const urlPrefix = document.querySelector("main").dataset.urlPrefix;
const searchFilterFormElement = document.querySelector("#form--searchFilters");
const searchResultsContainerElement = document.querySelector("#container--searchResults");
const limit = Number.parseInt(document.querySelector("#searchFilter--limit").value, 10);
const offsetElement = document.querySelector("#searchFilter--offset");
const getLots = () => {
const offset = Number.parseInt(offsetElement.value, 10);
searchResultsContainerElement.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.lots + "..." +
@ -42,17 +45,62 @@ Object.defineProperty(exports, "__esModule", { value: true });
"<th>" + exports.aliases.map + "</th>" +
"<th>" + exports.aliases.lot + " Type</th>" +
"<th>Status</th>" +
"</tr></thead>";
"</tr></thead>" +
"<table>" +
"<div class=\"level\">" +
("<div class=\"level-left\">" +
"<div class=\"level-item has-text-weight-bold\">" +
"Displaying " + (offset + 1).toString() +
" to " + Math.min(responseJSON.count, limit + offset) +
" of " + responseJSON.count +
"</div>" +
"</div>") +
("<div class=\"level-right\">" +
(offset > 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>" :
"") +
(limit + offset < responseJSON.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>";
searchResultsContainerElement.querySelector("table").append(resultsTbodyElement);
if (offset > 0) {
searchResultsContainerElement.querySelector("button[data-page='previous']").addEventListener("click", previousAndGetLots);
}
if (limit + offset < responseJSON.count) {
searchResultsContainerElement.querySelector("button[data-page='next']").addEventListener("click", nextAndGetLots);
}
});
};
const resetOffsetAndGetLots = () => {
offsetElement.value = "0";
getLots();
};
const previousAndGetLots = () => {
offsetElement.value = Math.max(Number.parseInt(offsetElement.value, 10) - limit, 0).toString();
getLots();
};
const nextAndGetLots = () => {
offsetElement.value = (Number.parseInt(offsetElement.value, 10) + limit).toString();
getLots();
};
const filterElements = searchFilterFormElement.querySelectorAll("input, select");
for (const filterElement of filterElements) {
filterElement.addEventListener("change", getLots);
filterElement.addEventListener("change", resetOffsetAndGetLots);
}
searchFilterFormElement.addEventListener("submit", (formEvent) => {
formEvent.preventDefault();
getLots();
resetOffsetAndGetLots();
});
getLots();
})();

View File

@ -6,6 +6,7 @@ import type {
cityssmGlobal
} from "@cityssm/bulma-webapp-js/src/types";
declare const cityssm: cityssmGlobal;
@ -15,8 +16,14 @@ declare const cityssm: cityssmGlobal;
const searchFilterFormElement = document.querySelector("#form--searchFilters") as HTMLFormElement;
const searchResultsContainerElement = document.querySelector("#container--searchResults") as HTMLElement;
const limit = Number.parseInt((document.querySelector("#searchFilter--limit") as HTMLInputElement).value, 10);
const offsetElement = document.querySelector("#searchFilter--offset") as HTMLInputElement;
const getLots = () => {
const offset = Number.parseInt(offsetElement.value, 10);
searchResultsContainerElement.innerHTML = "<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.lots + "..." +
@ -24,7 +31,8 @@ declare const cityssm: cityssmGlobal;
cityssm.postJSON(urlPrefix + "/lots/doSearchLots", searchFilterFormElement,
(responseJSON: {
lots: recordTypes.Lot[]
count: number;
lots: recordTypes.Lot[];
}) => {
if (responseJSON.lots.length === 0) {
@ -64,21 +72,71 @@ declare const cityssm: cityssmGlobal;
"<th>" + exports.aliases.map + "</th>" +
"<th>" + exports.aliases.lot + " Type</th>" +
"<th>Status</th>" +
"</tr></thead>";
"</tr></thead>" +
"<table>" +
"<div class=\"level\">" +
("<div class=\"level-left\">" +
"<div class=\"level-item has-text-weight-bold\">" +
"Displaying " + (offset + 1).toString() +
" to " + Math.min(responseJSON.count, limit + offset) +
" of " + responseJSON.count +
"</div>" +
"</div>") +
("<div class=\"level-right\">" +
(offset > 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>" :
"") +
(limit + offset < responseJSON.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>";
searchResultsContainerElement.querySelector("table").append(resultsTbodyElement);
if (offset > 0) {
searchResultsContainerElement.querySelector("button[data-page='previous']").addEventListener("click", previousAndGetLots);
}
if (limit + offset < responseJSON.count) {
searchResultsContainerElement.querySelector("button[data-page='next']").addEventListener("click", nextAndGetLots);
}
});
};
const resetOffsetAndGetLots = () => {
offsetElement.value = "0";
getLots();
}
const previousAndGetLots = () => {
offsetElement.value = Math.max(Number.parseInt(offsetElement.value, 10) - limit, 0).toString();
getLots();
};
const nextAndGetLots = () => {
offsetElement.value = (Number.parseInt(offsetElement.value, 10) + limit).toString();
getLots();
};
const filterElements = searchFilterFormElement.querySelectorAll("input, select") as NodeListOf < HTMLInputElement | HTMLSelectElement > ;
for (const filterElement of filterElements) {
filterElement.addEventListener("change", getLots);
filterElement.addEventListener("change", resetOffsetAndGetLots);
}
searchFilterFormElement.addEventListener("submit", (formEvent) => {
formEvent.preventDefault();
getLots();
resetOffsetAndGetLots();
});
getLots();

File diff suppressed because it is too large Load Diff

Before

Width:  |  Height:  |  Size: 567 KiB

After

Width:  |  Height:  |  Size: 643 KiB

View File

@ -23,9 +23,9 @@
inkscape:deskcolor="#d1d1d1"
inkscape:document-units="pt"
showgrid="false"
inkscape:zoom="0.23416834"
inkscape:cx="1283.2648"
inkscape:cy="495.37012"
inkscape:zoom="1.1479719"
inkscape:cx="1350.2073"
inkscape:cy="766.5693"
inkscape:window-width="1920"
inkscape:window-height="1009"
inkscape:window-x="-8"
@ -3780,133 +3780,6 @@
y="948.87"
id="use6821" />
</g>
<g
style="fill:rgb(0%,0%,0%);fill-opacity:1;"
id="g7517">
<use
xlink:href="#glyph7-1"
x="718.2"
y="113.93"
id="use7495" />
<use
xlink:href="#glyph7-2"
x="757.95361"
y="113.93"
id="use7497" />
<use
xlink:href="#glyph7-3"
x="791.590427"
y="113.93"
id="use7499" />
<use
xlink:href="#glyph7-4"
x="806.876864"
y="113.93"
id="use7501" />
<use
xlink:href="#glyph7-5"
x="837.482837"
y="113.93"
id="use7503" />
<use
xlink:href="#glyph7-6"
x="852.769273"
y="113.93"
id="use7505" />
<use
xlink:href="#glyph7-7"
x="889.49204"
y="113.93"
id="use7507" />
<use
xlink:href="#glyph7-8"
x="920.098013"
y="113.93"
id="use7509" />
<use
xlink:href="#glyph7-9"
x="953.73483"
y="113.93"
id="use7511" />
<use
xlink:href="#glyph7-3"
x="987.371647"
y="113.93"
id="use7513" />
<use
xlink:href="#glyph7-10"
x="1002.658084"
y="113.93"
id="use7515" />
</g>
<g
style="fill:rgb(0%,0%,0%);fill-opacity:1;"
id="g7535">
<use
xlink:href="#glyph7-11"
x="1032.639199"
y="113.93"
id="use7519" />
<use
xlink:href="#glyph7-12"
x="1066.291204"
y="113.93"
id="use7521" />
<use
xlink:href="#glyph7-7"
x="1087.709623"
y="113.93"
id="use7523" />
<use
xlink:href="#glyph7-5"
x="1118.330784"
y="113.93"
id="use7525" />
<use
xlink:href="#glyph7-13"
x="1133.632409"
y="113.93"
id="use7527" />
<use
xlink:href="#glyph7-7"
x="1173.401208"
y="113.93"
id="use7529" />
<use
xlink:href="#glyph7-14"
x="1204.02237"
y="113.93"
id="use7531" />
<use
xlink:href="#glyph7-7"
x="1252.993912"
y="113.93"
id="use7533" />
</g>
<g
style="fill:rgb(0%,0%,0%);fill-opacity:1;"
id="g7545">
<use
xlink:href="#glyph7-15"
x="1283.043857"
y="113.93"
id="use7537" />
<use
xlink:href="#glyph7-7"
x="1301.387964"
y="113.93"
id="use7539" />
<use
xlink:href="#glyph7-12"
x="1332.020764"
y="113.93"
id="use7541" />
<use
xlink:href="#glyph7-4"
x="1353.450821"
y="113.93"
id="use7543" />
</g>
<g
style="fill:rgb(0%,0%,0%);fill-opacity:1;"
id="g7713">
@ -9499,185 +9372,6 @@
y="659.84003"
id="use9011" />
</g>
<g
style="fill:#000000;fill-opacity:1"
id="g9157">
<use
xlink:href="#glyph0-1"
x="1035.3101"
y="633.58002"
id="use9147" />
<use
xlink:href="#glyph0-2"
x="1048.3724"
y="633.58002"
id="use9149" />
<use
xlink:href="#glyph0-3"
x="1053.3973"
y="633.58002"
id="use9151" />
<use
xlink:href="#glyph0-4"
x="1064.4504"
y="633.58002"
id="use9153" />
<use
xlink:href="#glyph0-5"
x="1074.5078"
y="633.58002"
id="use9155" />
</g>
<g
style="fill:#000000;fill-opacity:1"
id="g9167">
<use
xlink:href="#glyph0-6"
x="1084.8042"
y="633.58002"
id="use9159" />
<use
xlink:href="#glyph0-7"
x="1089.8324"
y="633.58002"
id="use9161" />
<use
xlink:href="#glyph0-16"
x="1098.8793"
y="633.58002"
id="use9163" />
<use
xlink:href="#glyph0-9"
x="1108.9399"
y="633.58002"
id="use9165" />
</g>
<g
style="fill:#000000;fill-opacity:1"
id="g9175">
<use
xlink:href="#glyph1-10"
x="1032.76"
y="650.81"
id="use9169" />
<use
xlink:href="#glyph1-11"
x="1043.3661"
y="650.81"
id="use9171" />
<use
xlink:href="#glyph1-12"
x="1052.379"
y="650.81"
id="use9173" />
</g>
<g
style="fill:#000000;fill-opacity:1"
id="g9193">
<use
xlink:href="#glyph1-13"
x="1065.2063"
y="650.81"
id="use9177" />
<use
xlink:href="#glyph1-3"
x="1072.7223"
y="650.81"
id="use9179" />
<use
xlink:href="#glyph1-5"
x="1076.9938"
y="650.81"
id="use9181" />
<use
xlink:href="#glyph1-3"
x="1086.2927"
y="650.81"
id="use9183" />
<use
xlink:href="#glyph1-4"
x="1090.5642"
y="650.81"
id="use9185" />
<use
xlink:href="#glyph1-3"
x="1096.8525"
y="650.81"
id="use9187" />
<use
xlink:href="#glyph1-17"
x="1101.124"
y="650.81"
id="use9189" />
<use
xlink:href="#glyph1-2"
x="1110.4231"
y="650.81"
id="use9191" />
</g>
<g
style="fill:#000000;fill-opacity:1"
id="g9209">
<use
xlink:href="#glyph1-14"
x="1037.3397"
y="667.4198"
id="use9195" />
<use
xlink:href="#glyph1-11"
x="1045.6906"
y="667.4198"
id="use9197" />
<use
xlink:href="#glyph1-15"
x="1054.699"
y="667.4198"
id="use9199" />
<use
xlink:href="#glyph1-13"
x="1060.7699"
y="667.4198"
id="use9201" />
<use
xlink:href="#glyph1-3"
x="1068.2877"
y="667.4198"
id="use9203" />
<use
xlink:href="#glyph1-5"
x="1072.561"
y="667.4198"
id="use9205" />
<use
xlink:href="#glyph1-3"
x="1081.8618"
y="667.4198"
id="use9207" />
</g>
<g
style="fill:#000000;fill-opacity:1"
id="g9219">
<use
xlink:href="#glyph1-4"
x="1085.9509"
y="667.4198"
id="use9211" />
<use
xlink:href="#glyph1-3"
x="1092.2406"
y="667.4198"
id="use9213" />
<use
xlink:href="#glyph1-5"
x="1096.5134"
y="667.4198"
id="use9215" />
<use
xlink:href="#glyph1-22"
x="1105.8138"
y="667.4198"
id="use9217" />
</g>
<g
style="fill:#000000;fill-opacity:1"
id="g9225">
@ -10518,122 +10212,6 @@
y="536.03979"
id="use8881" />
</g>
<g
style="fill:#000000;fill-opacity:1"
id="g9109">
<use
xlink:href="#glyph0-1"
x="632.04999"
y="502.19"
id="use9099" />
<use
xlink:href="#glyph0-2"
x="645.11243"
y="502.19"
id="use9101" />
<use
xlink:href="#glyph0-3"
x="650.13739"
y="502.19"
id="use9103" />
<use
xlink:href="#glyph0-4"
x="661.19043"
y="502.19"
id="use9105" />
<use
xlink:href="#glyph0-5"
x="671.24786"
y="502.19"
id="use9107" />
</g>
<g
style="fill:#000000;fill-opacity:1"
id="g9119">
<use
xlink:href="#glyph0-6"
x="681.54419"
y="502.19"
id="use9111" />
<use
xlink:href="#glyph0-7"
x="686.57227"
y="502.19"
id="use9113" />
<use
xlink:href="#glyph0-15"
x="695.61914"
y="502.19"
id="use9115" />
<use
xlink:href="#glyph0-9"
x="708.68475"
y="502.19"
id="use9117" />
</g>
<g
style="fill:#000000;fill-opacity:1"
id="g9135">
<use
xlink:href="#glyph1-14"
x="635.73999"
y="519.41998"
id="use9121" />
<use
xlink:href="#glyph1-11"
x="644.09082"
y="519.41998"
id="use9123" />
<use
xlink:href="#glyph1-15"
x="653.09937"
y="519.41998"
id="use9125" />
<use
xlink:href="#glyph1-13"
x="659.17029"
y="519.41998"
id="use9127" />
<use
xlink:href="#glyph1-3"
x="666.68805"
y="519.41998"
id="use9129" />
<use
xlink:href="#glyph1-5"
x="670.96136"
y="519.41998"
id="use9131" />
<use
xlink:href="#glyph1-3"
x="680.26221"
y="519.41998"
id="use9133" />
</g>
<g
style="fill:#000000;fill-opacity:1"
id="g9145">
<use
xlink:href="#glyph1-4"
x="684.3512"
y="519.41998"
id="use9137" />
<use
xlink:href="#glyph1-3"
x="690.64093"
y="519.41998"
id="use9139" />
<use
xlink:href="#glyph1-5"
x="694.91376"
y="519.41998"
id="use9141" />
<use
xlink:href="#glyph1-6"
x="704.21411"
y="519.41998"
id="use9143" />
</g>
<text
xml:space="preserve"
style="font-size:16px;fill:#000000;stroke-width:0.75"
@ -10717,7 +10295,7 @@
transform="rotate(-6.7,1345.7941,2628.6017)"><tspan
x="989.69073"
y="760.95215"
id="tspan32841">Algoma Central Railway</tspan></text>
id="tspan11213">Algoma Central Railway</tspan></text>
<text
xml:space="preserve"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:32px;font-family:sans-serif;-inkscape-font-specification:'sans-serif Bold';text-align:center;text-anchor:middle;fill:#000000;stroke-width:0.75"
@ -10751,5 +10329,37 @@
style="font-size:48px;stroke-width:0.75"
x="1054.2358"
y="186.84094">Holy Sepulchre Cemetery</tspan></text>
<text
xml:space="preserve"
style="font-weight:bold;font-size:16px;font-family:sans-serif;-inkscape-font-specification:'sans-serif Bold';text-align:center;text-anchor:middle;fill:#000000;stroke-width:0.75"
x="1080.6013"
y="625.88641"
id="text8954"><tspan
sodipodi:role="line"
id="tspan8952"
style="stroke-width:0.75;font-size:16px"
x="1080.6013"
y="625.88641">Block &quot;J&quot;</tspan><tspan
sodipodi:role="line"
style="stroke-width:0.75;font-size:16px"
x="1080.6013"
y="648.38641"
id="tspan8956">Rows 1 - 18</tspan></text>
<text
xml:space="preserve"
style="font-weight:bold;font-size:16px;font-family:sans-serif;-inkscape-font-specification:'sans-serif Bold';text-align:center;text-anchor:middle;fill:#000000;stroke-width:0.75"
x="674.88586"
y="502.40778"
id="text9010"><tspan
sodipodi:role="line"
id="tspan9008"
style="stroke-width:0.75"
x="674.88586"
y="502.40778">Block &quot;H&quot;</tspan><tspan
sodipodi:role="line"
style="stroke-width:0.75"
x="674.88586"
y="522.40778"
id="tspan9012">Lots 1 - 16</tspan></text>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 480 KiB

After

Width:  |  Height:  |  Size: 472 KiB

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 93 KiB

After

Width:  |  Height:  |  Size: 82 KiB

View File

@ -1 +1 @@
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),(()=>{const e=document.querySelector("main").dataset.urlPrefix,t=document.querySelector("#form--searchFilters"),s=document.querySelector("#container--searchResults"),a=()=>{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.lots+"...</div>",cityssm.postJSON(e+"/lots/doSearchLots",t,t=>{if(0===t.lots.length)return void(s.innerHTML='<div class="message is-info"><p class="message-body">There are no '+exports.aliases.lots.toLowerCase()+" that meet the search criteria.</p></div>");const a=document.createElement("tbody");for(const s of t.lots)a.insertAdjacentHTML("beforeend",'<tr><td><a class="has-text-weight-bold" href="'+e+"/lots/"+s.lotId+'">'+s.lotName+'</a></td><td><a href="'+e+"/maps/"+s.mapId+'">'+s.mapName+"</a></td><td>"+s.lotType+"</td><td>"+s.lotStatus+"<br />"+(s.lotOccupancyCount>0?'<span class="is-size-7">Currently Occupied</span>':"")+"</td></tr>");s.innerHTML='<table class="table is-fullwidth is-striped is-hoverable"><thead><tr><th>'+exports.aliases.lot+"</th><th>"+exports.aliases.map+"</th><th>"+exports.aliases.lot+" Type</th><th>Status</th></tr></thead>",s.querySelector("table").append(a)})},r=t.querySelectorAll("input, select");for(const e of r)e.addEventListener("change",a);t.addEventListener("submit",e=>{e.preventDefault(),a()}),a()})();
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),(()=>{const e=document.querySelector("main").dataset.urlPrefix,t=document.querySelector("#form--searchFilters"),s=document.querySelector("#container--searchResults"),a=Number.parseInt(document.querySelector("#searchFilter--limit").value,10),r=document.querySelector("#searchFilter--offset"),i=()=>{const i=Number.parseInt(r.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.lots+"...</div>",cityssm.postJSON(e+"/lots/doSearchLots",t,t=>{if(0===t.lots.length)return void(s.innerHTML='<div class="message is-info"><p class="message-body">There are no '+exports.aliases.lots.toLowerCase()+" that meet the search criteria.</p></div>");const r=document.createElement("tbody");for(const s of t.lots)r.insertAdjacentHTML("beforeend",'<tr><td><a class="has-text-weight-bold" href="'+e+"/lots/"+s.lotId+'">'+s.lotName+'</a></td><td><a href="'+e+"/maps/"+s.mapId+'">'+s.mapName+"</a></td><td>"+s.lotType+"</td><td>"+s.lotStatus+"<br />"+(s.lotOccupancyCount>0?'<span class="is-size-7">Currently Occupied</span>':"")+"</td></tr>");s.innerHTML='<table class="table is-fullwidth is-striped is-hoverable"><thead><tr><th>'+exports.aliases.lot+"</th><th>"+exports.aliases.map+"</th><th>"+exports.aliases.lot+' Type</th><th>Status</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(t.count,a+i)+" of "+t.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>':"")+(a+i<t.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(r),i>0&&s.querySelector("button[data-page='previous']").addEventListener("click",o),a+i<t.count&&s.querySelector("button[data-page='next']").addEventListener("click",n)})},l=()=>{r.value="0",i()},o=()=>{r.value=Math.max(Number.parseInt(r.value,10)-a,0).toString(),i()},n=()=>{r.value=(Number.parseInt(r.value,10)+a).toString(),i()},d=t.querySelectorAll("input, select");for(const e of d)e.addEventListener("change",l);t.addEventListener("submit",e=>{e.preventDefault(),l()}),i()})();

File diff suppressed because one or more lines are too long

View File

@ -11,6 +11,7 @@ import { getOccupants } from "../helpers/lotOccupancyDB/getOccupants.js";
import { addOccupant } from "../helpers/lotOccupancyDB/addOccupant.js";
import { addLotOccupancy } from "../helpers/lotOccupancyDB/addLotOccupancy.js";
import { addLotOccupancyOccupant } from "../helpers/lotOccupancyDB/addLotOccupancyOccupant.js";
import addLotOccupancyComment from "../helpers/lotOccupancyDB/addLotOccupancyComment.js";
const user = {
user: {
userName: "import.unix",
@ -22,11 +23,12 @@ const user = {
};
function purgeTables() {
const database = sqlite(databasePath);
database.prepare("delete from LotOccupancyComments").run();
database.prepare("delete from LotOccupancyOccupants").run();
database.prepare("delete from LotOccupancies").run();
database.prepare("delete from Occupants").run();
database.prepare("delete from Lots").run();
database.prepare("delete from sqlite_sequence where name in ('Lots', 'LotOccupancies', 'Occupants')").run();
database.prepare("delete from sqlite_sequence where name in ('Lots', 'LotOccupancies', 'LotOccupancyComments', 'Occupants')").run();
database.close();
}
function purgeConfigTables() {
@ -53,10 +55,15 @@ function formatDateString(year, month, day) {
}
const mapCache = new Map();
function getMap(masterRow) {
if (mapCache.has(masterRow.CM_CEMETERY)) {
return mapCache.get(masterRow.CM_CEMETERY);
let mapCacheKey = masterRow.CM_CEMETERY;
if (masterRow.CM_CEMETERY === "HS" &&
(masterRow.CM_BLOCK === "F" || masterRow.CM_BLOCK === "G" || masterRow.CM_BLOCK === "H" || masterRow.CM_BLOCK === "J")) {
mapCacheKey += "-" + masterRow.CM_BLOCK;
}
let map = getMapByMapDescription(masterRow.CM_CEMETERY);
if (mapCache.has(mapCacheKey)) {
return mapCache.get(mapCacheKey);
}
let map = getMapByMapDescription(mapCacheKey);
if (!map) {
console.log("Creating map: " + masterRow.CM_CEMETERY);
const mapId = addMap({
@ -74,12 +81,17 @@ function getMap(masterRow) {
}, user);
map = getMapFromDatabase(mapId);
}
mapCache.set(masterRow.CM_CEMETERY, map);
mapCache.set(mapCacheKey, map);
return map;
}
function importFromCSV() {
let masterRow;
const lotTypes = cacheFunctions.getLotTypes();
const casketLotType = cacheFunctions.getLotTypesByLotType("Casket Grave");
const columbariumLotType = cacheFunctions.getLotTypesByLotType("Columbarium");
const crematoriumLotType = cacheFunctions.getLotTypesByLotType("Crematorium");
const mausoleumLotType = cacheFunctions.getLotTypesByLotType("Mausoleum");
const nicheWallLotType = cacheFunctions.getLotTypesByLotType("Niche Wall");
const urnGardenLotType = cacheFunctions.getLotTypesByLotType("Urn Garden");
const availableLotStatus = cacheFunctions.getLotStatusByLotStatus("Available");
const preneedOccupancyType = cacheFunctions.getOccupancyTypeByOccupancyType("Preneed");
const preneedOwnerLotOccupantType = cacheFunctions.getLotOccupantTypesByLotOccupantType("Preneed Owner");
@ -103,15 +115,39 @@ function importFromCSV() {
(masterRow.CM_BLOCK === "" ? "" : masterRow.CM_BLOCK + "-") +
(masterRow.CM_RANGE1 === "0" && masterRow.CM_RANGE2 === "" ?
"" :
(masterRow.CM_RANGE2 === "" ?
masterRow.CM_RANGE1 :
masterRow.CM_RANGE2) + "-") +
masterRow.CM_LOT1 + masterRow.CM_LOT2 + "-" +
(masterRow.CM_RANGE1 + masterRow.CM_RANGE2) + "-") +
(masterRow.CM_LOT1 === "0" && masterRow.CM_LOT2 === "" ?
"" :
masterRow.CM_LOT1 + masterRow.CM_LOT2 + "-") +
masterRow.CM_GRAVE1 + masterRow.CM_GRAVE2 + "-" +
masterRow.CM_INTERMENT;
let lotType = casketLotType;
switch (masterRow.CM_CEMETERY) {
case "00": {
lotType = crematoriumLotType;
break;
}
case "GC":
case "HC": {
lotType = columbariumLotType;
break;
}
case "MA": {
lotType = mausoleumLotType;
break;
}
case "NW": {
lotType = nicheWallLotType;
break;
}
case "UG": {
lotType = urnGardenLotType;
break;
}
}
const lotId = addLot({
lotName: lotName,
lotTypeId: lotTypes[0].lotTypeId,
lotTypeId: lotType.lotTypeId,
lotStatusId: availableLotStatus.lotStatusId,
mapId: map.mapId,
mapKey: lotName,
@ -162,6 +198,22 @@ function importFromCSV() {
lotOccupantTypeId: preneedOwnerLotOccupantType.lotOccupantTypeId,
occupantId
}, user);
if (masterRow.CM_REMARK1 !== "") {
addLotOccupancyComment({
lotOccupancyId,
lotOccupancyCommentDateString: occupancyStartDateString,
lotOccupancyCommentTimeString: "00:00",
lotOccupancyComment: masterRow.CM_REMARK1
}, user);
}
if (masterRow.CM_REMARK2 !== "") {
addLotOccupancyComment({
lotOccupancyId,
lotOccupancyCommentDateString: occupancyStartDateString,
lotOccupancyCommentTimeString: "00:00",
lotOccupancyComment: masterRow.CM_REMARK2
}, user);
}
if (occupancyEndDateString === "") {
updateLotStatus(lotId, reservedLotStatus.lotStatusId, user);
}
@ -196,6 +248,22 @@ function importFromCSV() {
lotOccupantTypeId: deceasedLotOccupantType.lotOccupantTypeId,
occupantId
}, user);
if (masterRow.CM_REMARK1 !== "") {
addLotOccupancyComment({
lotOccupancyId,
lotOccupancyCommentDateString: occupancyStartDateString,
lotOccupancyCommentTimeString: "00:00",
lotOccupancyComment: masterRow.CM_REMARK1
}, user);
}
if (masterRow.CM_REMARK2 !== "") {
addLotOccupancyComment({
lotOccupancyId,
lotOccupancyCommentDateString: occupancyStartDateString,
lotOccupancyCommentTimeString: "00:00",
lotOccupancyComment: masterRow.CM_REMARK2
}, user);
}
updateLotStatus(lotId, takenLotStatus.lotStatusId, user);
}
}

View File

@ -38,6 +38,7 @@ import {
} from "../helpers/lotOccupancyDB/addLotOccupancyOccupant.js";
import type * as recordTypes from "../types/recordTypes";
import addLotOccupancyComment from "../helpers/lotOccupancyDB/addLotOccupancyComment.js";
interface MasterRecord {
@ -103,11 +104,12 @@ const user: recordTypes.PartialSession = {
function purgeTables() {
const database = sqlite(databasePath);
database.prepare("delete from LotOccupancyComments").run();
database.prepare("delete from LotOccupancyOccupants").run();
database.prepare("delete from LotOccupancies").run();
database.prepare("delete from Occupants").run();
database.prepare("delete from Lots").run();
database.prepare("delete from sqlite_sequence where name in ('Lots', 'LotOccupancies', 'Occupants')").run();
database.prepare("delete from sqlite_sequence where name in ('Lots', 'LotOccupancies', 'LotOccupancyComments', 'Occupants')").run();
database.close();
}
@ -149,11 +151,19 @@ const mapCache: Map < string, recordTypes.Map > = new Map();
function getMap(masterRow: MasterRecord): recordTypes.Map {
if (mapCache.has(masterRow.CM_CEMETERY)) {
return mapCache.get(masterRow.CM_CEMETERY);
let mapCacheKey = masterRow.CM_CEMETERY;
if (masterRow.CM_CEMETERY === "HS" &&
(masterRow.CM_BLOCK === "F" || masterRow.CM_BLOCK === "G" || masterRow.CM_BLOCK === "H" || masterRow.CM_BLOCK === "J")) {
mapCacheKey += "-" + masterRow.CM_BLOCK;
}
let map = getMapByMapDescription(masterRow.CM_CEMETERY);
if (mapCache.has(mapCacheKey)) {
return mapCache.get(mapCacheKey);
}
let map = getMapByMapDescription(mapCacheKey);
if (!map) {
@ -176,7 +186,7 @@ function getMap(masterRow: MasterRecord): recordTypes.Map {
map = getMapFromDatabase(mapId);
}
mapCache.set(masterRow.CM_CEMETERY, map);
mapCache.set(mapCacheKey, map);
return map;
}
@ -187,7 +197,12 @@ function importFromCSV() {
let masterRow: MasterRecord;
// Load cached values
const lotTypes = cacheFunctions.getLotTypes();
const casketLotType = cacheFunctions.getLotTypesByLotType("Casket Grave");
const columbariumLotType = cacheFunctions.getLotTypesByLotType("Columbarium");
const crematoriumLotType = cacheFunctions.getLotTypesByLotType("Crematorium");
const mausoleumLotType = cacheFunctions.getLotTypesByLotType("Mausoleum");
const nicheWallLotType = cacheFunctions.getLotTypesByLotType("Niche Wall");
const urnGardenLotType = cacheFunctions.getLotTypesByLotType("Urn Garden");
const availableLotStatus = cacheFunctions.getLotStatusByLotStatus("Available");
@ -220,16 +235,42 @@ function importFromCSV() {
(masterRow.CM_BLOCK === "" ? "" : masterRow.CM_BLOCK + "-") +
(masterRow.CM_RANGE1 === "0" && masterRow.CM_RANGE2 === "" ?
"" :
(masterRow.CM_RANGE2 === "" ?
masterRow.CM_RANGE1 :
masterRow.CM_RANGE2) + "-") +
masterRow.CM_LOT1 + masterRow.CM_LOT2 + "-" +
(masterRow.CM_RANGE1 + masterRow.CM_RANGE2) + "-") +
(masterRow.CM_LOT1 === "0" && masterRow.CM_LOT2 === "" ?
"" :
masterRow.CM_LOT1 + masterRow.CM_LOT2 + "-") +
masterRow.CM_GRAVE1 + masterRow.CM_GRAVE2 + "-" +
masterRow.CM_INTERMENT;
let lotType = casketLotType;
switch (masterRow.CM_CEMETERY) {
case "00": {
lotType = crematoriumLotType;
break;
}
case "GC":
case "HC": {
lotType = columbariumLotType;
break;
}
case "MA": {
lotType = mausoleumLotType;
break;
}
case "NW": {
lotType = nicheWallLotType;
break;
}
case "UG": {
lotType = urnGardenLotType;
break;
}
}
const lotId = addLot({
lotName: lotName,
lotTypeId: lotTypes[0].lotTypeId,
lotTypeId: lotType.lotTypeId,
lotStatusId: availableLotStatus.lotStatusId,
mapId: map.mapId,
mapKey: lotName,
@ -301,6 +342,24 @@ function importFromCSV() {
occupantId
}, user);
if (masterRow.CM_REMARK1 !== "") {
addLotOccupancyComment({
lotOccupancyId,
lotOccupancyCommentDateString: occupancyStartDateString,
lotOccupancyCommentTimeString: "00:00",
lotOccupancyComment: masterRow.CM_REMARK1
}, user);
}
if (masterRow.CM_REMARK2 !== "") {
addLotOccupancyComment({
lotOccupancyId,
lotOccupancyCommentDateString: occupancyStartDateString,
lotOccupancyCommentTimeString: "00:00",
lotOccupancyComment: masterRow.CM_REMARK2
}, user);
}
if (occupancyEndDateString === "") {
updateLotStatus(lotId, reservedLotStatus.lotStatusId, user);
}
@ -350,6 +409,24 @@ function importFromCSV() {
occupantId
}, user);
if (masterRow.CM_REMARK1 !== "") {
addLotOccupancyComment({
lotOccupancyId,
lotOccupancyCommentDateString: occupancyStartDateString,
lotOccupancyCommentTimeString: "00:00",
lotOccupancyComment: masterRow.CM_REMARK1
}, user);
}
if (masterRow.CM_REMARK2 !== "") {
addLotOccupancyComment({
lotOccupancyId,
lotOccupancyCommentDateString: occupancyStartDateString,
lotOccupancyCommentTimeString: "00:00",
lotOccupancyComment: masterRow.CM_REMARK2
}, user);
}
updateLotStatus(lotId, takenLotStatus.lotStatusId, user);
}
}

View File

@ -63,11 +63,24 @@ export interface Lot extends Record {
lotStatusId?: number;
lotStatus?: LotStatus | string;
lotOccupancyCount?: number;
lotOccupancies?: LotOccupancy[];
}
export interface OccupancyType extends Record {
occupancyTypeId?: number;
occupancyType?: string;
orderNumber?: number;
occupancyTypeFields?: OccupancyTypeField[];
}
export interface OccupancyTypeField {
occupancyTypeFieldId?: number;
occupancyTypeId?: number;
occupancyTypeField?: string;
occupancyTypeFieldValues?: string;
isRequired?: boolean;
pattern?: string;
minimumLength?: number;
maximumLength?: number;
orderNumber?: number;
}
export interface LotOccupantType extends Record {
lotOccupantTypeId?: number;
@ -84,6 +97,18 @@ export interface Occupant extends Record {
occupantPostalCode?: string;
occupantPhoneNumber?: string;
}
export interface LotOccupancy extends Record {
lotOccupancyId?: number;
occupancyTypeId?: number;
occupancyType?: OccupancyType | string;
lotId?: number;
occupantId?: number;
occupant?: Occupant;
occupancyStartDate?: number;
occupancyStartDateString?: string;
occupancyEndDate?: number;
occupancyEndDateString?: string;
}
export interface User {
userName: string;
userProperties?: UserProperties;

View File

@ -91,6 +91,7 @@ export interface Lot extends Record {
lotStatus?: LotStatus | string;
lotOccupancyCount?: number;
lotOccupancies?: LotOccupancy[];
}
@ -98,6 +99,20 @@ export interface OccupancyType extends Record {
occupancyTypeId?: number;
occupancyType?: string;
orderNumber?: number;
occupancyTypeFields?: OccupancyTypeField[];
}
export interface OccupancyTypeField {
occupancyTypeFieldId?: number;
occupancyTypeId?: number;
occupancyTypeField?: string;
occupancyTypeFieldValues?: string;
isRequired?: boolean;
pattern?: string;
minimumLength?: number;
maximumLength?: number;
orderNumber?: number;
}
@ -120,6 +135,25 @@ export interface Occupant extends Record {
}
export interface LotOccupancy extends Record {
lotOccupancyId?: number;
occupancyTypeId?: number;
occupancyType?: OccupancyType | string;
lotId?: number;
occupantId?: number;
occupant?: Occupant;
occupancyStartDate?: number;
occupancyStartDateString?: string;
occupancyEndDate?: number;
occupancyEndDateString?: string;
}
/*
* USER TYPES
*/

View File

@ -41,6 +41,12 @@
</span>
<span><%= configFunctions.getProperty("aliases.lots") %></span>
</a>
<a class="navbar-item" href="<%= urlPrefix %>/maps">
<span class="icon mr-1">
<i class="far fa-fw fa-map" aria-hidden="true"></i>
</span>
<span><%= configFunctions.getProperty("aliases.maps") %></span>
</a>
<div class="navbar-item has-dropdown">
@ -51,12 +57,6 @@
</span>
</a>
<div class="navbar-dropdown">
<a class="navbar-item" href="<%= urlPrefix %>/maps">
<span class="icon mr-1">
<i class="far fa-fw fa-map" aria-hidden="true"></i>
</span>
<span><%= configFunctions.getProperty("aliases.maps") %></span>
</a>
<a class="navbar-item" href="<%= urlPrefix %>/reports">
<span class="icon mr-1">
<i class="fas fa-fw fa-file" aria-hidden="true"></i>

View File

@ -25,8 +25,8 @@
<div class="box">
<form id="form--searchFilters">
<input name="limit" type="hidden" value="100" />
<input name="offset" type="hidden" value="0" />
<input id="searchFilter--limit" name="limit" type="hidden" value="100" />
<input id="searchFilter--offset" name="offset" type="hidden" value="0" />
<div class="columns">
<div class="column">
<div class="field">

View File

@ -20,6 +20,11 @@
<%= lot.lotName %>
</h1>
<div>
<strong><%= configFunctions.getProperty("aliases.lot") %> Type</strong><br />
<%= lot.lotType %>
</div>
<% if (user.userProperties.canUpdate) { %>
<div class="fixed-container is-fixed-bottom-right mx-4 my-4 has-text-right is-hidden-print">
<a class="button is-circle is-primary has-tooltip-left" data-tooltip="Update <%= configFunctions.getProperty("aliases.lot") %>" href="<%= urlPrefix %>/lots/<%= lot.lotId %>/edit>">

View File

@ -75,9 +75,9 @@
<h2 class="title is-4">Image</h2>
<% if (map.mapSVG) { %>
<% const imageURL = urlPrefix + "/images/maps/" + map.mapSVG %>
<div class="image">
<a class="image" href="<%= urlPrefix %>/images/maps/<%= map.mapSVG %>" target="_blank">
<%- include('../public/images/maps/' + map.mapSVG); -%>
</div>
</a>
<% } else { %>
<div class="message is-info">
<p class="message-body">There are no image associated with this <%= configFunctions.getProperty("aliases.map").toLowerCase() %>.</p>
@ -87,9 +87,14 @@
</div>
<h2 class="title is-4">
<%= configFunctions.getProperty("aliases.lots") %>
<span class="tag"><%= map.lotCount %></span>
Related Searches
</h2>
<a class="button is-link" href="<%= urlPrefix %>/lots?mapId=<%= map.mapId %>">
<span class="icon is-small"><i class="fas fa-vector-square" aria-hidden="true"></i></span>
<span class="mr-2"><%= configFunctions.getProperty("aliases.lots") %></span>
<span class="tag"><%= map.lotCount %></span>
</a>
</div>
</div>