internal data lists

move deathAgePeriods and purchaserRelationships out of config
pull/11/head
Dan Gowans 2025-04-25 13:41:31 -04:00
parent b356d771ab
commit 14bd8e0ea4
11 changed files with 58 additions and 37 deletions

2
app.js
View File

@ -10,6 +10,7 @@ import rateLimit from 'express-rate-limit';
import session from 'express-session';
import createError from 'http-errors';
import FileStore from 'session-file-store';
import dataLists from './data/dataLists.js';
import { DEBUG_NAMESPACE } from './debug.config.js';
import * as permissionHandlers from './handlers/permissions.js';
import { getSafeRedirectURL } from './helpers/authentication.helpers.js';
@ -141,6 +142,7 @@ app.use((request, response, next) => {
response.locals.configFunctions = configFunctions;
response.locals.printFunctions = printFunctions;
response.locals.dateTimeFunctions = dateTimeFunctions;
response.locals.dataLists = dataLists;
response.locals.urlPrefix = configFunctions.getConfigProperty('reverseProxy.urlPrefix');
next();
});

3
app.ts
View File

@ -12,6 +12,7 @@ import session from 'express-session'
import createError from 'http-errors'
import FileStore from 'session-file-store'
import dataLists from './data/dataLists.js'
import { DEBUG_NAMESPACE } from './debug.config.js'
import * as permissionHandlers from './handlers/permissions.js'
import { getSafeRedirectURL } from './helpers/authentication.helpers.js'
@ -244,6 +245,8 @@ app.use((request, response, next) => {
response.locals.printFunctions = printFunctions
response.locals.dateTimeFunctions = dateTimeFunctions
response.locals.dataLists = dataLists
response.locals.urlPrefix = configFunctions.getConfigProperty(
'reverseProxy.urlPrefix'
)

View File

@ -38,9 +38,7 @@ export declare const configDefaultValues: {
'settings.burialSites.refreshImageChanges': boolean;
'settings.contracts.burialSiteIdIsRequired': boolean;
'settings.contracts.contractEndDateIsRequired': boolean;
'settings.contracts.deathAgePeriods': string[];
'settings.contracts.prints': string[];
'settings.contracts.purchaserRelationships': string[];
'settings.fees.taxPercentageDefault': number;
'settings.workOrders.workOrderNumberLength': number;
'settings.workOrders.calendarEmailAddress': string;

View File

@ -49,21 +49,7 @@ export const configDefaultValues = {
'settings.burialSites.refreshImageChanges': false,
'settings.contracts.burialSiteIdIsRequired': true,
'settings.contracts.contractEndDateIsRequired': false,
'settings.contracts.deathAgePeriods': [
'Years',
'Months',
'Days',
'Stillborn'
],
'settings.contracts.prints': ['screen/contract'],
'settings.contracts.purchaserRelationships': [
'Spouse',
'Child',
'Parent',
'Sibling',
'Friend',
'Self'
],
'settings.fees.taxPercentageDefault': 0,
'settings.workOrders.workOrderNumberLength': 6,
'settings.workOrders.calendarEmailAddress': 'no-reply@127.0.0.1',

View File

@ -73,21 +73,8 @@ export const configDefaultValues = {
'settings.contracts.burialSiteIdIsRequired': true,
'settings.contracts.contractEndDateIsRequired': false,
'settings.contracts.deathAgePeriods': [
'Years',
'Months',
'Days',
'Stillborn'
],
'settings.contracts.prints': ['screen/contract'],
'settings.contracts.purchaserRelationships': [
'Spouse',
'Child',
'Parent',
'Sibling',
'Friend',
'Self'
],
'settings.fees.taxPercentageDefault': 0,

7
data/dataLists.d.ts vendored 100644
View File

@ -0,0 +1,7 @@
export declare const deathAgePeriods: readonly ["Years", "Months", "Days", "Stillborn"];
export declare const purchaserRelationships: readonly ["Spouse", "Husband", "Wife", "Child", "Parent", "Sibling", "Friend", "Self"];
declare const _default: {
deathAgePeriods: readonly ["Years", "Months", "Days", "Stillborn"];
purchaserRelationships: readonly ["Spouse", "Husband", "Wife", "Child", "Parent", "Sibling", "Friend", "Self"];
};
export default _default;

20
data/dataLists.js 100644
View File

@ -0,0 +1,20 @@
export const deathAgePeriods = [
'Years',
'Months',
'Days',
'Stillborn'
];
export const purchaserRelationships = [
'Spouse',
'Husband',
'Wife',
'Child',
'Parent',
'Sibling',
'Friend',
'Self'
];
export default {
deathAgePeriods,
purchaserRelationships
};

22
data/dataLists.ts 100644
View File

@ -0,0 +1,22 @@
export const deathAgePeriods = [
'Years',
'Months',
'Days',
'Stillborn'
] as const
export const purchaserRelationships = [
'Spouse',
'Husband',
'Wife',
'Child',
'Parent',
'Sibling',
'Friend',
'Self'
] as const
export default {
deathAgePeriods,
purchaserRelationships
}

View File

@ -41,9 +41,7 @@ export interface Config {
contracts: {
burialSiteIdIsRequired?: boolean;
contractEndDateIsRequired?: boolean;
deathAgePeriods?: string[];
prints?: string[];
purchaserRelationships?: string[];
};
workOrders: {
calendarEmailAddress?: string;

View File

@ -55,9 +55,7 @@ export interface Config {
contracts: {
burialSiteIdIsRequired?: boolean
contractEndDateIsRequired?: boolean
deathAgePeriods?: string[]
prints?: string[]
purchaserRelationships?: string[]
}
workOrders: {

View File

@ -535,7 +535,7 @@
</div>
</div>
<datalist id="datalist--purchaserRelationships">
<% for (const relationship of configFunctions.getConfigProperty('settings.contracts.purchaserRelationships')) { %>
<% for (const relationship of dataLists.purchaserRelationships) { %>
<option value="<%= relationship %>">
<% } %>
</datalist>
@ -695,7 +695,7 @@
<div class="control is-expanded">
<div class="select is-fullwidth">
<select id="contract--deathAgePeriod" name="deathAgePeriod" aria-label="Death Age Period">
<% for (const period of configFunctions.getConfigProperty('settings.contracts.deathAgePeriods')) { %>
<% for (const period of dataLists.deathAgePeriods) { %>
<option value="<%= period %>"
<%= (contract.deathAgePeriod === period ? " selected" : "") %>>
<%= period %>
@ -979,7 +979,7 @@
exports.contractInterments = <%- JSON.stringify(contract.contractInterments) %>;
exports.intermentContainerTypes = <%- JSON.stringify(intermentContainerTypes) %>;
exports.deathAgePeriods = <%- JSON.stringify(configFunctions.getConfigProperty('settings.contracts.deathAgePeriods')) %>;
exports.deathAgePeriods = <%- JSON.stringify(dataLists.deathAgePeriods) %>;
exports.contractComments = <%- JSON.stringify(contract.contractComments) %>;
exports.contractFees = <%- JSON.stringify(contract.contractFees) %>;
exports.contractTransactions = <%- JSON.stringify(contract.contractTransactions) %>;