toggle past contracts

pull/3/head
Dan Gowans 2025-03-25 12:21:07 -04:00
parent 2d3b8042a0
commit 16db467481
6 changed files with 99 additions and 21 deletions

View File

@ -367,4 +367,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
?.addEventListener('click', openAddCommentModal); ?.addEventListener('click', openAddCommentModal);
renderBurialSiteComments(); renderBurialSiteComments();
} }
/*
* Contracts
*/
document
.querySelector('#burialSite--contractsToggle')
?.addEventListener('click', () => {
const tableRowElements = document.querySelectorAll('#burialSite--contractsTbody tr[data-is-active="false"]');
for (const tableRowElement of tableRowElements) {
tableRowElement.classList.toggle('is-hidden');
}
});
})(); })();

View File

@ -8,7 +8,6 @@ import type {
BurialSiteComment, BurialSiteComment,
BurialSiteTypeField BurialSiteTypeField
} from '../../types/recordTypes.js' } from '../../types/recordTypes.js'
import type { Sunrise } from './types.js' import type { Sunrise } from './types.js'
declare const cityssm: cityssmGlobal declare const cityssm: cityssmGlobal
@ -401,9 +400,9 @@ declare const exports: Record<string, unknown>
}, },
(rawResponseJSON) => { (rawResponseJSON) => {
const responseJSON = rawResponseJSON as { const responseJSON = rawResponseJSON as {
success: boolean
errorMessage?: string
burialSiteComments: BurialSiteComment[] burialSiteComments: BurialSiteComment[]
errorMessage?: string
success: boolean
} }
if (responseJSON.success) { if (responseJSON.success) {
@ -508,8 +507,8 @@ declare const exports: Record<string, unknown>
formEvent.currentTarget, formEvent.currentTarget,
(rawResponseJSON) => { (rawResponseJSON) => {
const responseJSON = rawResponseJSON as { const responseJSON = rawResponseJSON as {
success: boolean
burialSiteComments: BurialSiteComment[] burialSiteComments: BurialSiteComment[]
success: boolean
} }
if (responseJSON.success) { if (responseJSON.success) {
@ -559,4 +558,20 @@ declare const exports: Record<string, unknown>
?.addEventListener('click', openAddCommentModal) ?.addEventListener('click', openAddCommentModal)
renderBurialSiteComments() renderBurialSiteComments()
} }
/*
* Contracts
*/
document
.querySelector('#burialSite--contractsToggle')
?.addEventListener('click', () => {
const tableRowElements = document.querySelectorAll(
'#burialSite--contractsTbody tr[data-is-active="false"]'
)
for (const tableRowElement of tableRowElements) {
tableRowElement.classList.toggle('is-hidden')
}
})
})() })()

View File

@ -3,7 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
(() => { (() => {
const mapContainerElement = document.querySelector('#burialSite--cemeterySvg'); const mapContainerElement = document.querySelector('#burialSite--cemeterySvg');
if (mapContainerElement !== null) { if (mapContainerElement !== null) {
;
exports.sunrise.highlightMap(mapContainerElement, mapContainerElement.dataset.cemeterySvgId ?? '', 'success'); exports.sunrise.highlightMap(mapContainerElement, mapContainerElement.dataset.cemeterySvgId ?? '', 'success');
} }
document
.querySelector('#burialSite--contractsToggle')
?.addEventListener('click', () => {
const tableRowElements = document.querySelectorAll('#burialSite--contractsTbody tr[data-is-active="false"]');
for (const tableRowElement of tableRowElements) {
tableRowElement.classList.toggle('is-hidden');
}
});
})(); })();

View File

@ -1,15 +1,30 @@
import type { Sunrise } from './types.js' import type { Sunrise } from './types.js'
declare const exports: Record<string, unknown> declare const exports: {
sunrise: Sunrise
}
;(() => { ;(() => {
const mapContainerElement: HTMLElement | null = const mapContainerElement: HTMLElement | null = document.querySelector(
document.querySelector('#burialSite--cemeterySvg') '#burialSite--cemeterySvg'
)
if (mapContainerElement !== null) { if (mapContainerElement !== null) {
;(exports.sunrise as Sunrise).highlightMap( exports.sunrise.highlightMap(
mapContainerElement, mapContainerElement,
mapContainerElement.dataset.cemeterySvgId ?? '', mapContainerElement.dataset.cemeterySvgId ?? '',
'success' 'success'
) )
} }
document
.querySelector('#burialSite--contractsToggle')
?.addEventListener('click', () => {
const tableRowElements = document.querySelectorAll(
'#burialSite--contractsTbody tr[data-is-active="false"]'
)
for (const tableRowElement of tableRowElements) {
tableRowElement.classList.toggle('is-hidden')
}
})
})() })()

View File

@ -416,8 +416,10 @@
<div class="level-item"> <div class="level-item">
<h2 class="has-text-weight-bold is-size-5"> <h2 class="has-text-weight-bold is-size-5">
Contracts Contracts
<span class="tag"><%= burialSite.contracts.length %></span> </h2>
</h2> </div>
<div class="level-item">
<span class="tag"><%= burialSite.contracts.length %></span>
</div> </div>
</div> </div>
<div class="level-right"> <div class="level-right">
@ -427,6 +429,15 @@
<span>Create New Contract</span> <span>Create New Contract</span>
</a> </a>
</div> </div>
<% if (burialSite.contracts.length > 0) { %>
<div class="level-item">
<button class="button is-info is-small"
id="burialSite--contractsToggle" type="button">
<span class="icon"><i class="fas fa-eye" aria-hidden="true"></i></span>
<span>Show/Hide Past Contracts</span>
</button>
</div>
<% } %>
</div> </div>
</div> </div>
</div> </div>
@ -438,7 +449,7 @@
</p> </p>
</div> </div>
<% } else { %> <% } else { %>
<table class="table is-fullwidth is-striped is-hoverable"> <table class="table is-fullwidth is-striped is-hoverable has-sticky-header">
<thead> <thead>
<tr> <tr>
<th class="has-width-10">&nbsp;</th> <th class="has-width-10">&nbsp;</th>
@ -448,11 +459,11 @@
<th>Interments</th> <th>Interments</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody id="burialSite--contractsTbody">
<% const currentDate = dateTimeFunctions.dateToInteger(new Date()); %> <% const currentDate = dateTimeFunctions.dateToInteger(new Date()); %>
<% for (const contract of burialSite.contracts) { %> <% for (const contract of burialSite.contracts) { %>
<% const isActive = !(contract.contractEndDate && contract.contractEndDate < currentDate); %> <% const isActive = !(contract.contractEndDate && contract.contractEndDate < currentDate); %>
<tr> <tr data-is-active="<%= isActive %>" class="<%= isActive ? "" : "is-hidden" %>">
<td class="has-text-centered"> <td class="has-text-centered">
<% if (isActive) { %> <% if (isActive) { %>
<i class="fas fa-play" title="Current Contract"></i> <i class="fas fa-play" title="Current Contract"></i>

View File

@ -144,10 +144,29 @@
<% } %> <% } %>
<div class="panel"> <div class="panel">
<h2 class="panel-heading"> <div class="panel-heading">
Contracts <div class="level is-mobile">
<span class="tag"><%= burialSite.contracts.length %></span> <div class="level-left">
</h2> <div class="level-item">
<h2 class="has-text-weight-bold">Contracts</h2>
</div>
<div class="level-item">
<span class="tag"><%= burialSite.contracts.length %></span>
</div>
</div>
<% if (burialSite.contracts.length > 0) { %>
<div class="level-right">
<div class="level-item">
<button class="button is-info is-small"
id="burialSite--contractsToggle" type="button">
<span class="icon"><i class="fas fa-eye" aria-hidden="true"></i></span>
<span>Show/Hide Past Contracts</span>
</button>
</div>
</div>
<% } %>
</div>
</div>
<div class="panel-block is-block"> <div class="panel-block is-block">
<% if (burialSite.contracts.length === 0) { %> <% if (burialSite.contracts.length === 0) { %>
<div class="message is-info"> <div class="message is-info">
@ -156,7 +175,7 @@
</p> </p>
</div> </div>
<% } else { %> <% } else { %>
<table class="table is-fullwidth is-striped is-hoverable"> <table class="table is-fullwidth is-striped is-hoverable has-sticky-header">
<thead> <thead>
<tr> <tr>
<th class="has-width-10">&nbsp;</th> <th class="has-width-10">&nbsp;</th>
@ -166,11 +185,11 @@
<th>Interments</th> <th>Interments</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody id="burialSite--contractsTbody">
<% const currentDate = dateTimeFunctions.dateToInteger(new Date()); %> <% const currentDate = dateTimeFunctions.dateToInteger(new Date()); %>
<% for (const contract of burialSite.contracts) { %> <% for (const contract of burialSite.contracts) { %>
<% const isActive = !(contract.contractEndDate && contract.contractEndDate < currentDate); %> <% const isActive = !(contract.contractEndDate && contract.contractEndDate < currentDate); %>
<tr> <tr data-is-active="<%= isActive %>" class="<%= isActive ? "" : "is-hidden" %>">
<td class="has-text-centered"> <td class="has-text-centered">
<% if (isActive) { %> <% if (isActive) { %>
<i class="fas fa-play" title="Current Contract"></i> <i class="fas fa-play" title="Current Contract"></i>