restore deleted burial sites
parent
9048235ef2
commit
7371be711a
|
|
@ -30,23 +30,6 @@ export function deleteBurialSite(burialSiteId, user) {
|
|||
where burialSiteId = ?
|
||||
and recordDelete_timeMillis is null`)
|
||||
.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();
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,30 +44,6 @@ export function deleteBurialSite(burialSiteId: number, user: User): boolean {
|
|||
)
|
||||
.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()
|
||||
|
||||
return true
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
import type { BurialSite } from '../types/record.types.js';
|
||||
export default function getBurialSite(burialSiteId: number | string): Promise<BurialSite | undefined>;
|
||||
export declare function getBurialSiteByBurialSiteName(burialSiteName: string): Promise<BurialSite | undefined>;
|
||||
export default function getBurialSite(burialSiteId: number | string, includeDeleted?: boolean): Promise<BurialSite | undefined>;
|
||||
export declare function getBurialSiteByBurialSiteName(burialSiteName: string, includeDeleted?: boolean): Promise<BurialSite | undefined>;
|
||||
|
|
|
|||
|
|
@ -19,22 +19,25 @@ const baseSQL = `select l.burialSiteId,
|
|||
l.cemeteryId, m.cemeteryName,
|
||||
m.cemeteryLatitude, m.cemeteryLongitude,
|
||||
m.cemeterySvg, l.cemeterySvgId, l.burialSiteImage,
|
||||
l.burialSiteLatitude, l.burialSiteLongitude
|
||||
l.burialSiteLatitude, l.burialSiteLongitude,
|
||||
|
||||
l.recordDelete_userName, l.recordDelete_timeMillis
|
||||
|
||||
from BurialSites l
|
||||
left join BurialSiteTypes t on l.burialSiteTypeId = t.burialSiteTypeId
|
||||
left join BurialSiteStatuses s on l.burialSiteStatusId = s.burialSiteStatusId
|
||||
left join Cemeteries m on l.cemeteryId = m.cemeteryId
|
||||
where l.recordDelete_timeMillis is null`;
|
||||
export default async function getBurialSite(burialSiteId) {
|
||||
return await _getBurialSite(`${baseSQL} and l.burialSiteId = ?`, burialSiteId);
|
||||
left join Cemeteries m on l.cemeteryId = m.cemeteryId`;
|
||||
export default async function getBurialSite(burialSiteId, includeDeleted = false) {
|
||||
return await _getBurialSite(`l.burialSiteId = ?`, burialSiteId, includeDeleted);
|
||||
}
|
||||
export async function getBurialSiteByBurialSiteName(burialSiteName) {
|
||||
return await _getBurialSite(`${baseSQL} and l.burialSiteName = ?`, burialSiteName);
|
||||
export async function getBurialSiteByBurialSiteName(burialSiteName, includeDeleted = false) {
|
||||
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 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) {
|
||||
const contracts = await getContracts({
|
||||
burialSiteId: burialSite.burialSiteId
|
||||
|
|
|
|||
|
|
@ -23,38 +23,49 @@ const baseSQL = `select l.burialSiteId,
|
|||
l.cemeteryId, m.cemeteryName,
|
||||
m.cemeteryLatitude, m.cemeteryLongitude,
|
||||
m.cemeterySvg, l.cemeterySvgId, l.burialSiteImage,
|
||||
l.burialSiteLatitude, l.burialSiteLongitude
|
||||
l.burialSiteLatitude, l.burialSiteLongitude,
|
||||
|
||||
l.recordDelete_userName, l.recordDelete_timeMillis
|
||||
|
||||
from BurialSites l
|
||||
left join BurialSiteTypes t on l.burialSiteTypeId = t.burialSiteTypeId
|
||||
left join BurialSiteStatuses s on l.burialSiteStatusId = s.burialSiteStatusId
|
||||
left join Cemeteries m on l.cemeteryId = m.cemeteryId
|
||||
where l.recordDelete_timeMillis is null`
|
||||
left join Cemeteries m on l.cemeteryId = m.cemeteryId`
|
||||
|
||||
export default async function getBurialSite(
|
||||
burialSiteId: number | string
|
||||
burialSiteId: number | string,
|
||||
includeDeleted = false
|
||||
): Promise<BurialSite | undefined> {
|
||||
return await _getBurialSite(`${baseSQL} and l.burialSiteId = ?`, burialSiteId)
|
||||
return await _getBurialSite(
|
||||
`l.burialSiteId = ?`,
|
||||
burialSiteId,
|
||||
includeDeleted
|
||||
)
|
||||
}
|
||||
|
||||
export async function getBurialSiteByBurialSiteName(
|
||||
burialSiteName: string
|
||||
burialSiteName: string,
|
||||
includeDeleted = false
|
||||
): Promise<BurialSite | undefined> {
|
||||
return await _getBurialSite(
|
||||
`${baseSQL} and l.burialSiteName = ?`,
|
||||
burialSiteName
|
||||
`l.burialSiteName = ?`,
|
||||
burialSiteName,
|
||||
includeDeleted
|
||||
)
|
||||
}
|
||||
|
||||
async function _getBurialSite(
|
||||
sql: string,
|
||||
burialSiteIdOrLotName: number | string
|
||||
whereClausePiece: string,
|
||||
burialSiteIdOrLotName: number | string,
|
||||
includeDeleted = false
|
||||
): Promise<BurialSite | undefined> {
|
||||
const database = sqlite(sunriseDB, { readonly: true })
|
||||
|
||||
const burialSite = database.prepare(sql).get(burialSiteIdOrLotName) as
|
||||
| BurialSite
|
||||
| undefined
|
||||
const burialSite = database
|
||||
.prepare(
|
||||
`${baseSQL} ${includeDeleted ? 'where' : 'where l.recordDelete_timeMillis is null and'} ${whereClausePiece}`
|
||||
)
|
||||
.get(burialSiteIdOrLotName) as BurialSite | undefined
|
||||
|
||||
if (burialSite !== undefined) {
|
||||
const contracts = await getContracts(
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ export default async function getContract(contractId, connectedDatabase) {
|
|||
.prepare(`select o.contractId,
|
||||
o.contractTypeId, t.contractType, t.isPreneed,
|
||||
o.burialSiteId, l.burialSiteName, l.burialSiteTypeId,
|
||||
case when l.recordDelete_timeMillis is null then 1 else 0 end as burialSiteIsActive,
|
||||
l.cemeteryId, m.cemeteryName,
|
||||
o.contractStartDate, userFn_dateIntegerToString(o.contractStartDate) as contractStartDateString,
|
||||
o.contractEndDate, userFn_dateIntegerToString(o.contractEndDate) as contractEndDateString,
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ export default async function getContract(
|
|||
`select o.contractId,
|
||||
o.contractTypeId, t.contractType, t.isPreneed,
|
||||
o.burialSiteId, l.burialSiteName, l.burialSiteTypeId,
|
||||
case when l.recordDelete_timeMillis is null then 1 else 0 end as burialSiteIsActive,
|
||||
l.cemeteryId, m.cemeteryName,
|
||||
o.contractStartDate, userFn_dateIntegerToString(o.contractStartDate) as contractStartDateString,
|
||||
o.contractEndDate, userFn_dateIntegerToString(o.contractEndDate) as contractEndDateString,
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ export default async function getContracts(filters, options, connectedDatabase)
|
|||
.prepare(`select o.contractId,
|
||||
o.contractTypeId, t.contractType, t.isPreneed,
|
||||
o.burialSiteId, lt.burialSiteType, l.burialSiteName,
|
||||
case when l.recordDelete_timeMillis is null then 1 else 0 end as burialSiteIsActive,
|
||||
l.cemeteryId, m.cemeteryName,
|
||||
o.contractStartDate, userFn_dateIntegerToString(o.contractStartDate) as contractStartDateString,
|
||||
o.contractEndDate, userFn_dateIntegerToString(o.contractEndDate) as contractEndDateString,
|
||||
|
|
|
|||
|
|
@ -95,6 +95,7 @@ export default async function getContracts(
|
|||
`select o.contractId,
|
||||
o.contractTypeId, t.contractType, t.isPreneed,
|
||||
o.burialSiteId, lt.burialSiteType, l.burialSiteName,
|
||||
case when l.recordDelete_timeMillis is null then 1 else 0 end as burialSiteIsActive,
|
||||
l.cemeteryId, m.cemeteryName,
|
||||
o.contractStartDate, userFn_dateIntegerToString(o.contractStartDate) as contractStartDateString,
|
||||
o.contractEndDate, userFn_dateIntegerToString(o.contractEndDate) as contractEndDateString,
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
export declare function restoreBurialSite(burialSiteId: number, user: User): boolean;
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -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
|
||||
}
|
||||
|
|
@ -2,17 +2,20 @@ import getBurialSite from '../../database/getBurialSite.js';
|
|||
import { getNextBurialSiteId, getPreviousBurialSiteId } from '../../helpers/burialSites.helpers.js';
|
||||
import { getConfigProperty } from '../../helpers/config.helpers.js';
|
||||
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) {
|
||||
response.redirect(`${getConfigProperty('reverseProxy.urlPrefix')}/burialSites/?error=burialSiteIdNotFound`);
|
||||
return;
|
||||
}
|
||||
const burialSiteIsDeleted = burialSite.recordDelete_timeMillis !== null;
|
||||
response.render('burialSite-view', {
|
||||
headTitle: burialSite.burialSiteName,
|
||||
burialSite
|
||||
});
|
||||
if (!burialSiteIsDeleted) {
|
||||
response.on('finish', () => {
|
||||
getNextBurialSiteId(burialSite.burialSiteId);
|
||||
getPreviousBurialSiteId(burialSite.burialSiteId);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,10 @@ export default async function handler(
|
|||
request: Request,
|
||||
response: Response
|
||||
): Promise<void> {
|
||||
const burialSite = await getBurialSite(request.params.burialSiteId)
|
||||
const burialSite = await getBurialSite(
|
||||
request.params.burialSiteId,
|
||||
request.session.user?.userProperties?.canUpdate
|
||||
)
|
||||
|
||||
if (burialSite === undefined) {
|
||||
response.redirect(
|
||||
|
|
@ -20,14 +23,18 @@ export default async function handler(
|
|||
return
|
||||
}
|
||||
|
||||
const burialSiteIsDeleted = burialSite.recordDelete_timeMillis !== null
|
||||
|
||||
response.render('burialSite-view', {
|
||||
headTitle: burialSite.burialSiteName,
|
||||
|
||||
burialSite
|
||||
})
|
||||
|
||||
if (!burialSiteIsDeleted) {
|
||||
response.on('finish', () => {
|
||||
getNextBurialSiteId(burialSite.burialSiteId)
|
||||
getPreviousBurialSiteId(burialSite.burialSiteId)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,4 @@
|
|||
import type { Request, Response } from 'express';
|
||||
export default function handler(request: Request<unknown, unknown, {
|
||||
burialSiteId: number;
|
||||
}>, response: Response): void;
|
||||
|
|
@ -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();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -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()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
@ -39,4 +39,41 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|||
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
|
||||
}
|
||||
});
|
||||
});
|
||||
})();
|
||||
|
|
|
|||
|
|
@ -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 { Sunrise } from './types.js'
|
||||
|
||||
declare const cityssm: cityssmGlobal
|
||||
declare const bulmaJS: BulmaJS
|
||||
|
||||
declare const L: typeof Leaflet
|
||||
declare const exports: {
|
||||
sunrise: Sunrise
|
||||
|
|
@ -72,4 +77,58 @@ declare const exports: {
|
|||
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
|
||||
}
|
||||
})
|
||||
})
|
||||
})()
|
||||
|
|
|
|||
|
|
@ -75,6 +75,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|||
: 'has-text-danger'}" aria-hidden="true"></i>
|
||||
</span>`;
|
||||
}
|
||||
const burialSiteLinkClass = contract.burialSiteIsActive === 0 ? 'has-text-danger-dark' : '';
|
||||
// eslint-disable-next-line no-unsanitized/method
|
||||
resultsTbodyElement.insertAdjacentHTML('beforeend', `<tr class="avoid-page-break">
|
||||
<td class="has-width-1">
|
||||
|
|
@ -88,7 +89,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|||
</td><td>
|
||||
${(contract.burialSiteId ?? -1) === -1
|
||||
? '<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)}">
|
||||
${cityssm.escapeHTML(contract.burialSiteName ?? '')}
|
||||
</a>`}<br />
|
||||
|
|
|
|||
|
|
@ -130,6 +130,9 @@ declare const exports: Record<string, unknown>
|
|||
</span>`
|
||||
}
|
||||
|
||||
const burialSiteLinkClass =
|
||||
contract.burialSiteIsActive === 0 ? 'has-text-danger-dark' : ''
|
||||
|
||||
// eslint-disable-next-line no-unsanitized/method
|
||||
resultsTbodyElement.insertAdjacentHTML(
|
||||
'beforeend',
|
||||
|
|
@ -146,7 +149,8 @@ declare const exports: Record<string, unknown>
|
|||
${
|
||||
(contract.burialSiteId ?? -1) === -1
|
||||
? '<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)}">
|
||||
${cityssm.escapeHTML(contract.burialSiteName ?? '')}
|
||||
</a>`
|
||||
|
|
|
|||
|
|
@ -10,18 +10,19 @@ import handler_doCreateBurialSite from '../handlers/burialSites-post/doCreateBur
|
|||
import handler_doDeleteBurialSite from '../handlers/burialSites-post/doDeleteBurialSite.js';
|
||||
import handler_doDeleteBurialSiteComment from '../handlers/burialSites-post/doDeleteBurialSiteComment.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_doUpdateBurialSite from '../handlers/burialSites-post/doUpdateBurialSite.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();
|
||||
/*
|
||||
* Lot Search
|
||||
* Burial Site Search
|
||||
*/
|
||||
router.get('/', handler_search);
|
||||
router.post('/doSearchBurialSites', handler_doSearchBurialSites);
|
||||
/*
|
||||
* Lot View / Edit
|
||||
* Burial Site View / Edit
|
||||
*/
|
||||
router.get('/new', updateGetHandler, handler_new);
|
||||
router.get('/:burialSiteId', handler_view);
|
||||
|
|
@ -32,6 +33,10 @@ router.post('/doGetBurialSiteTypeFields', updatePostHandler, handler_doGetBurial
|
|||
router.post('/doCreateBurialSite', updatePostHandler, handler_doCreateBurialSite);
|
||||
router.post('/doUpdateBurialSite', updatePostHandler, handler_doUpdateBurialSite);
|
||||
router.post('/doDeleteBurialSite', updatePostHandler, handler_doDeleteBurialSite);
|
||||
router.post('/doRestoreBurialSite', adminPostHandler, handler_doRestoreBurialSite);
|
||||
/*
|
||||
* Burial Site Comments
|
||||
*/
|
||||
router.post('/doAddBurialSiteComment', updatePostHandler, handler_doAddBurialSiteComment);
|
||||
router.post('/doUpdateBurialSiteComment', updatePostHandler, handler_doUpdateBurialSiteComment);
|
||||
router.post('/doDeleteBurialSiteComment', updatePostHandler, handler_doDeleteBurialSiteComment);
|
||||
|
|
|
|||
|
|
@ -11,15 +11,16 @@ import handler_doCreateBurialSite from '../handlers/burialSites-post/doCreateBur
|
|||
import handler_doDeleteBurialSite from '../handlers/burialSites-post/doDeleteBurialSite.js'
|
||||
import handler_doDeleteBurialSiteComment from '../handlers/burialSites-post/doDeleteBurialSiteComment.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_doUpdateBurialSite from '../handlers/burialSites-post/doUpdateBurialSite.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()
|
||||
|
||||
/*
|
||||
* Lot Search
|
||||
* Burial Site Search
|
||||
*/
|
||||
|
||||
router.get('/', handler_search)
|
||||
|
|
@ -27,7 +28,7 @@ router.get('/', handler_search)
|
|||
router.post('/doSearchBurialSites', handler_doSearchBurialSites)
|
||||
|
||||
/*
|
||||
* Lot View / Edit
|
||||
* Burial Site View / Edit
|
||||
*/
|
||||
|
||||
router.get('/new', updateGetHandler, handler_new)
|
||||
|
|
@ -64,6 +65,16 @@ router.post(
|
|||
handler_doDeleteBurialSite
|
||||
)
|
||||
|
||||
router.post(
|
||||
'/doRestoreBurialSite',
|
||||
adminPostHandler,
|
||||
handler_doRestoreBurialSite
|
||||
)
|
||||
|
||||
/*
|
||||
* Burial Site Comments
|
||||
*/
|
||||
|
||||
router.post(
|
||||
'/doAddBurialSiteComment',
|
||||
updatePostHandler,
|
||||
|
|
|
|||
|
|
@ -107,6 +107,7 @@ export interface Contract extends Record {
|
|||
isPreneed: boolean;
|
||||
printEJS?: string;
|
||||
burialSiteId?: number;
|
||||
burialSiteIsActive?: 0 | 1;
|
||||
burialSiteName?: string;
|
||||
burialSiteType?: string;
|
||||
burialSiteTypeId?: number;
|
||||
|
|
@ -285,8 +286,8 @@ export interface Record {
|
|||
recordUpdate_timeString?: string;
|
||||
recordUpdate_userName?: string;
|
||||
recordDelete_dateString?: string;
|
||||
recordDelete_timeMillis?: number;
|
||||
recordDelete_userName?: string;
|
||||
recordDelete_timeMillis?: number | null;
|
||||
recordDelete_userName?: string | null;
|
||||
}
|
||||
export interface WorkOrder extends Record {
|
||||
workOrderId: number;
|
||||
|
|
|
|||
|
|
@ -153,6 +153,7 @@ export interface Contract extends Record {
|
|||
printEJS?: string
|
||||
|
||||
burialSiteId?: number
|
||||
burialSiteIsActive?: 0 | 1
|
||||
burialSiteName?: string
|
||||
burialSiteType?: string
|
||||
burialSiteTypeId?: number
|
||||
|
|
@ -393,8 +394,8 @@ export interface Record {
|
|||
recordUpdate_userName?: string
|
||||
|
||||
recordDelete_dateString?: string
|
||||
recordDelete_timeMillis?: number
|
||||
recordDelete_userName?: string
|
||||
recordDelete_timeMillis?: number | null
|
||||
recordDelete_userName?: string | null
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -21,6 +21,21 @@
|
|||
<%= burialSite.burialSiteName %>
|
||||
</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="column">
|
||||
<span class="has-text-weight-bold">
|
||||
|
|
@ -28,6 +43,14 @@
|
|||
</span>
|
||||
</div>
|
||||
<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">
|
||||
<a class="button is-link is-outlined has-tooltip-left"
|
||||
data-tooltip="Previous Burial Site"
|
||||
|
|
@ -55,6 +78,7 @@
|
|||
</a>
|
||||
<% } %>
|
||||
</div>
|
||||
<% } %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -125,7 +125,9 @@
|
|||
<p class="mb-2">
|
||||
<strong>Burial Site</strong><br />
|
||||
<% 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 { %>
|
||||
<span class="has-text-grey">(No Burial Site)</span>
|
||||
<% } %>
|
||||
|
|
|
|||
Loading…
Reference in New Issue