diff --git a/cypress/e2e/01-admin/occupancyTypeManagement.cy.d.ts b/cypress/e2e/01-admin/contractTypeManagement.cy.d.ts similarity index 100% rename from cypress/e2e/01-admin/occupancyTypeManagement.cy.d.ts rename to cypress/e2e/01-admin/contractTypeManagement.cy.d.ts diff --git a/cypress/e2e/01-admin/occupancyTypeManagement.cy.js b/cypress/e2e/01-admin/contractTypeManagement.cy.js similarity index 66% rename from cypress/e2e/01-admin/occupancyTypeManagement.cy.js rename to cypress/e2e/01-admin/contractTypeManagement.cy.js index 4b8b9c9c..03fac1f7 100644 --- a/cypress/e2e/01-admin/occupancyTypeManagement.cy.js +++ b/cypress/e2e/01-admin/contractTypeManagement.cy.js @@ -1,11 +1,11 @@ import { testAdmin } from '../../../test/_globals.js'; import { login, logout } from '../../support/index.js'; -describe('Admin - Occupancy Type Management', () => { +describe('Admin - Contract Type Management', () => { beforeEach('Loads page', () => { logout(); login(testAdmin); - cy.visit('/admin/occupancyTypes'); - cy.location('pathname').should('equal', '/admin/occupancyTypes'); + cy.visit('/admin/contractTypes'); + cy.location('pathname').should('equal', '/admin/contractTypes'); }); afterEach(logout); it('Has no detectable accessibility issues', () => { diff --git a/cypress/e2e/01-admin/occupancyTypeManagement.cy.ts b/cypress/e2e/01-admin/contractTypeManagement.cy.ts similarity index 65% rename from cypress/e2e/01-admin/occupancyTypeManagement.cy.ts rename to cypress/e2e/01-admin/contractTypeManagement.cy.ts index 4a5cb2be..663d9ca3 100644 --- a/cypress/e2e/01-admin/occupancyTypeManagement.cy.ts +++ b/cypress/e2e/01-admin/contractTypeManagement.cy.ts @@ -1,12 +1,12 @@ import { testAdmin } from '../../../test/_globals.js' import { login, logout } from '../../support/index.js' -describe('Admin - Occupancy Type Management', () => { +describe('Admin - Contract Type Management', () => { beforeEach('Loads page', () => { logout() login(testAdmin) - cy.visit('/admin/occupancyTypes') - cy.location('pathname').should('equal', '/admin/occupancyTypes') + cy.visit('/admin/contractTypes') + cy.location('pathname').should('equal', '/admin/contractTypes') }) afterEach(logout) diff --git a/cypress/e2e/02-update/lots.cy.js b/cypress/e2e/02-update/lots.cy.js index db9ebbb1..8ae70571 100644 --- a/cypress/e2e/02-update/lots.cy.js +++ b/cypress/e2e/02-update/lots.cy.js @@ -9,11 +9,11 @@ describe('Update - Lots', () => { it('Has a "Create" link on the Lot Search', () => { cy.visit('/lots'); cy.location('pathname').should('equal', '/lots'); - cy.get("a[href$='/lots/new']").should('exist'); + cy.get("a[href$='/burialSites/new']").should('exist'); }); describe('Update a New Lot', () => { it('Has no detectable accessibility issues', () => { - cy.visit('/lots/new'); + cy.visit('/burialSites/new'); cy.injectAxe(); cy.checkA11y(); }); diff --git a/cypress/e2e/02-update/lots.cy.ts b/cypress/e2e/02-update/lots.cy.ts index 6d84f266..dee30068 100644 --- a/cypress/e2e/02-update/lots.cy.ts +++ b/cypress/e2e/02-update/lots.cy.ts @@ -12,12 +12,12 @@ describe('Update - Lots', () => { it('Has a "Create" link on the Lot Search', () => { cy.visit('/lots') cy.location('pathname').should('equal', '/lots') - cy.get("a[href$='/lots/new']").should('exist') + cy.get("a[href$='/burialSites/new']").should('exist') }) describe('Update a New Lot', () => { it('Has no detectable accessibility issues', () => { - cy.visit('/lots/new') + cy.visit('/burialSites/new') cy.injectAxe() cy.checkA11y() }) diff --git a/cypress/e2e/03-readOnly/readOnlyUser.cy.js b/cypress/e2e/03-readOnly/readOnlyUser.cy.js index babf8e15..f782f360 100644 --- a/cypress/e2e/03-readOnly/readOnlyUser.cy.js +++ b/cypress/e2e/03-readOnly/readOnlyUser.cy.js @@ -16,16 +16,16 @@ describe('Read Only User', () => { cy.log('Has no links to admin areas'); cy.get("a[href*='/admin']").should('not.exist'); }); - it('Has no link to create maps on Map Search', () => { - cy.visit('/maps'); + it('Has no link to create cemeteries on Cemetery Search', () => { + cy.visit('/cemeteries'); cy.get("a[href*='/new']").should('not.exist'); }); - it('Has no link to create lots on Lot Search', () => { - cy.visit('/lots'); + it('Has no link to create burial sites on Burial Site Search', () => { + cy.visit('/burialSites'); cy.get("a[href*='/new']").should('not.exist'); }); - it('Has no link to create occupancies on Occupancy Search', () => { - cy.visit('/lotOccupancies'); + it('Has no link to create contracts on Contract Search', () => { + cy.visit('/contracts'); cy.get("a[href*='/new']").should('not.exist'); }); it('Has no link to create work orders on Work Order Search', () => { diff --git a/cypress/e2e/03-readOnly/readOnlyUser.cy.ts b/cypress/e2e/03-readOnly/readOnlyUser.cy.ts index 6ef3262a..05395533 100644 --- a/cypress/e2e/03-readOnly/readOnlyUser.cy.ts +++ b/cypress/e2e/03-readOnly/readOnlyUser.cy.ts @@ -25,18 +25,18 @@ describe('Read Only User', () => { cy.get("a[href*='/admin']").should('not.exist') }) - it('Has no link to create maps on Map Search', () => { - cy.visit('/maps') + it('Has no link to create cemeteries on Cemetery Search', () => { + cy.visit('/cemeteries') cy.get("a[href*='/new']").should('not.exist') }) - it('Has no link to create lots on Lot Search', () => { - cy.visit('/lots') + it('Has no link to create burial sites on Burial Site Search', () => { + cy.visit('/burialSites') cy.get("a[href*='/new']").should('not.exist') }) - it('Has no link to create occupancies on Occupancy Search', () => { - cy.visit('/lotOccupancies') + it('Has no link to create contracts on Contract Search', () => { + cy.visit('/contracts') cy.get("a[href*='/new']").should('not.exist') }) diff --git a/data/config.baseSsm.js b/data/config.baseSsm.js index d536054c..2a0afd24 100644 --- a/data/config.baseSsm.js +++ b/data/config.baseSsm.js @@ -3,13 +3,14 @@ export const config = { ...cemeteryConfig }; config.aliases.externalReceiptNumber = 'GP Receipt Number'; config.settings.burialSites.burialSiteNameSegments = { separator: '-', + includeCemeteryKey: true, segments: { 1: { - isRequired: true, + isRequired: false, isAvailable: true, label: 'Block', minLength: 1, - maxLength: 3 + maxLength: 1 }, 2: { isRequired: true, @@ -23,7 +24,7 @@ config.settings.burialSites.burialSiteNameSegments = { isAvailable: true, label: 'Lot', minLength: 1, - maxLength: 3 + maxLength: 4 }, 4: { isRequired: true, diff --git a/data/config.baseSsm.ts b/data/config.baseSsm.ts index 815d9d30..3965c51b 100644 --- a/data/config.baseSsm.ts +++ b/data/config.baseSsm.ts @@ -8,13 +8,14 @@ config.aliases.externalReceiptNumber = 'GP Receipt Number' config.settings.burialSites.burialSiteNameSegments = { separator: '-', + includeCemeteryKey: true, segments: { 1: { - isRequired: true, + isRequired: false, isAvailable: true, label: 'Block', minLength: 1, - maxLength: 3 + maxLength: 1 }, 2: { isRequired: true, @@ -28,7 +29,7 @@ config.settings.burialSites.burialSiteNameSegments = { isAvailable: true, label: 'Lot', minLength: 1, - maxLength: 3 + maxLength: 4 }, 4: { isRequired: true, diff --git a/database/addBurialSite.js b/database/addBurialSite.js index 11acfb84..d88edcb2 100644 --- a/database/addBurialSite.js +++ b/database/addBurialSite.js @@ -1,10 +1,12 @@ import { buildBurialSiteName } from '../helpers/burialSites.helpers.js'; import addOrUpdateBurialSiteField from './addOrUpdateBurialSiteField.js'; +import getCemetery from './getCemetery.js'; import { acquireConnection } from './pool.js'; export default async function addBurialSite(burialSiteForm, user) { const database = await acquireConnection(); const rightNowMillis = Date.now(); - const burialSiteName = buildBurialSiteName(burialSiteForm); + const cemetery = burialSiteForm.cemeteryId === '' ? undefined : await getCemetery(burialSiteForm.cemeteryId, database); + const burialSiteName = buildBurialSiteName(cemetery?.cemeteryKey, burialSiteForm); const result = database .prepare(`insert into BurialSites ( burialSiteNameSegment1, diff --git a/database/addBurialSite.ts b/database/addBurialSite.ts index d66f29ec..28a876ad 100644 --- a/database/addBurialSite.ts +++ b/database/addBurialSite.ts @@ -1,6 +1,7 @@ import { buildBurialSiteName } from '../helpers/burialSites.helpers.js' import addOrUpdateBurialSiteField from './addOrUpdateBurialSiteField.js' +import getCemetery from './getCemetery.js' import { acquireConnection } from './pool.js' export interface AddBurialSiteForm { @@ -31,7 +32,11 @@ export default async function addBurialSite( const rightNowMillis = Date.now() - const burialSiteName = buildBurialSiteName(burialSiteForm) + const cemetery = burialSiteForm.cemeteryId === '' ? undefined : await getCemetery(burialSiteForm.cemeteryId, database) + + const burialSiteName = buildBurialSiteName( + cemetery?.cemeteryKey, + burialSiteForm) const result = database .prepare( diff --git a/database/addBurialSiteTypeField.d.ts b/database/addBurialSiteTypeField.d.ts index 682b1531..49e2f48f 100644 --- a/database/addBurialSiteTypeField.d.ts +++ b/database/addBurialSiteTypeField.d.ts @@ -5,8 +5,8 @@ export interface AddBurialSiteTypeFieldForm { fieldValues?: string; isRequired?: string; pattern?: string; - minimumLength?: string | number; - maximumLength?: string | number; + minLength?: string | number; + maxLength?: string | number; orderNumber?: number; } export default function addBurialSiteTypeField(addForm: AddBurialSiteTypeFieldForm, user: User): Promise; diff --git a/database/addBurialSiteTypeField.js b/database/addBurialSiteTypeField.js index 66b3f6cb..25b95998 100644 --- a/database/addBurialSiteTypeField.js +++ b/database/addBurialSiteTypeField.js @@ -8,12 +8,12 @@ export default async function addBurialSiteTypeField(addForm, user) { burialSiteTypeId, burialSiteTypeField, fieldType, fieldValues, isRequired, pattern, - minimumLength, maximumLength, + minLength, maxLength, orderNumber, recordCreate_userName, recordCreate_timeMillis, recordUpdate_userName, recordUpdate_timeMillis) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`) - .run(addForm.burialSiteTypeId, addForm.burialSiteTypeField, addForm.fieldType ?? 'text', addForm.fieldValues ?? '', addForm.isRequired === '' ? 0 : 1, addForm.pattern ?? '', addForm.minimumLength ?? 0, addForm.maximumLength ?? 100, addForm.orderNumber ?? -1, user.userName, rightNowMillis, user.userName, rightNowMillis); + .run(addForm.burialSiteTypeId, addForm.burialSiteTypeField, addForm.fieldType ?? 'text', addForm.fieldValues ?? '', addForm.isRequired === '' ? 0 : 1, addForm.pattern ?? '', addForm.minLength ?? 0, addForm.maxLength ?? 100, addForm.orderNumber ?? -1, user.userName, rightNowMillis, user.userName, rightNowMillis); database.release(); clearCacheByTableName('BurialSiteTypeFields'); return result.lastInsertRowid; diff --git a/database/addBurialSiteTypeField.ts b/database/addBurialSiteTypeField.ts index 730ebfd0..b7e58753 100644 --- a/database/addBurialSiteTypeField.ts +++ b/database/addBurialSiteTypeField.ts @@ -9,8 +9,8 @@ export interface AddBurialSiteTypeFieldForm { fieldValues?: string isRequired?: string pattern?: string - minimumLength?: string | number - maximumLength?: string | number + minLength?: string | number + maxLength?: string | number orderNumber?: number } @@ -28,7 +28,7 @@ export default async function addBurialSiteTypeField( burialSiteTypeId, burialSiteTypeField, fieldType, fieldValues, isRequired, pattern, - minimumLength, maximumLength, + minLength, maxLength, orderNumber, recordCreate_userName, recordCreate_timeMillis, recordUpdate_userName, recordUpdate_timeMillis) @@ -41,8 +41,8 @@ export default async function addBurialSiteTypeField( addForm.fieldValues ?? '', addForm.isRequired === '' ? 0 : 1, addForm.pattern ?? '', - addForm.minimumLength ?? 0, - addForm.maximumLength ?? 100, + addForm.minLength ?? 0, + addForm.maxLength ?? 100, addForm.orderNumber ?? -1, user.userName, rightNowMillis, diff --git a/database/addContractTypeField.d.ts b/database/addContractTypeField.d.ts index 1597c31c..d743c20e 100644 --- a/database/addContractTypeField.d.ts +++ b/database/addContractTypeField.d.ts @@ -5,8 +5,8 @@ export interface AddContractTypeFieldForm { fieldType?: string; isRequired?: string; pattern?: string; - minimumLength?: string | number; - maximumLength?: string | number; + minLength?: string | number; + maxLength?: string | number; orderNumber?: number; } export default function addContractTypeField(addForm: AddContractTypeFieldForm, user: User): Promise; diff --git a/database/addContractTypeField.js b/database/addContractTypeField.js index aea9de8c..3b5a4b92 100644 --- a/database/addContractTypeField.js +++ b/database/addContractTypeField.js @@ -7,12 +7,12 @@ export default async function addContractTypeField(addForm, user) { .prepare(`insert into ContractTypeFields ( contractTypeId, contractTypeField, fieldType, fieldValues, isRequired, pattern, - minimumLength, maximumLength, + minLength, maxLength, orderNumber, recordCreate_userName, recordCreate_timeMillis, recordUpdate_userName, recordUpdate_timeMillis) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`) - .run(addForm.contractTypeId ?? undefined, addForm.contractTypeField, addForm.fieldType ?? 'text', addForm.fieldValues ?? '', addForm.isRequired === '' ? 0 : 1, addForm.pattern ?? '', addForm.minimumLength ?? 0, addForm.maximumLength ?? 100, addForm.orderNumber ?? -1, user.userName, rightNowMillis, user.userName, rightNowMillis); + .run(addForm.contractTypeId ?? undefined, addForm.contractTypeField, addForm.fieldType ?? 'text', addForm.fieldValues ?? '', addForm.isRequired === '' ? 0 : 1, addForm.pattern ?? '', addForm.minLength ?? 0, addForm.maxLength ?? 100, addForm.orderNumber ?? -1, user.userName, rightNowMillis, user.userName, rightNowMillis); database.release(); clearCacheByTableName('ContractTypeFields'); return result.lastInsertRowid; diff --git a/database/addContractTypeField.ts b/database/addContractTypeField.ts index 718b523e..2c3fc87a 100644 --- a/database/addContractTypeField.ts +++ b/database/addContractTypeField.ts @@ -9,8 +9,8 @@ export interface AddContractTypeFieldForm { fieldType?: string isRequired?: string pattern?: string - minimumLength?: string | number - maximumLength?: string | number + minLength?: string | number + maxLength?: string | number orderNumber?: number } @@ -27,7 +27,7 @@ export default async function addContractTypeField( `insert into ContractTypeFields ( contractTypeId, contractTypeField, fieldType, fieldValues, isRequired, pattern, - minimumLength, maximumLength, + minLength, maxLength, orderNumber, recordCreate_userName, recordCreate_timeMillis, recordUpdate_userName, recordUpdate_timeMillis) @@ -40,8 +40,8 @@ export default async function addContractTypeField( addForm.fieldValues ?? '', addForm.isRequired === '' ? 0 : 1, addForm.pattern ?? '', - addForm.minimumLength ?? 0, - addForm.maximumLength ?? 100, + addForm.minLength ?? 0, + addForm.maxLength ?? 100, addForm.orderNumber ?? -1, user.userName, rightNowMillis, diff --git a/database/getBurialSite.js b/database/getBurialSite.js index 47ceeaa8..f16aa1be 100644 --- a/database/getBurialSite.js +++ b/database/getBurialSite.js @@ -13,7 +13,7 @@ const baseSQL = `select l.burialSiteId, l.burialSiteStatusId, s.burialSiteStatus, l.cemeteryId, m.cemeteryName, m.cemeterySvg, l.cemeterySvgId, - l.burialSiteLatitude, l.burialSiteLongitude, + l.burialSiteLatitude, l.burialSiteLongitude from BurialSites l left join BurialSiteTypes t on l.burialSiteTypeId = t.burialSiteTypeId diff --git a/database/getBurialSite.ts b/database/getBurialSite.ts index dbf934d3..40d4f86a 100644 --- a/database/getBurialSite.ts +++ b/database/getBurialSite.ts @@ -16,7 +16,7 @@ const baseSQL = `select l.burialSiteId, l.burialSiteStatusId, s.burialSiteStatus, l.cemeteryId, m.cemeteryName, m.cemeterySvg, l.cemeterySvgId, - l.burialSiteLatitude, l.burialSiteLongitude, + l.burialSiteLatitude, l.burialSiteLongitude from BurialSites l left join BurialSiteTypes t on l.burialSiteTypeId = t.burialSiteTypeId diff --git a/database/getBurialSiteContractFields.js b/database/getBurialSiteContractFields.js index 9e4e82e8..5c239835 100644 --- a/database/getBurialSiteContractFields.js +++ b/database/getBurialSiteContractFields.js @@ -4,7 +4,7 @@ export default async function getBurialSiteContractField(burialSiteContractId, c const fields = database .prepare(`select o.burialSiteContractId, o.contractTypeFieldId, o.fieldValue, f.contractTypeField, f.fieldType, f.fieldValues, - f.isRequired, f.pattern, f.minimumLength, f.maximumLength, + f.isRequired, f.pattern, f.minLength, f.maxLength, f.orderNumber, t.orderNumber as contractTypeOrderNumber from BurialSiteContractFields o left join ContractTypeFields f on o.contractTypeFieldId = f.contractTypeFieldId @@ -16,7 +16,7 @@ export default async function getBurialSiteContractField(burialSiteContractId, c select ? as burialSiteContractId, f.contractTypeFieldId, '' as fieldValue, f.contractTypeField, f.fieldType, f.fieldValues, - f.isRequired, f.pattern, f.minimumLength, f.maximumLength, + f.isRequired, f.pattern, f.minLength, f.maxLength, f.orderNumber, t.orderNumber as contractTypeOrderNumber from ContractTypeFields f left join ContractTypes t on f.contractTypeId = t.contractTypeId diff --git a/database/getBurialSiteContractFields.ts b/database/getBurialSiteContractFields.ts index be7f85a3..cc900bc1 100644 --- a/database/getBurialSiteContractFields.ts +++ b/database/getBurialSiteContractFields.ts @@ -14,7 +14,7 @@ export default async function getBurialSiteContractField( .prepare( `select o.burialSiteContractId, o.contractTypeFieldId, o.fieldValue, f.contractTypeField, f.fieldType, f.fieldValues, - f.isRequired, f.pattern, f.minimumLength, f.maximumLength, + f.isRequired, f.pattern, f.minLength, f.maxLength, f.orderNumber, t.orderNumber as contractTypeOrderNumber from BurialSiteContractFields o left join ContractTypeFields f on o.contractTypeFieldId = f.contractTypeFieldId @@ -26,7 +26,7 @@ export default async function getBurialSiteContractField( select ? as burialSiteContractId, f.contractTypeFieldId, '' as fieldValue, f.contractTypeField, f.fieldType, f.fieldValues, - f.isRequired, f.pattern, f.minimumLength, f.maximumLength, + f.isRequired, f.pattern, f.minLength, f.maxLength, f.orderNumber, t.orderNumber as contractTypeOrderNumber from ContractTypeFields f left join ContractTypes t on f.contractTypeId = t.contractTypeId diff --git a/database/getBurialSiteContracts.js b/database/getBurialSiteContracts.js index d4972774..80be4291 100644 --- a/database/getBurialSiteContracts.js +++ b/database/getBurialSiteContracts.js @@ -10,7 +10,7 @@ function buildWhereClause(filters) { let sqlWhereClause = ' where o.recordDelete_timeMillis is null'; const sqlParameters = []; if ((filters.burialSiteId ?? '') !== '') { - sqlWhereClause += ' and o.lotId = ?'; + sqlWhereClause += ' and o.burialSiteId = ?'; sqlParameters.push(filters.burialSiteId); } const lotNameFilters = getBurialSiteNameWhereClause(filters.burialSiteName, filters.burialSiteNameSearchType ?? '', 'l'); diff --git a/database/getBurialSiteContracts.ts b/database/getBurialSiteContracts.ts index 00d086aa..8dab26b6 100644 --- a/database/getBurialSiteContracts.ts +++ b/database/getBurialSiteContracts.ts @@ -51,7 +51,7 @@ function buildWhereClause(filters: GetBurialSiteContractsFilters): { const sqlParameters: unknown[] = [] if ((filters.burialSiteId ?? '') !== '') { - sqlWhereClause += ' and o.lotId = ?' + sqlWhereClause += ' and o.burialSiteId = ?' sqlParameters.push(filters.burialSiteId) } diff --git a/database/getBurialSiteFields.js b/database/getBurialSiteFields.js index 052854e4..13f4b4d9 100644 --- a/database/getBurialSiteFields.js +++ b/database/getBurialSiteFields.js @@ -5,7 +5,7 @@ export default async function getBurialSiteFields(burialSiteId, connectedDatabas .prepare(`select l.burialSiteId, l.burialSiteTypeFieldId, l.fieldValue, f.burialSiteTypeField, f.fieldType, f.fieldValues, - f.isRequired, f.pattern, f.minimumLength, f.maximumLength, + f.isRequired, f.pattern, f.minLength, f.maxLength, f.orderNumber, t.orderNumber as burialSiteTypeOrderNumber from BurialSiteFields l left join BurialSiteTypeFields f on l.burialSiteTypeFieldId = f.burialSiteTypeFieldId @@ -18,7 +18,7 @@ export default async function getBurialSiteFields(burialSiteId, connectedDatabas select ? as burialSiteId, f.burialSiteTypeFieldId, '' as fieldValue, f.burialSiteTypeField, f.fieldType, f.fieldValues, - f.isRequired, f.pattern, f.minimumLength, f.maximumLength, + f.isRequired, f.pattern, f.minLength, f.maxLength, f.orderNumber, t.orderNumber as burialSiteTypeOrderNumber from BurialSiteTypeFields f left join BurialSiteTypes t on f.burialSiteTypeId = t.burialSiteTypeId diff --git a/database/getBurialSiteFields.ts b/database/getBurialSiteFields.ts index cf0bdea3..35c41986 100644 --- a/database/getBurialSiteFields.ts +++ b/database/getBurialSiteFields.ts @@ -15,7 +15,7 @@ export default async function getBurialSiteFields( `select l.burialSiteId, l.burialSiteTypeFieldId, l.fieldValue, f.burialSiteTypeField, f.fieldType, f.fieldValues, - f.isRequired, f.pattern, f.minimumLength, f.maximumLength, + f.isRequired, f.pattern, f.minLength, f.maxLength, f.orderNumber, t.orderNumber as burialSiteTypeOrderNumber from BurialSiteFields l left join BurialSiteTypeFields f on l.burialSiteTypeFieldId = f.burialSiteTypeFieldId @@ -28,7 +28,7 @@ export default async function getBurialSiteFields( select ? as burialSiteId, f.burialSiteTypeFieldId, '' as fieldValue, f.burialSiteTypeField, f.fieldType, f.fieldValues, - f.isRequired, f.pattern, f.minimumLength, f.maximumLength, + f.isRequired, f.pattern, f.minLength, f.maxLength, f.orderNumber, t.orderNumber as burialSiteTypeOrderNumber from BurialSiteTypeFields f left join BurialSiteTypes t on f.burialSiteTypeId = t.burialSiteTypeId diff --git a/database/getBurialSiteTypeFields.js b/database/getBurialSiteTypeFields.js index 1a3068e0..1c089397 100644 --- a/database/getBurialSiteTypeFields.js +++ b/database/getBurialSiteTypeFields.js @@ -5,7 +5,7 @@ export default async function getBurialSiteTypeFields(burialSiteTypeId, connecte const typeFields = database .prepare(`select burialSiteTypeFieldId, burialSiteTypeField, fieldType, fieldValues, - isRequired, pattern, minimumLength, maximumLength, orderNumber + isRequired, pattern, minLength, maxLength, orderNumber from BurialSiteTypeFields where recordDelete_timeMillis is null and burialSiteTypeId = ? diff --git a/database/getBurialSiteTypeFields.ts b/database/getBurialSiteTypeFields.ts index dae08858..aa659cad 100644 --- a/database/getBurialSiteTypeFields.ts +++ b/database/getBurialSiteTypeFields.ts @@ -15,7 +15,7 @@ export default async function getBurialSiteTypeFields( .prepare( `select burialSiteTypeFieldId, burialSiteTypeField, fieldType, fieldValues, - isRequired, pattern, minimumLength, maximumLength, orderNumber + isRequired, pattern, minLength, maxLength, orderNumber from BurialSiteTypeFields where recordDelete_timeMillis is null and burialSiteTypeId = ? diff --git a/database/getBurialSites.js b/database/getBurialSites.js index 737cd93e..130ebf8c 100644 --- a/database/getBurialSites.js +++ b/database/getBurialSites.js @@ -70,6 +70,7 @@ export default async function getBurialSites(filters, options, connectedDatabase l.burialSiteNameSegment3, l.burialSiteNameSegment4, l.burialSiteNameSegment5, + l.burialSiteName, t.burialSiteType, l.cemeteryId, m.cemeteryName, l.cemeterySvgId, l.burialSiteStatusId, s.burialSiteStatus diff --git a/database/getBurialSites.ts b/database/getBurialSites.ts index 54fe8a47..3c181c13 100644 --- a/database/getBurialSites.ts +++ b/database/getBurialSites.ts @@ -123,6 +123,7 @@ export default async function getBurialSites( l.burialSiteNameSegment3, l.burialSiteNameSegment4, l.burialSiteNameSegment5, + l.burialSiteName, t.burialSiteType, l.cemeteryId, m.cemeteryName, l.cemeterySvgId, l.burialSiteStatusId, s.burialSiteStatus diff --git a/database/getCemetery.d.ts b/database/getCemetery.d.ts index 83cfca22..7abca40c 100644 --- a/database/getCemetery.d.ts +++ b/database/getCemetery.d.ts @@ -1,2 +1,3 @@ +import type { PoolConnection } from 'better-sqlite-pool'; import type { Cemetery } from '../types/recordTypes.js'; -export default function getCemetery(cemeteryId: number | string): Promise; +export default function getCemetery(cemeteryId: number | string, connectedDatabase?: PoolConnection): Promise; diff --git a/database/getCemetery.js b/database/getCemetery.js index 6712be9b..15a8f7c9 100644 --- a/database/getCemetery.js +++ b/database/getCemetery.js @@ -1,7 +1,7 @@ import { acquireConnection } from './pool.js'; -export default async function getCemetery(cemeteryId) { - const database = await acquireConnection(); - const map = database +export default async function getCemetery(cemeteryId, connectedDatabase) { + const database = connectedDatabase ?? (await acquireConnection()); + const cemetery = database .prepare(`select m.cemeteryId, m.cemeteryName, m.cemeteryKey, m.cemeteryDescription, m.cemeteryLatitude, m.cemeteryLongitude, m.cemeterySvg, m.cemeteryAddress1, m.cemeteryAddress2, m.cemeteryCity, m.cemeteryProvince, m.cemeteryPostalCode, @@ -22,6 +22,8 @@ export default async function getCemetery(cemeteryId) { m.recordUpdate_userName, m.recordUpdate_timeMillis, m.recordDelete_userName, m.recordDelete_timeMillis`) .get(cemeteryId); - database.release(); - return map; + if (connectedDatabase === undefined) { + database.release(); + } + return cemetery; } diff --git a/database/getCemetery.ts b/database/getCemetery.ts index 1f7e0622..96f3903f 100644 --- a/database/getCemetery.ts +++ b/database/getCemetery.ts @@ -1,13 +1,16 @@ +import type { PoolConnection } from 'better-sqlite-pool' + import type { Cemetery } from '../types/recordTypes.js' import { acquireConnection } from './pool.js' export default async function getCemetery( - cemeteryId: number | string + cemeteryId: number | string, + connectedDatabase?: PoolConnection ): Promise { - const database = await acquireConnection() + const database = connectedDatabase ?? (await acquireConnection()) - const map = database + const cemetery = database .prepare( `select m.cemeteryId, m.cemeteryName, m.cemeteryKey, m.cemeteryDescription, m.cemeteryLatitude, m.cemeteryLongitude, m.cemeterySvg, @@ -31,7 +34,9 @@ export default async function getCemetery( ) .get(cemeteryId) as Cemetery | undefined - database.release() + if (connectedDatabase === undefined) { + database.release() + } - return map + return cemetery } diff --git a/database/getContractTypeFields.js b/database/getContractTypeFields.js index 636b4724..af8f611a 100644 --- a/database/getContractTypeFields.js +++ b/database/getContractTypeFields.js @@ -8,7 +8,7 @@ export default async function getContractTypeFields(contractTypeId, connectedDat } const contractTypeFields = database .prepare(`select contractTypeFieldId, contractTypeField, fieldType, - fieldValues, isRequired, pattern, minimumLength, maximumLength, orderNumber + fieldValues, isRequired, pattern, minLength, maxLength, orderNumber from ContractTypeFields where recordDelete_timeMillis is null ${(contractTypeId ?? -1) === -1 diff --git a/database/getContractTypeFields.ts b/database/getContractTypeFields.ts index a867ebf4..86b9068a 100644 --- a/database/getContractTypeFields.ts +++ b/database/getContractTypeFields.ts @@ -20,7 +20,7 @@ export default async function getContractTypeFields( const contractTypeFields = database .prepare( `select contractTypeFieldId, contractTypeField, fieldType, - fieldValues, isRequired, pattern, minimumLength, maximumLength, orderNumber + fieldValues, isRequired, pattern, minLength, maxLength, orderNumber from ContractTypeFields where recordDelete_timeMillis is null ${ diff --git a/database/moveContractTypeField.js b/database/moveContractTypeField.js index f07b28f3..743e89f2 100644 --- a/database/moveContractTypeField.js +++ b/database/moveContractTypeField.js @@ -28,9 +28,9 @@ export async function moveContractTypeFieldDown(contractTypeFieldId) { export async function moveContractTypeFieldDownToBottom(contractTypeFieldId) { const database = await acquireConnection(); const currentField = getCurrentField(contractTypeFieldId, database); - const occupancyTypeParameters = []; + const contractTypeParameters = []; if (currentField.contractTypeId) { - occupancyTypeParameters.push(currentField.contractTypeId); + contractTypeParameters.push(currentField.contractTypeId); } const maxOrderNumber = database .prepare(`select max(orderNumber) as maxOrderNumber @@ -39,10 +39,10 @@ export async function moveContractTypeFieldDownToBottom(contractTypeFieldId) { ${currentField.contractTypeId === undefined ? ' and contractTypeId is null' : ' and contractTypeId = ?'}`) - .get(occupancyTypeParameters).maxOrderNumber; + .get(contractTypeParameters).maxOrderNumber; if (currentField.orderNumber !== maxOrderNumber) { updateRecordOrderNumber('ContractTypeFields', contractTypeFieldId, maxOrderNumber + 1, database); - occupancyTypeParameters.push(currentField.orderNumber); + contractTypeParameters.push(currentField.orderNumber); database .prepare(`update ContractTypeFields set orderNumber = orderNumber - 1 where recordDelete_timeMillis is null @@ -50,7 +50,7 @@ export async function moveContractTypeFieldDownToBottom(contractTypeFieldId) { ? ' and contractTypeId is null' : ' and contractTypeId = ?'} and orderNumber > ?`) - .run(occupancyTypeParameters); + .run(contractTypeParameters); } database.release(); clearCacheByTableName('ContractTypeFields'); @@ -82,11 +82,11 @@ export async function moveContractTypeFieldUpToTop(contractTypeFieldId) { const currentField = getCurrentField(contractTypeFieldId, database); if (currentField.orderNumber > 0) { updateRecordOrderNumber('ContractTypeFields', contractTypeFieldId, -1, database); - const occupancyTypeParameters = []; + const contractTypeParameters = []; if (currentField.contractTypeId) { - occupancyTypeParameters.push(currentField.contractTypeId); + contractTypeParameters.push(currentField.contractTypeId); } - occupancyTypeParameters.push(currentField.orderNumber); + contractTypeParameters.push(currentField.orderNumber); database .prepare(`update ContractTypeFields set orderNumber = orderNumber + 1 @@ -94,7 +94,7 @@ export async function moveContractTypeFieldUpToTop(contractTypeFieldId) { ${currentField.contractTypeId ? ' and contractTypeId = ?' : ' and contractTypeId is null'} and orderNumber < ?`) - .run(occupancyTypeParameters); + .run(contractTypeParameters); } database.release(); clearCacheByTableName('ContractTypeFields'); diff --git a/database/moveContractTypeField.ts b/database/moveContractTypeField.ts index b9a86010..4ec00e69 100644 --- a/database/moveContractTypeField.ts +++ b/database/moveContractTypeField.ts @@ -63,10 +63,10 @@ export async function moveContractTypeFieldDownToBottom( const currentField = getCurrentField(contractTypeFieldId, database) - const occupancyTypeParameters: unknown[] = [] + const contractTypeParameters: unknown[] = [] if (currentField.contractTypeId) { - occupancyTypeParameters.push(currentField.contractTypeId) + contractTypeParameters.push(currentField.contractTypeId) } const maxOrderNumber: number = ( @@ -81,7 +81,7 @@ export async function moveContractTypeFieldDownToBottom( : ' and contractTypeId = ?' }` ) - .get(occupancyTypeParameters) as { maxOrderNumber: number } + .get(contractTypeParameters) as { maxOrderNumber: number } ).maxOrderNumber if (currentField.orderNumber !== maxOrderNumber) { @@ -92,7 +92,7 @@ export async function moveContractTypeFieldDownToBottom( database ) - occupancyTypeParameters.push(currentField.orderNumber) + contractTypeParameters.push(currentField.orderNumber) database .prepare( @@ -105,7 +105,7 @@ export async function moveContractTypeFieldDownToBottom( } and orderNumber > ?` ) - .run(occupancyTypeParameters) + .run(contractTypeParameters) } database.release() @@ -170,13 +170,13 @@ export async function moveContractTypeFieldUpToTop( database ) - const occupancyTypeParameters: unknown[] = [] + const contractTypeParameters: unknown[] = [] if (currentField.contractTypeId) { - occupancyTypeParameters.push(currentField.contractTypeId) + contractTypeParameters.push(currentField.contractTypeId) } - occupancyTypeParameters.push(currentField.orderNumber) + contractTypeParameters.push(currentField.orderNumber) database .prepare( @@ -189,7 +189,7 @@ export async function moveContractTypeFieldUpToTop( : ' and contractTypeId is null' } and orderNumber < ?` ) - .run(occupancyTypeParameters) + .run(contractTypeParameters) } database.release() diff --git a/database/updateBurialSite.d.ts b/database/updateBurialSite.d.ts index dc598daf..f37a6e58 100644 --- a/database/updateBurialSite.d.ts +++ b/database/updateBurialSite.d.ts @@ -1,6 +1,6 @@ export interface UpdateBurialSiteForm { burialSiteId: string | number; - burialSiteNameSegment1: string; + burialSiteNameSegment1?: string; burialSiteNameSegment2?: string; burialSiteNameSegment3?: string; burialSiteNameSegment4?: string; diff --git a/database/updateBurialSite.js b/database/updateBurialSite.js index 96c61c21..50ecbb7e 100644 --- a/database/updateBurialSite.js +++ b/database/updateBurialSite.js @@ -1,8 +1,14 @@ +import { buildBurialSiteName } from '../helpers/burialSites.helpers.js'; import addOrUpdateBurialSiteField from './addOrUpdateBurialSiteField.js'; import deleteBurialSiteField from './deleteBurialSiteField.js'; +import getCemetery from './getCemetery.js'; import { acquireConnection } from './pool.js'; export default async function updateBurialSite(updateForm, user) { const database = await acquireConnection(); + const cemetery = updateForm.cemeteryId === '' + ? undefined + : await getCemetery(updateForm.cemeteryId, database); + const burialSiteName = buildBurialSiteName(cemetery?.cemeteryKey, updateForm); const result = database .prepare(`update BurialSites set burialSiteNameSegment1 = ?, @@ -10,6 +16,7 @@ export default async function updateBurialSite(updateForm, user) { burialSiteNameSegment3 = ?, burialSiteNameSegment4 = ?, burialSiteNameSegment5 = ?, + burialSiteName = ?, burialSiteTypeId = ?, burialSiteStatusId = ?, cemeteryId = ?, @@ -18,9 +25,9 @@ export default async function updateBurialSite(updateForm, user) { burialSiteLongitude = ?, recordUpdate_userName = ?, recordUpdate_timeMillis = ? - where lotId = ? + where burialSiteId = ? and recordDelete_timeMillis is null`) - .run(updateForm.burialSiteNameSegment1, updateForm.burialSiteNameSegment2 ?? '', updateForm.burialSiteNameSegment3 ?? '', updateForm.burialSiteNameSegment4 ?? '', updateForm.burialSiteNameSegment5 ?? '', updateForm.burialSiteTypeId, updateForm.burialSiteStatusId === '' + .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.burialSiteLatitude === '' ? undefined diff --git a/database/updateBurialSite.ts b/database/updateBurialSite.ts index e16a4d6e..af77470d 100644 --- a/database/updateBurialSite.ts +++ b/database/updateBurialSite.ts @@ -1,11 +1,14 @@ +import { buildBurialSiteName } from '../helpers/burialSites.helpers.js' + import addOrUpdateBurialSiteField from './addOrUpdateBurialSiteField.js' import deleteBurialSiteField from './deleteBurialSiteField.js' +import getCemetery from './getCemetery.js' import { acquireConnection } from './pool.js' export interface UpdateBurialSiteForm { burialSiteId: string | number - burialSiteNameSegment1: string + burialSiteNameSegment1?: string burialSiteNameSegment2?: string burialSiteNameSegment3?: string burialSiteNameSegment4?: string @@ -30,6 +33,16 @@ export default async function updateBurialSite( ): Promise { const database = await acquireConnection() + const cemetery = + updateForm.cemeteryId === '' + ? undefined + : await getCemetery(updateForm.cemeteryId, database) + + const burialSiteName = buildBurialSiteName( + cemetery?.cemeteryKey, + updateForm + ) + const result = database .prepare( `update BurialSites @@ -38,6 +51,7 @@ export default async function updateBurialSite( burialSiteNameSegment3 = ?, burialSiteNameSegment4 = ?, burialSiteNameSegment5 = ?, + burialSiteName = ?, burialSiteTypeId = ?, burialSiteStatusId = ?, cemeteryId = ?, @@ -46,15 +60,16 @@ export default async function updateBurialSite( burialSiteLongitude = ?, recordUpdate_userName = ?, recordUpdate_timeMillis = ? - where lotId = ? + where burialSiteId = ? and recordDelete_timeMillis is null` ) .run( - updateForm.burialSiteNameSegment1, + updateForm.burialSiteNameSegment1 ?? '', updateForm.burialSiteNameSegment2 ?? '', updateForm.burialSiteNameSegment3 ?? '', updateForm.burialSiteNameSegment4 ?? '', updateForm.burialSiteNameSegment5 ?? '', + burialSiteName, updateForm.burialSiteTypeId, updateForm.burialSiteStatusId === '' ? undefined diff --git a/database/updateBurialSiteTypeField.d.ts b/database/updateBurialSiteTypeField.d.ts index 94a077b0..9dbf2f34 100644 --- a/database/updateBurialSiteTypeField.d.ts +++ b/database/updateBurialSiteTypeField.d.ts @@ -3,8 +3,8 @@ export interface UpdateBurialSiteTypeFieldForm { burialSiteTypeField: string; isRequired: '0' | '1'; fieldType?: string; - minimumLength?: string; - maximumLength?: string; + minLength?: string; + maxLength?: string; pattern?: string; fieldValues: string; } diff --git a/database/updateBurialSiteTypeField.js b/database/updateBurialSiteTypeField.js index 856f5b80..fc2315e8 100644 --- a/database/updateBurialSiteTypeField.js +++ b/database/updateBurialSiteTypeField.js @@ -7,15 +7,15 @@ export default async function updateBurialSiteTypeField(updateForm, user) { set burialSiteTypeField = ?, isRequired = ?, fieldType = ?, - minimumLength = ?, - maximumLength = ?, + minLength = ?, + maxLength = ?, pattern = ?, fieldValues = ?, recordUpdate_userName = ?, recordUpdate_timeMillis = ? where burialSiteTypeFieldId = ? and recordDelete_timeMillis is null`) - .run(updateForm.burialSiteTypeField, Number.parseInt(updateForm.isRequired, 10), updateForm.fieldType ?? 'text', updateForm.minimumLength ?? 0, updateForm.maximumLength ?? 100, updateForm.pattern ?? '', updateForm.fieldValues, user.userName, Date.now(), updateForm.burialSiteTypeFieldId); + .run(updateForm.burialSiteTypeField, Number.parseInt(updateForm.isRequired, 10), updateForm.fieldType ?? 'text', updateForm.minLength ?? 0, updateForm.maxLength ?? 100, updateForm.pattern ?? '', updateForm.fieldValues, user.userName, Date.now(), updateForm.burialSiteTypeFieldId); database.release(); clearCacheByTableName('BurialSiteTypeFields'); return result.changes > 0; diff --git a/database/updateBurialSiteTypeField.ts b/database/updateBurialSiteTypeField.ts index e228695d..2c4eb999 100644 --- a/database/updateBurialSiteTypeField.ts +++ b/database/updateBurialSiteTypeField.ts @@ -7,8 +7,8 @@ export interface UpdateBurialSiteTypeFieldForm { burialSiteTypeField: string isRequired: '0' | '1' fieldType?: string - minimumLength?: string - maximumLength?: string + minLength?: string + maxLength?: string pattern?: string fieldValues: string } @@ -25,8 +25,8 @@ export default async function updateBurialSiteTypeField( set burialSiteTypeField = ?, isRequired = ?, fieldType = ?, - minimumLength = ?, - maximumLength = ?, + minLength = ?, + maxLength = ?, pattern = ?, fieldValues = ?, recordUpdate_userName = ?, @@ -38,8 +38,8 @@ export default async function updateBurialSiteTypeField( updateForm.burialSiteTypeField, Number.parseInt(updateForm.isRequired, 10), updateForm.fieldType ?? 'text', - updateForm.minimumLength ?? 0, - updateForm.maximumLength ?? 100, + updateForm.minLength ?? 0, + updateForm.maxLength ?? 100, updateForm.pattern ?? '', updateForm.fieldValues, user.userName, diff --git a/database/updateContractTypeField.d.ts b/database/updateContractTypeField.d.ts index 03b06c67..92187fdc 100644 --- a/database/updateContractTypeField.d.ts +++ b/database/updateContractTypeField.d.ts @@ -3,8 +3,8 @@ export interface UpdateContractTypeFieldForm { contractTypeField: string; isRequired: '0' | '1'; fieldType?: string; - minimumLength?: string; - maximumLength?: string; + minLength?: string; + maxLength?: string; pattern?: string; fieldValues: string; } diff --git a/database/updateContractTypeField.js b/database/updateContractTypeField.js index f3951349..bdb17729 100644 --- a/database/updateContractTypeField.js +++ b/database/updateContractTypeField.js @@ -7,15 +7,15 @@ export default async function updateContractTypeField(updateForm, user) { set contractTypeField = ?, isRequired = ?, fieldType = ?, - minimumLength = ?, - maximumLength = ?, + minLength = ?, + maxLength = ?, pattern = ?, fieldValues = ?, recordUpdate_userName = ?, recordUpdate_timeMillis = ? where contractTypeFieldId = ? and recordDelete_timeMillis is null`) - .run(updateForm.contractTypeField, Number.parseInt(updateForm.isRequired, 10), updateForm.fieldType ?? 'text', updateForm.minimumLength ?? 0, updateForm.maximumLength ?? 100, updateForm.pattern ?? '', updateForm.fieldValues, user.userName, Date.now(), updateForm.contractTypeFieldId); + .run(updateForm.contractTypeField, Number.parseInt(updateForm.isRequired, 10), updateForm.fieldType ?? 'text', updateForm.minLength ?? 0, updateForm.maxLength ?? 100, updateForm.pattern ?? '', updateForm.fieldValues, user.userName, Date.now(), updateForm.contractTypeFieldId); database.release(); clearCacheByTableName('ContractTypeFields'); return result.changes > 0; diff --git a/database/updateContractTypeField.ts b/database/updateContractTypeField.ts index 3c304010..580d3b4c 100644 --- a/database/updateContractTypeField.ts +++ b/database/updateContractTypeField.ts @@ -7,8 +7,8 @@ export interface UpdateContractTypeFieldForm { contractTypeField: string isRequired: '0' | '1' fieldType?: string - minimumLength?: string - maximumLength?: string + minLength?: string + maxLength?: string pattern?: string fieldValues: string } @@ -25,8 +25,8 @@ export default async function updateContractTypeField( set contractTypeField = ?, isRequired = ?, fieldType = ?, - minimumLength = ?, - maximumLength = ?, + minLength = ?, + maxLength = ?, pattern = ?, fieldValues = ?, recordUpdate_userName = ?, @@ -38,8 +38,8 @@ export default async function updateContractTypeField( updateForm.contractTypeField, Number.parseInt(updateForm.isRequired, 10), updateForm.fieldType ?? 'text', - updateForm.minimumLength ?? 0, - updateForm.maximumLength ?? 100, + updateForm.minLength ?? 0, + updateForm.maxLength ?? 100, updateForm.pattern ?? '', updateForm.fieldValues, user.userName, diff --git a/handlers/admin-get/contractTypes.js b/handlers/admin-get/contractTypes.js index 38db0afb..4c4efe70 100644 --- a/handlers/admin-get/contractTypes.js +++ b/handlers/admin-get/contractTypes.js @@ -5,17 +5,17 @@ export default async function handler(_request, response) { const contractTypes = await getContractTypes(); const allContractTypeFields = await getAllContractTypeFields(); const contractTypePrints = getConfigProperty('settings.contracts.prints'); - const occupancyTypePrintTitles = {}; + const contractTypePrintTitles = {}; for (const printEJS of contractTypePrints) { const printConfig = getPrintConfig(printEJS); if (printConfig !== undefined) { - occupancyTypePrintTitles[printEJS] = printConfig.title; + contractTypePrintTitles[printEJS] = printConfig.title; } } response.render('admin-contractTypes', { headTitle: `Contract Type Management`, - occupancyTypes: contractTypes, + contractTypes, allContractTypeFields, - occupancyTypePrintTitles + contractTypePrintTitles }); } diff --git a/handlers/admin-get/contractTypes.ts b/handlers/admin-get/contractTypes.ts index edefed91..aa2c5001 100644 --- a/handlers/admin-get/contractTypes.ts +++ b/handlers/admin-get/contractTypes.ts @@ -16,20 +16,20 @@ export default async function handler( const contractTypePrints = getConfigProperty('settings.contracts.prints') - const occupancyTypePrintTitles = {} + const contractTypePrintTitles = {} for (const printEJS of contractTypePrints) { const printConfig = getPrintConfig(printEJS) if (printConfig !== undefined) { - occupancyTypePrintTitles[printEJS] = printConfig.title + contractTypePrintTitles[printEJS] = printConfig.title } } response.render('admin-contractTypes', { headTitle: `Contract Type Management`, - occupancyTypes: contractTypes, + contractTypes, allContractTypeFields, - occupancyTypePrintTitles + contractTypePrintTitles }) } diff --git a/handlers/burialSites-get/view.js b/handlers/burialSites-get/view.js index 4b05ad5f..0d460e0d 100644 --- a/handlers/burialSites-get/view.js +++ b/handlers/burialSites-get/view.js @@ -9,7 +9,7 @@ export default async function handler(request, response) { } response.render('burialSite-view', { headTitle: burialSite.burialSiteName, - lot: burialSite + burialSite }); response.on('finish', () => { void getNextBurialSiteId(burialSite.burialSiteId); diff --git a/handlers/burialSites-get/view.ts b/handlers/burialSites-get/view.ts index 6b7afb6f..84154513 100644 --- a/handlers/burialSites-get/view.ts +++ b/handlers/burialSites-get/view.ts @@ -22,7 +22,7 @@ export default async function handler( response.render('burialSite-view', { headTitle: burialSite.burialSiteName, - lot: burialSite + burialSite }) response.on('finish', () => { diff --git a/helpers/burialSiteContracts.helpers.d.ts b/helpers/burialSiteContracts.helpers.d.ts index 47eb5108..1ef415d2 100644 --- a/helpers/burialSiteContracts.helpers.d.ts +++ b/helpers/burialSiteContracts.helpers.d.ts @@ -1,4 +1,4 @@ import type { BurialSiteContract, BurialSiteContractFee } from '../types/recordTypes.js'; -export declare function getFieldValueByContractTypeField(burialSiteContract: BurialSiteContract, occupancyTypeField: string): string | undefined; +export declare function getFieldValueByContractTypeField(burialSiteContract: BurialSiteContract, contractTypeField: string): string | undefined; export declare function getFeesByFeeCategory(burialSiteContract: BurialSiteContract, feeCategory: string, feeCategoryContains?: boolean): BurialSiteContractFee[]; export declare function getTransactionTotal(burialSiteContract: BurialSiteContract): number; diff --git a/helpers/burialSiteContracts.helpers.js b/helpers/burialSiteContracts.helpers.js index f4af7c6b..180e2952 100644 --- a/helpers/burialSiteContracts.helpers.js +++ b/helpers/burialSiteContracts.helpers.js @@ -1,7 +1,7 @@ -export function getFieldValueByContractTypeField(burialSiteContract, occupancyTypeField) { - const occupancyTypeFieldLowerCase = occupancyTypeField.toLowerCase(); +export function getFieldValueByContractTypeField(burialSiteContract, contractTypeField) { + const contractTypeFieldLowerCase = contractTypeField.toLowerCase(); const field = (burialSiteContract.burialSiteContractFields ?? []).find((possibleField) => possibleField.contractTypeField.toLowerCase() === - occupancyTypeFieldLowerCase); + contractTypeFieldLowerCase); if (field === undefined) { return undefined; } diff --git a/helpers/burialSiteContracts.helpers.ts b/helpers/burialSiteContracts.helpers.ts index 402748c9..c83c885d 100644 --- a/helpers/burialSiteContracts.helpers.ts +++ b/helpers/burialSiteContracts.helpers.ts @@ -5,14 +5,14 @@ import type { export function getFieldValueByContractTypeField( burialSiteContract: BurialSiteContract, - occupancyTypeField: string + contractTypeField: string ): string | undefined { - const occupancyTypeFieldLowerCase = occupancyTypeField.toLowerCase() + const contractTypeFieldLowerCase = contractTypeField.toLowerCase() const field = (burialSiteContract.burialSiteContractFields ?? []).find( (possibleField) => (possibleField.contractTypeField as string).toLowerCase() === - occupancyTypeFieldLowerCase + contractTypeFieldLowerCase ) if (field === undefined) { diff --git a/helpers/burialSites.helpers.d.ts b/helpers/burialSites.helpers.d.ts index 8416c4e4..23a59f65 100644 --- a/helpers/burialSites.helpers.d.ts +++ b/helpers/burialSites.helpers.d.ts @@ -1,7 +1,7 @@ export declare function getNextBurialSiteId(burialSiteId: number): Promise; export declare function getPreviousBurialSiteId(burialSiteId: number): Promise; export declare function clearNextPreviousBurialSiteIdCache(burialSiteId?: number, relayMessage?: boolean): void; -export declare function buildBurialSiteName(segments: { +export declare function buildBurialSiteName(cemeteryKey: string | undefined, segments: { burialSiteNameSegment1?: string; burialSiteNameSegment2?: string; burialSiteNameSegment3?: string; diff --git a/helpers/burialSites.helpers.js b/helpers/burialSites.helpers.js index c770ce01..de18aefd 100644 --- a/helpers/burialSites.helpers.js +++ b/helpers/burialSites.helpers.js @@ -85,8 +85,11 @@ export function clearNextPreviousBurialSiteIdCache(burialSiteId = -1, relayMessa catch { } } const segmentConfig = getConfigProperty('settings.burialSites.burialSiteNameSegments'); -export function buildBurialSiteName(segments) { +export function buildBurialSiteName(cemeteryKey, segments) { const segmentPieces = []; + if (segmentConfig.includeCemeteryKey && cemeteryKey !== undefined) { + segmentPieces.push(cemeteryKey); + } // eslint-disable-next-line @typescript-eslint/no-magic-numbers for (let segmentIndex = 1; segmentIndex <= 5; segmentIndex++) { const segmentIndexString = segmentIndex.toString(); diff --git a/helpers/burialSites.helpers.ts b/helpers/burialSites.helpers.ts index 9ad438fc..3779ac6f 100644 --- a/helpers/burialSites.helpers.ts +++ b/helpers/burialSites.helpers.ts @@ -138,7 +138,7 @@ const segmentConfig = getConfigProperty( 'settings.burialSites.burialSiteNameSegments' ) -export function buildBurialSiteName(segments: { +export function buildBurialSiteName(cemeteryKey: string | undefined, segments: { burialSiteNameSegment1?: string burialSiteNameSegment2?: string burialSiteNameSegment3?: string @@ -147,6 +147,10 @@ export function buildBurialSiteName(segments: { }): string { const segmentPieces: string[] = [] + if (segmentConfig.includeCemeteryKey && cemeteryKey !== undefined) { + segmentPieces.push(cemeteryKey) + } + // eslint-disable-next-line @typescript-eslint/no-magic-numbers for (let segmentIndex = 1; segmentIndex <= 5; segmentIndex++) { const segmentIndexString = segmentIndex.toString() diff --git a/helpers/functions.cache.d.ts b/helpers/functions.cache.d.ts index 46667cb3..f6eb1801 100644 --- a/helpers/functions.cache.d.ts +++ b/helpers/functions.cache.d.ts @@ -17,6 +17,6 @@ export declare function getWorkOrderMilestoneTypeById(workOrderMilestoneTypeId: export declare function getWorkOrderMilestoneTypeByWorkOrderMilestoneType(workOrderMilestoneTypeString: string): Promise; export declare function preloadCaches(): Promise; export declare function clearCaches(): void; -type CacheTableNames = 'BurialSiteStatuses' | 'BurialSiteTypes' | 'BurialSiteTypeFields' | 'ContractTypes' | 'ContractTypeFields' | 'ContractTypePrints' | 'WorkOrderMilestoneTypes' | 'WorkOrderTypes' | 'FeeCategories'; +type CacheTableNames = 'BurialSiteStatuses' | 'BurialSiteTypes' | 'BurialSiteTypeFields' | 'ContractTypes' | 'ContractTypeFields' | 'ContractTypePrints' | 'WorkOrderMilestoneTypes' | 'WorkOrderTypes' | 'FeeCategories' | 'Fees'; export declare function clearCacheByTableName(tableName: CacheTableNames, relayMessage?: boolean): void; export {}; diff --git a/helpers/functions.cache.ts b/helpers/functions.cache.ts index 08900004..c84d07aa 100644 --- a/helpers/functions.cache.ts +++ b/helpers/functions.cache.ts @@ -281,6 +281,7 @@ type CacheTableNames = | 'WorkOrderMilestoneTypes' | 'WorkOrderTypes' | 'FeeCategories' + | 'Fees' export function clearCacheByTableName( tableName: CacheTableNames, diff --git a/package-lock.json b/package-lock.json index b2ffe7ab..9c0d1f41 100644 --- a/package-lock.json +++ b/package-lock.json @@ -79,14 +79,14 @@ "bulma-steps": "^2.2.1", "bulma-switch": "^2.0.4", "bulma-tooltip": "^3.0.2", - "cypress": "^14.0.3", + "cypress": "^14.1.0", "cypress-axe": "^1.6.0", "eslint-config-cityssm": "^20.0.0", "gulp": "^5.0.0", "gulp-sass": "^6.0.0", "nodemon": "^3.1.9", "prettier-config-cityssm": "^1.0.0", - "sass": "^1.85.0" + "sass": "^1.85.1" }, "engines": { "node": ">=18.0.0" @@ -4728,9 +4728,9 @@ "license": "ISC" }, "node_modules/cypress": { - "version": "14.0.3", - "resolved": "https://registry.npmjs.org/cypress/-/cypress-14.0.3.tgz", - "integrity": "sha512-yIdvobANw3kS+KF/t5vwjjPNufBA8ux7iQHaWxPTkUw2yCKI72m9mKM24eOwE84Wk4ALPsSvEcGbDrwgmhr4RA==", + "version": "14.1.0", + "resolved": "https://registry.npmjs.org/cypress/-/cypress-14.1.0.tgz", + "integrity": "sha512-pPPj8Uu9NwjaaiXAEcjYZZmgsq6v9Zs1Nw6a+zRF+ANgYSNhH4S32SjFRsvMcuOHR/8dp4GBJhBPqIPSs+TxaA==", "dev": true, "hasInstallScript": true, "license": "MIT", @@ -4746,7 +4746,7 @@ "cachedir": "^2.3.0", "chalk": "^4.1.0", "check-more-types": "^2.24.0", - "ci-info": "^4.0.0", + "ci-info": "^4.1.0", "cli-cursor": "^3.1.0", "cli-table3": "~0.6.1", "commander": "^6.2.1", @@ -11317,9 +11317,9 @@ "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" }, "node_modules/sass": { - "version": "1.85.0", - "resolved": "https://registry.npmjs.org/sass/-/sass-1.85.0.tgz", - "integrity": "sha512-3ToiC1xZ1Y8aU7+CkgCI/tqyuPXEmYGJXO7H4uqp0xkLXUqp88rQQ4j1HmP37xSJLbCJPaIiv+cT1y+grssrww==", + "version": "1.85.1", + "resolved": "https://registry.npmjs.org/sass/-/sass-1.85.1.tgz", + "integrity": "sha512-Uk8WpxM5v+0cMR0XjX9KfRIacmSG86RH4DCCZjLU2rFh5tyutt9siAXJ7G+YfxQ99Q6wrRMbMlVl6KqUms71ag==", "dev": true, "license": "MIT", "dependencies": { diff --git a/package.json b/package.json index 75e6fb56..635a6e34 100644 --- a/package.json +++ b/package.json @@ -103,13 +103,13 @@ "bulma-steps": "^2.2.1", "bulma-switch": "^2.0.4", "bulma-tooltip": "^3.0.2", - "cypress": "^14.0.3", + "cypress": "^14.1.0", "cypress-axe": "^1.6.0", "eslint-config-cityssm": "^20.0.0", "gulp": "^5.0.0", "gulp-sass": "^6.0.0", "nodemon": "^3.1.9", "prettier-config-cityssm": "^1.0.0", - "sass": "^1.85.0" + "sass": "^1.85.1" } } diff --git a/public/html/adminLotTypes-editLotTypeField.html b/public/html/adminLotTypes-editLotTypeField.html index 563630d1..6bc0c44f 100644 --- a/public/html/adminLotTypes-editLotTypeField.html +++ b/public/html/adminLotTypes-editLotTypeField.html @@ -76,14 +76,14 @@
-
-