restore deleted burial sites

pull/11/head
Dan Gowans 2025-05-01 10:38:13 -04:00
parent 9048235ef2
commit 7371be711a
27 changed files with 344 additions and 116 deletions

View File

@ -30,23 +30,6 @@ export function deleteBurialSite(burialSiteId, user) {
where burialSiteId = ? where burialSiteId = ?
and recordDelete_timeMillis is null`) and recordDelete_timeMillis is null`)
.run(user.userName, rightNowMillis, burialSiteId); .run(user.userName, rightNowMillis, burialSiteId);
/*
* Delete fields and comments
*/
database
.prepare(`update BurialSiteFields
set recordDelete_userName = ?,
recordDelete_timeMillis = ?
where burialSiteId = ?
and recordDelete_timeMillis is null`)
.run(user.userName, rightNowMillis, burialSiteId);
database
.prepare(`update BurialSiteComments
set recordDelete_userName = ?,
recordDelete_timeMillis = ?
where burialSiteId = ?
and recordDelete_timeMillis is null`)
.run(user.userName, rightNowMillis, burialSiteId);
database.close(); database.close();
return true; return true;
} }

View File

@ -44,30 +44,6 @@ export function deleteBurialSite(burialSiteId: number, user: User): boolean {
) )
.run(user.userName, rightNowMillis, burialSiteId) .run(user.userName, rightNowMillis, burialSiteId)
/*
* Delete fields and comments
*/
database
.prepare(
`update BurialSiteFields
set recordDelete_userName = ?,
recordDelete_timeMillis = ?
where burialSiteId = ?
and recordDelete_timeMillis is null`
)
.run(user.userName, rightNowMillis, burialSiteId)
database
.prepare(
`update BurialSiteComments
set recordDelete_userName = ?,
recordDelete_timeMillis = ?
where burialSiteId = ?
and recordDelete_timeMillis is null`
)
.run(user.userName, rightNowMillis, burialSiteId)
database.close() database.close()
return true return true

View File

@ -1,3 +1,3 @@
import type { BurialSite } from '../types/record.types.js'; import type { BurialSite } from '../types/record.types.js';
export default function getBurialSite(burialSiteId: number | string): Promise<BurialSite | undefined>; export default function getBurialSite(burialSiteId: number | string, includeDeleted?: boolean): Promise<BurialSite | undefined>;
export declare function getBurialSiteByBurialSiteName(burialSiteName: string): Promise<BurialSite | undefined>; export declare function getBurialSiteByBurialSiteName(burialSiteName: string, includeDeleted?: boolean): Promise<BurialSite | undefined>;

View File

@ -19,22 +19,25 @@ const baseSQL = `select l.burialSiteId,
l.cemeteryId, m.cemeteryName, l.cemeteryId, m.cemeteryName,
m.cemeteryLatitude, m.cemeteryLongitude, m.cemeteryLatitude, m.cemeteryLongitude,
m.cemeterySvg, l.cemeterySvgId, l.burialSiteImage, m.cemeterySvg, l.cemeterySvgId, l.burialSiteImage,
l.burialSiteLatitude, l.burialSiteLongitude l.burialSiteLatitude, l.burialSiteLongitude,
l.recordDelete_userName, l.recordDelete_timeMillis
from BurialSites l from BurialSites l
left join BurialSiteTypes t on l.burialSiteTypeId = t.burialSiteTypeId left join BurialSiteTypes t on l.burialSiteTypeId = t.burialSiteTypeId
left join BurialSiteStatuses s on l.burialSiteStatusId = s.burialSiteStatusId left join BurialSiteStatuses s on l.burialSiteStatusId = s.burialSiteStatusId
left join Cemeteries m on l.cemeteryId = m.cemeteryId left join Cemeteries m on l.cemeteryId = m.cemeteryId`;
where l.recordDelete_timeMillis is null`; export default async function getBurialSite(burialSiteId, includeDeleted = false) {
export default async function getBurialSite(burialSiteId) { return await _getBurialSite(`l.burialSiteId = ?`, burialSiteId, includeDeleted);
return await _getBurialSite(`${baseSQL} and l.burialSiteId = ?`, burialSiteId);
} }
export async function getBurialSiteByBurialSiteName(burialSiteName) { export async function getBurialSiteByBurialSiteName(burialSiteName, includeDeleted = false) {
return await _getBurialSite(`${baseSQL} and l.burialSiteName = ?`, burialSiteName); return await _getBurialSite(`l.burialSiteName = ?`, burialSiteName, includeDeleted);
} }
async function _getBurialSite(sql, burialSiteIdOrLotName) { async function _getBurialSite(whereClausePiece, burialSiteIdOrLotName, includeDeleted = false) {
const database = sqlite(sunriseDB, { readonly: true }); const database = sqlite(sunriseDB, { readonly: true });
const burialSite = database.prepare(sql).get(burialSiteIdOrLotName); const burialSite = database
.prepare(`${baseSQL} ${includeDeleted ? 'where' : 'where l.recordDelete_timeMillis is null and'} ${whereClausePiece}`)
.get(burialSiteIdOrLotName);
if (burialSite !== undefined) { if (burialSite !== undefined) {
const contracts = await getContracts({ const contracts = await getContracts({
burialSiteId: burialSite.burialSiteId burialSiteId: burialSite.burialSiteId

View File

@ -23,38 +23,49 @@ const baseSQL = `select l.burialSiteId,
l.cemeteryId, m.cemeteryName, l.cemeteryId, m.cemeteryName,
m.cemeteryLatitude, m.cemeteryLongitude, m.cemeteryLatitude, m.cemeteryLongitude,
m.cemeterySvg, l.cemeterySvgId, l.burialSiteImage, m.cemeterySvg, l.cemeterySvgId, l.burialSiteImage,
l.burialSiteLatitude, l.burialSiteLongitude l.burialSiteLatitude, l.burialSiteLongitude,
l.recordDelete_userName, l.recordDelete_timeMillis
from BurialSites l from BurialSites l
left join BurialSiteTypes t on l.burialSiteTypeId = t.burialSiteTypeId left join BurialSiteTypes t on l.burialSiteTypeId = t.burialSiteTypeId
left join BurialSiteStatuses s on l.burialSiteStatusId = s.burialSiteStatusId left join BurialSiteStatuses s on l.burialSiteStatusId = s.burialSiteStatusId
left join Cemeteries m on l.cemeteryId = m.cemeteryId left join Cemeteries m on l.cemeteryId = m.cemeteryId`
where l.recordDelete_timeMillis is null`
export default async function getBurialSite( export default async function getBurialSite(
burialSiteId: number | string burialSiteId: number | string,
includeDeleted = false
): Promise<BurialSite | undefined> { ): Promise<BurialSite | undefined> {
return await _getBurialSite(`${baseSQL} and l.burialSiteId = ?`, burialSiteId) return await _getBurialSite(
`l.burialSiteId = ?`,
burialSiteId,
includeDeleted
)
} }
export async function getBurialSiteByBurialSiteName( export async function getBurialSiteByBurialSiteName(
burialSiteName: string burialSiteName: string,
includeDeleted = false
): Promise<BurialSite | undefined> { ): Promise<BurialSite | undefined> {
return await _getBurialSite( return await _getBurialSite(
`${baseSQL} and l.burialSiteName = ?`, `l.burialSiteName = ?`,
burialSiteName burialSiteName,
includeDeleted
) )
} }
async function _getBurialSite( async function _getBurialSite(
sql: string, whereClausePiece: string,
burialSiteIdOrLotName: number | string burialSiteIdOrLotName: number | string,
includeDeleted = false
): Promise<BurialSite | undefined> { ): Promise<BurialSite | undefined> {
const database = sqlite(sunriseDB, { readonly: true }) const database = sqlite(sunriseDB, { readonly: true })
const burialSite = database.prepare(sql).get(burialSiteIdOrLotName) as const burialSite = database
| BurialSite .prepare(
| undefined `${baseSQL} ${includeDeleted ? 'where' : 'where l.recordDelete_timeMillis is null and'} ${whereClausePiece}`
)
.get(burialSiteIdOrLotName) as BurialSite | undefined
if (burialSite !== undefined) { if (burialSite !== undefined) {
const contracts = await getContracts( const contracts = await getContracts(

View File

@ -16,6 +16,7 @@ export default async function getContract(contractId, connectedDatabase) {
.prepare(`select o.contractId, .prepare(`select o.contractId,
o.contractTypeId, t.contractType, t.isPreneed, o.contractTypeId, t.contractType, t.isPreneed,
o.burialSiteId, l.burialSiteName, l.burialSiteTypeId, o.burialSiteId, l.burialSiteName, l.burialSiteTypeId,
case when l.recordDelete_timeMillis is null then 1 else 0 end as burialSiteIsActive,
l.cemeteryId, m.cemeteryName, l.cemeteryId, m.cemeteryName,
o.contractStartDate, userFn_dateIntegerToString(o.contractStartDate) as contractStartDateString, o.contractStartDate, userFn_dateIntegerToString(o.contractStartDate) as contractStartDateString,
o.contractEndDate, userFn_dateIntegerToString(o.contractEndDate) as contractEndDateString, o.contractEndDate, userFn_dateIntegerToString(o.contractEndDate) as contractEndDateString,

View File

@ -33,6 +33,7 @@ export default async function getContract(
`select o.contractId, `select o.contractId,
o.contractTypeId, t.contractType, t.isPreneed, o.contractTypeId, t.contractType, t.isPreneed,
o.burialSiteId, l.burialSiteName, l.burialSiteTypeId, o.burialSiteId, l.burialSiteName, l.burialSiteTypeId,
case when l.recordDelete_timeMillis is null then 1 else 0 end as burialSiteIsActive,
l.cemeteryId, m.cemeteryName, l.cemeteryId, m.cemeteryName,
o.contractStartDate, userFn_dateIntegerToString(o.contractStartDate) as contractStartDateString, o.contractStartDate, userFn_dateIntegerToString(o.contractStartDate) as contractStartDateString,
o.contractEndDate, userFn_dateIntegerToString(o.contractEndDate) as contractEndDateString, o.contractEndDate, userFn_dateIntegerToString(o.contractEndDate) as contractEndDateString,

View File

@ -32,6 +32,7 @@ export default async function getContracts(filters, options, connectedDatabase)
.prepare(`select o.contractId, .prepare(`select o.contractId,
o.contractTypeId, t.contractType, t.isPreneed, o.contractTypeId, t.contractType, t.isPreneed,
o.burialSiteId, lt.burialSiteType, l.burialSiteName, o.burialSiteId, lt.burialSiteType, l.burialSiteName,
case when l.recordDelete_timeMillis is null then 1 else 0 end as burialSiteIsActive,
l.cemeteryId, m.cemeteryName, l.cemeteryId, m.cemeteryName,
o.contractStartDate, userFn_dateIntegerToString(o.contractStartDate) as contractStartDateString, o.contractStartDate, userFn_dateIntegerToString(o.contractStartDate) as contractStartDateString,
o.contractEndDate, userFn_dateIntegerToString(o.contractEndDate) as contractEndDateString, o.contractEndDate, userFn_dateIntegerToString(o.contractEndDate) as contractEndDateString,

View File

@ -95,6 +95,7 @@ export default async function getContracts(
`select o.contractId, `select o.contractId,
o.contractTypeId, t.contractType, t.isPreneed, o.contractTypeId, t.contractType, t.isPreneed,
o.burialSiteId, lt.burialSiteType, l.burialSiteName, o.burialSiteId, lt.burialSiteType, l.burialSiteName,
case when l.recordDelete_timeMillis is null then 1 else 0 end as burialSiteIsActive,
l.cemeteryId, m.cemeteryName, l.cemeteryId, m.cemeteryName,
o.contractStartDate, userFn_dateIntegerToString(o.contractStartDate) as contractStartDateString, o.contractStartDate, userFn_dateIntegerToString(o.contractStartDate) as contractStartDateString,
o.contractEndDate, userFn_dateIntegerToString(o.contractEndDate) as contractEndDateString, o.contractEndDate, userFn_dateIntegerToString(o.contractEndDate) as contractEndDateString,

View File

@ -0,0 +1 @@
export declare function restoreBurialSite(burialSiteId: number, user: User): boolean;

View File

@ -0,0 +1,17 @@
import sqlite from 'better-sqlite3';
import { sunriseDB } from '../helpers/database.helpers.js';
export function restoreBurialSite(burialSiteId, user) {
const database = sqlite(sunriseDB);
const rightNowMillis = Date.now();
const result = database
.prepare(`update BurialSites
set recordDelete_userName = null,
recordDelete_timeMillis = null,
recordUpdate_userName = ?,
recordUpdate_timeMillis = ?
where burialSiteId = ?
and recordDelete_timeMillis is not null`)
.run(user.userName, rightNowMillis, burialSiteId);
database.close();
return result.changes > 0;
}

View File

@ -0,0 +1,25 @@
import sqlite from 'better-sqlite3'
import { sunriseDB } from '../helpers/database.helpers.js'
export function restoreBurialSite(burialSiteId: number, user: User): boolean {
const database = sqlite(sunriseDB)
const rightNowMillis = Date.now()
const result = database
.prepare(
`update BurialSites
set recordDelete_userName = null,
recordDelete_timeMillis = null,
recordUpdate_userName = ?,
recordUpdate_timeMillis = ?
where burialSiteId = ?
and recordDelete_timeMillis is not null`
)
.run(user.userName, rightNowMillis, burialSiteId)
database.close()
return result.changes > 0
}

View File

@ -2,17 +2,20 @@ import getBurialSite from '../../database/getBurialSite.js';
import { getNextBurialSiteId, getPreviousBurialSiteId } from '../../helpers/burialSites.helpers.js'; import { getNextBurialSiteId, getPreviousBurialSiteId } from '../../helpers/burialSites.helpers.js';
import { getConfigProperty } from '../../helpers/config.helpers.js'; import { getConfigProperty } from '../../helpers/config.helpers.js';
export default async function handler(request, response) { export default async function handler(request, response) {
const burialSite = await getBurialSite(request.params.burialSiteId); const burialSite = await getBurialSite(request.params.burialSiteId, request.session.user?.userProperties?.canUpdate);
if (burialSite === undefined) { if (burialSite === undefined) {
response.redirect(`${getConfigProperty('reverseProxy.urlPrefix')}/burialSites/?error=burialSiteIdNotFound`); response.redirect(`${getConfigProperty('reverseProxy.urlPrefix')}/burialSites/?error=burialSiteIdNotFound`);
return; return;
} }
const burialSiteIsDeleted = burialSite.recordDelete_timeMillis !== null;
response.render('burialSite-view', { response.render('burialSite-view', {
headTitle: burialSite.burialSiteName, headTitle: burialSite.burialSiteName,
burialSite burialSite
}); });
if (!burialSiteIsDeleted) {
response.on('finish', () => { response.on('finish', () => {
getNextBurialSiteId(burialSite.burialSiteId); getNextBurialSiteId(burialSite.burialSiteId);
getPreviousBurialSiteId(burialSite.burialSiteId); getPreviousBurialSiteId(burialSite.burialSiteId);
}); });
} }
}

View File

@ -11,7 +11,10 @@ export default async function handler(
request: Request, request: Request,
response: Response response: Response
): Promise<void> { ): Promise<void> {
const burialSite = await getBurialSite(request.params.burialSiteId) const burialSite = await getBurialSite(
request.params.burialSiteId,
request.session.user?.userProperties?.canUpdate
)
if (burialSite === undefined) { if (burialSite === undefined) {
response.redirect( response.redirect(
@ -20,14 +23,18 @@ export default async function handler(
return return
} }
const burialSiteIsDeleted = burialSite.recordDelete_timeMillis !== null
response.render('burialSite-view', { response.render('burialSite-view', {
headTitle: burialSite.burialSiteName, headTitle: burialSite.burialSiteName,
burialSite burialSite
}) })
if (!burialSiteIsDeleted) {
response.on('finish', () => { response.on('finish', () => {
getNextBurialSiteId(burialSite.burialSiteId) getNextBurialSiteId(burialSite.burialSiteId)
getPreviousBurialSiteId(burialSite.burialSiteId) getPreviousBurialSiteId(burialSite.burialSiteId)
}) })
} }
}

View File

@ -0,0 +1,4 @@
import type { Request, Response } from 'express';
export default function handler(request: Request<unknown, unknown, {
burialSiteId: number;
}>, response: Response): void;

View File

@ -0,0 +1,17 @@
import { restoreBurialSite } from '../../database/restoreBurialSite.js';
import { clearNextPreviousBurialSiteIdCache } from '../../helpers/burialSites.helpers.js';
export default function handler(request, response) {
const success = restoreBurialSite(request.body.burialSiteId, request.session.user);
const burialSiteId = typeof request.body.burialSiteId === 'string'
? Number.parseInt(request.body.burialSiteId, 10)
: request.body.burialSiteId;
response.json({
success,
burialSiteId
});
if (success) {
response.on('finish', () => {
clearNextPreviousBurialSiteIdCache();
});
}
}

View File

@ -0,0 +1,31 @@
import type { Request, Response } from 'express'
import { restoreBurialSite } from '../../database/restoreBurialSite.js'
import { clearNextPreviousBurialSiteIdCache } from '../../helpers/burialSites.helpers.js'
export default function handler(
request: Request<unknown, unknown, { burialSiteId: number }>,
response: Response
): void {
const success = restoreBurialSite(
request.body.burialSiteId,
request.session.user as User
)
const burialSiteId =
typeof request.body.burialSiteId === 'string'
? Number.parseInt(request.body.burialSiteId, 10)
: request.body.burialSiteId
response.json({
success,
burialSiteId
})
if (success) {
response.on('finish', () => {
clearNextPreviousBurialSiteIdCache()
})
}
}

View File

@ -39,4 +39,41 @@ Object.defineProperty(exports, "__esModule", { value: true });
tableRowElement.classList.toggle('is-hidden'); tableRowElement.classList.toggle('is-hidden');
} }
}); });
/*
* Restore Deleted
*/
document
.querySelector('button.is-restore-burial-site-button')
?.addEventListener('click', (clickEvent) => {
clickEvent.preventDefault();
const buttonElement = clickEvent.currentTarget;
const burialSiteId = buttonElement.dataset.burialSiteId ?? '';
if (burialSiteId === '') {
return;
}
function doRestore() {
cityssm.postJSON(`${sunrise.urlPrefix}/burialSites/doRestoreBurialSite`, { burialSiteId }, (rawResponseJSON) => {
const responseJSON = rawResponseJSON;
if (responseJSON.success) {
globalThis.location.reload();
}
else {
bulmaJS.alert({
title: 'Error Restoring Burial Site',
message: responseJSON.errorMessage ?? '',
contextualColorName: 'danger'
});
}
});
}
bulmaJS.confirm({
contextualColorName: 'warning',
title: 'Restore Burial Site',
message: 'Are you sure you want to restore this burial site? It will be visible again.',
okButton: {
text: 'Yes, Restore Burial Site',
callbackFunction: doRestore
}
});
});
})(); })();

View File

@ -1,7 +1,12 @@
import type { BulmaJS } from '@cityssm/bulma-js/types.js'
import type { cityssmGlobal } from '@cityssm/bulma-webapp-js/src/types.js'
import type * as Leaflet from 'leaflet' import type * as Leaflet from 'leaflet'
import type { Sunrise } from './types.js' import type { Sunrise } from './types.js'
declare const cityssm: cityssmGlobal
declare const bulmaJS: BulmaJS
declare const L: typeof Leaflet declare const L: typeof Leaflet
declare const exports: { declare const exports: {
sunrise: Sunrise sunrise: Sunrise
@ -72,4 +77,58 @@ declare const exports: {
tableRowElement.classList.toggle('is-hidden') tableRowElement.classList.toggle('is-hidden')
} }
}) })
/*
* Restore Deleted
*/
document
.querySelector('button.is-restore-burial-site-button')
?.addEventListener('click', (clickEvent) => {
clickEvent.preventDefault()
const buttonElement = clickEvent.currentTarget as HTMLButtonElement
const burialSiteId = buttonElement.dataset.burialSiteId ?? ''
if (burialSiteId === '') {
return
}
function doRestore(): void {
cityssm.postJSON(
`${sunrise.urlPrefix}/burialSites/doRestoreBurialSite`,
{ burialSiteId },
(rawResponseJSON) => {
const responseJSON = rawResponseJSON as {
success: boolean
errorMessage?: string
}
if (responseJSON.success) {
globalThis.location.reload()
} else {
bulmaJS.alert({
title: 'Error Restoring Burial Site',
message: responseJSON.errorMessage ?? '',
contextualColorName: 'danger'
})
}
}
)
}
bulmaJS.confirm({
contextualColorName: 'warning',
title: 'Restore Burial Site',
message:
'Are you sure you want to restore this burial site? It will be visible again.',
okButton: {
text: 'Yes, Restore Burial Site',
callbackFunction: doRestore
}
})
})
})() })()

View File

@ -75,6 +75,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
: 'has-text-danger'}" aria-hidden="true"></i> : 'has-text-danger'}" aria-hidden="true"></i>
</span>`; </span>`;
} }
const burialSiteLinkClass = contract.burialSiteIsActive === 0 ? 'has-text-danger-dark' : '';
// eslint-disable-next-line no-unsanitized/method // eslint-disable-next-line no-unsanitized/method
resultsTbodyElement.insertAdjacentHTML('beforeend', `<tr class="avoid-page-break"> resultsTbodyElement.insertAdjacentHTML('beforeend', `<tr class="avoid-page-break">
<td class="has-width-1"> <td class="has-width-1">
@ -88,7 +89,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
</td><td> </td><td>
${(contract.burialSiteId ?? -1) === -1 ${(contract.burialSiteId ?? -1) === -1
? '<span class="has-text-grey">(No Burial Site)</span>' ? '<span class="has-text-grey">(No Burial Site)</span>'
: `<a class="has-tooltip-right" data-tooltip="${cityssm.escapeHTML(contract.burialSiteType ?? '')}" : `<a class="has-tooltip-right ${burialSiteLinkClass}"
data-tooltip="${cityssm.escapeHTML(contract.burialSiteType ?? '')}"
href="${sunrise.getBurialSiteURL(contract.burialSiteId)}"> href="${sunrise.getBurialSiteURL(contract.burialSiteId)}">
${cityssm.escapeHTML(contract.burialSiteName ?? '')} ${cityssm.escapeHTML(contract.burialSiteName ?? '')}
</a>`}<br /> </a>`}<br />

View File

@ -130,6 +130,9 @@ declare const exports: Record<string, unknown>
</span>` </span>`
} }
const burialSiteLinkClass =
contract.burialSiteIsActive === 0 ? 'has-text-danger-dark' : ''
// eslint-disable-next-line no-unsanitized/method // eslint-disable-next-line no-unsanitized/method
resultsTbodyElement.insertAdjacentHTML( resultsTbodyElement.insertAdjacentHTML(
'beforeend', 'beforeend',
@ -146,7 +149,8 @@ declare const exports: Record<string, unknown>
${ ${
(contract.burialSiteId ?? -1) === -1 (contract.burialSiteId ?? -1) === -1
? '<span class="has-text-grey">(No Burial Site)</span>' ? '<span class="has-text-grey">(No Burial Site)</span>'
: `<a class="has-tooltip-right" data-tooltip="${cityssm.escapeHTML(contract.burialSiteType ?? '')}" : `<a class="has-tooltip-right ${burialSiteLinkClass}"
data-tooltip="${cityssm.escapeHTML(contract.burialSiteType ?? '')}"
href="${sunrise.getBurialSiteURL(contract.burialSiteId)}"> href="${sunrise.getBurialSiteURL(contract.burialSiteId)}">
${cityssm.escapeHTML(contract.burialSiteName ?? '')} ${cityssm.escapeHTML(contract.burialSiteName ?? '')}
</a>` </a>`

View File

@ -10,18 +10,19 @@ import handler_doCreateBurialSite from '../handlers/burialSites-post/doCreateBur
import handler_doDeleteBurialSite from '../handlers/burialSites-post/doDeleteBurialSite.js'; import handler_doDeleteBurialSite from '../handlers/burialSites-post/doDeleteBurialSite.js';
import handler_doDeleteBurialSiteComment from '../handlers/burialSites-post/doDeleteBurialSiteComment.js'; import handler_doDeleteBurialSiteComment from '../handlers/burialSites-post/doDeleteBurialSiteComment.js';
import handler_doGetBurialSiteTypeFields from '../handlers/burialSites-post/doGetBurialSiteTypeFields.js'; import handler_doGetBurialSiteTypeFields from '../handlers/burialSites-post/doGetBurialSiteTypeFields.js';
import handler_doRestoreBurialSite from '../handlers/burialSites-post/doRestoreBurialSite.js';
import handler_doSearchBurialSites from '../handlers/burialSites-post/doSearchBurialSites.js'; import handler_doSearchBurialSites from '../handlers/burialSites-post/doSearchBurialSites.js';
import handler_doUpdateBurialSite from '../handlers/burialSites-post/doUpdateBurialSite.js'; import handler_doUpdateBurialSite from '../handlers/burialSites-post/doUpdateBurialSite.js';
import handler_doUpdateBurialSiteComment from '../handlers/burialSites-post/doUpdateBurialSiteComment.js'; import handler_doUpdateBurialSiteComment from '../handlers/burialSites-post/doUpdateBurialSiteComment.js';
import { updateGetHandler, updatePostHandler } from '../handlers/permissions.js'; import { adminPostHandler, updateGetHandler, updatePostHandler } from '../handlers/permissions.js';
export const router = Router(); export const router = Router();
/* /*
* Lot Search * Burial Site Search
*/ */
router.get('/', handler_search); router.get('/', handler_search);
router.post('/doSearchBurialSites', handler_doSearchBurialSites); router.post('/doSearchBurialSites', handler_doSearchBurialSites);
/* /*
* Lot View / Edit * Burial Site View / Edit
*/ */
router.get('/new', updateGetHandler, handler_new); router.get('/new', updateGetHandler, handler_new);
router.get('/:burialSiteId', handler_view); router.get('/:burialSiteId', handler_view);
@ -32,6 +33,10 @@ router.post('/doGetBurialSiteTypeFields', updatePostHandler, handler_doGetBurial
router.post('/doCreateBurialSite', updatePostHandler, handler_doCreateBurialSite); router.post('/doCreateBurialSite', updatePostHandler, handler_doCreateBurialSite);
router.post('/doUpdateBurialSite', updatePostHandler, handler_doUpdateBurialSite); router.post('/doUpdateBurialSite', updatePostHandler, handler_doUpdateBurialSite);
router.post('/doDeleteBurialSite', updatePostHandler, handler_doDeleteBurialSite); router.post('/doDeleteBurialSite', updatePostHandler, handler_doDeleteBurialSite);
router.post('/doRestoreBurialSite', adminPostHandler, handler_doRestoreBurialSite);
/*
* Burial Site Comments
*/
router.post('/doAddBurialSiteComment', updatePostHandler, handler_doAddBurialSiteComment); router.post('/doAddBurialSiteComment', updatePostHandler, handler_doAddBurialSiteComment);
router.post('/doUpdateBurialSiteComment', updatePostHandler, handler_doUpdateBurialSiteComment); router.post('/doUpdateBurialSiteComment', updatePostHandler, handler_doUpdateBurialSiteComment);
router.post('/doDeleteBurialSiteComment', updatePostHandler, handler_doDeleteBurialSiteComment); router.post('/doDeleteBurialSiteComment', updatePostHandler, handler_doDeleteBurialSiteComment);

View File

@ -11,15 +11,16 @@ import handler_doCreateBurialSite from '../handlers/burialSites-post/doCreateBur
import handler_doDeleteBurialSite from '../handlers/burialSites-post/doDeleteBurialSite.js' import handler_doDeleteBurialSite from '../handlers/burialSites-post/doDeleteBurialSite.js'
import handler_doDeleteBurialSiteComment from '../handlers/burialSites-post/doDeleteBurialSiteComment.js' import handler_doDeleteBurialSiteComment from '../handlers/burialSites-post/doDeleteBurialSiteComment.js'
import handler_doGetBurialSiteTypeFields from '../handlers/burialSites-post/doGetBurialSiteTypeFields.js' import handler_doGetBurialSiteTypeFields from '../handlers/burialSites-post/doGetBurialSiteTypeFields.js'
import handler_doRestoreBurialSite from '../handlers/burialSites-post/doRestoreBurialSite.js'
import handler_doSearchBurialSites from '../handlers/burialSites-post/doSearchBurialSites.js' import handler_doSearchBurialSites from '../handlers/burialSites-post/doSearchBurialSites.js'
import handler_doUpdateBurialSite from '../handlers/burialSites-post/doUpdateBurialSite.js' import handler_doUpdateBurialSite from '../handlers/burialSites-post/doUpdateBurialSite.js'
import handler_doUpdateBurialSiteComment from '../handlers/burialSites-post/doUpdateBurialSiteComment.js' import handler_doUpdateBurialSiteComment from '../handlers/burialSites-post/doUpdateBurialSiteComment.js'
import { updateGetHandler, updatePostHandler } from '../handlers/permissions.js' import { adminPostHandler, updateGetHandler, updatePostHandler } from '../handlers/permissions.js'
export const router = Router() export const router = Router()
/* /*
* Lot Search * Burial Site Search
*/ */
router.get('/', handler_search) router.get('/', handler_search)
@ -27,7 +28,7 @@ router.get('/', handler_search)
router.post('/doSearchBurialSites', handler_doSearchBurialSites) router.post('/doSearchBurialSites', handler_doSearchBurialSites)
/* /*
* Lot View / Edit * Burial Site View / Edit
*/ */
router.get('/new', updateGetHandler, handler_new) router.get('/new', updateGetHandler, handler_new)
@ -64,6 +65,16 @@ router.post(
handler_doDeleteBurialSite handler_doDeleteBurialSite
) )
router.post(
'/doRestoreBurialSite',
adminPostHandler,
handler_doRestoreBurialSite
)
/*
* Burial Site Comments
*/
router.post( router.post(
'/doAddBurialSiteComment', '/doAddBurialSiteComment',
updatePostHandler, updatePostHandler,

View File

@ -107,6 +107,7 @@ export interface Contract extends Record {
isPreneed: boolean; isPreneed: boolean;
printEJS?: string; printEJS?: string;
burialSiteId?: number; burialSiteId?: number;
burialSiteIsActive?: 0 | 1;
burialSiteName?: string; burialSiteName?: string;
burialSiteType?: string; burialSiteType?: string;
burialSiteTypeId?: number; burialSiteTypeId?: number;
@ -285,8 +286,8 @@ export interface Record {
recordUpdate_timeString?: string; recordUpdate_timeString?: string;
recordUpdate_userName?: string; recordUpdate_userName?: string;
recordDelete_dateString?: string; recordDelete_dateString?: string;
recordDelete_timeMillis?: number; recordDelete_timeMillis?: number | null;
recordDelete_userName?: string; recordDelete_userName?: string | null;
} }
export interface WorkOrder extends Record { export interface WorkOrder extends Record {
workOrderId: number; workOrderId: number;

View File

@ -153,6 +153,7 @@ export interface Contract extends Record {
printEJS?: string printEJS?: string
burialSiteId?: number burialSiteId?: number
burialSiteIsActive?: 0 | 1
burialSiteName?: string burialSiteName?: string
burialSiteType?: string burialSiteType?: string
burialSiteTypeId?: number burialSiteTypeId?: number
@ -393,8 +394,8 @@ export interface Record {
recordUpdate_userName?: string recordUpdate_userName?: string
recordDelete_dateString?: string recordDelete_dateString?: string
recordDelete_timeMillis?: number recordDelete_timeMillis?: number | null
recordDelete_userName?: string recordDelete_userName?: string | null
} }
/* /*

View File

@ -21,6 +21,21 @@
<%= burialSite.burialSiteName %> <%= burialSite.burialSiteName %>
</h1> </h1>
<% const burialSiteIsDeleted = burialSite.recordDelete_timeMillis !== null; %>
<% if (burialSiteIsDeleted) { %>
<div class="message is-danger">
<div class="message-header">
<p>Burial Site Deleted</p>
</div>
<div class="message-body">
<p>This burial site has been deleted. It is no longer available for use.</p>
<% if (!user.userProperties.isAdmin) { %>
<p>To restore this burial site, please contact your system administrator.</p>
<% } %>
</div>
</div>
<% } %>
<div class="columns is-vcentered is-fixed-bottom has-background-white has-shadow is-hidden-print"> <div class="columns is-vcentered is-fixed-bottom has-background-white has-shadow is-hidden-print">
<div class="column"> <div class="column">
<span class="has-text-weight-bold"> <span class="has-text-weight-bold">
@ -28,6 +43,14 @@
</span> </span>
</div> </div>
<div class="column is-narrow has-text-right"> <div class="column is-narrow has-text-right">
<% if (burialSiteIsDeleted && user.userProperties.isAdmin) { %>
<button class="button is-danger is-restore-burial-site-button"
data-burial-site-id="<%= burialSite.burialSiteId %>"
type="button">
<span class="icon"><i class="fas fa-undo" aria-hidden="true"></i></span>
<span>Restore Burial Site</span>
</button>
<% } else if (!burialSiteIsDeleted) { %>
<div class="buttons is-right"> <div class="buttons is-right">
<a class="button is-link is-outlined has-tooltip-left" <a class="button is-link is-outlined has-tooltip-left"
data-tooltip="Previous Burial Site" data-tooltip="Previous Burial Site"
@ -55,6 +78,7 @@
</a> </a>
<% } %> <% } %>
</div> </div>
<% } %>
</div> </div>
</div> </div>

View File

@ -125,7 +125,9 @@
<p class="mb-2"> <p class="mb-2">
<strong>Burial Site</strong><br /> <strong>Burial Site</strong><br />
<% if (contract.burialSiteId) { %> <% if (contract.burialSiteId) { %>
<a href="<%= urlPrefix %>/burialSites/<%= contract.burialSiteId %>"><%= contract.burialSiteName %></a> <a class="<%= contract.burialSiteIsActive ? '' : 'has-text-danger-dark' %>" href="<%= urlPrefix %>/burialSites/<%= contract.burialSiteId %>">
<%= contract.burialSiteName %>
</a>
<% } else { %> <% } else { %>
<span class="has-text-grey">(No Burial Site)</span> <span class="has-text-grey">(No Burial Site)</span>
<% } %> <% } %>