track burial site capacities
alter table BurialSiteTypes add bodyCapacityMax smallint alter table BurialSiteTypes add crematedCapacityMax smallint alter table BurialSites add bodyCapacity smallint alter table BurialSites add crematedCapacity smallintpull/11/head
parent
9c47b48abc
commit
db05999c72
|
|
@ -6,6 +6,7 @@ export const config = {
|
|||
settings: {
|
||||
adminCleanup: {},
|
||||
burialSites: {},
|
||||
burialSiteTypes: {},
|
||||
cemeteries: {},
|
||||
contracts: {},
|
||||
dynamicsGP: {
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ export const config: Config = {
|
|||
settings: {
|
||||
adminCleanup: {},
|
||||
burialSites: {},
|
||||
burialSiteTypes: {},
|
||||
cemeteries: {},
|
||||
contracts: {},
|
||||
dynamicsGP: {
|
||||
|
|
|
|||
|
|
@ -33,6 +33,8 @@ export declare const configDefaultValues: {
|
|||
'settings.longitudeMax': number;
|
||||
'settings.longitudeMin': number;
|
||||
'settings.cemeteries.refreshImageChanges': boolean;
|
||||
'settings.burialSiteTypes.bodyCapacityMaxDefault': number;
|
||||
'settings.burialSiteTypes.crematedCapacityMaxDefault': number;
|
||||
'settings.burialSites.burialSiteNameSegments': ConfigBurialSiteNameSegments;
|
||||
'settings.burialSites.burialSiteNameSegments.includeCemeteryKey': boolean;
|
||||
'settings.burialSites.refreshImageChanges': boolean;
|
||||
|
|
|
|||
|
|
@ -32,6 +32,10 @@ export const configDefaultValues = {
|
|||
'settings.longitudeMax': 180,
|
||||
'settings.longitudeMin': -180,
|
||||
'settings.cemeteries.refreshImageChanges': false,
|
||||
// eslint-disable-next-line no-secrets/no-secrets
|
||||
'settings.burialSiteTypes.bodyCapacityMaxDefault': 2,
|
||||
// eslint-disable-next-line no-secrets/no-secrets
|
||||
'settings.burialSiteTypes.crematedCapacityMaxDefault': 6,
|
||||
'settings.burialSites.burialSiteNameSegments': {
|
||||
includeCemeteryKey: false,
|
||||
separator: '-',
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
import type { config as MSSQLConfig } from 'mssql'
|
||||
|
||||
import { hoursToMillis } from '@cityssm/to-millis'
|
||||
import type { config as MSSQLConfig } from 'mssql'
|
||||
|
||||
import type {
|
||||
ConfigActiveDirectory,
|
||||
|
|
@ -52,6 +51,12 @@ export const configDefaultValues = {
|
|||
|
||||
'settings.cemeteries.refreshImageChanges': false,
|
||||
|
||||
// eslint-disable-next-line no-secrets/no-secrets
|
||||
'settings.burialSiteTypes.bodyCapacityMaxDefault': 2,
|
||||
|
||||
// eslint-disable-next-line no-secrets/no-secrets
|
||||
'settings.burialSiteTypes.crematedCapacityMaxDefault': 6,
|
||||
|
||||
'settings.burialSites.burialSiteNameSegments': {
|
||||
includeCemeteryKey: false,
|
||||
separator: '-',
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ export interface AddBurialSiteForm {
|
|||
burialSiteNameSegment5?: string;
|
||||
burialSiteStatusId: number | string;
|
||||
burialSiteTypeId: number | string;
|
||||
bodyCapacity?: number | string;
|
||||
crematedCapacity?: number | string;
|
||||
burialSiteImage?: string;
|
||||
cemeteryId: number | string;
|
||||
cemeterySvgId?: string;
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import getCemetery from './getCemetery.js';
|
|||
* @returns The new burial site's id.
|
||||
* @throws If an active burial site with the same name already exists.
|
||||
*/
|
||||
// eslint-disable-next-line complexity
|
||||
export default function addBurialSite(burialSiteForm, user) {
|
||||
const database = sqlite(sunriseDB);
|
||||
const rightNowMillis = Date.now();
|
||||
|
|
@ -38,17 +39,22 @@ export default function addBurialSite(burialSiteForm, user) {
|
|||
burialSiteNameSegment5,
|
||||
burialSiteName,
|
||||
burialSiteTypeId, burialSiteStatusId,
|
||||
bodyCapacity, crematedCapacity,
|
||||
cemeteryId, cemeterySvgId, burialSiteImage,
|
||||
burialSiteLatitude, burialSiteLongitude,
|
||||
|
||||
recordCreate_userName, recordCreate_timeMillis,
|
||||
recordUpdate_userName, recordUpdate_timeMillis)
|
||||
values (?, ?, ?,
|
||||
values (?, ?, ?, ?, ?,
|
||||
?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
|
||||
?, ?, ?, ?)`)
|
||||
.run(burialSiteForm.burialSiteNameSegment1 ?? '', burialSiteForm.burialSiteNameSegment2 ?? '', burialSiteForm.burialSiteNameSegment3 ?? '', burialSiteForm.burialSiteNameSegment4 ?? '', burialSiteForm.burialSiteNameSegment5 ?? '', burialSiteName, burialSiteForm.burialSiteTypeId, burialSiteForm.burialSiteStatusId === ''
|
||||
? undefined
|
||||
: burialSiteForm.burialSiteStatusId, burialSiteForm.cemeteryId === '' ? undefined : burialSiteForm.cemeteryId, burialSiteForm.cemeterySvgId, burialSiteForm.burialSiteImage ?? '', burialSiteForm.burialSiteLatitude === ''
|
||||
: burialSiteForm.burialSiteStatusId, burialSiteForm.bodyCapacity === ''
|
||||
? undefined
|
||||
: burialSiteForm.bodyCapacity, burialSiteForm.crematedCapacity === ''
|
||||
? undefined
|
||||
: burialSiteForm.crematedCapacity, burialSiteForm.cemeteryId === '' ? undefined : burialSiteForm.cemeteryId, burialSiteForm.cemeterySvgId, burialSiteForm.burialSiteImage ?? '', burialSiteForm.burialSiteLatitude === ''
|
||||
? undefined
|
||||
: burialSiteForm.burialSiteLatitude, burialSiteForm.burialSiteLongitude === ''
|
||||
? undefined
|
||||
|
|
|
|||
|
|
@ -16,6 +16,9 @@ export interface AddBurialSiteForm {
|
|||
burialSiteStatusId: number | string
|
||||
burialSiteTypeId: number | string
|
||||
|
||||
bodyCapacity?: number | string
|
||||
crematedCapacity?: number | string
|
||||
|
||||
burialSiteImage?: string
|
||||
cemeteryId: number | string
|
||||
cemeterySvgId?: string
|
||||
|
|
@ -35,6 +38,7 @@ export interface AddBurialSiteForm {
|
|||
* @returns The new burial site's id.
|
||||
* @throws If an active burial site with the same name already exists.
|
||||
*/
|
||||
// eslint-disable-next-line complexity
|
||||
export default function addBurialSite(
|
||||
burialSiteForm: AddBurialSiteForm,
|
||||
user: User
|
||||
|
|
@ -80,12 +84,13 @@ export default function addBurialSite(
|
|||
burialSiteNameSegment5,
|
||||
burialSiteName,
|
||||
burialSiteTypeId, burialSiteStatusId,
|
||||
bodyCapacity, crematedCapacity,
|
||||
cemeteryId, cemeterySvgId, burialSiteImage,
|
||||
burialSiteLatitude, burialSiteLongitude,
|
||||
|
||||
recordCreate_userName, recordCreate_timeMillis,
|
||||
recordUpdate_userName, recordUpdate_timeMillis)
|
||||
values (?, ?, ?,
|
||||
values (?, ?, ?, ?, ?,
|
||||
?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
|
||||
?, ?, ?, ?)`
|
||||
)
|
||||
|
|
@ -100,6 +105,15 @@ export default function addBurialSite(
|
|||
burialSiteForm.burialSiteStatusId === ''
|
||||
? undefined
|
||||
: burialSiteForm.burialSiteStatusId,
|
||||
|
||||
burialSiteForm.bodyCapacity === ''
|
||||
? undefined
|
||||
: burialSiteForm.bodyCapacity,
|
||||
|
||||
burialSiteForm.crematedCapacity === ''
|
||||
? undefined
|
||||
: burialSiteForm.crematedCapacity,
|
||||
|
||||
burialSiteForm.cemeteryId === '' ? undefined : burialSiteForm.cemeteryId,
|
||||
burialSiteForm.cemeterySvgId,
|
||||
burialSiteForm.burialSiteImage ?? '',
|
||||
|
|
|
|||
|
|
@ -0,0 +1,7 @@
|
|||
export interface AddBurialSiteTypeForm {
|
||||
burialSiteType: string;
|
||||
bodyCapacityMax: number | string;
|
||||
crematedCapacityMax: number | string;
|
||||
orderNumber?: number | string;
|
||||
}
|
||||
export default function addBurialSiteType(addForm: AddBurialSiteTypeForm, user: User): number;
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
import sqlite from 'better-sqlite3';
|
||||
import { sunriseDB } from '../helpers/database.helpers.js';
|
||||
import { clearCacheByTableName } from '../helpers/functions.cache.js';
|
||||
export default function addBurialSiteType(addForm, user) {
|
||||
const database = sqlite(sunriseDB);
|
||||
const rightNowMillis = Date.now();
|
||||
const result = database
|
||||
.prepare(`insert into BurialSiteTypes (
|
||||
burialSiteType, bodyCapacityMax, crematedCapacityMax,
|
||||
orderNumber,
|
||||
recordCreate_userName, recordCreate_timeMillis,
|
||||
recordUpdate_userName, recordUpdate_timeMillis)
|
||||
values (?, ?, ?, ?, ?, ?, ?, ?)`)
|
||||
.run(addForm.burialSiteType, addForm.bodyCapacityMax === '' ? undefined : addForm.bodyCapacityMax, addForm.crematedCapacityMax === ''
|
||||
? undefined
|
||||
: addForm.crematedCapacityMax, addForm.orderNumber ?? -1, user.userName, rightNowMillis, user.userName, rightNowMillis);
|
||||
database.close();
|
||||
clearCacheByTableName('BurialSiteTypes');
|
||||
return result.lastInsertRowid;
|
||||
}
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
import sqlite from 'better-sqlite3'
|
||||
|
||||
import { sunriseDB } from '../helpers/database.helpers.js'
|
||||
import { clearCacheByTableName } from '../helpers/functions.cache.js'
|
||||
|
||||
export interface AddBurialSiteTypeForm {
|
||||
burialSiteType: string
|
||||
|
||||
bodyCapacityMax: number | string
|
||||
crematedCapacityMax: number | string
|
||||
|
||||
orderNumber?: number | string
|
||||
}
|
||||
|
||||
export default function addBurialSiteType(
|
||||
addForm: AddBurialSiteTypeForm,
|
||||
user: User
|
||||
): number {
|
||||
const database = sqlite(sunriseDB)
|
||||
|
||||
const rightNowMillis = Date.now()
|
||||
|
||||
const result = database
|
||||
.prepare(
|
||||
`insert into BurialSiteTypes (
|
||||
burialSiteType, bodyCapacityMax, crematedCapacityMax,
|
||||
orderNumber,
|
||||
recordCreate_userName, recordCreate_timeMillis,
|
||||
recordUpdate_userName, recordUpdate_timeMillis)
|
||||
values (?, ?, ?, ?, ?, ?, ?, ?)`
|
||||
)
|
||||
.run(
|
||||
addForm.burialSiteType,
|
||||
addForm.bodyCapacityMax === '' ? undefined : addForm.bodyCapacityMax,
|
||||
addForm.crematedCapacityMax === ''
|
||||
? undefined
|
||||
: addForm.crematedCapacityMax,
|
||||
addForm.orderNumber ?? -1,
|
||||
user.userName,
|
||||
rightNowMillis,
|
||||
user.userName,
|
||||
rightNowMillis
|
||||
)
|
||||
|
||||
database.close()
|
||||
|
||||
clearCacheByTableName('BurialSiteTypes')
|
||||
|
||||
return result.lastInsertRowid as number
|
||||
}
|
||||
|
|
@ -1,3 +1,3 @@
|
|||
type RecordTable = 'BurialSiteStatuses' | 'BurialSiteTypes' | 'WorkOrderMilestoneTypes' | 'WorkOrderTypes';
|
||||
type RecordTable = 'BurialSiteStatuses' | 'WorkOrderMilestoneTypes' | 'WorkOrderTypes';
|
||||
export default function addRecord(recordTable: RecordTable, recordName: string, orderNumber: number | string, user: User): number;
|
||||
export {};
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ import { sunriseDB } from '../helpers/database.helpers.js';
|
|||
import { clearCacheByTableName } from '../helpers/functions.cache.js';
|
||||
const recordNameColumns = new Map([
|
||||
['BurialSiteStatuses', 'burialSiteStatus'],
|
||||
['BurialSiteTypes', 'burialSiteType'],
|
||||
['WorkOrderMilestoneTypes', 'workOrderMilestoneType'],
|
||||
['WorkOrderTypes', 'workOrderType']
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -5,13 +5,11 @@ import { clearCacheByTableName } from '../helpers/functions.cache.js'
|
|||
|
||||
type RecordTable =
|
||||
| 'BurialSiteStatuses'
|
||||
| 'BurialSiteTypes'
|
||||
| 'WorkOrderMilestoneTypes'
|
||||
| 'WorkOrderTypes'
|
||||
|
||||
const recordNameColumns = new Map<RecordTable, string>([
|
||||
['BurialSiteStatuses', 'burialSiteStatus'],
|
||||
['BurialSiteTypes', 'burialSiteType'],
|
||||
['WorkOrderMilestoneTypes', 'workOrderMilestoneType'],
|
||||
['WorkOrderTypes', 'workOrderType']
|
||||
])
|
||||
|
|
|
|||
|
|
@ -13,6 +13,9 @@ const baseSQL = `select l.burialSiteId,
|
|||
l.burialSiteName,
|
||||
l.burialSiteStatusId, s.burialSiteStatus,
|
||||
|
||||
l.bodyCapacity, l.crematedCapacity,
|
||||
t.bodyCapacityMax, t.crematedCapacityMax,
|
||||
|
||||
l.cemeteryId, m.cemeteryName,
|
||||
m.cemeteryLatitude, m.cemeteryLongitude,
|
||||
m.cemeterySvg, l.cemeterySvgId, l.burialSiteImage,
|
||||
|
|
|
|||
|
|
@ -17,6 +17,9 @@ const baseSQL = `select l.burialSiteId,
|
|||
l.burialSiteName,
|
||||
l.burialSiteStatusId, s.burialSiteStatus,
|
||||
|
||||
l.bodyCapacity, l.crematedCapacity,
|
||||
t.bodyCapacityMax, t.crematedCapacityMax,
|
||||
|
||||
l.cemeteryId, m.cemeteryName,
|
||||
m.cemeteryLatitude, m.cemeteryLongitude,
|
||||
m.cemeterySvg, l.cemeterySvgId, l.burialSiteImage,
|
||||
|
|
|
|||
|
|
@ -4,9 +4,11 @@ import getBurialSiteTypeFields from './getBurialSiteTypeFields.js';
|
|||
import { updateRecordOrderNumber } from './updateRecordOrderNumber.js';
|
||||
export default function getBurialSiteTypes(includeDeleted = false) {
|
||||
const database = sqlite(sunriseDB);
|
||||
const updateOrderNumbers = !database.readonly && !includeDeleted;
|
||||
const updateOrderNumbers = !includeDeleted;
|
||||
const burialSiteTypes = database
|
||||
.prepare(`select burialSiteTypeId, burialSiteType, orderNumber
|
||||
.prepare(`select burialSiteTypeId, burialSiteType,
|
||||
bodyCapacityMax, crematedCapacityMax,
|
||||
orderNumber
|
||||
from BurialSiteTypes
|
||||
${includeDeleted ? '' : ' where recordDelete_timeMillis is null '}
|
||||
order by orderNumber, burialSiteType`)
|
||||
|
|
|
|||
|
|
@ -11,11 +11,13 @@ export default function getBurialSiteTypes(
|
|||
): BurialSiteType[] {
|
||||
const database = sqlite(sunriseDB)
|
||||
|
||||
const updateOrderNumbers = !database.readonly && !includeDeleted
|
||||
const updateOrderNumbers = !includeDeleted
|
||||
|
||||
const burialSiteTypes = database
|
||||
.prepare(
|
||||
`select burialSiteTypeId, burialSiteType, orderNumber
|
||||
`select burialSiteTypeId, burialSiteType,
|
||||
bodyCapacityMax, crematedCapacityMax,
|
||||
orderNumber
|
||||
from BurialSiteTypes
|
||||
${includeDeleted ? '' : ' where recordDelete_timeMillis is null '}
|
||||
order by orderNumber, burialSiteType`
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@ export interface GetBurialSitesFilters {
|
|||
burialSiteNameSearchType?: '' | 'endsWith' | 'startsWith';
|
||||
burialSiteName?: string;
|
||||
cemeteryId?: number | string;
|
||||
burialSiteTypeId?: number | string;
|
||||
burialSiteStatusId?: number | string;
|
||||
burialSiteTypeId?: number | string;
|
||||
contractStatus?: '' | 'occupied' | 'unoccupied';
|
||||
workOrderId?: number | string;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ export default function getBurialSites(filters, options, connectedDatabase) {
|
|||
l.burialSiteNameSegment5,
|
||||
l.burialSiteName,
|
||||
t.burialSiteType,
|
||||
l.bodyCapacity, l.crematedCapacity,
|
||||
l.cemeteryId, m.cemeteryName, l.cemeterySvgId,
|
||||
l.burialSiteStatusId, s.burialSiteStatus
|
||||
${includeContractCount
|
||||
|
|
|
|||
|
|
@ -9,8 +9,9 @@ export interface GetBurialSitesFilters {
|
|||
burialSiteNameSearchType?: '' | 'endsWith' | 'startsWith'
|
||||
burialSiteName?: string
|
||||
cemeteryId?: number | string
|
||||
burialSiteTypeId?: number | string
|
||||
|
||||
burialSiteStatusId?: number | string
|
||||
burialSiteTypeId?: number | string
|
||||
contractStatus?: '' | 'occupied' | 'unoccupied'
|
||||
workOrderId?: number | string
|
||||
}
|
||||
|
|
@ -75,6 +76,7 @@ export default function getBurialSites(
|
|||
l.burialSiteNameSegment5,
|
||||
l.burialSiteName,
|
||||
t.burialSiteType,
|
||||
l.bodyCapacity, l.crematedCapacity,
|
||||
l.cemeteryId, m.cemeteryName, l.cemeterySvgId,
|
||||
l.burialSiteStatusId, s.burialSiteStatus
|
||||
${
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import sqlite from 'better-sqlite3';
|
|||
import Debug from 'debug';
|
||||
import { DEBUG_NAMESPACE } from '../debug.config.js';
|
||||
import { sunriseDB as databasePath } from '../helpers/database.helpers.js';
|
||||
import addBurialSiteType from './addBurialSiteType.js';
|
||||
import addCommittalType from './addCommittalType.js';
|
||||
import addContractType from './addContractType.js';
|
||||
import addFeeCategory from './addFeeCategory.js';
|
||||
|
|
@ -23,6 +24,8 @@ const createStatements = [
|
|||
`create table if not exists BurialSiteTypes (
|
||||
burialSiteTypeId integer not null primary key autoincrement,
|
||||
burialSiteType varchar(100) not null,
|
||||
bodyCapacityMax smallint,
|
||||
crematedCapacityMax smallint,
|
||||
orderNumber smallint not null default 0,
|
||||
${recordColumns})`,
|
||||
`create index if not exists idx_BurialSiteTypes_orderNumber
|
||||
|
|
@ -94,6 +97,9 @@ const createStatements = [
|
|||
burialSiteNameSegment5 varchar(20) not null,
|
||||
burialSiteName varchar(200) not null,
|
||||
|
||||
bodyCapacity smallint,
|
||||
crematedCapacity smallint,
|
||||
|
||||
cemeteryId integer,
|
||||
cemeterySvgId varchar(100),
|
||||
burialSiteImage varchar(100) not null default '',
|
||||
|
|
@ -412,12 +418,42 @@ export function initializeDatabase() {
|
|||
}
|
||||
function initializeData() {
|
||||
debug('Initializing data...');
|
||||
addRecord('BurialSiteTypes', 'Casket Grave', 1, initializingUser);
|
||||
addRecord('BurialSiteTypes', 'Columbarium', 2, initializingUser);
|
||||
addRecord('BurialSiteTypes', 'Mausoleum', 2, initializingUser);
|
||||
addRecord('BurialSiteTypes', 'Niche Wall', 2, initializingUser);
|
||||
addRecord('BurialSiteTypes', 'Urn Garden', 2, initializingUser);
|
||||
addRecord('BurialSiteTypes', 'Crematorium', 2, initializingUser);
|
||||
addBurialSiteType({
|
||||
burialSiteType: 'In-Ground Grave',
|
||||
bodyCapacityMax: 2,
|
||||
crematedCapacityMax: 6,
|
||||
orderNumber: 1
|
||||
}, initializingUser);
|
||||
addBurialSiteType({
|
||||
burialSiteType: 'Columbarium',
|
||||
bodyCapacityMax: 0,
|
||||
crematedCapacityMax: '',
|
||||
orderNumber: 2
|
||||
}, initializingUser);
|
||||
addBurialSiteType({
|
||||
burialSiteType: 'Mausoleum',
|
||||
bodyCapacityMax: 2,
|
||||
crematedCapacityMax: 0,
|
||||
orderNumber: 2
|
||||
}, initializingUser);
|
||||
addBurialSiteType({
|
||||
burialSiteType: 'Niche Wall',
|
||||
bodyCapacityMax: 0,
|
||||
crematedCapacityMax: 1,
|
||||
orderNumber: 2
|
||||
}, initializingUser);
|
||||
addBurialSiteType({
|
||||
burialSiteType: 'Urn Garden',
|
||||
bodyCapacityMax: 0,
|
||||
crematedCapacityMax: 1,
|
||||
orderNumber: 2
|
||||
}, initializingUser);
|
||||
addBurialSiteType({
|
||||
burialSiteType: 'Crematorium',
|
||||
bodyCapacityMax: 0,
|
||||
crematedCapacityMax: 1,
|
||||
orderNumber: 2
|
||||
}, initializingUser);
|
||||
addRecord('BurialSiteStatuses', 'Available', 1, initializingUser);
|
||||
addRecord('BurialSiteStatuses', 'Reserved', 2, initializingUser);
|
||||
addRecord('BurialSiteStatuses', 'Taken', 3, initializingUser);
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import Debug from 'debug'
|
|||
import { DEBUG_NAMESPACE } from '../debug.config.js'
|
||||
import { sunriseDB as databasePath } from '../helpers/database.helpers.js'
|
||||
|
||||
import addBurialSiteType from './addBurialSiteType.js'
|
||||
import addCommittalType from './addCommittalType.js'
|
||||
import addContractType from './addContractType.js'
|
||||
import addFeeCategory from './addFeeCategory.js'
|
||||
|
|
@ -30,6 +31,8 @@ const createStatements = [
|
|||
`create table if not exists BurialSiteTypes (
|
||||
burialSiteTypeId integer not null primary key autoincrement,
|
||||
burialSiteType varchar(100) not null,
|
||||
bodyCapacityMax smallint,
|
||||
crematedCapacityMax smallint,
|
||||
orderNumber smallint not null default 0,
|
||||
${recordColumns})`,
|
||||
|
||||
|
|
@ -112,6 +115,9 @@ const createStatements = [
|
|||
burialSiteNameSegment5 varchar(20) not null,
|
||||
burialSiteName varchar(200) not null,
|
||||
|
||||
bodyCapacity smallint,
|
||||
crematedCapacity smallint,
|
||||
|
||||
cemeteryId integer,
|
||||
cemeterySvgId varchar(100),
|
||||
burialSiteImage varchar(100) not null default '',
|
||||
|
|
@ -482,12 +488,71 @@ export function initializeDatabase(): boolean {
|
|||
function initializeData(): void {
|
||||
debug('Initializing data...')
|
||||
|
||||
addRecord('BurialSiteTypes', 'Casket Grave', 1, initializingUser)
|
||||
addRecord('BurialSiteTypes', 'Columbarium', 2, initializingUser)
|
||||
addRecord('BurialSiteTypes', 'Mausoleum', 2, initializingUser)
|
||||
addRecord('BurialSiteTypes', 'Niche Wall', 2, initializingUser)
|
||||
addRecord('BurialSiteTypes', 'Urn Garden', 2, initializingUser)
|
||||
addRecord('BurialSiteTypes', 'Crematorium', 2, initializingUser)
|
||||
addBurialSiteType(
|
||||
{
|
||||
burialSiteType: 'In-Ground Grave',
|
||||
|
||||
bodyCapacityMax: 2,
|
||||
crematedCapacityMax: 6,
|
||||
orderNumber: 1
|
||||
},
|
||||
initializingUser
|
||||
)
|
||||
|
||||
addBurialSiteType(
|
||||
{
|
||||
burialSiteType: 'Columbarium',
|
||||
|
||||
bodyCapacityMax: 0,
|
||||
crematedCapacityMax: '',
|
||||
orderNumber: 2
|
||||
},
|
||||
initializingUser
|
||||
)
|
||||
|
||||
addBurialSiteType(
|
||||
{
|
||||
burialSiteType: 'Mausoleum',
|
||||
|
||||
bodyCapacityMax: 2,
|
||||
crematedCapacityMax: 0,
|
||||
orderNumber: 2
|
||||
},
|
||||
initializingUser
|
||||
)
|
||||
|
||||
addBurialSiteType(
|
||||
{
|
||||
burialSiteType: 'Niche Wall',
|
||||
|
||||
bodyCapacityMax: 0,
|
||||
crematedCapacityMax: 1,
|
||||
orderNumber: 2
|
||||
},
|
||||
initializingUser
|
||||
)
|
||||
|
||||
addBurialSiteType(
|
||||
{
|
||||
burialSiteType: 'Urn Garden',
|
||||
|
||||
bodyCapacityMax: 0,
|
||||
crematedCapacityMax: 1,
|
||||
orderNumber: 2
|
||||
},
|
||||
initializingUser
|
||||
)
|
||||
|
||||
addBurialSiteType(
|
||||
{
|
||||
burialSiteType: 'Crematorium',
|
||||
|
||||
bodyCapacityMax: 0,
|
||||
crematedCapacityMax: 1,
|
||||
orderNumber: 2
|
||||
},
|
||||
initializingUser
|
||||
)
|
||||
|
||||
addRecord('BurialSiteStatuses', 'Available', 1, initializingUser)
|
||||
addRecord('BurialSiteStatuses', 'Reserved', 2, initializingUser)
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@ export interface UpdateBurialSiteForm {
|
|||
burialSiteNameSegment5?: string;
|
||||
burialSiteStatusId: number | string;
|
||||
burialSiteTypeId: number | string;
|
||||
bodyCapacity?: number | string;
|
||||
crematedCapacity?: number | string;
|
||||
burialSiteImage: string;
|
||||
cemeteryId: number | string;
|
||||
cemeterySvgId: string;
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import getCemetery from './getCemetery.js';
|
|||
* @returns True if the burial site was updated.
|
||||
* @throws If an active burial site with the same name already exists.
|
||||
*/
|
||||
// eslint-disable-next-line complexity
|
||||
export default function updateBurialSite(updateForm, user) {
|
||||
const database = sqlite(sunriseDB);
|
||||
const cemetery = updateForm.cemeteryId === ''
|
||||
|
|
@ -40,6 +41,8 @@ export default function updateBurialSite(updateForm, user) {
|
|||
burialSiteName = ?,
|
||||
burialSiteTypeId = ?,
|
||||
burialSiteStatusId = ?,
|
||||
bodyCapacity = ?,
|
||||
crematedCapacity = ?,
|
||||
cemeteryId = ?,
|
||||
cemeterySvgId = ?,
|
||||
burialSiteImage = ?,
|
||||
|
|
@ -51,7 +54,9 @@ export default function updateBurialSite(updateForm, user) {
|
|||
and recordDelete_timeMillis is null`)
|
||||
.run(updateForm.burialSiteNameSegment1 ?? '', updateForm.burialSiteNameSegment2 ?? '', updateForm.burialSiteNameSegment3 ?? '', updateForm.burialSiteNameSegment4 ?? '', updateForm.burialSiteNameSegment5 ?? '', burialSiteName, updateForm.burialSiteTypeId, updateForm.burialSiteStatusId === ''
|
||||
? undefined
|
||||
: updateForm.burialSiteStatusId, updateForm.cemeteryId === '' ? undefined : updateForm.cemeteryId, updateForm.cemeterySvgId, updateForm.burialSiteImage, updateForm.burialSiteLatitude === ''
|
||||
: updateForm.burialSiteStatusId, updateForm.bodyCapacity === '' ? undefined : updateForm.bodyCapacity, updateForm.crematedCapacity === ''
|
||||
? undefined
|
||||
: updateForm.crematedCapacity, updateForm.cemeteryId === '' ? undefined : updateForm.cemeteryId, updateForm.cemeterySvgId, updateForm.burialSiteImage, updateForm.burialSiteLatitude === ''
|
||||
? undefined
|
||||
: updateForm.burialSiteLatitude, updateForm.burialSiteLongitude === ''
|
||||
? undefined
|
||||
|
|
|
|||
|
|
@ -19,6 +19,9 @@ export interface UpdateBurialSiteForm {
|
|||
burialSiteStatusId: number | string
|
||||
burialSiteTypeId: number | string
|
||||
|
||||
bodyCapacity?: number | string
|
||||
crematedCapacity?: number | string
|
||||
|
||||
burialSiteImage: string
|
||||
cemeteryId: number | string
|
||||
cemeterySvgId: string
|
||||
|
|
@ -37,6 +40,7 @@ export interface UpdateBurialSiteForm {
|
|||
* @returns True if the burial site was updated.
|
||||
* @throws If an active burial site with the same name already exists.
|
||||
*/
|
||||
// eslint-disable-next-line complexity
|
||||
export default function updateBurialSite(
|
||||
updateForm: UpdateBurialSiteForm,
|
||||
user: User
|
||||
|
|
@ -79,6 +83,8 @@ export default function updateBurialSite(
|
|||
burialSiteName = ?,
|
||||
burialSiteTypeId = ?,
|
||||
burialSiteStatusId = ?,
|
||||
bodyCapacity = ?,
|
||||
crematedCapacity = ?,
|
||||
cemeteryId = ?,
|
||||
cemeterySvgId = ?,
|
||||
burialSiteImage = ?,
|
||||
|
|
@ -100,6 +106,13 @@ export default function updateBurialSite(
|
|||
updateForm.burialSiteStatusId === ''
|
||||
? undefined
|
||||
: updateForm.burialSiteStatusId,
|
||||
|
||||
updateForm.bodyCapacity === '' ? undefined : updateForm.bodyCapacity,
|
||||
|
||||
updateForm.crematedCapacity === ''
|
||||
? undefined
|
||||
: updateForm.crematedCapacity,
|
||||
|
||||
updateForm.cemeteryId === '' ? undefined : updateForm.cemeteryId,
|
||||
updateForm.cemeterySvgId,
|
||||
updateForm.burialSiteImage,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,7 @@
|
|||
export interface UpdateBurialSiteTypeForm {
|
||||
burialSiteTypeId: number | string;
|
||||
burialSiteType: string;
|
||||
bodyCapacityMax: number | string;
|
||||
crematedCapacityMax: number | string;
|
||||
}
|
||||
export default function updateBurialSiteType(updateForm: UpdateBurialSiteTypeForm, user: User): boolean;
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
import sqlite from 'better-sqlite3';
|
||||
import { sunriseDB } from '../helpers/database.helpers.js';
|
||||
import { clearCacheByTableName } from '../helpers/functions.cache.js';
|
||||
export default function updateBurialSiteType(updateForm, user) {
|
||||
const database = sqlite(sunriseDB);
|
||||
const rightNowMillis = Date.now();
|
||||
const result = database
|
||||
.prepare(`update BurialSiteTypes
|
||||
set burialSiteType = ?,
|
||||
bodyCapacityMax = ?,
|
||||
crematedCapacityMax = ?,
|
||||
recordUpdate_userName = ?, recordUpdate_timeMillis = ?
|
||||
where recordDelete_timeMillis is null
|
||||
and burialSiteTypeId = ?`)
|
||||
.run(updateForm.burialSiteType, updateForm.bodyCapacityMax === ''
|
||||
? undefined
|
||||
: updateForm.bodyCapacityMax, updateForm.crematedCapacityMax === ''
|
||||
? undefined
|
||||
: updateForm.crematedCapacityMax, user.userName, rightNowMillis, updateForm.burialSiteTypeId);
|
||||
database.close();
|
||||
clearCacheByTableName('BurialSiteTypes');
|
||||
return result.changes > 0;
|
||||
}
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
import sqlite from 'better-sqlite3'
|
||||
|
||||
import { sunriseDB } from '../helpers/database.helpers.js'
|
||||
import { clearCacheByTableName } from '../helpers/functions.cache.js'
|
||||
|
||||
export interface UpdateBurialSiteTypeForm {
|
||||
burialSiteTypeId: number | string
|
||||
|
||||
burialSiteType: string
|
||||
|
||||
bodyCapacityMax: number | string
|
||||
crematedCapacityMax: number | string
|
||||
}
|
||||
|
||||
export default function updateBurialSiteType(
|
||||
updateForm: UpdateBurialSiteTypeForm,
|
||||
user: User
|
||||
): boolean {
|
||||
const database = sqlite(sunriseDB)
|
||||
|
||||
const rightNowMillis = Date.now()
|
||||
|
||||
const result = database
|
||||
.prepare(
|
||||
`update BurialSiteTypes
|
||||
set burialSiteType = ?,
|
||||
bodyCapacityMax = ?,
|
||||
crematedCapacityMax = ?,
|
||||
recordUpdate_userName = ?, recordUpdate_timeMillis = ?
|
||||
where recordDelete_timeMillis is null
|
||||
and burialSiteTypeId = ?`
|
||||
)
|
||||
.run(
|
||||
updateForm.burialSiteType,
|
||||
updateForm.bodyCapacityMax === ''
|
||||
? undefined
|
||||
: updateForm.bodyCapacityMax,
|
||||
updateForm.crematedCapacityMax === ''
|
||||
? undefined
|
||||
: updateForm.crematedCapacityMax,
|
||||
|
||||
user.userName,
|
||||
rightNowMillis,
|
||||
updateForm.burialSiteTypeId
|
||||
)
|
||||
|
||||
database.close()
|
||||
|
||||
clearCacheByTableName('BurialSiteTypes')
|
||||
|
||||
return result.changes > 0
|
||||
}
|
||||
|
|
@ -1,3 +1,3 @@
|
|||
type RecordTable = 'BurialSiteStatuses' | 'BurialSiteTypes' | 'CommittalTypes' | 'WorkOrderMilestoneTypes' | 'WorkOrderTypes';
|
||||
type RecordTable = 'BurialSiteStatuses' | 'CommittalTypes' | 'WorkOrderMilestoneTypes' | 'WorkOrderTypes';
|
||||
export declare function updateRecord(recordTable: RecordTable, recordId: number | string, recordName: string, user: User): boolean;
|
||||
export {};
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ import { sunriseDB } from '../helpers/database.helpers.js';
|
|||
import { clearCacheByTableName } from '../helpers/functions.cache.js';
|
||||
const recordNameIdColumns = new Map([
|
||||
['BurialSiteStatuses', ['burialSiteStatus', 'burialSiteStatusId']],
|
||||
['BurialSiteTypes', ['burialSiteType', 'burialSiteTypeId']],
|
||||
['CommittalTypes', ['committalType', 'committalTypeId']],
|
||||
[
|
||||
'WorkOrderMilestoneTypes',
|
||||
|
|
|
|||
|
|
@ -5,14 +5,12 @@ import { clearCacheByTableName } from '../helpers/functions.cache.js'
|
|||
|
||||
type RecordTable =
|
||||
| 'BurialSiteStatuses'
|
||||
| 'BurialSiteTypes'
|
||||
| 'CommittalTypes'
|
||||
| 'WorkOrderMilestoneTypes'
|
||||
| 'WorkOrderTypes'
|
||||
|
||||
const recordNameIdColumns = new Map<RecordTable, string[]>([
|
||||
['BurialSiteStatuses', ['burialSiteStatus', 'burialSiteStatusId']],
|
||||
['BurialSiteTypes', ['burialSiteType', 'burialSiteTypeId']],
|
||||
['CommittalTypes', ['committalType', 'committalTypeId']],
|
||||
[
|
||||
'WorkOrderMilestoneTypes',
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
import type { Request, Response } from 'express';
|
||||
export default function handler(request: Request<unknown, unknown, {
|
||||
burialSiteType: string;
|
||||
orderNumber?: number | string;
|
||||
}>, response: Response): void;
|
||||
import { type AddBurialSiteTypeForm } from '../../database/addBurialSiteType.js';
|
||||
export default function handler(request: Request<unknown, unknown, AddBurialSiteTypeForm>, response: Response): void;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import addRecord from '../../database/addRecord.js';
|
||||
import addBurialSiteType from '../../database/addBurialSiteType.js';
|
||||
import { getBurialSiteTypes } from '../../helpers/functions.cache.js';
|
||||
export default function handler(request, response) {
|
||||
const burialSiteTypeId = addRecord('BurialSiteTypes', request.body.burialSiteType, request.body.orderNumber ?? -1, request.session.user);
|
||||
const burialSiteTypeId = addBurialSiteType(request.body, request.session.user);
|
||||
const burialSiteTypes = getBurialSiteTypes();
|
||||
response.json({
|
||||
success: true,
|
||||
|
|
|
|||
|
|
@ -1,20 +1,16 @@
|
|||
import type { Request, Response } from 'express'
|
||||
|
||||
import addRecord from '../../database/addRecord.js'
|
||||
import addBurialSiteType, {
|
||||
type AddBurialSiteTypeForm
|
||||
} from '../../database/addBurialSiteType.js'
|
||||
import { getBurialSiteTypes } from '../../helpers/functions.cache.js'
|
||||
|
||||
export default function handler(
|
||||
request: Request<
|
||||
unknown,
|
||||
unknown,
|
||||
{ burialSiteType: string; orderNumber?: number | string }
|
||||
>,
|
||||
request: Request<unknown, unknown, AddBurialSiteTypeForm>,
|
||||
response: Response
|
||||
): void {
|
||||
const burialSiteTypeId = addRecord(
|
||||
'BurialSiteTypes',
|
||||
request.body.burialSiteType,
|
||||
request.body.orderNumber ?? -1,
|
||||
const burialSiteTypeId = addBurialSiteType(
|
||||
request.body,
|
||||
request.session.user as User
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
import type { Request, Response } from 'express';
|
||||
export default function handler(request: Request<unknown, unknown, {
|
||||
burialSiteTypeId: string;
|
||||
burialSiteType: string;
|
||||
}>, response: Response): void;
|
||||
import { type UpdateBurialSiteTypeForm } from '../../database/updateBurialSiteType.js';
|
||||
export default function handler(request: Request<unknown, unknown, UpdateBurialSiteTypeForm>, response: Response): void;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { updateRecord } from '../../database/updateRecord.js';
|
||||
import updateBurialSiteType from '../../database/updateBurialSiteType.js';
|
||||
import { getBurialSiteTypes } from '../../helpers/functions.cache.js';
|
||||
export default function handler(request, response) {
|
||||
const success = updateRecord('BurialSiteTypes', request.body.burialSiteTypeId, request.body.burialSiteType, request.session.user);
|
||||
const success = updateBurialSiteType(request.body, request.session.user);
|
||||
const burialSiteTypes = getBurialSiteTypes();
|
||||
response.json({
|
||||
success,
|
||||
|
|
|
|||
|
|
@ -1,20 +1,16 @@
|
|||
import type { Request, Response } from 'express'
|
||||
|
||||
import { updateRecord } from '../../database/updateRecord.js'
|
||||
import updateBurialSiteType, {
|
||||
type UpdateBurialSiteTypeForm
|
||||
} from '../../database/updateBurialSiteType.js'
|
||||
import { getBurialSiteTypes } from '../../helpers/functions.cache.js'
|
||||
|
||||
export default function handler(
|
||||
request: Request<
|
||||
unknown,
|
||||
unknown,
|
||||
{ burialSiteTypeId: string; burialSiteType: string }
|
||||
>,
|
||||
request: Request<unknown, unknown, UpdateBurialSiteTypeForm>,
|
||||
response: Response
|
||||
): void {
|
||||
const success = updateRecord(
|
||||
'BurialSiteTypes',
|
||||
request.body.burialSiteTypeId,
|
||||
request.body.burialSiteType,
|
||||
const success = updateBurialSiteType(
|
||||
request.body,
|
||||
request.session.user as User
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,11 @@ import { getBurialSiteImages } from '../../helpers/images.helpers.js';
|
|||
export default async function handler(request, response) {
|
||||
const burialSite = {
|
||||
burialSiteId: -1,
|
||||
contracts: []
|
||||
contracts: [],
|
||||
// eslint-disable-next-line unicorn/no-null
|
||||
bodyCapacity: null,
|
||||
// eslint-disable-next-line unicorn/no-null
|
||||
crematedCapacity: null
|
||||
};
|
||||
const cemeteries = getCemeteries();
|
||||
if (request.query.cemeteryId !== undefined) {
|
||||
|
|
|
|||
|
|
@ -14,7 +14,13 @@ export default async function handler(
|
|||
): Promise<void> {
|
||||
const burialSite: BurialSite = {
|
||||
burialSiteId: -1,
|
||||
contracts: []
|
||||
contracts: [],
|
||||
|
||||
// eslint-disable-next-line unicorn/no-null
|
||||
bodyCapacity: null,
|
||||
|
||||
// eslint-disable-next-line unicorn/no-null
|
||||
crematedCapacity: null
|
||||
}
|
||||
|
||||
const cemeteries = getCemeteries()
|
||||
|
|
|
|||
|
|
@ -26,6 +26,43 @@
|
|||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="columns">
|
||||
<div class="column">
|
||||
<div class="field">
|
||||
<label class="label" for="burialSiteTypeAdd--bodyCapacityMax"
|
||||
>Body Capacity Max</label
|
||||
>
|
||||
<div class="control">
|
||||
<input
|
||||
class="input has-text-right"
|
||||
id="burialSiteTypeAdd--bodyCapacityMax"
|
||||
name="bodyCapacityMax"
|
||||
type="number"
|
||||
min="0"
|
||||
max="100"
|
||||
step="1"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="column">
|
||||
<div class="field">
|
||||
<label class="label" for="burialSiteTypeAdd--crematedCapacityMax"
|
||||
>Cremated Capacity Max</label
|
||||
>
|
||||
<div class="control">
|
||||
<input
|
||||
class="input has-text-right"
|
||||
id="burialSiteTypeAdd--crematedCapacityMax"
|
||||
name="crematedCapacityMax"
|
||||
type="number"
|
||||
min="0"
|
||||
max="100"
|
||||
step="1"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</section>
|
||||
<footer class="modal-card-foot is-justify-content-right">
|
||||
|
|
|
|||
|
|
@ -34,6 +34,44 @@
|
|||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="columns">
|
||||
<div class="column">
|
||||
<div class="field">
|
||||
<label class="label" for="burialSiteTypeEdit--bodyCapacityMax"
|
||||
>Body Capacity Max</label
|
||||
>
|
||||
<div class="control">
|
||||
<input
|
||||
class="input has-text-right"
|
||||
id="burialSiteTypeEdit--bodyCapacityMax"
|
||||
name="bodyCapacityMax"
|
||||
type="number"
|
||||
min="0"
|
||||
max="100"
|
||||
step="1"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="column">
|
||||
<div class="field">
|
||||
<label class="label" for="burialSiteTypeEdit--crematedCapacityMax"
|
||||
>Cremated Capacity Max</label
|
||||
>
|
||||
<div class="control">
|
||||
<input
|
||||
class="input has-text-right"
|
||||
id="burialSiteTypeEdit--crematedCapacityMax"
|
||||
name="crematedCapacityMax"
|
||||
type="number"
|
||||
min="0"
|
||||
max="100"
|
||||
step="1"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</section>
|
||||
<footer class="modal-card-foot is-justify-content-right">
|
||||
|
|
|
|||
|
|
@ -86,6 +86,28 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|||
});
|
||||
// Burial Site Type
|
||||
const burialSiteTypeIdElement = document.querySelector('#burialSite--burialSiteTypeId');
|
||||
function updateCapacities() {
|
||||
const bodyCapacityMax = burialSiteTypeIdElement.selectedOptions[0].dataset.bodyCapacityMax;
|
||||
const bodyCapacityElement = document.querySelector('#burialSite--bodyCapacity');
|
||||
bodyCapacityElement.max =
|
||||
bodyCapacityMax === ''
|
||||
? exports.bodyCapacityMaxDefault
|
||||
: bodyCapacityMax ?? '';
|
||||
bodyCapacityElement.placeholder =
|
||||
bodyCapacityMax === ''
|
||||
? exports.bodyCapacityMaxDefault
|
||||
: bodyCapacityMax ?? '';
|
||||
const crematedCapacityMax = burialSiteTypeIdElement.selectedOptions[0].dataset.crematedCapacityMax;
|
||||
const crematedCapacityElement = document.querySelector('#burialSite--crematedCapacity');
|
||||
crematedCapacityElement.max =
|
||||
crematedCapacityMax === ''
|
||||
? exports.crematedCapacityMaxDefault
|
||||
: crematedCapacityMax ?? '';
|
||||
crematedCapacityElement.placeholder =
|
||||
crematedCapacityMax === ''
|
||||
? exports.crematedCapacityMaxDefault
|
||||
: crematedCapacityMax ?? '';
|
||||
}
|
||||
if (isCreate) {
|
||||
const burialSiteFieldsContainerElement = document.querySelector('#container--burialSiteFields');
|
||||
burialSiteTypeIdElement.addEventListener('change', () => {
|
||||
|
|
@ -177,12 +199,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|||
text: 'Revert the Change',
|
||||
callbackFunction() {
|
||||
burialSiteTypeIdElement.value = originalBurialSiteTypeId;
|
||||
updateCapacities();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
burialSiteTypeIdElement.addEventListener('change', updateCapacities);
|
||||
// Leaflet Map
|
||||
document
|
||||
.querySelector('#button--selectCoordinate')
|
||||
|
|
|
|||
|
|
@ -14,7 +14,14 @@ import type { Sunrise } from './types.js'
|
|||
declare const cityssm: cityssmGlobal
|
||||
declare const bulmaJS: BulmaJS
|
||||
|
||||
declare const exports: Record<string, unknown>
|
||||
declare const exports: {
|
||||
sunrise: Sunrise
|
||||
|
||||
burialSiteComments?: BurialSiteComment[]
|
||||
|
||||
bodyCapacityMaxDefault: string
|
||||
crematedCapacityMaxDefault: string
|
||||
}
|
||||
;(() => {
|
||||
const sunrise = exports.sunrise as Sunrise
|
||||
|
||||
|
|
@ -142,6 +149,42 @@ declare const exports: Record<string, unknown>
|
|||
'#burialSite--burialSiteTypeId'
|
||||
) as HTMLSelectElement
|
||||
|
||||
function updateCapacities(): void {
|
||||
const bodyCapacityMax =
|
||||
burialSiteTypeIdElement.selectedOptions[0].dataset.bodyCapacityMax
|
||||
|
||||
const bodyCapacityElement = document.querySelector(
|
||||
'#burialSite--bodyCapacity'
|
||||
) as HTMLInputElement
|
||||
|
||||
bodyCapacityElement.max =
|
||||
bodyCapacityMax === ''
|
||||
? exports.bodyCapacityMaxDefault
|
||||
: bodyCapacityMax ?? ''
|
||||
|
||||
bodyCapacityElement.placeholder =
|
||||
bodyCapacityMax === ''
|
||||
? exports.bodyCapacityMaxDefault
|
||||
: bodyCapacityMax ?? ''
|
||||
|
||||
const crematedCapacityMax =
|
||||
burialSiteTypeIdElement.selectedOptions[0].dataset.crematedCapacityMax
|
||||
|
||||
const crematedCapacityElement = document.querySelector(
|
||||
'#burialSite--crematedCapacity'
|
||||
) as HTMLInputElement
|
||||
|
||||
crematedCapacityElement.max =
|
||||
crematedCapacityMax === ''
|
||||
? exports.crematedCapacityMaxDefault
|
||||
: crematedCapacityMax ?? ''
|
||||
|
||||
crematedCapacityElement.placeholder =
|
||||
crematedCapacityMax === ''
|
||||
? exports.crematedCapacityMaxDefault
|
||||
: crematedCapacityMax ?? ''
|
||||
}
|
||||
|
||||
if (isCreate) {
|
||||
const burialSiteFieldsContainerElement = document.querySelector(
|
||||
'#container--burialSiteFields'
|
||||
|
|
@ -265,16 +308,19 @@ declare const exports: Record<string, unknown>
|
|||
message: `Are you sure you want to change the burial site type?\n
|
||||
This change affects the additional fields associated with this record.`,
|
||||
contextualColorName: 'warning',
|
||||
|
||||
okButton: {
|
||||
text: 'Yes, Keep the Change',
|
||||
callbackFunction() {
|
||||
refreshAfterSave = true
|
||||
}
|
||||
},
|
||||
|
||||
cancelButton: {
|
||||
text: 'Revert the Change',
|
||||
callbackFunction() {
|
||||
burialSiteTypeIdElement.value = originalBurialSiteTypeId
|
||||
updateCapacities()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
@ -282,6 +328,8 @@ declare const exports: Record<string, unknown>
|
|||
})
|
||||
}
|
||||
|
||||
burialSiteTypeIdElement.addEventListener('change', updateCapacities)
|
||||
|
||||
// Leaflet Map
|
||||
|
||||
document
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|||
}
|
||||
else {
|
||||
bulmaJS.alert({
|
||||
title: "Error Updating Burial Site Type",
|
||||
title: 'Error Updating Burial Site Type',
|
||||
message: responseJSON.errorMessage ?? '',
|
||||
contextualColorName: 'danger'
|
||||
});
|
||||
|
|
@ -49,11 +49,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|||
}, burialSiteTypeResponseHandler);
|
||||
}
|
||||
bulmaJS.confirm({
|
||||
title: "Delete Burial Site Type",
|
||||
message: "Are you sure you want to delete this burial site type?",
|
||||
title: 'Delete Burial Site Type',
|
||||
message: 'Are you sure you want to delete this burial site type?',
|
||||
contextualColorName: 'warning',
|
||||
okButton: {
|
||||
text: "Yes, Delete Burial Site Type",
|
||||
text: 'Yes, Delete Burial Site Type',
|
||||
callbackFunction: doDelete
|
||||
}
|
||||
});
|
||||
|
|
@ -77,6 +77,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|||
sunrise.populateAliases(modalElement);
|
||||
modalElement.querySelector('#burialSiteTypeEdit--burialSiteTypeId').value = burialSiteTypeId.toString();
|
||||
modalElement.querySelector('#burialSiteTypeEdit--burialSiteType').value = burialSiteType.burialSiteType;
|
||||
modalElement.querySelector('#burialSiteTypeEdit--bodyCapacityMax').value = burialSiteType.bodyCapacityMax?.toString() ?? '';
|
||||
modalElement.querySelector('#burialSiteTypeEdit--crematedCapacityMax').value = burialSiteType.crematedCapacityMax?.toString() ?? '';
|
||||
},
|
||||
onshown(modalElement, closeModalFunction) {
|
||||
editCloseModalFunction = closeModalFunction;
|
||||
|
|
@ -331,6 +333,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|||
<div class="level-item">
|
||||
<h2 class="title is-5 has-text-white">${cityssm.escapeHTML(burialSiteType.burialSiteType)}</h2>
|
||||
</div>
|
||||
<div class="level-item">
|
||||
<div class="tags">
|
||||
${burialSiteType.bodyCapacityMax === null
|
||||
? ''
|
||||
: `<span class="tag is-info">
|
||||
Bodies: ${cityssm.escapeHTML(burialSiteType.bodyCapacityMax.toString())}
|
||||
</span>`}
|
||||
${burialSiteType.crematedCapacityMax === null
|
||||
? ''
|
||||
: `<span class="tag is-info">
|
||||
Cremains: ${cityssm.escapeHTML(burialSiteType.crematedCapacityMax.toString())}
|
||||
</span>`}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="level-right is-hidden-print">
|
||||
<div class="level-item">
|
||||
|
|
@ -390,7 +406,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|||
}
|
||||
else {
|
||||
bulmaJS.alert({
|
||||
title: "Error Adding Burial Site Type",
|
||||
title: 'Error Adding Burial Site Type',
|
||||
message: responseJSON.errorMessage ?? '',
|
||||
contextualColorName: 'danger'
|
||||
});
|
||||
|
|
@ -400,6 +416,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|||
cityssm.openHtmlModal('adminBurialSiteTypes-add', {
|
||||
onshow(modalElement) {
|
||||
sunrise.populateAliases(modalElement);
|
||||
modalElement.querySelector('#burialSiteTypeAdd--bodyCapacityMax').value = exports.bodyCapacityMaxDefault.toString();
|
||||
modalElement.querySelector('#burialSiteTypeAdd--crematedCapacityMax').value = exports.crematedCapacityMaxDefault.toString();
|
||||
},
|
||||
onshown(modalElement, closeModalFunction) {
|
||||
addCloseModalFunction = closeModalFunction;
|
||||
|
|
|
|||
|
|
@ -14,7 +14,14 @@ import type { Sunrise } from './types.js'
|
|||
declare const cityssm: cityssmGlobal
|
||||
declare const bulmaJS: BulmaJS
|
||||
|
||||
declare const exports: Record<string, unknown>
|
||||
declare const exports: {
|
||||
sunrise: Sunrise
|
||||
|
||||
burialSiteTypes?: BurialSiteType[]
|
||||
|
||||
bodyCapacityMaxDefault: number
|
||||
crematedCapacityMaxDefault: number
|
||||
}
|
||||
|
||||
type ResponseJSON =
|
||||
| {
|
||||
|
|
@ -81,7 +88,7 @@ type ResponseJSON =
|
|||
renderBurialSiteTypes()
|
||||
} else {
|
||||
bulmaJS.alert({
|
||||
title: "Error Updating Burial Site Type",
|
||||
title: 'Error Updating Burial Site Type',
|
||||
message: responseJSON.errorMessage ?? '',
|
||||
contextualColorName: 'danger'
|
||||
})
|
||||
|
|
@ -109,11 +116,11 @@ type ResponseJSON =
|
|||
}
|
||||
|
||||
bulmaJS.confirm({
|
||||
title: "Delete Burial Site Type",
|
||||
message: "Are you sure you want to delete this burial site type?",
|
||||
title: 'Delete Burial Site Type',
|
||||
message: 'Are you sure you want to delete this burial site type?',
|
||||
contextualColorName: 'warning',
|
||||
okButton: {
|
||||
text: "Yes, Delete Burial Site Type",
|
||||
text: 'Yes, Delete Burial Site Type',
|
||||
callbackFunction: doDelete
|
||||
}
|
||||
})
|
||||
|
|
@ -165,6 +172,16 @@ type ResponseJSON =
|
|||
'#burialSiteTypeEdit--burialSiteType'
|
||||
) as HTMLInputElement
|
||||
).value = burialSiteType.burialSiteType
|
||||
;(
|
||||
modalElement.querySelector(
|
||||
'#burialSiteTypeEdit--bodyCapacityMax'
|
||||
) as HTMLInputElement
|
||||
).value = burialSiteType.bodyCapacityMax?.toString() ?? ''
|
||||
;(
|
||||
modalElement.querySelector(
|
||||
'#burialSiteTypeEdit--crematedCapacityMax'
|
||||
) as HTMLInputElement
|
||||
).value = burialSiteType.crematedCapacityMax?.toString() ?? ''
|
||||
},
|
||||
onshown(modalElement, closeModalFunction) {
|
||||
editCloseModalFunction = closeModalFunction
|
||||
|
|
@ -363,8 +380,7 @@ type ResponseJSON =
|
|||
function confirmDoDelete(): void {
|
||||
bulmaJS.confirm({
|
||||
title: 'Delete Field',
|
||||
message:
|
||||
`Are you sure you want to delete this field?
|
||||
message: `Are you sure you want to delete this field?
|
||||
Note that historical records that make use of this field will not be affected.`,
|
||||
contextualColorName: 'warning',
|
||||
okButton: {
|
||||
|
|
@ -603,6 +619,28 @@ type ResponseJSON =
|
|||
<div class="level-item">
|
||||
<h2 class="title is-5 has-text-white">${cityssm.escapeHTML(burialSiteType.burialSiteType)}</h2>
|
||||
</div>
|
||||
<div class="level-item">
|
||||
<div class="tags">
|
||||
${
|
||||
burialSiteType.bodyCapacityMax === null
|
||||
? ''
|
||||
: `<span class="tag is-info">
|
||||
Bodies: ${cityssm.escapeHTML(
|
||||
burialSiteType.bodyCapacityMax.toString()
|
||||
)}
|
||||
</span>`
|
||||
}
|
||||
${
|
||||
burialSiteType.crematedCapacityMax === null
|
||||
? ''
|
||||
: `<span class="tag is-info">
|
||||
Cremains: ${cityssm.escapeHTML(
|
||||
burialSiteType.crematedCapacityMax.toString()
|
||||
)}
|
||||
</span>`
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="level-right is-hidden-print">
|
||||
<div class="level-item">
|
||||
|
|
@ -689,7 +727,7 @@ type ResponseJSON =
|
|||
renderBurialSiteTypes()
|
||||
} else {
|
||||
bulmaJS.alert({
|
||||
title: "Error Adding Burial Site Type",
|
||||
title: 'Error Adding Burial Site Type',
|
||||
message: responseJSON.errorMessage ?? '',
|
||||
contextualColorName: 'danger'
|
||||
})
|
||||
|
|
@ -701,6 +739,16 @@ type ResponseJSON =
|
|||
cityssm.openHtmlModal('adminBurialSiteTypes-add', {
|
||||
onshow(modalElement) {
|
||||
sunrise.populateAliases(modalElement)
|
||||
;(
|
||||
modalElement.querySelector(
|
||||
'#burialSiteTypeAdd--bodyCapacityMax'
|
||||
) as HTMLInputElement
|
||||
).value = exports.bodyCapacityMaxDefault.toString()
|
||||
;(
|
||||
modalElement.querySelector(
|
||||
'#burialSiteTypeAdd--crematedCapacityMax'
|
||||
) as HTMLInputElement
|
||||
).value = exports.crematedCapacityMaxDefault.toString()
|
||||
},
|
||||
onshown(modalElement, closeModalFunction) {
|
||||
addCloseModalFunction = closeModalFunction
|
||||
|
|
|
|||
|
|
@ -223,8 +223,9 @@ async function importFromMasterCSV() {
|
|||
const deathDateString = masterRow.CM_DEATH_YR === ''
|
||||
? ''
|
||||
: formatDateString(masterRow.CM_DEATH_YR, masterRow.CM_DEATH_MON, masterRow.CM_DEATH_DAY);
|
||||
const intermentContainerTypeKey = contractType.contractType === 'Cremation' &&
|
||||
masterRow.CM_CONTAINER_TYPE !== ''
|
||||
const intermentContainerTypeKey = masterRow.CM_CONTAINER_TYPE === '' &&
|
||||
(contractType.contractType === 'Cremation' ||
|
||||
masterRow.CM_CREMATION === 'Y')
|
||||
? 'U'
|
||||
: masterRow.CM_CONTAINER_TYPE;
|
||||
const intermentContainerTypeId = intermentContainerTypeKey === ''
|
||||
|
|
@ -623,7 +624,7 @@ async function importFromWorkOrderCSV() {
|
|||
? ''
|
||||
: getCommittalTypeIdByKey(workOrderRow.WO_COMMITTAL_TYPE, user);
|
||||
const intermentContainerTypeKey = contractType.contractType === 'Cremation' &&
|
||||
workOrderRow.WO_CONTAINER_TYPE !== ''
|
||||
workOrderRow.WO_CONTAINER_TYPE === ''
|
||||
? 'U'
|
||||
: workOrderRow.WO_CONTAINER_TYPE;
|
||||
const intermentContainerTypeId = intermentContainerTypeKey === ''
|
||||
|
|
|
|||
|
|
@ -381,8 +381,9 @@ async function importFromMasterCSV(): Promise<void> {
|
|||
)
|
||||
|
||||
const intermentContainerTypeKey =
|
||||
contractType.contractType === 'Cremation' &&
|
||||
masterRow.CM_CONTAINER_TYPE !== ''
|
||||
masterRow.CM_CONTAINER_TYPE === '' &&
|
||||
(contractType.contractType === 'Cremation' ||
|
||||
masterRow.CM_CREMATION === 'Y')
|
||||
? 'U'
|
||||
: masterRow.CM_CONTAINER_TYPE
|
||||
|
||||
|
|
@ -997,7 +998,7 @@ async function importFromWorkOrderCSV(): Promise<void> {
|
|||
|
||||
const intermentContainerTypeKey =
|
||||
contractType.contractType === 'Cremation' &&
|
||||
workOrderRow.WO_CONTAINER_TYPE !== ''
|
||||
workOrderRow.WO_CONTAINER_TYPE === ''
|
||||
? 'U'
|
||||
: workOrderRow.WO_CONTAINER_TYPE
|
||||
|
||||
|
|
|
|||
|
|
@ -34,6 +34,10 @@ export interface Config {
|
|||
cemeteries: {
|
||||
refreshImageChanges?: boolean;
|
||||
};
|
||||
burialSiteTypes: {
|
||||
bodyCapacityMaxDefault?: number;
|
||||
crematedCapacityMaxDefault?: number;
|
||||
};
|
||||
burialSites: {
|
||||
burialSiteNameSegments?: ConfigBurialSiteNameSegments;
|
||||
refreshImageChanges?: boolean;
|
||||
|
|
|
|||
|
|
@ -47,6 +47,11 @@ export interface Config {
|
|||
refreshImageChanges?: boolean
|
||||
}
|
||||
|
||||
burialSiteTypes: {
|
||||
bodyCapacityMaxDefault?: number
|
||||
crematedCapacityMaxDefault?: number
|
||||
}
|
||||
|
||||
burialSites: {
|
||||
burialSiteNameSegments?: ConfigBurialSiteNameSegments
|
||||
refreshImageChanges?: boolean
|
||||
|
|
|
|||
|
|
@ -10,6 +10,10 @@ export interface BurialSite extends Record {
|
|||
burialSiteNameSegment5?: string;
|
||||
burialSiteType?: string;
|
||||
burialSiteTypeId?: number;
|
||||
bodyCapacity: number | null;
|
||||
bodyCapacityMax?: number | null;
|
||||
crematedCapacity: number | null;
|
||||
crematedCapacityMax?: number | null;
|
||||
cemetery?: Cemetery;
|
||||
cemeteryId?: number | null;
|
||||
cemeteryName?: string;
|
||||
|
|
@ -49,6 +53,8 @@ export interface BurialSiteStatus extends Record {
|
|||
export interface BurialSiteType extends Record {
|
||||
burialSiteTypeId: number;
|
||||
burialSiteType: string;
|
||||
bodyCapacityMax: number | null;
|
||||
crematedCapacityMax: number | null;
|
||||
burialSiteTypeFields?: BurialSiteTypeField[];
|
||||
orderNumber?: number;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,11 @@ export interface BurialSite extends Record {
|
|||
burialSiteType?: string
|
||||
burialSiteTypeId?: number
|
||||
|
||||
bodyCapacity: number | null
|
||||
bodyCapacityMax?: number | null
|
||||
crematedCapacity: number | null
|
||||
crematedCapacityMax?: number | null
|
||||
|
||||
cemetery?: Cemetery
|
||||
cemeteryId?: number | null
|
||||
cemeteryName?: string
|
||||
|
|
@ -70,6 +75,10 @@ export interface BurialSiteType extends Record {
|
|||
burialSiteTypeId: number
|
||||
|
||||
burialSiteType: string
|
||||
|
||||
bodyCapacityMax: number | null
|
||||
crematedCapacityMax: number | null
|
||||
|
||||
burialSiteTypeFields?: BurialSiteTypeField[]
|
||||
orderNumber?: number
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,6 +44,8 @@
|
|||
|
||||
<script>
|
||||
exports.burialSiteTypes = <%- JSON.stringify(burialSiteTypes) %>;
|
||||
exports.bodyCapacityMaxDefault = <%- JSON.stringify(configFunctions.getConfigProperty('settings.burialSiteTypes.bodyCapacityMaxDefault')) %>
|
||||
exports.crematedCapacityMaxDefault = <%- JSON.stringify(configFunctions.getConfigProperty('settings.burialSiteTypes.crematedCapacityMaxDefault')) %>
|
||||
</script>
|
||||
|
||||
<script src="<%= urlPrefix %>/javascripts/burialSiteTypes.admin.js"></script>
|
||||
|
|
|
|||
|
|
@ -195,7 +195,11 @@
|
|||
<% } %>
|
||||
id="burialSite--burialSiteTypeId" name="burialSiteTypeId" required>
|
||||
<% if (isCreate) { %>
|
||||
<option value="">(Select a Type)</option>
|
||||
<option value=""
|
||||
data-body-capacity-max="<%= configFunctions.getConfigProperty('settings.burialSiteTypes.bodyCapacityMaxDefault') %>"
|
||||
data-cremated-capacity-max="<%= configFunctions.getConfigProperty('settings.burialSiteTypes.crematedCapacityMaxDefault') %>">
|
||||
(Select a Type)
|
||||
</option>
|
||||
<% } %>
|
||||
<% let typeIsFound = false; %>
|
||||
<% for (const burialSiteType of burialSiteTypes) { %>
|
||||
|
|
@ -205,13 +209,18 @@
|
|||
}
|
||||
%>
|
||||
<option value="<%= burialSiteType.burialSiteTypeId %>"
|
||||
data-body-capacity-max="<%= burialSiteType.bodyCapacityMax %>"
|
||||
data-cremated-capacity-max="<%= burialSiteType.crematedCapacityMax %>"
|
||||
<%= (burialSite.burialSiteTypeId === burialSiteType.burialSiteTypeId ? " selected" : "") %>
|
||||
<%= (!isCreate && burialSite.burialSiteTypeId !== burialSiteType.burialSiteTypeId ? " disabled" : "") %>>
|
||||
<%= burialSiteType.burialSiteType %>
|
||||
</option>
|
||||
<% } %>
|
||||
<% if (burialSite.burialSiteTypeId && !typeIsFound) { %>
|
||||
<option value="<%= burialSite.burialSiteTypeId %>" selected>
|
||||
<option value="<%= burialSite.burialSiteTypeId %>"
|
||||
data-body-capacity-max="<%= burialSite.bodyCapacityMax %>"
|
||||
data-cremated-capacity-max="<%= burialSite.crematedCapacityMax %>"
|
||||
selected>
|
||||
<%= burialSite.burialSiteType %>
|
||||
</option>
|
||||
<% } %>
|
||||
|
|
@ -224,6 +233,38 @@
|
|||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="columns">
|
||||
<div class="column">
|
||||
<div class="field">
|
||||
<label class="label" for="burialSite--bodyCapacity">Body Capacity</label>
|
||||
<div class="control">
|
||||
<input class="input has-text-right"
|
||||
id="burialSite--bodyCapacity" name="bodyCapacity" type="number"
|
||||
min="0"
|
||||
max="<%= burialSite.bodyCapacityMax ?? configFunctions.getConfigProperty('settings.burialSiteTypes.bodyCapacityMaxDefault') %>"
|
||||
step="1"
|
||||
placeholder="<%= burialSite.bodyCapacityMax ?? configFunctions.getConfigProperty('settings.burialSiteTypes.bodyCapacityMaxDefault') %>"
|
||||
value="<%= burialSite.bodyCapacity %>"
|
||||
onwheel="return false" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="column">
|
||||
<div class="field">
|
||||
<label class="label" for="burialSite--crematedCapacity">Cremated Capacity</label>
|
||||
<div class="control">
|
||||
<input class="input has-text-right"
|
||||
id="burialSite--crematedCapacity" name="crematedCapacity" type="number"
|
||||
min="0"
|
||||
max="<%= burialSite.crematedCapacityMax ?? configFunctions.getConfigProperty('settings.burialSiteTypes.crematedCapacityMaxDefault') %>"
|
||||
step="1"
|
||||
placeholder="<%= burialSite.crematedCapacityMax ?? configFunctions.getConfigProperty('settings.burialSiteTypes.crematedCapacityMaxDefault') %>"
|
||||
value="<%= burialSite.crematedCapacity %>"
|
||||
onwheel="return false" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<label class="label" for="burialSite--burialSiteStatusId">
|
||||
Burial Site Status
|
||||
</label>
|
||||
|
|
@ -581,6 +622,10 @@
|
|||
|
||||
<%- include('_footerA'); -%>
|
||||
|
||||
<script>
|
||||
exports.bodyCapacityMaxDefault = <%- JSON.stringify(configFunctions.getConfigProperty('settings.burialSiteTypes.bodyCapacityMaxDefault')) %>;
|
||||
exports.crematedCapacityMaxDefault = <%- JSON.stringify(configFunctions.getConfigProperty('settings.burialSiteTypes.crematedCapacityMaxDefault')) %>;
|
||||
</script>
|
||||
<% if (!isCreate) { %>
|
||||
<script>
|
||||
exports.burialSiteComments = <%- JSON.stringify(burialSite.burialSiteComments) %>;
|
||||
|
|
|
|||
Loading…
Reference in New Issue