parent
14bd8e0ea4
commit
c7640f6dfd
|
|
@ -177,6 +177,11 @@
|
||||||
</div>
|
</div>
|
||||||
<label class="label" for="contractIntermentAdd--deathAge">Death Age</label>
|
<label class="label" for="contractIntermentAdd--deathAge">Death Age</label>
|
||||||
<div class="field has-addons">
|
<div class="field has-addons">
|
||||||
|
<div class="control">
|
||||||
|
<button class="button" type="button" id="button--calculateDeathAge" aria-label="Calculate Age" disabled>
|
||||||
|
<span class="icon is-small"><i class="fas fa-calculator" aria-hidden="true"></i></span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
<div class="control is-expanded">
|
<div class="control is-expanded">
|
||||||
<input class="input has-text-right" id="contractIntermentAdd--deathAge" name="deathAge" type="number" min="0" max="150" />
|
<input class="input has-text-right" id="contractIntermentAdd--deathAge" name="deathAge" type="number" min="0" max="150" />
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -184,6 +184,11 @@
|
||||||
</div>
|
</div>
|
||||||
<label class="label" for="contractIntermentEdit--deathAge">Death Age</label>
|
<label class="label" for="contractIntermentEdit--deathAge">Death Age</label>
|
||||||
<div class="field has-addons">
|
<div class="field has-addons">
|
||||||
|
<div class="control">
|
||||||
|
<button class="button" type="button" id="button--calculateDeathAge" aria-label="Calculate Age" disabled>
|
||||||
|
<span class="icon is-small"><i class="fas fa-calculator" aria-hidden="true"></i></span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
<div class="control is-expanded">
|
<div class="control is-expanded">
|
||||||
<input class="input has-text-right" id="contractIntermentEdit--deathAge" name="deathAge" type="number" min="0" max="150" />
|
<input class="input has-text-right" id="contractIntermentEdit--deathAge" name="deathAge" type="number" min="0" max="150" />
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -435,7 +435,43 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
}
|
}
|
||||||
setUnsavedChanges();
|
setUnsavedChanges();
|
||||||
});
|
});
|
||||||
sunrise.initializeMinDateUpdate(document.querySelector('#contract--birthDateString'), document.querySelector('#contract--deathDateString'));
|
const birthDateStringElement = document.querySelector('#contract--birthDateString');
|
||||||
sunrise.initializeMinDateUpdate(document.querySelector('#contract--deathDateString'), document.querySelector('#contract--funeralDateString'));
|
const deathDateStringElement = document.querySelector('#contract--deathDateString');
|
||||||
|
sunrise.initializeMinDateUpdate(birthDateStringElement, deathDateStringElement);
|
||||||
|
sunrise.initializeMinDateUpdate(deathDateStringElement, document.querySelector('#contract--funeralDateString'));
|
||||||
|
const calculateDeathAgeButtonElement = document.querySelector('#button--calculateDeathAge');
|
||||||
|
function toggleDeathAgeCalculatorButton() {
|
||||||
|
if (birthDateStringElement.value === '' ||
|
||||||
|
deathDateStringElement.value === '') {
|
||||||
|
calculateDeathAgeButtonElement.setAttribute('disabled', 'disabled');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
calculateDeathAgeButtonElement.removeAttribute('disabled');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
birthDateStringElement.addEventListener('change', toggleDeathAgeCalculatorButton);
|
||||||
|
deathDateStringElement.addEventListener('change', toggleDeathAgeCalculatorButton);
|
||||||
|
calculateDeathAgeButtonElement.addEventListener('click', (clickEvent) => {
|
||||||
|
clickEvent.preventDefault();
|
||||||
|
const birthDate = new Date(birthDateStringElement.value);
|
||||||
|
const deathDate = new Date(deathDateStringElement.value);
|
||||||
|
const ageInDays = Math.floor((deathDate.getTime() - birthDate.getTime()) / (1000 * 60 * 60 * 24));
|
||||||
|
const ageInYears = Math.floor(ageInDays / 365.25);
|
||||||
|
const deathAgeElement = document.querySelector('#contract--deathAge');
|
||||||
|
const deathAgePeriodElement = document.querySelector('#contract--deathAgePeriod');
|
||||||
|
if (ageInYears > 0) {
|
||||||
|
deathAgeElement.value = ageInYears.toString();
|
||||||
|
deathAgePeriodElement.value = 'Years';
|
||||||
|
}
|
||||||
|
else if (ageInDays > 0) {
|
||||||
|
deathAgeElement.value = ageInDays.toString();
|
||||||
|
deathAgePeriodElement.value = 'Days';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
deathAgeElement.value = '0';
|
||||||
|
deathAgePeriodElement.value = 'Stillborn';
|
||||||
|
}
|
||||||
|
setUnsavedChanges();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
|
|
||||||
|
|
@ -724,14 +724,80 @@ declare const exports: {
|
||||||
setUnsavedChanges()
|
setUnsavedChanges()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const birthDateStringElement = document.querySelector(
|
||||||
|
'#contract--birthDateString'
|
||||||
|
) as HTMLInputElement
|
||||||
|
|
||||||
|
const deathDateStringElement = document.querySelector(
|
||||||
|
'#contract--deathDateString'
|
||||||
|
) as HTMLInputElement
|
||||||
|
|
||||||
sunrise.initializeMinDateUpdate(
|
sunrise.initializeMinDateUpdate(
|
||||||
document.querySelector('#contract--birthDateString') as HTMLInputElement,
|
birthDateStringElement,
|
||||||
document.querySelector('#contract--deathDateString') as HTMLInputElement
|
deathDateStringElement
|
||||||
)
|
)
|
||||||
|
|
||||||
sunrise.initializeMinDateUpdate(
|
sunrise.initializeMinDateUpdate(
|
||||||
document.querySelector('#contract--deathDateString') as HTMLInputElement,
|
deathDateStringElement,
|
||||||
document.querySelector('#contract--funeralDateString') as HTMLInputElement
|
document.querySelector('#contract--funeralDateString') as HTMLInputElement
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const calculateDeathAgeButtonElement = document.querySelector(
|
||||||
|
'#button--calculateDeathAge'
|
||||||
|
) as HTMLButtonElement
|
||||||
|
|
||||||
|
function toggleDeathAgeCalculatorButton(): void {
|
||||||
|
if (
|
||||||
|
birthDateStringElement.value === '' ||
|
||||||
|
deathDateStringElement.value === ''
|
||||||
|
) {
|
||||||
|
calculateDeathAgeButtonElement.setAttribute('disabled', 'disabled')
|
||||||
|
} else {
|
||||||
|
calculateDeathAgeButtonElement.removeAttribute('disabled')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
birthDateStringElement.addEventListener(
|
||||||
|
'change',
|
||||||
|
toggleDeathAgeCalculatorButton
|
||||||
|
)
|
||||||
|
deathDateStringElement.addEventListener(
|
||||||
|
'change',
|
||||||
|
toggleDeathAgeCalculatorButton
|
||||||
|
)
|
||||||
|
|
||||||
|
calculateDeathAgeButtonElement.addEventListener('click', (clickEvent) => {
|
||||||
|
clickEvent.preventDefault()
|
||||||
|
|
||||||
|
const birthDate = new Date(birthDateStringElement.value)
|
||||||
|
const deathDate = new Date(deathDateStringElement.value)
|
||||||
|
|
||||||
|
const ageInDays = Math.floor(
|
||||||
|
(deathDate.getTime() - birthDate.getTime()) / (1000 * 60 * 60 * 24)
|
||||||
|
)
|
||||||
|
|
||||||
|
const ageInYears = Math.floor(ageInDays / 365.25)
|
||||||
|
|
||||||
|
const deathAgeElement = document.querySelector(
|
||||||
|
'#contract--deathAge'
|
||||||
|
) as HTMLInputElement
|
||||||
|
|
||||||
|
const deathAgePeriodElement = document.querySelector(
|
||||||
|
'#contract--deathAgePeriod'
|
||||||
|
) as HTMLInputElement
|
||||||
|
|
||||||
|
if (ageInYears > 0) {
|
||||||
|
deathAgeElement.value = ageInYears.toString()
|
||||||
|
deathAgePeriodElement.value = 'Years'
|
||||||
|
} else if (ageInDays > 0) {
|
||||||
|
deathAgeElement.value = ageInDays.toString()
|
||||||
|
deathAgePeriodElement.value = 'Days'
|
||||||
|
} else {
|
||||||
|
deathAgeElement.value = '0'
|
||||||
|
deathAgePeriodElement.value = 'Stillborn'
|
||||||
|
}
|
||||||
|
|
||||||
|
setUnsavedChanges()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
})()
|
})()
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,48 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
delete exports.deathAgePeriods;
|
delete exports.deathAgePeriods;
|
||||||
const intermentContainerTypes = exports.intermentContainerTypes;
|
const intermentContainerTypes = exports.intermentContainerTypes;
|
||||||
delete exports.intermentContainerTypes;
|
delete exports.intermentContainerTypes;
|
||||||
|
function initializeDeathAgeCalculator(fieldPrefix) {
|
||||||
|
const birthDateStringElement = document.querySelector(`#${fieldPrefix}--birthDateString`);
|
||||||
|
const deathDateStringElement = document.querySelector(`#${fieldPrefix}--deathDateString`);
|
||||||
|
const calculateDeathAgeButtonElement = document.querySelector('#button--calculateDeathAge');
|
||||||
|
function toggleDeathAgeCalculatorButton() {
|
||||||
|
if (birthDateStringElement.value === '' ||
|
||||||
|
deathDateStringElement.value === '') {
|
||||||
|
calculateDeathAgeButtonElement.setAttribute('disabled', 'disabled');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
calculateDeathAgeButtonElement.removeAttribute('disabled');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
toggleDeathAgeCalculatorButton();
|
||||||
|
birthDateStringElement.addEventListener('change', toggleDeathAgeCalculatorButton);
|
||||||
|
deathDateStringElement.addEventListener('change', toggleDeathAgeCalculatorButton);
|
||||||
|
const deathAgeElement = document.querySelector(`#${fieldPrefix}--deathAge`);
|
||||||
|
const deathAgePeriodElement = document.querySelector(`#${fieldPrefix}--deathAgePeriod`);
|
||||||
|
function calculateDeathAge() {
|
||||||
|
if (birthDateStringElement.value === '' ||
|
||||||
|
deathDateStringElement.value === '') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const birthDate = new Date(birthDateStringElement.value);
|
||||||
|
const deathDate = new Date(deathDateStringElement.value);
|
||||||
|
const ageInDays = Math.floor((deathDate.getTime() - birthDate.getTime()) / (1000 * 60 * 60 * 24));
|
||||||
|
const ageInYears = Math.floor(ageInDays / 365.25);
|
||||||
|
if (ageInYears > 0) {
|
||||||
|
deathAgeElement.value = ageInYears.toString();
|
||||||
|
deathAgePeriodElement.value = 'Years';
|
||||||
|
}
|
||||||
|
else if (ageInDays > 0) {
|
||||||
|
deathAgeElement.value = ageInDays.toString();
|
||||||
|
deathAgePeriodElement.value = 'Days';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
deathAgeElement.value = '0';
|
||||||
|
deathAgePeriodElement.value = 'Stillborn';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
calculateDeathAgeButtonElement.addEventListener('click', calculateDeathAge);
|
||||||
|
}
|
||||||
function openEditContractInterment(clickEvent) {
|
function openEditContractInterment(clickEvent) {
|
||||||
const intermentNumber = clickEvent.currentTarget.closest('tr')?.dataset.intermentNumber;
|
const intermentNumber = clickEvent.currentTarget.closest('tr')?.dataset.intermentNumber;
|
||||||
if (intermentNumber === undefined) {
|
if (intermentNumber === undefined) {
|
||||||
|
|
@ -123,6 +165,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
modalElement
|
modalElement
|
||||||
.querySelector('form')
|
.querySelector('form')
|
||||||
?.addEventListener('submit', submitForm);
|
?.addEventListener('submit', submitForm);
|
||||||
|
initializeDeathAgeCalculator('contractIntermentEdit');
|
||||||
},
|
},
|
||||||
onremoved() {
|
onremoved() {
|
||||||
bulmaJS.toggleHtmlClipped();
|
bulmaJS.toggleHtmlClipped();
|
||||||
|
|
@ -290,6 +333,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
modalElement
|
modalElement
|
||||||
.querySelector('form')
|
.querySelector('form')
|
||||||
?.addEventListener('submit', submitForm);
|
?.addEventListener('submit', submitForm);
|
||||||
|
initializeDeathAgeCalculator('contractIntermentAdd');
|
||||||
},
|
},
|
||||||
onremoved() {
|
onremoved() {
|
||||||
bulmaJS.toggleHtmlClipped();
|
bulmaJS.toggleHtmlClipped();
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,83 @@ declare const exports: Record<string, unknown>
|
||||||
exports.intermentContainerTypes as IntermentContainerType[]
|
exports.intermentContainerTypes as IntermentContainerType[]
|
||||||
delete exports.intermentContainerTypes
|
delete exports.intermentContainerTypes
|
||||||
|
|
||||||
|
function initializeDeathAgeCalculator(
|
||||||
|
fieldPrefix: 'contractIntermentAdd' | 'contractIntermentEdit'
|
||||||
|
): void {
|
||||||
|
const birthDateStringElement = document.querySelector(
|
||||||
|
`#${fieldPrefix}--birthDateString`
|
||||||
|
) as HTMLInputElement
|
||||||
|
|
||||||
|
const deathDateStringElement = document.querySelector(
|
||||||
|
`#${fieldPrefix}--deathDateString`
|
||||||
|
) as HTMLInputElement
|
||||||
|
|
||||||
|
const calculateDeathAgeButtonElement = document.querySelector(
|
||||||
|
'#button--calculateDeathAge'
|
||||||
|
) as HTMLButtonElement
|
||||||
|
|
||||||
|
function toggleDeathAgeCalculatorButton(): void {
|
||||||
|
if (
|
||||||
|
birthDateStringElement.value === '' ||
|
||||||
|
deathDateStringElement.value === ''
|
||||||
|
) {
|
||||||
|
calculateDeathAgeButtonElement.setAttribute('disabled', 'disabled')
|
||||||
|
} else {
|
||||||
|
calculateDeathAgeButtonElement.removeAttribute('disabled')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
toggleDeathAgeCalculatorButton()
|
||||||
|
|
||||||
|
birthDateStringElement.addEventListener(
|
||||||
|
'change',
|
||||||
|
toggleDeathAgeCalculatorButton
|
||||||
|
)
|
||||||
|
deathDateStringElement.addEventListener(
|
||||||
|
'change',
|
||||||
|
toggleDeathAgeCalculatorButton
|
||||||
|
)
|
||||||
|
|
||||||
|
const deathAgeElement = document.querySelector(
|
||||||
|
`#${fieldPrefix}--deathAge`
|
||||||
|
) as HTMLInputElement
|
||||||
|
|
||||||
|
const deathAgePeriodElement = document.querySelector(
|
||||||
|
`#${fieldPrefix}--deathAgePeriod`
|
||||||
|
) as HTMLSelectElement
|
||||||
|
|
||||||
|
function calculateDeathAge(): void {
|
||||||
|
if (
|
||||||
|
birthDateStringElement.value === '' ||
|
||||||
|
deathDateStringElement.value === ''
|
||||||
|
) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const birthDate = new Date(birthDateStringElement.value)
|
||||||
|
const deathDate = new Date(deathDateStringElement.value)
|
||||||
|
|
||||||
|
const ageInDays = Math.floor(
|
||||||
|
(deathDate.getTime() - birthDate.getTime()) / (1000 * 60 * 60 * 24)
|
||||||
|
)
|
||||||
|
|
||||||
|
const ageInYears = Math.floor(ageInDays / 365.25)
|
||||||
|
|
||||||
|
if (ageInYears > 0) {
|
||||||
|
deathAgeElement.value = ageInYears.toString()
|
||||||
|
deathAgePeriodElement.value = 'Years'
|
||||||
|
} else if (ageInDays > 0) {
|
||||||
|
deathAgeElement.value = ageInDays.toString()
|
||||||
|
deathAgePeriodElement.value = 'Days'
|
||||||
|
} else {
|
||||||
|
deathAgeElement.value = '0'
|
||||||
|
deathAgePeriodElement.value = 'Stillborn'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
calculateDeathAgeButtonElement.addEventListener('click', calculateDeathAge)
|
||||||
|
}
|
||||||
|
|
||||||
function openEditContractInterment(clickEvent: Event): void {
|
function openEditContractInterment(clickEvent: Event): void {
|
||||||
const intermentNumber = (clickEvent.currentTarget as HTMLElement).closest(
|
const intermentNumber = (clickEvent.currentTarget as HTMLElement).closest(
|
||||||
'tr'
|
'tr'
|
||||||
|
|
@ -198,7 +275,10 @@ declare const exports: Record<string, unknown>
|
||||||
modalElement
|
modalElement
|
||||||
.querySelector('form')
|
.querySelector('form')
|
||||||
?.addEventListener('submit', submitForm)
|
?.addEventListener('submit', submitForm)
|
||||||
|
|
||||||
|
initializeDeathAgeCalculator('contractIntermentEdit')
|
||||||
},
|
},
|
||||||
|
|
||||||
onremoved() {
|
onremoved() {
|
||||||
bulmaJS.toggleHtmlClipped()
|
bulmaJS.toggleHtmlClipped()
|
||||||
}
|
}
|
||||||
|
|
@ -424,7 +504,10 @@ declare const exports: Record<string, unknown>
|
||||||
modalElement
|
modalElement
|
||||||
.querySelector('form')
|
.querySelector('form')
|
||||||
?.addEventListener('submit', submitForm)
|
?.addEventListener('submit', submitForm)
|
||||||
|
|
||||||
|
initializeDeathAgeCalculator('contractIntermentAdd')
|
||||||
},
|
},
|
||||||
|
|
||||||
onremoved() {
|
onremoved() {
|
||||||
bulmaJS.toggleHtmlClipped()
|
bulmaJS.toggleHtmlClipped()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -687,6 +687,11 @@
|
||||||
</div>
|
</div>
|
||||||
<label class="label" for="contract--deathAge">Death Age</label>
|
<label class="label" for="contract--deathAge">Death Age</label>
|
||||||
<div class="field has-addons">
|
<div class="field has-addons">
|
||||||
|
<div class="control">
|
||||||
|
<button class="button" type="button" id="button--calculateDeathAge" aria-label="Calculate Age" disabled>
|
||||||
|
<span class="icon is-small"><i class="fas fa-calculator" aria-hidden="true"></i></span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
<div class="control is-expanded">
|
<div class="control is-expanded">
|
||||||
<input class="input has-text-right" id="contract--deathAge" name="deathAge" type="number"
|
<input class="input has-text-right" id="contract--deathAge" name="deathAge" type="number"
|
||||||
min="0" max="150"
|
min="0" max="150"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue