@@ -1,8 +1,24 @@
|
||||
export function markPreparationDirty(
|
||||
form: HTMLFormElement,
|
||||
dirty: boolean,
|
||||
managed = false,
|
||||
): void {
|
||||
form.setAttribute('data-preparation-dirty', dirty ? 'true' : 'false');
|
||||
if (managed) form.setAttribute('data-preparation-managed', 'true');
|
||||
// Explicit query forms change consultation criteria, not a business preparation.
|
||||
form.setAttribute(
|
||||
'data-preparation-dirty',
|
||||
dirty && form.getAttribute('data-query-form') !== 'true'
|
||||
? 'true'
|
||||
: 'false',
|
||||
);
|
||||
}
|
||||
|
||||
/** A form that publishes its own dirty state owns clearing and restoring it. */
|
||||
export function usesGenericPreparationTracking(form: HTMLFormElement): boolean {
|
||||
return (
|
||||
form.getAttribute('data-query-form') !== 'true' &&
|
||||
form.getAttribute('data-preparation-managed') !== 'true'
|
||||
);
|
||||
}
|
||||
|
||||
/** Recover restored preparations even when their effect ran before the guard subscribed. */
|
||||
@@ -20,6 +36,7 @@ export function connectedDirtyForms(
|
||||
].filter(
|
||||
(form) =>
|
||||
form.isConnected &&
|
||||
form.getAttribute('data-query-form') !== 'true' &&
|
||||
form.getAttribute('data-preparation-dirty') !== 'false',
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user