parent
dc9a9b2bcc
commit
f6eb3bf550
|
|
@ -6,11 +6,11 @@ export interface AddBurialSiteForm {
|
||||||
burialSiteNameSegment5?: string;
|
burialSiteNameSegment5?: string;
|
||||||
burialSiteStatusId: number | string;
|
burialSiteStatusId: number | string;
|
||||||
burialSiteTypeId: number | string;
|
burialSiteTypeId: number | string;
|
||||||
burialSiteImage: string;
|
burialSiteImage?: string;
|
||||||
cemeteryId: number | string;
|
cemeteryId: number | string;
|
||||||
cemeterySvgId: string;
|
cemeterySvgId?: string;
|
||||||
burialSiteLatitude: string;
|
burialSiteLatitude?: string;
|
||||||
burialSiteLongitude: string;
|
burialSiteLongitude?: string;
|
||||||
burialSiteTypeFieldIds?: string;
|
burialSiteTypeFieldIds?: string;
|
||||||
[fieldValue_burialSiteTypeFieldId: string]: unknown;
|
[fieldValue_burialSiteTypeFieldId: string]: unknown;
|
||||||
}
|
}
|
||||||
|
|
@ -21,4 +21,7 @@ export interface AddBurialSiteForm {
|
||||||
* @returns The new burial site's id.
|
* @returns The new burial site's id.
|
||||||
* @throws If an active burial site with the same name already exists.
|
* @throws If an active burial site with the same name already exists.
|
||||||
*/
|
*/
|
||||||
export default function addBurialSite(burialSiteForm: AddBurialSiteForm, user: User): number;
|
export default function addBurialSite(burialSiteForm: AddBurialSiteForm, user: User): {
|
||||||
|
burialSiteId: number;
|
||||||
|
burialSiteName: string;
|
||||||
|
};
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ export default function addBurialSite(burialSiteForm, user) {
|
||||||
?, ?, ?, ?)`)
|
?, ?, ?, ?)`)
|
||||||
.run(burialSiteForm.burialSiteNameSegment1 ?? '', burialSiteForm.burialSiteNameSegment2 ?? '', burialSiteForm.burialSiteNameSegment3 ?? '', burialSiteForm.burialSiteNameSegment4 ?? '', burialSiteForm.burialSiteNameSegment5 ?? '', burialSiteName, burialSiteForm.burialSiteTypeId, burialSiteForm.burialSiteStatusId === ''
|
.run(burialSiteForm.burialSiteNameSegment1 ?? '', burialSiteForm.burialSiteNameSegment2 ?? '', burialSiteForm.burialSiteNameSegment3 ?? '', burialSiteForm.burialSiteNameSegment4 ?? '', burialSiteForm.burialSiteNameSegment5 ?? '', burialSiteName, burialSiteForm.burialSiteTypeId, burialSiteForm.burialSiteStatusId === ''
|
||||||
? undefined
|
? undefined
|
||||||
: burialSiteForm.burialSiteStatusId, burialSiteForm.cemeteryId === '' ? undefined : burialSiteForm.cemeteryId, burialSiteForm.cemeterySvgId, burialSiteForm.burialSiteImage, burialSiteForm.burialSiteLatitude === ''
|
: burialSiteForm.burialSiteStatusId, burialSiteForm.cemeteryId === '' ? undefined : burialSiteForm.cemeteryId, burialSiteForm.cemeterySvgId, burialSiteForm.burialSiteImage ?? '', burialSiteForm.burialSiteLatitude === ''
|
||||||
? undefined
|
? undefined
|
||||||
: burialSiteForm.burialSiteLatitude, burialSiteForm.burialSiteLongitude === ''
|
: burialSiteForm.burialSiteLatitude, burialSiteForm.burialSiteLongitude === ''
|
||||||
? undefined
|
? undefined
|
||||||
|
|
@ -66,5 +66,8 @@ export default function addBurialSite(burialSiteForm, user) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
database.close();
|
database.close();
|
||||||
return burialSiteId;
|
return {
|
||||||
|
burialSiteId,
|
||||||
|
burialSiteName
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,12 +16,12 @@ export interface AddBurialSiteForm {
|
||||||
burialSiteStatusId: number | string
|
burialSiteStatusId: number | string
|
||||||
burialSiteTypeId: number | string
|
burialSiteTypeId: number | string
|
||||||
|
|
||||||
burialSiteImage: string
|
burialSiteImage?: string
|
||||||
cemeteryId: number | string
|
cemeteryId: number | string
|
||||||
cemeterySvgId: string
|
cemeterySvgId?: string
|
||||||
|
|
||||||
burialSiteLatitude: string
|
burialSiteLatitude?: string
|
||||||
burialSiteLongitude: string
|
burialSiteLongitude?: string
|
||||||
|
|
||||||
burialSiteTypeFieldIds?: string
|
burialSiteTypeFieldIds?: string
|
||||||
|
|
||||||
|
|
@ -38,7 +38,7 @@ export interface AddBurialSiteForm {
|
||||||
export default function addBurialSite(
|
export default function addBurialSite(
|
||||||
burialSiteForm: AddBurialSiteForm,
|
burialSiteForm: AddBurialSiteForm,
|
||||||
user: User
|
user: User
|
||||||
): number {
|
): { burialSiteId: number; burialSiteName: string } {
|
||||||
const database = sqlite(sunriseDB)
|
const database = sqlite(sunriseDB)
|
||||||
|
|
||||||
const rightNowMillis = Date.now()
|
const rightNowMillis = Date.now()
|
||||||
|
|
@ -102,7 +102,7 @@ export default function addBurialSite(
|
||||||
: burialSiteForm.burialSiteStatusId,
|
: burialSiteForm.burialSiteStatusId,
|
||||||
burialSiteForm.cemeteryId === '' ? undefined : burialSiteForm.cemeteryId,
|
burialSiteForm.cemeteryId === '' ? undefined : burialSiteForm.cemeteryId,
|
||||||
burialSiteForm.cemeterySvgId,
|
burialSiteForm.cemeterySvgId,
|
||||||
burialSiteForm.burialSiteImage,
|
burialSiteForm.burialSiteImage ?? '',
|
||||||
burialSiteForm.burialSiteLatitude === ''
|
burialSiteForm.burialSiteLatitude === ''
|
||||||
? undefined
|
? undefined
|
||||||
: burialSiteForm.burialSiteLatitude,
|
: burialSiteForm.burialSiteLatitude,
|
||||||
|
|
@ -141,5 +141,8 @@ export default function addBurialSite(
|
||||||
|
|
||||||
database.close()
|
database.close()
|
||||||
|
|
||||||
return burialSiteId
|
return {
|
||||||
|
burialSiteId,
|
||||||
|
burialSiteName
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,11 @@ import addBurialSite from '../../database/addBurialSite.js';
|
||||||
import { clearNextPreviousBurialSiteIdCache } from '../../helpers/burialSites.helpers.js';
|
import { clearNextPreviousBurialSiteIdCache } from '../../helpers/burialSites.helpers.js';
|
||||||
export default function handler(request, response) {
|
export default function handler(request, response) {
|
||||||
try {
|
try {
|
||||||
const burialSiteId = addBurialSite(request.body, request.session.user);
|
const burialSite = addBurialSite(request.body, request.session.user);
|
||||||
response.json({
|
response.json({
|
||||||
success: true,
|
success: true,
|
||||||
burialSiteId
|
burialSiteId: burialSite.burialSiteId,
|
||||||
|
burialSiteName: burialSite.burialSiteName,
|
||||||
});
|
});
|
||||||
response.on('finish', () => {
|
response.on('finish', () => {
|
||||||
clearNextPreviousBurialSiteIdCache(-1);
|
clearNextPreviousBurialSiteIdCache(-1);
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ export default function handler(
|
||||||
response: Response
|
response: Response
|
||||||
): void {
|
): void {
|
||||||
try {
|
try {
|
||||||
const burialSiteId = addBurialSite(
|
const burialSite = addBurialSite(
|
||||||
request.body,
|
request.body,
|
||||||
request.session.user as User
|
request.session.user as User
|
||||||
)
|
)
|
||||||
|
|
@ -18,7 +18,8 @@ export default function handler(
|
||||||
response.json({
|
response.json({
|
||||||
success: true,
|
success: true,
|
||||||
|
|
||||||
burialSiteId
|
burialSiteId: burialSite.burialSiteId,
|
||||||
|
burialSiteName: burialSite.burialSiteName,
|
||||||
})
|
})
|
||||||
|
|
||||||
response.on('finish', () => {
|
response.on('finish', () => {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
|
import getCemeteries from '../../database/getCemeteries.js';
|
||||||
import getContract from '../../database/getContract.js';
|
import getContract from '../../database/getContract.js';
|
||||||
import getFuneralHomes from '../../database/getFuneralHomes.js';
|
import getFuneralHomes from '../../database/getFuneralHomes.js';
|
||||||
import { getConfigProperty } from '../../helpers/config.helpers.js';
|
import { getConfigProperty } from '../../helpers/config.helpers.js';
|
||||||
import { getCommittalTypes, getContractTypePrintsById, getContractTypes, getIntermentContainerTypes, getWorkOrderTypes } from '../../helpers/functions.cache.js';
|
import { getBurialSiteStatuses, getBurialSiteTypes, getCommittalTypes, getContractTypePrintsById, getContractTypes, getIntermentContainerTypes, getWorkOrderTypes } from '../../helpers/functions.cache.js';
|
||||||
export default async function handler(request, response) {
|
export default async function handler(request, response) {
|
||||||
const contract = await getContract(request.params.contractId);
|
const contract = await getContract(request.params.contractId);
|
||||||
if (contract === undefined) {
|
if (contract === undefined) {
|
||||||
|
|
@ -9,10 +10,22 @@ export default async function handler(request, response) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const contractTypePrints = getContractTypePrintsById(contract.contractTypeId);
|
const contractTypePrints = getContractTypePrintsById(contract.contractTypeId);
|
||||||
|
/*
|
||||||
|
* Contract Drop Lists
|
||||||
|
*/
|
||||||
const contractTypes = getContractTypes();
|
const contractTypes = getContractTypes();
|
||||||
const funeralHomes = getFuneralHomes();
|
const funeralHomes = getFuneralHomes();
|
||||||
const committalTypes = getCommittalTypes();
|
const committalTypes = getCommittalTypes();
|
||||||
const intermentContainerTypes = getIntermentContainerTypes();
|
const intermentContainerTypes = getIntermentContainerTypes();
|
||||||
|
/*
|
||||||
|
* Burial Site Drop Lists
|
||||||
|
*/
|
||||||
|
const burialSiteStatuses = getBurialSiteStatuses();
|
||||||
|
const burialSiteTypes = getBurialSiteTypes();
|
||||||
|
const cemeteries = getCemeteries();
|
||||||
|
/*
|
||||||
|
* Work Order Drop Lists
|
||||||
|
*/
|
||||||
const workOrderTypes = getWorkOrderTypes();
|
const workOrderTypes = getWorkOrderTypes();
|
||||||
response.render('contract-edit', {
|
response.render('contract-edit', {
|
||||||
headTitle: 'Contract Update',
|
headTitle: 'Contract Update',
|
||||||
|
|
@ -22,6 +35,9 @@ export default async function handler(request, response) {
|
||||||
contractTypes,
|
contractTypes,
|
||||||
funeralHomes,
|
funeralHomes,
|
||||||
intermentContainerTypes,
|
intermentContainerTypes,
|
||||||
|
burialSiteStatuses,
|
||||||
|
burialSiteTypes,
|
||||||
|
cemeteries,
|
||||||
workOrderTypes,
|
workOrderTypes,
|
||||||
isCreate: false
|
isCreate: false
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,12 @@
|
||||||
import type { Request, Response } from 'express'
|
import type { Request, Response } from 'express'
|
||||||
|
|
||||||
|
import getCemeteries from '../../database/getCemeteries.js'
|
||||||
import getContract from '../../database/getContract.js'
|
import getContract from '../../database/getContract.js'
|
||||||
import getFuneralHomes from '../../database/getFuneralHomes.js'
|
import getFuneralHomes from '../../database/getFuneralHomes.js'
|
||||||
import { getConfigProperty } from '../../helpers/config.helpers.js'
|
import { getConfigProperty } from '../../helpers/config.helpers.js'
|
||||||
import {
|
import {
|
||||||
|
getBurialSiteStatuses,
|
||||||
|
getBurialSiteTypes,
|
||||||
getCommittalTypes,
|
getCommittalTypes,
|
||||||
getContractTypePrintsById,
|
getContractTypePrintsById,
|
||||||
getContractTypes,
|
getContractTypes,
|
||||||
|
|
@ -28,10 +31,27 @@ export default async function handler(
|
||||||
|
|
||||||
const contractTypePrints = getContractTypePrintsById(contract.contractTypeId)
|
const contractTypePrints = getContractTypePrintsById(contract.contractTypeId)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Contract Drop Lists
|
||||||
|
*/
|
||||||
|
|
||||||
const contractTypes = getContractTypes()
|
const contractTypes = getContractTypes()
|
||||||
const funeralHomes = getFuneralHomes()
|
const funeralHomes = getFuneralHomes()
|
||||||
const committalTypes = getCommittalTypes()
|
const committalTypes = getCommittalTypes()
|
||||||
const intermentContainerTypes = getIntermentContainerTypes()
|
const intermentContainerTypes = getIntermentContainerTypes()
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Burial Site Drop Lists
|
||||||
|
*/
|
||||||
|
|
||||||
|
const burialSiteStatuses = getBurialSiteStatuses()
|
||||||
|
const burialSiteTypes = getBurialSiteTypes()
|
||||||
|
const cemeteries = getCemeteries()
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Work Order Drop Lists
|
||||||
|
*/
|
||||||
|
|
||||||
const workOrderTypes = getWorkOrderTypes()
|
const workOrderTypes = getWorkOrderTypes()
|
||||||
|
|
||||||
response.render('contract-edit', {
|
response.render('contract-edit', {
|
||||||
|
|
@ -44,6 +64,11 @@ export default async function handler(
|
||||||
contractTypes,
|
contractTypes,
|
||||||
funeralHomes,
|
funeralHomes,
|
||||||
intermentContainerTypes,
|
intermentContainerTypes,
|
||||||
|
|
||||||
|
burialSiteStatuses,
|
||||||
|
burialSiteTypes,
|
||||||
|
cemeteries,
|
||||||
|
|
||||||
workOrderTypes,
|
workOrderTypes,
|
||||||
|
|
||||||
isCreate: false
|
isCreate: false
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
import { dateToInteger, dateToString } from '@cityssm/utils-datetime';
|
import { dateToInteger, dateToString } from '@cityssm/utils-datetime';
|
||||||
import getBurialSite from '../../database/getBurialSite.js';
|
import getBurialSite from '../../database/getBurialSite.js';
|
||||||
|
import getCemeteries from '../../database/getCemeteries.js';
|
||||||
import getFuneralHomes from '../../database/getFuneralHomes.js';
|
import getFuneralHomes from '../../database/getFuneralHomes.js';
|
||||||
import { getConfigProperty } from '../../helpers/config.helpers.js';
|
import { getConfigProperty } from '../../helpers/config.helpers.js';
|
||||||
import { getCommittalTypes, getContractTypes, getIntermentContainerTypes } from '../../helpers/functions.cache.js';
|
import { getBurialSiteStatuses, getBurialSiteTypes, getCommittalTypes, getContractTypes, getIntermentContainerTypes } from '../../helpers/functions.cache.js';
|
||||||
export default async function handler(request, response) {
|
export default async function handler(request, response) {
|
||||||
const startDate = new Date();
|
const startDate = new Date();
|
||||||
const contract = {
|
const contract = {
|
||||||
|
|
@ -21,10 +22,19 @@ export default async function handler(request, response) {
|
||||||
contract.cemeteryName = burialSite.cemeteryName;
|
contract.cemeteryName = burialSite.cemeteryName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
* Contract Drop Lists
|
||||||
|
*/
|
||||||
const contractTypes = getContractTypes();
|
const contractTypes = getContractTypes();
|
||||||
const funeralHomes = getFuneralHomes();
|
const funeralHomes = getFuneralHomes();
|
||||||
const committalTypes = getCommittalTypes();
|
const committalTypes = getCommittalTypes();
|
||||||
const intermentContainerTypes = getIntermentContainerTypes();
|
const intermentContainerTypes = getIntermentContainerTypes();
|
||||||
|
/*
|
||||||
|
* Burial Site Drop Lists
|
||||||
|
*/
|
||||||
|
const burialSiteStatuses = getBurialSiteStatuses();
|
||||||
|
const burialSiteTypes = getBurialSiteTypes();
|
||||||
|
const cemeteries = getCemeteries();
|
||||||
response.render('contract-edit', {
|
response.render('contract-edit', {
|
||||||
headTitle: 'Create a New Contract',
|
headTitle: 'Create a New Contract',
|
||||||
contract,
|
contract,
|
||||||
|
|
@ -32,6 +42,9 @@ export default async function handler(request, response) {
|
||||||
contractTypes,
|
contractTypes,
|
||||||
funeralHomes,
|
funeralHomes,
|
||||||
intermentContainerTypes,
|
intermentContainerTypes,
|
||||||
|
burialSiteStatuses,
|
||||||
|
burialSiteTypes,
|
||||||
|
cemeteries,
|
||||||
isCreate: true
|
isCreate: true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,12 @@ import type { Request, Response } from 'express'
|
||||||
import { dateToInteger, dateToString } from '@cityssm/utils-datetime'
|
import { dateToInteger, dateToString } from '@cityssm/utils-datetime'
|
||||||
|
|
||||||
import getBurialSite from '../../database/getBurialSite.js'
|
import getBurialSite from '../../database/getBurialSite.js'
|
||||||
|
import getCemeteries from '../../database/getCemeteries.js'
|
||||||
import getFuneralHomes from '../../database/getFuneralHomes.js'
|
import getFuneralHomes from '../../database/getFuneralHomes.js'
|
||||||
import { getConfigProperty } from '../../helpers/config.helpers.js'
|
import { getConfigProperty } from '../../helpers/config.helpers.js'
|
||||||
import {
|
import {
|
||||||
|
getBurialSiteStatuses,
|
||||||
|
getBurialSiteTypes,
|
||||||
getCommittalTypes,
|
getCommittalTypes,
|
||||||
getContractTypes,
|
getContractTypes,
|
||||||
getIntermentContainerTypes
|
getIntermentContainerTypes
|
||||||
|
|
@ -38,11 +41,23 @@ export default async function handler(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Contract Drop Lists
|
||||||
|
*/
|
||||||
|
|
||||||
const contractTypes = getContractTypes()
|
const contractTypes = getContractTypes()
|
||||||
const funeralHomes = getFuneralHomes()
|
const funeralHomes = getFuneralHomes()
|
||||||
const committalTypes = getCommittalTypes()
|
const committalTypes = getCommittalTypes()
|
||||||
const intermentContainerTypes = getIntermentContainerTypes()
|
const intermentContainerTypes = getIntermentContainerTypes()
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Burial Site Drop Lists
|
||||||
|
*/
|
||||||
|
|
||||||
|
const burialSiteStatuses = getBurialSiteStatuses()
|
||||||
|
const burialSiteTypes = getBurialSiteTypes()
|
||||||
|
const cemeteries = getCemeteries()
|
||||||
|
|
||||||
response.render('contract-edit', {
|
response.render('contract-edit', {
|
||||||
headTitle: 'Create a New Contract',
|
headTitle: 'Create a New Contract',
|
||||||
|
|
||||||
|
|
@ -53,6 +68,10 @@ export default async function handler(
|
||||||
funeralHomes,
|
funeralHomes,
|
||||||
intermentContainerTypes,
|
intermentContainerTypes,
|
||||||
|
|
||||||
|
burialSiteStatuses,
|
||||||
|
burialSiteTypes,
|
||||||
|
cemeteries,
|
||||||
|
|
||||||
isCreate: true
|
isCreate: true
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,18 @@
|
||||||
></button>
|
></button>
|
||||||
</header>
|
</header>
|
||||||
<section class="modal-card-body">
|
<section class="modal-card-body">
|
||||||
|
<div class="tabs is-boxed">
|
||||||
|
<ul>
|
||||||
|
<li class="is-active">
|
||||||
|
<a href="#tab--burialSiteSelect">Select Existing</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<a href="#tab--burialSiteCreate">Create New</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<div class="tab-containers">
|
||||||
|
<div id="tab--burialSiteSelect">
|
||||||
<div class="box">
|
<div class="box">
|
||||||
<form id="form--burialSiteSelect">
|
<form id="form--burialSiteSelect">
|
||||||
<input name="limit" type="hidden" value="100" />
|
<input name="limit" type="hidden" value="100" />
|
||||||
|
|
@ -51,6 +63,62 @@
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<div id="resultsContainer--burialSiteSelect"></div>
|
<div id="resultsContainer--burialSiteSelect"></div>
|
||||||
|
</div>
|
||||||
|
<div id="tab--burialSiteCreate" class="is-hidden">
|
||||||
|
<form id="form--burialSiteCreate">
|
||||||
|
<label class="label" for="burialSiteCreate--burialSiteNameSegment1">
|
||||||
|
New Burial Site Name
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<div class="field">
|
||||||
|
<label class="label" for="burialSiteCreate--cemeteryId">Cemetery</label>
|
||||||
|
<div class="control">
|
||||||
|
<div class="select is-fullwidth">
|
||||||
|
<select id="burialSiteCreate--cemeteryId" name="cemeteryId">
|
||||||
|
<option value="">(No Cemetery Selected)</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="columns">
|
||||||
|
<div class="column">
|
||||||
|
<div class="field">
|
||||||
|
<label class="label" for="burialSiteCreate--burialSiteTypeId">Burial Site Type</label>
|
||||||
|
<div class="control">
|
||||||
|
<div class="select is-fullwidth">
|
||||||
|
<select id="burialSiteCreate--burialSiteTypeId" name="burialSiteTypeId" required>
|
||||||
|
<option value="">(Select a Type)</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="column">
|
||||||
|
<div class="field">
|
||||||
|
<label class="label" for="burialSiteCreate--burialSiteStatusId">Burial Site Status</label>
|
||||||
|
<div class="control">
|
||||||
|
<div class="select is-fullwidth">
|
||||||
|
<select id="burialSiteCreate--burialSiteStatusId" name="burialSiteStatusId">
|
||||||
|
<option value="">(No Status)</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p class="has-text-right">
|
||||||
|
<button class="button is-primary" type="submit">
|
||||||
|
<span class="icon is-small">
|
||||||
|
<i class="fas fa-plus" aria-hidden="true"></i>
|
||||||
|
</span>
|
||||||
|
<span>Create Burial Site and Select</span>
|
||||||
|
</button>
|
||||||
|
</p>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</section>
|
</section>
|
||||||
<footer class="modal-card-foot is-justify-content-right">
|
<footer class="modal-card-foot is-justify-content-right">
|
||||||
<button class="button is-close-modal-button" type="button">Cancel</button>
|
<button class="button is-close-modal-button" type="button">Cancel</button>
|
||||||
|
|
|
||||||
|
|
@ -238,6 +238,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
let burialSiteSelectCloseModalFunction;
|
let burialSiteSelectCloseModalFunction;
|
||||||
let burialSiteSelectFormElement;
|
let burialSiteSelectFormElement;
|
||||||
let burialSiteSelectResultsElement;
|
let burialSiteSelectResultsElement;
|
||||||
|
let burialSiteCreateFormElement;
|
||||||
function renderSelectedBurialSiteAndClose(burialSiteId, burialSiteName) {
|
function renderSelectedBurialSiteAndClose(burialSiteId, burialSiteName) {
|
||||||
;
|
;
|
||||||
document.querySelector('#contract--burialSiteId').value = burialSiteId.toString();
|
document.querySelector('#contract--burialSiteId').value = burialSiteId.toString();
|
||||||
|
|
@ -291,6 +292,23 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
burialSiteSelectResultsElement.append(panelElement);
|
burialSiteSelectResultsElement.append(panelElement);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
function createBurialSite(createEvent) {
|
||||||
|
createEvent.preventDefault();
|
||||||
|
cityssm.postJSON(`${sunrise.urlPrefix}/burialSites/doCreateBurialSite`, burialSiteCreateFormElement, (rawResponseJSON) => {
|
||||||
|
const responseJSON = rawResponseJSON;
|
||||||
|
if (responseJSON.success) {
|
||||||
|
setUnsavedChanges();
|
||||||
|
renderSelectedBurialSiteAndClose(responseJSON.burialSiteId ?? 0, responseJSON.burialSiteName ?? '');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
bulmaJS.alert({
|
||||||
|
title: 'Error Creating Burial Site',
|
||||||
|
message: responseJSON.errorMessage ?? '',
|
||||||
|
contextualColorName: 'danger'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
cityssm.openHtmlModal('contract-selectBurialSite', {
|
cityssm.openHtmlModal('contract-selectBurialSite', {
|
||||||
onshow(modalElement) {
|
onshow(modalElement) {
|
||||||
sunrise.populateAliases(modalElement);
|
sunrise.populateAliases(modalElement);
|
||||||
|
|
@ -317,6 +335,40 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
submitEvent.preventDefault();
|
submitEvent.preventDefault();
|
||||||
});
|
});
|
||||||
searchBurialSites();
|
searchBurialSites();
|
||||||
|
/*
|
||||||
|
* New Burial Site Tab
|
||||||
|
*/
|
||||||
|
const burialSiteNameSegmentsFieldElement = document.querySelector('#template--burialSiteNameSegments > div.field').cloneNode(true);
|
||||||
|
burialSiteNameSegmentsFieldElement
|
||||||
|
.querySelector('input[name="burialSiteNameSegment1"]')
|
||||||
|
?.setAttribute('id', 'burialSiteCreate--burialSiteNameSegment1');
|
||||||
|
modalElement
|
||||||
|
.querySelector('label[for="burialSiteCreate--burialSiteNameSegment1"]')
|
||||||
|
?.insertAdjacentElement('afterend', burialSiteNameSegmentsFieldElement);
|
||||||
|
const cemeterySelectElement = modalElement.querySelector('#burialSiteCreate--cemeteryId');
|
||||||
|
for (const cemetery of exports.cemeteries) {
|
||||||
|
const optionElement = document.createElement('option');
|
||||||
|
optionElement.value = cemetery.cemeteryId?.toString() ?? '';
|
||||||
|
optionElement.textContent =
|
||||||
|
cemetery.cemeteryName === '' ? '(No Name)' : cemetery.cemeteryName;
|
||||||
|
cemeterySelectElement.append(optionElement);
|
||||||
|
}
|
||||||
|
const burialSiteTypeSelectElement = modalElement.querySelector('#burialSiteCreate--burialSiteTypeId');
|
||||||
|
for (const burialSiteType of exports.burialSiteTypes) {
|
||||||
|
const optionElement = document.createElement('option');
|
||||||
|
optionElement.value = burialSiteType.burialSiteTypeId.toString();
|
||||||
|
optionElement.textContent = burialSiteType.burialSiteType;
|
||||||
|
burialSiteTypeSelectElement.append(optionElement);
|
||||||
|
}
|
||||||
|
const burialSiteStatusSelectElement = modalElement.querySelector('#burialSiteCreate--burialSiteStatusId');
|
||||||
|
for (const burialSiteStatus of exports.burialSiteStatuses) {
|
||||||
|
const optionElement = document.createElement('option');
|
||||||
|
optionElement.value = burialSiteStatus.burialSiteStatusId.toString();
|
||||||
|
optionElement.textContent = burialSiteStatus.burialSiteStatus;
|
||||||
|
burialSiteStatusSelectElement.append(optionElement);
|
||||||
|
}
|
||||||
|
burialSiteCreateFormElement = modalElement.querySelector('#form--burialSiteCreate');
|
||||||
|
burialSiteCreateFormElement.addEventListener('submit', createBurialSite);
|
||||||
},
|
},
|
||||||
onremoved() {
|
onremoved() {
|
||||||
bulmaJS.toggleHtmlClipped();
|
bulmaJS.toggleHtmlClipped();
|
||||||
|
|
|
||||||
|
|
@ -4,15 +4,27 @@
|
||||||
import type { BulmaJS } from '@cityssm/bulma-js/types.js'
|
import type { BulmaJS } from '@cityssm/bulma-js/types.js'
|
||||||
import type { cityssmGlobal } from '@cityssm/bulma-webapp-js/src/types.js'
|
import type { cityssmGlobal } from '@cityssm/bulma-webapp-js/src/types.js'
|
||||||
|
|
||||||
import type { BurialSite, ContractTypeField } from '../../types/record.types.js'
|
import type {
|
||||||
|
BurialSite,
|
||||||
|
BurialSiteStatus,
|
||||||
|
BurialSiteType,
|
||||||
|
Cemetery,
|
||||||
|
ContractTypeField
|
||||||
|
} from '../../types/record.types.js'
|
||||||
|
|
||||||
import type { Sunrise } from './types.js'
|
import type { Sunrise } from './types.js'
|
||||||
|
|
||||||
declare const cityssm: cityssmGlobal
|
declare const cityssm: cityssmGlobal
|
||||||
declare const bulmaJS: BulmaJS
|
declare const bulmaJS: BulmaJS
|
||||||
declare const exports: Record<string, unknown>
|
declare const exports: {
|
||||||
|
sunrise: Sunrise
|
||||||
|
|
||||||
|
burialSiteStatuses: BurialSiteStatus[]
|
||||||
|
burialSiteTypes: BurialSiteType[]
|
||||||
|
cemeteries: Cemetery[]
|
||||||
|
}
|
||||||
;(() => {
|
;(() => {
|
||||||
const sunrise = exports.sunrise as Sunrise
|
const sunrise = exports.sunrise
|
||||||
|
|
||||||
const contractId = (
|
const contractId = (
|
||||||
document.querySelector('#contract--contractId') as HTMLInputElement
|
document.querySelector('#contract--contractId') as HTMLInputElement
|
||||||
|
|
@ -363,6 +375,8 @@ declare const exports: Record<string, unknown>
|
||||||
let burialSiteSelectFormElement: HTMLFormElement
|
let burialSiteSelectFormElement: HTMLFormElement
|
||||||
let burialSiteSelectResultsElement: HTMLElement
|
let burialSiteSelectResultsElement: HTMLElement
|
||||||
|
|
||||||
|
let burialSiteCreateFormElement: HTMLFormElement
|
||||||
|
|
||||||
function renderSelectedBurialSiteAndClose(
|
function renderSelectedBurialSiteAndClose(
|
||||||
burialSiteId: number | string,
|
burialSiteId: number | string,
|
||||||
burialSiteName: string
|
burialSiteName: string
|
||||||
|
|
@ -452,6 +466,39 @@ declare const exports: Record<string, unknown>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function createBurialSite(createEvent: Event): void {
|
||||||
|
createEvent.preventDefault()
|
||||||
|
|
||||||
|
cityssm.postJSON(
|
||||||
|
`${sunrise.urlPrefix}/burialSites/doCreateBurialSite`,
|
||||||
|
burialSiteCreateFormElement,
|
||||||
|
(rawResponseJSON) => {
|
||||||
|
const responseJSON = rawResponseJSON as {
|
||||||
|
success: boolean
|
||||||
|
errorMessage?: string
|
||||||
|
|
||||||
|
burialSiteId?: number
|
||||||
|
burialSiteName?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
if (responseJSON.success) {
|
||||||
|
setUnsavedChanges()
|
||||||
|
|
||||||
|
renderSelectedBurialSiteAndClose(
|
||||||
|
responseJSON.burialSiteId ?? 0,
|
||||||
|
responseJSON.burialSiteName ?? ''
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
bulmaJS.alert({
|
||||||
|
title: 'Error Creating Burial Site',
|
||||||
|
message: responseJSON.errorMessage ?? '',
|
||||||
|
contextualColorName: 'danger'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
cityssm.openHtmlModal('contract-selectBurialSite', {
|
cityssm.openHtmlModal('contract-selectBurialSite', {
|
||||||
onshow(modalElement) {
|
onshow(modalElement) {
|
||||||
sunrise.populateAliases(modalElement)
|
sunrise.populateAliases(modalElement)
|
||||||
|
|
@ -512,7 +559,71 @@ declare const exports: Record<string, unknown>
|
||||||
)
|
)
|
||||||
|
|
||||||
searchBurialSites()
|
searchBurialSites()
|
||||||
|
|
||||||
|
/*
|
||||||
|
* New Burial Site Tab
|
||||||
|
*/
|
||||||
|
|
||||||
|
const burialSiteNameSegmentsFieldElement = (
|
||||||
|
document.querySelector(
|
||||||
|
'#template--burialSiteNameSegments > div.field'
|
||||||
|
) as HTMLElement
|
||||||
|
).cloneNode(true) as HTMLElement
|
||||||
|
|
||||||
|
burialSiteNameSegmentsFieldElement
|
||||||
|
.querySelector('input[name="burialSiteNameSegment1"]')
|
||||||
|
?.setAttribute('id', 'burialSiteCreate--burialSiteNameSegment1')
|
||||||
|
|
||||||
|
modalElement
|
||||||
|
.querySelector(
|
||||||
|
'label[for="burialSiteCreate--burialSiteNameSegment1"]'
|
||||||
|
)
|
||||||
|
?.insertAdjacentElement(
|
||||||
|
'afterend',
|
||||||
|
burialSiteNameSegmentsFieldElement
|
||||||
|
)
|
||||||
|
|
||||||
|
const cemeterySelectElement = modalElement.querySelector(
|
||||||
|
'#burialSiteCreate--cemeteryId'
|
||||||
|
) as HTMLSelectElement
|
||||||
|
|
||||||
|
for (const cemetery of exports.cemeteries) {
|
||||||
|
const optionElement = document.createElement('option')
|
||||||
|
optionElement.value = cemetery.cemeteryId?.toString() ?? ''
|
||||||
|
optionElement.textContent =
|
||||||
|
cemetery.cemeteryName === '' ? '(No Name)' : cemetery.cemeteryName
|
||||||
|
cemeterySelectElement.append(optionElement)
|
||||||
|
}
|
||||||
|
|
||||||
|
const burialSiteTypeSelectElement = modalElement.querySelector(
|
||||||
|
'#burialSiteCreate--burialSiteTypeId'
|
||||||
|
) as HTMLSelectElement
|
||||||
|
|
||||||
|
for (const burialSiteType of exports.burialSiteTypes) {
|
||||||
|
const optionElement = document.createElement('option')
|
||||||
|
optionElement.value = burialSiteType.burialSiteTypeId.toString()
|
||||||
|
optionElement.textContent = burialSiteType.burialSiteType
|
||||||
|
burialSiteTypeSelectElement.append(optionElement)
|
||||||
|
}
|
||||||
|
|
||||||
|
const burialSiteStatusSelectElement = modalElement.querySelector(
|
||||||
|
'#burialSiteCreate--burialSiteStatusId'
|
||||||
|
) as HTMLSelectElement
|
||||||
|
|
||||||
|
for (const burialSiteStatus of exports.burialSiteStatuses) {
|
||||||
|
const optionElement = document.createElement('option')
|
||||||
|
optionElement.value = burialSiteStatus.burialSiteStatusId.toString()
|
||||||
|
optionElement.textContent = burialSiteStatus.burialSiteStatus
|
||||||
|
burialSiteStatusSelectElement.append(optionElement)
|
||||||
|
}
|
||||||
|
|
||||||
|
burialSiteCreateFormElement = modalElement.querySelector(
|
||||||
|
'#form--burialSiteCreate'
|
||||||
|
) as HTMLFormElement
|
||||||
|
|
||||||
|
burialSiteCreateFormElement.addEventListener('submit', createBurialSite)
|
||||||
},
|
},
|
||||||
|
|
||||||
onremoved() {
|
onremoved() {
|
||||||
bulmaJS.toggleHtmlClipped()
|
bulmaJS.toggleHtmlClipped()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -195,7 +195,7 @@
|
||||||
<% } %>
|
<% } %>
|
||||||
id="burialSite--burialSiteTypeId" name="burialSiteTypeId" required>
|
id="burialSite--burialSiteTypeId" name="burialSiteTypeId" required>
|
||||||
<% if (isCreate) { %>
|
<% if (isCreate) { %>
|
||||||
<option value="">(No Type)</option>
|
<option value="">(Select a Type)</option>
|
||||||
<% } %>
|
<% } %>
|
||||||
<% let typeIsFound = false; %>
|
<% let typeIsFound = false; %>
|
||||||
<% for (const burialSiteType of burialSiteTypes) { %>
|
<% for (const burialSiteType of burialSiteTypes) { %>
|
||||||
|
|
|
||||||
|
|
@ -921,6 +921,55 @@
|
||||||
<option value="<%= configFunctions.getConfigProperty('settings.cityDefault') %>">
|
<option value="<%= configFunctions.getConfigProperty('settings.cityDefault') %>">
|
||||||
</datalist>
|
</datalist>
|
||||||
|
|
||||||
|
<%
|
||||||
|
const burialSiteNameSegments = configFunctions.getConfigProperty('settings.burialSites.burialSiteNameSegments')
|
||||||
|
%>
|
||||||
|
<div class="is-hidden" id="template--burialSiteNameSegments">
|
||||||
|
<div class="field has-addons">
|
||||||
|
<% for (let segmentIndex = 1; segmentIndex <= 5; segmentIndex += 1) { %>
|
||||||
|
<%
|
||||||
|
const segmentIndexString = segmentIndex.toString();
|
||||||
|
const segment = burialSiteNameSegments.segments[segmentIndexString];
|
||||||
|
%>
|
||||||
|
<% if (segment?.isAvailable ?? false) { %>
|
||||||
|
<% if (segmentIndex !== 1 && (burialSiteNameSegments.separator ?? '') !== '') { %>
|
||||||
|
<p class="control">
|
||||||
|
<span class="button is-static">
|
||||||
|
<%= burialSiteNameSegments.separator %>
|
||||||
|
</span>
|
||||||
|
</p>
|
||||||
|
<% } %>
|
||||||
|
<% if ((segment.prefix ?? '') !== '') { %>
|
||||||
|
<p class="control">
|
||||||
|
<span class="button is-static">
|
||||||
|
<%= segment.prefix %>
|
||||||
|
</span>
|
||||||
|
</p>
|
||||||
|
<% } %>
|
||||||
|
<div class="control"
|
||||||
|
data-tooltip="<%= segment.label ?? '' %>">
|
||||||
|
|
||||||
|
<input class="input"
|
||||||
|
name="burialSiteNameSegment<%= segmentIndexString %>"
|
||||||
|
type="text"
|
||||||
|
minlength="<%= Math.max(Math.min(segment.minLength ?? 1, 20), 1) %>"
|
||||||
|
maxlength="<%= Math.max(Math.min(segment.maxLength ?? 20, 20), 1) %>"
|
||||||
|
placeholder="<%= segment.label ?? '' %>"
|
||||||
|
aria-label="<%= segment.label ?? '' %>"
|
||||||
|
<%= (segment.isRequired ?? false) ? ' required' : '' %> />
|
||||||
|
</div>
|
||||||
|
<% if ((segment.suffix ?? '') !== '') { %>
|
||||||
|
<p class="control">
|
||||||
|
<span class="button is-static">
|
||||||
|
<%= segment.suffix %>
|
||||||
|
</span>
|
||||||
|
</p>
|
||||||
|
<% } %>
|
||||||
|
<% } %>
|
||||||
|
<% } %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<%- include('_footerA'); -%>
|
<%- include('_footerA'); -%>
|
||||||
|
|
||||||
<% if (!isCreate) { %>
|
<% if (!isCreate) { %>
|
||||||
|
|
@ -939,6 +988,12 @@
|
||||||
</script>
|
</script>
|
||||||
<% } %>
|
<% } %>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
exports.burialSiteStatuses = <%- JSON.stringify(burialSiteStatuses) %>;
|
||||||
|
exports.burialSiteTypes = <%- JSON.stringify(burialSiteTypes) %>;
|
||||||
|
exports.cemeteries = <%- JSON.stringify(cemeteries) %>;
|
||||||
|
</script>
|
||||||
|
|
||||||
<script src="<%= urlPrefix %>/javascripts/contract.edit.js"></script>
|
<script src="<%= urlPrefix %>/javascripts/contract.edit.js"></script>
|
||||||
<% if (!isCreate) { %>
|
<% if (!isCreate) { %>
|
||||||
<script src="<%= urlPrefix %>/javascripts/contract.editInterments.js"></script>
|
<script src="<%= urlPrefix %>/javascripts/contract.editInterments.js"></script>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue