@memberjunction/ng-base-forms 6.2.0-edge.0 → 6.2.0-edge.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/base-form-component.d.ts +34 -0
- package/dist/lib/base-form-component.d.ts.map +1 -1
- package/dist/lib/base-form-component.js +68 -1
- package/dist/lib/base-form-component.js.map +1 -1
- package/dist/lib/base-form-section-info.js +5 -5
- package/dist/lib/base-form-section-info.js.map +1 -1
- package/dist/lib/chrome/resolve-form-chrome.d.ts.map +1 -1
- package/dist/lib/chrome/resolve-form-chrome.js +22 -12
- package/dist/lib/chrome/resolve-form-chrome.js.map +1 -1
- package/dist/lib/container/record-form-container.component.d.ts +41 -12
- package/dist/lib/container/record-form-container.component.d.ts.map +1 -1
- package/dist/lib/container/record-form-container.component.js +476 -378
- package/dist/lib/container/record-form-container.component.js.map +1 -1
- package/dist/lib/duplicate-entry-check/duplicate-entry-check.d.ts +150 -0
- package/dist/lib/duplicate-entry-check/duplicate-entry-check.d.ts.map +1 -0
- package/dist/lib/duplicate-entry-check/duplicate-entry-check.js +263 -0
- package/dist/lib/duplicate-entry-check/duplicate-entry-check.js.map +1 -0
- package/dist/lib/explorer-entity-data-grid.component.d.ts +18 -1
- package/dist/lib/explorer-entity-data-grid.component.d.ts.map +1 -1
- package/dist/lib/explorer-entity-data-grid.component.js +38 -10
- package/dist/lib/explorer-entity-data-grid.component.js.map +1 -1
- package/dist/lib/field/form-field.component.d.ts +42 -5
- package/dist/lib/field/form-field.component.d.ts.map +1 -1
- package/dist/lib/field/form-field.component.js +118 -23
- package/dist/lib/field/form-field.component.js.map +1 -1
- package/dist/lib/form-field-edit.coordinator.d.ts +25 -0
- package/dist/lib/form-field-edit.coordinator.d.ts.map +1 -0
- package/dist/lib/form-field-edit.coordinator.js +27 -0
- package/dist/lib/form-field-edit.coordinator.js.map +1 -0
- package/dist/lib/form-state.service.d.ts +58 -0
- package/dist/lib/form-state.service.d.ts.map +1 -1
- package/dist/lib/form-state.service.js +156 -40
- package/dist/lib/form-state.service.js.map +1 -1
- package/dist/lib/host/entity-form-host.component.d.ts +10 -2
- package/dist/lib/host/entity-form-host.component.d.ts.map +1 -1
- package/dist/lib/host/entity-form-host.component.js +24 -8
- package/dist/lib/host/entity-form-host.component.js.map +1 -1
- package/dist/lib/interactive-form/interactive-form.component.d.ts +16 -4
- package/dist/lib/interactive-form/interactive-form.component.d.ts.map +1 -1
- package/dist/lib/interactive-form/interactive-form.component.js +38 -12
- package/dist/lib/interactive-form/interactive-form.component.js.map +1 -1
- package/dist/lib/isa-related-panel/isa-related-card.component.d.ts +3 -3
- package/dist/lib/isa-related-panel/isa-related-card.component.js +6 -6
- package/dist/lib/isa-related-panel/isa-related-card.component.js.map +1 -1
- package/dist/lib/isa-related-panel/isa-related-panel.component.d.ts +3 -3
- package/dist/lib/isa-related-panel/isa-related-panel.component.js +8 -8
- package/dist/lib/isa-related-panel/isa-related-panel.component.js.map +1 -1
- package/dist/lib/overlays/form-slide-in.component.d.ts +2 -0
- package/dist/lib/overlays/form-slide-in.component.d.ts.map +1 -1
- package/dist/lib/overlays/form-slide-in.component.js +5 -1
- package/dist/lib/overlays/form-slide-in.component.js.map +1 -1
- package/dist/lib/panel/collapsible-panel.component.d.ts +9 -9
- package/dist/lib/panel/collapsible-panel.component.js +23 -23
- package/dist/lib/panel/collapsible-panel.component.js.map +1 -1
- package/dist/lib/panel-slot/base-form-panel.d.ts +2 -0
- package/dist/lib/panel-slot/base-form-panel.d.ts.map +1 -1
- package/dist/lib/panel-slot/base-form-panel.js +5 -1
- package/dist/lib/panel-slot/base-form-panel.js.map +1 -1
- package/dist/lib/panel-slot/form-contribution.d.ts +12 -0
- package/dist/lib/panel-slot/form-contribution.d.ts.map +1 -1
- package/dist/lib/panel-slot/form-contribution.js +43 -10
- package/dist/lib/panel-slot/form-contribution.js.map +1 -1
- package/dist/lib/panel-slot/form-slot-coordinator.service.d.ts +10 -0
- package/dist/lib/panel-slot/form-slot-coordinator.service.d.ts.map +1 -1
- package/dist/lib/panel-slot/form-slot-coordinator.service.js +25 -5
- package/dist/lib/panel-slot/form-slot-coordinator.service.js.map +1 -1
- package/dist/lib/panel-slot/related-entity-grid-panel.component.d.ts +2 -0
- package/dist/lib/panel-slot/related-entity-grid-panel.component.d.ts.map +1 -1
- package/dist/lib/panel-slot/related-entity-grid-panel.component.js +5 -1
- package/dist/lib/panel-slot/related-entity-grid-panel.component.js.map +1 -1
- package/dist/lib/section-loader-component.d.ts +5 -1
- package/dist/lib/section-loader-component.d.ts.map +1 -1
- package/dist/lib/section-loader-component.js +13 -5
- package/dist/lib/section-loader-component.js.map +1 -1
- package/dist/lib/section-manager/section-manager.component.d.ts +2 -2
- package/dist/lib/section-manager/section-manager.component.js +6 -6
- package/dist/lib/section-manager/section-manager.component.js.map +1 -1
- package/dist/lib/toolbar/form-toolbar.component.d.ts +127 -7
- package/dist/lib/toolbar/form-toolbar.component.d.ts.map +1 -1
- package/dist/lib/toolbar/form-toolbar.component.js +935 -334
- package/dist/lib/toolbar/form-toolbar.component.js.map +1 -1
- package/dist/lib/types/form-events.d.ts +6 -0
- package/dist/lib/types/form-events.d.ts.map +1 -1
- package/dist/lib/types/form-events.js +6 -0
- package/dist/lib/types/form-events.js.map +1 -1
- package/dist/lib/types/form-toolbar-item.d.ts +20 -1
- package/dist/lib/types/form-toolbar-item.d.ts.map +1 -1
- package/dist/lib/types/form-toolbar-item.js.map +1 -1
- package/dist/lib/types/form-types.d.ts +7 -0
- package/dist/lib/types/form-types.d.ts.map +1 -1
- package/dist/lib/types/form-types.js +5 -1
- package/dist/lib/types/form-types.js.map +1 -1
- package/dist/lib/types/toolbar-config.d.ts +16 -0
- package/dist/lib/types/toolbar-config.d.ts.map +1 -1
- package/dist/lib/types/toolbar-config.js +3 -0
- package/dist/lib/types/toolbar-config.js.map +1 -1
- package/dist/module.d.ts +2 -1
- package/dist/module.d.ts.map +1 -1
- package/dist/module.js +7 -3
- package/dist/module.js.map +1 -1
- package/dist/public-api.d.ts +2 -0
- package/dist/public-api.d.ts.map +1 -1
- package/dist/public-api.js +3 -0
- package/dist/public-api.js.map +1 -1
- package/package.json +20 -18
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { Observable } from 'rxjs';
|
|
2
|
+
import { BaseSingleton } from '@memberjunction/global';
|
|
3
|
+
import type { DuplicateEntryCandidate, DuplicateEntryCheckResult } from '@memberjunction/graphql-dataprovider';
|
|
4
|
+
/**
|
|
5
|
+
* How long the entry-time duplicate check waits after the last field edit before it asks the
|
|
6
|
+
* server, in milliseconds. A newer edit restarts the wait. Calibration will set it from measured
|
|
7
|
+
* typing pauses.
|
|
8
|
+
*/
|
|
9
|
+
export declare const DUPLICATE_ENTRY_CHECK_DEBOUNCE_MS = 600;
|
|
10
|
+
/**
|
|
11
|
+
* How long the form waits for one entry-time duplicate check, in milliseconds. A check that takes
|
|
12
|
+
* longer is abandoned and shows nothing, which is how the form behaves without the check.
|
|
13
|
+
* Calibration will set it from the check's measured p95.
|
|
14
|
+
*/
|
|
15
|
+
export declare const DUPLICATE_ENTRY_CHECK_BUDGET_MS = 1500;
|
|
16
|
+
/**
|
|
17
|
+
* How long one check may keep the form from starting another, in milliseconds. A form has at most
|
|
18
|
+
* one check in flight: edits made meanwhile wait for its answer, then run as one check on the latest
|
|
19
|
+
* values. The server stops a check at its own budget, a little above
|
|
20
|
+
* {@link DUPLICATE_ENTRY_CHECK_BUDGET_MS} (`DUPLICATE_ENTRY_CHECK_SERVER_BUDGET_MS` in
|
|
21
|
+
* `@memberjunction/ai-vector-dupe`, 2000 ms), so a check still unanswered at this point was lost in
|
|
22
|
+
* transport, and no longer holds the next one back.
|
|
23
|
+
*/
|
|
24
|
+
export declare const DUPLICATE_ENTRY_CHECK_IN_FLIGHT_LIMIT_MS = 3000;
|
|
25
|
+
/**
|
|
26
|
+
* The most characters of one field's text a check sends. Longer text is cut, which keeps the request
|
|
27
|
+
* under the server's size limit however long a note is. The server cuts to the same length before
|
|
28
|
+
* the text reaches the template or the decision model.
|
|
29
|
+
*/
|
|
30
|
+
export declare const DUPLICATE_ENTRY_CHECK_MAX_FIELD_TEXT_LENGTH = 500;
|
|
31
|
+
/** Asks the server whether the values being entered for a new record duplicate existing records. */
|
|
32
|
+
export type DuplicateEntryCheckFunction = (entityName: string, values: Record<string, DuplicateEntryCheckValue>) => Promise<DuplicateEntryCheckResult>;
|
|
33
|
+
/** One field of a record, as the entry-time check reads it. A `BaseEntity`'s `EntityField` satisfies it. */
|
|
34
|
+
export interface DuplicateEntryCheckField {
|
|
35
|
+
readonly Name: string;
|
|
36
|
+
/** The field's current value, of whatever type the field holds. */
|
|
37
|
+
readonly Value: unknown;
|
|
38
|
+
readonly EntityFieldInfo: {
|
|
39
|
+
readonly IsPrimaryKey: boolean;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/** The parts of a record the entry-time check reads. A `BaseEntity` satisfies it. */
|
|
43
|
+
export interface DuplicateEntryCheckRecord {
|
|
44
|
+
readonly IsSaved: boolean;
|
|
45
|
+
readonly EntityInfo: {
|
|
46
|
+
readonly Name: string;
|
|
47
|
+
};
|
|
48
|
+
readonly Fields: ReadonlyArray<DuplicateEntryCheckField>;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* The entities the entry-time check has stopped asking about this session: those that answered
|
|
52
|
+
* `NotConfigured` (no entity document turns the check on) or `NotAuthorized` (the user may not run
|
|
53
|
+
* it). Held in memory only: it resets when the app reloads and is never persisted.
|
|
54
|
+
*/
|
|
55
|
+
export declare class DuplicateEntryCheckSession extends BaseSingleton<DuplicateEntryCheckSession> {
|
|
56
|
+
private readonly stopped;
|
|
57
|
+
protected constructor();
|
|
58
|
+
/** The session-wide instance. */
|
|
59
|
+
static get Instance(): DuplicateEntryCheckSession;
|
|
60
|
+
/** Whether the check stopped asking about the entity earlier this session. */
|
|
61
|
+
IsStopped(entityName: string): boolean;
|
|
62
|
+
/** Stops the check for the entity, so no form asks about it again this session. */
|
|
63
|
+
Stop(entityName: string): void;
|
|
64
|
+
private keyOf;
|
|
65
|
+
}
|
|
66
|
+
/** The session state a controller reads and writes. {@link DuplicateEntryCheckSession} provides it. */
|
|
67
|
+
export type DuplicateEntryCheckSessionState = Pick<DuplicateEntryCheckSession, 'IsStopped' | 'Stop'>;
|
|
68
|
+
/** One value an entry-time check sends. */
|
|
69
|
+
export type DuplicateEntryCheckValue = string | number | boolean;
|
|
70
|
+
/**
|
|
71
|
+
* The values an entry-time check sends for a record: every field except primary keys and MJ system
|
|
72
|
+
* fields (`__mj_*`), and only those holding a value. Text is cut to
|
|
73
|
+
* {@link DUPLICATE_ENTRY_CHECK_MAX_FIELD_TEXT_LENGTH} characters and a date is sent as its ISO
|
|
74
|
+
* string; a value of any other kind is not sent, since the server accepts only scalars.
|
|
75
|
+
*/
|
|
76
|
+
export declare function DuplicateEntryCheckValues(record: DuplicateEntryCheckRecord): Record<string, DuplicateEntryCheckValue>;
|
|
77
|
+
/**
|
|
78
|
+
* Runs the entry-time duplicate check for one form and holds the candidates to flag. Framework-free,
|
|
79
|
+
* so the timing rules are testable without a DOM:
|
|
80
|
+
*
|
|
81
|
+
* - **New records only.** An edit to a saved record, or to an entity the check stopped asking about
|
|
82
|
+
* this session (it answered `NotConfigured` or `NotAuthorized`), starts nothing.
|
|
83
|
+
* - **Debounced.** A check starts {@link DUPLICATE_ENTRY_CHECK_DEBOUNCE_MS} after the last edit, on
|
|
84
|
+
* the record's values at that moment.
|
|
85
|
+
* - **One at a time.** A form has at most one check in flight. A check due meanwhile waits for it to
|
|
86
|
+
* answer (or for {@link DUPLICATE_ENTRY_CHECK_IN_FLIGHT_LIMIT_MS}), and however many edits came in
|
|
87
|
+
* between, runs once, on the latest values. Checks never pile up on the server.
|
|
88
|
+
* - **Within budget.** A check that has not answered within {@link DUPLICATE_ENTRY_CHECK_BUDGET_MS} is
|
|
89
|
+
* abandoned and shows nothing.
|
|
90
|
+
* - **Newest wins.** An answer to a check that newer edits have overtaken is never shown.
|
|
91
|
+
* - **Flag only.** It never blocks a save; once the record is saved the notice goes away.
|
|
92
|
+
*/
|
|
93
|
+
export declare class DuplicateEntryCheckController {
|
|
94
|
+
private readonly check;
|
|
95
|
+
private readonly session;
|
|
96
|
+
private readonly changed$;
|
|
97
|
+
/** Emits whenever the candidates or the notice's visibility change. */
|
|
98
|
+
readonly Changed$: Observable<void>;
|
|
99
|
+
private candidates;
|
|
100
|
+
private readonly dismissedIDs;
|
|
101
|
+
private debounceTimer;
|
|
102
|
+
/** Incremented by every check that starts, and by anything that must void the checks in flight. */
|
|
103
|
+
private sequence;
|
|
104
|
+
private disposed;
|
|
105
|
+
/** Whether a check is in flight, so the next one must wait. */
|
|
106
|
+
private inFlight;
|
|
107
|
+
/** The record of the check waiting for the one in flight, if any. */
|
|
108
|
+
private waiting;
|
|
109
|
+
/**
|
|
110
|
+
* @param check asks the server about the values being entered
|
|
111
|
+
* @param session where the entities the check stopped for are remembered; the session-wide
|
|
112
|
+
* instance by default
|
|
113
|
+
*/
|
|
114
|
+
constructor(check: DuplicateEntryCheckFunction, session?: DuplicateEntryCheckSessionState);
|
|
115
|
+
/** The flagged candidates from the latest answer, most probable first. */
|
|
116
|
+
get Candidates(): readonly DuplicateEntryCandidate[];
|
|
117
|
+
/** Whether the notice shows: some flagged candidate has not been dismissed. */
|
|
118
|
+
get IsNoticeVisible(): boolean;
|
|
119
|
+
/**
|
|
120
|
+
* A person edited a field of `record`. For a new record this restarts the debounce, after which
|
|
121
|
+
* the check runs on the record's values.
|
|
122
|
+
*/
|
|
123
|
+
RecordEdited(record: DuplicateEntryCheckRecord): void;
|
|
124
|
+
/** The record was saved: the notice goes away, and no pending or in-flight check brings it back. */
|
|
125
|
+
RecordSaved(): void;
|
|
126
|
+
/** The person dismissed the notice. It shows again only for a candidate they have not dismissed. */
|
|
127
|
+
Dismiss(): void;
|
|
128
|
+
/** Stops the debounce and ignores any answer still in flight. Call when the form is destroyed. */
|
|
129
|
+
Dispose(): void;
|
|
130
|
+
private canCheck;
|
|
131
|
+
private runCheck;
|
|
132
|
+
/** The check's answer. A rejected check is a failure, so the promise never rejects. */
|
|
133
|
+
private ask;
|
|
134
|
+
/**
|
|
135
|
+
* Marks a check in flight until it answers, or until {@link DUPLICATE_ENTRY_CHECK_IN_FLIGHT_LIMIT_MS}
|
|
136
|
+
* passes, then runs the check that waited for it, if any.
|
|
137
|
+
*/
|
|
138
|
+
private holdUntilAnswered;
|
|
139
|
+
private runWaiting;
|
|
140
|
+
/** The answer, or null when it did not come within the budget. */
|
|
141
|
+
private withinBudget;
|
|
142
|
+
/**
|
|
143
|
+
* Shows what an answer flags. Only `Checked` flags anything; `NotConfigured` and `NotAuthorized`
|
|
144
|
+
* stop later checks of the entity for the session.
|
|
145
|
+
*/
|
|
146
|
+
private apply;
|
|
147
|
+
private show;
|
|
148
|
+
private clearDebounce;
|
|
149
|
+
}
|
|
150
|
+
//# sourceMappingURL=duplicate-entry-check.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"duplicate-entry-check.d.ts","sourceRoot":"","sources":["../../../src/lib/duplicate-entry-check/duplicate-entry-check.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAW,MAAM,MAAM,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,KAAK,EAAE,uBAAuB,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AAE/G;;;;GAIG;AACH,eAAO,MAAM,iCAAiC,MAAM,CAAC;AAErD;;;;GAIG;AACH,eAAO,MAAM,+BAA+B,OAAO,CAAC;AAEpD;;;;;;;GAOG;AACH,eAAO,MAAM,wCAAwC,OAAO,CAAC;AAE7D;;;;GAIG;AACH,eAAO,MAAM,2CAA2C,MAAM,CAAC;AAE/D,oGAAoG;AACpG,MAAM,MAAM,2BAA2B,GAAG,CACtC,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,M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berjunction/global';
|
|
3
|
+
/**
|
|
4
|
+
* How long the entry-time duplicate check waits after the last field edit before it asks the
|
|
5
|
+
* server, in milliseconds. A newer edit restarts the wait. Calibration will set it from measured
|
|
6
|
+
* typing pauses.
|
|
7
|
+
*/
|
|
8
|
+
export const DUPLICATE_ENTRY_CHECK_DEBOUNCE_MS = 600;
|
|
9
|
+
/**
|
|
10
|
+
* How long the form waits for one entry-time duplicate check, in milliseconds. A check that takes
|
|
11
|
+
* longer is abandoned and shows nothing, which is how the form behaves without the check.
|
|
12
|
+
* Calibration will set it from the check's measured p95.
|
|
13
|
+
*/
|
|
14
|
+
export const DUPLICATE_ENTRY_CHECK_BUDGET_MS = 1500;
|
|
15
|
+
/**
|
|
16
|
+
* How long one check may keep the form from starting another, in milliseconds. A form has at most
|
|
17
|
+
* one check in flight: edits made meanwhile wait for its answer, then run as one check on the latest
|
|
18
|
+
* values. The server stops a check at its own budget, a little above
|
|
19
|
+
* {@link DUPLICATE_ENTRY_CHECK_BUDGET_MS} (`DUPLICATE_ENTRY_CHECK_SERVER_BUDGET_MS` in
|
|
20
|
+
* `@memberjunction/ai-vector-dupe`, 2000 ms), so a check still unanswered at this point was lost in
|
|
21
|
+
* transport, and no longer holds the next one back.
|
|
22
|
+
*/
|
|
23
|
+
export const DUPLICATE_ENTRY_CHECK_IN_FLIGHT_LIMIT_MS = 3000;
|
|
24
|
+
/**
|
|
25
|
+
* The most characters of one field's text a check sends. Longer text is cut, which keeps the request
|
|
26
|
+
* under the server's size limit however long a note is. The server cuts to the same length before
|
|
27
|
+
* the text reaches the template or the decision model.
|
|
28
|
+
*/
|
|
29
|
+
export const DUPLICATE_ENTRY_CHECK_MAX_FIELD_TEXT_LENGTH = 500;
|
|
30
|
+
/**
|
|
31
|
+
* The entities the entry-time check has stopped asking about this session: those that answered
|
|
32
|
+
* `NotConfigured` (no entity document turns the check on) or `NotAuthorized` (the user may not run
|
|
33
|
+
* it). Held in memory only: it resets when the app reloads and is never persisted.
|
|
34
|
+
*/
|
|
35
|
+
export class DuplicateEntryCheckSession extends BaseSingleton {
|
|
36
|
+
stopped = new Set();
|
|
37
|
+
constructor() {
|
|
38
|
+
super();
|
|
39
|
+
}
|
|
40
|
+
/** The session-wide instance. */
|
|
41
|
+
static get Instance() {
|
|
42
|
+
return super.getInstance();
|
|
43
|
+
}
|
|
44
|
+
/** Whether the check stopped asking about the entity earlier this session. */
|
|
45
|
+
IsStopped(entityName) {
|
|
46
|
+
return this.stopped.has(this.keyOf(entityName));
|
|
47
|
+
}
|
|
48
|
+
/** Stops the check for the entity, so no form asks about it again this session. */
|
|
49
|
+
Stop(entityName) {
|
|
50
|
+
this.stopped.add(this.keyOf(entityName));
|
|
51
|
+
}
|
|
52
|
+
keyOf(entityName) {
|
|
53
|
+
return entityName.trim().toLowerCase();
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* The values an entry-time check sends for a record: every field except primary keys and MJ system
|
|
58
|
+
* fields (`__mj_*`), and only those holding a value. Text is cut to
|
|
59
|
+
* {@link DUPLICATE_ENTRY_CHECK_MAX_FIELD_TEXT_LENGTH} characters and a date is sent as its ISO
|
|
60
|
+
* string; a value of any other kind is not sent, since the server accepts only scalars.
|
|
61
|
+
*/
|
|
62
|
+
export function DuplicateEntryCheckValues(record) {
|
|
63
|
+
const values = {};
|
|
64
|
+
for (const field of record.Fields) {
|
|
65
|
+
if (field.EntityFieldInfo.IsPrimaryKey || field.Name.startsWith('__mj_')) {
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
const value = toCheckValue(field.Value);
|
|
69
|
+
if (value !== null) {
|
|
70
|
+
values[field.Name] = value;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return values;
|
|
74
|
+
}
|
|
75
|
+
/** A field's value as a check sends it, or null when it sends none: empty, or not a scalar. */
|
|
76
|
+
function toCheckValue(value) {
|
|
77
|
+
if (typeof value === 'string') {
|
|
78
|
+
return value.trim().length === 0 ? null : value.slice(0, DUPLICATE_ENTRY_CHECK_MAX_FIELD_TEXT_LENGTH);
|
|
79
|
+
}
|
|
80
|
+
if (typeof value === 'number' || typeof value === 'boolean') {
|
|
81
|
+
return value;
|
|
82
|
+
}
|
|
83
|
+
if (value instanceof Date) {
|
|
84
|
+
return Number.isNaN(value.getTime()) ? null : value.toISOString();
|
|
85
|
+
}
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Runs the entry-time duplicate check for one form and holds the candidates to flag. Framework-free,
|
|
90
|
+
* so the timing rules are testable without a DOM:
|
|
91
|
+
*
|
|
92
|
+
* - **New records only.** An edit to a saved record, or to an entity the check stopped asking about
|
|
93
|
+
* this session (it answered `NotConfigured` or `NotAuthorized`), starts nothing.
|
|
94
|
+
* - **Debounced.** A check starts {@link DUPLICATE_ENTRY_CHECK_DEBOUNCE_MS} after the last edit, on
|
|
95
|
+
* the record's values at that moment.
|
|
96
|
+
* - **One at a time.** A form has at most one check in flight. A check due meanwhile waits for it to
|
|
97
|
+
* answer (or for {@link DUPLICATE_ENTRY_CHECK_IN_FLIGHT_LIMIT_MS}), and however many edits came in
|
|
98
|
+
* between, runs once, on the latest values. Checks never pile up on the server.
|
|
99
|
+
* - **Within budget.** A check that has not answered within {@link DUPLICATE_ENTRY_CHECK_BUDGET_MS} is
|
|
100
|
+
* abandoned and shows nothing.
|
|
101
|
+
* - **Newest wins.** An answer to a check that newer edits have overtaken is never shown.
|
|
102
|
+
* - **Flag only.** It never blocks a save; once the record is saved the notice goes away.
|
|
103
|
+
*/
|
|
104
|
+
export class DuplicateEntryCheckController {
|
|
105
|
+
check;
|
|
106
|
+
session;
|
|
107
|
+
changed$ = new Subject();
|
|
108
|
+
/** Emits whenever the candidates or the notice's visibility change. */
|
|
109
|
+
Changed$ = this.changed$.asObservable();
|
|
110
|
+
candidates = [];
|
|
111
|
+
dismissedIDs = new Set();
|
|
112
|
+
debounceTimer = null;
|
|
113
|
+
/** Incremented by every check that starts, and by anything that must void the checks in flight. */
|
|
114
|
+
sequence = 0;
|
|
115
|
+
disposed = false;
|
|
116
|
+
/** Whether a check is in flight, so the next one must wait. */
|
|
117
|
+
inFlight = false;
|
|
118
|
+
/** The record of the check waiting for the one in flight, if any. */
|
|
119
|
+
waiting = null;
|
|
120
|
+
/**
|
|
121
|
+
* @param check asks the server about the values being entered
|
|
122
|
+
* @param session where the entities the check stopped for are remembered; the session-wide
|
|
123
|
+
* instance by default
|
|
124
|
+
*/
|
|
125
|
+
constructor(check, session = DuplicateEntryCheckSession.Instance) {
|
|
126
|
+
this.check = check;
|
|
127
|
+
this.session = session;
|
|
128
|
+
}
|
|
129
|
+
/** The flagged candidates from the latest answer, most probable first. */
|
|
130
|
+
get Candidates() {
|
|
131
|
+
return this.candidates;
|
|
132
|
+
}
|
|
133
|
+
/** Whether the notice shows: some flagged candidate has not been dismissed. */
|
|
134
|
+
get IsNoticeVisible() {
|
|
135
|
+
return this.candidates.some(c => !this.dismissedIDs.has(c.RecordID));
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* A person edited a field of `record`. For a new record this restarts the debounce, after which
|
|
139
|
+
* the check runs on the record's values.
|
|
140
|
+
*/
|
|
141
|
+
RecordEdited(record) {
|
|
142
|
+
if (!this.canCheck(record)) {
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
this.clearDebounce();
|
|
146
|
+
this.debounceTimer = setTimeout(() => void this.runCheck(record), DUPLICATE_ENTRY_CHECK_DEBOUNCE_MS);
|
|
147
|
+
}
|
|
148
|
+
/** The record was saved: the notice goes away, and no pending or in-flight check brings it back. */
|
|
149
|
+
RecordSaved() {
|
|
150
|
+
this.sequence++;
|
|
151
|
+
this.waiting = null;
|
|
152
|
+
this.clearDebounce();
|
|
153
|
+
this.dismissedIDs.clear();
|
|
154
|
+
this.show([]);
|
|
155
|
+
}
|
|
156
|
+
/** The person dismissed the notice. It shows again only for a candidate they have not dismissed. */
|
|
157
|
+
Dismiss() {
|
|
158
|
+
this.candidates.forEach(c => this.dismissedIDs.add(c.RecordID));
|
|
159
|
+
this.changed$.next();
|
|
160
|
+
}
|
|
161
|
+
/** Stops the debounce and ignores any answer still in flight. Call when the form is destroyed. */
|
|
162
|
+
Dispose() {
|
|
163
|
+
this.disposed = true;
|
|
164
|
+
this.sequence++;
|
|
165
|
+
this.waiting = null;
|
|
166
|
+
this.clearDebounce();
|
|
167
|
+
this.changed$.complete();
|
|
168
|
+
}
|
|
169
|
+
canCheck(record) {
|
|
170
|
+
return !this.disposed && !record.IsSaved && !this.session.IsStopped(record.EntityInfo.Name);
|
|
171
|
+
}
|
|
172
|
+
async runCheck(record) {
|
|
173
|
+
this.debounceTimer = null;
|
|
174
|
+
if (!this.canCheck(record)) {
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
if (this.inFlight) {
|
|
178
|
+
// Wait for the check in flight; its answer is for older values, so it is void.
|
|
179
|
+
this.waiting = record;
|
|
180
|
+
this.sequence++;
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
const call = ++this.sequence;
|
|
184
|
+
const values = DuplicateEntryCheckValues(record);
|
|
185
|
+
if (Object.keys(values).length === 0) {
|
|
186
|
+
this.show([]);
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
const entityName = record.EntityInfo.Name;
|
|
190
|
+
const answered = this.ask(entityName, values);
|
|
191
|
+
this.holdUntilAnswered(answered);
|
|
192
|
+
const result = await this.withinBudget(answered);
|
|
193
|
+
if (call !== this.sequence || this.disposed || record.IsSaved) {
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
this.apply(entityName, result);
|
|
197
|
+
}
|
|
198
|
+
/** The check's answer. A rejected check is a failure, so the promise never rejects. */
|
|
199
|
+
ask(entityName, values) {
|
|
200
|
+
return this.check(entityName, values).catch((error) => ({
|
|
201
|
+
Status: 'Failed',
|
|
202
|
+
ErrorMessage: error instanceof Error ? error.message : String(error),
|
|
203
|
+
Candidates: [],
|
|
204
|
+
}));
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Marks a check in flight until it answers, or until {@link DUPLICATE_ENTRY_CHECK_IN_FLIGHT_LIMIT_MS}
|
|
208
|
+
* passes, then runs the check that waited for it, if any.
|
|
209
|
+
*/
|
|
210
|
+
holdUntilAnswered(answered) {
|
|
211
|
+
this.inFlight = true;
|
|
212
|
+
let limitTimer;
|
|
213
|
+
const limit = new Promise(resolve => {
|
|
214
|
+
limitTimer = setTimeout(resolve, DUPLICATE_ENTRY_CHECK_IN_FLIGHT_LIMIT_MS);
|
|
215
|
+
});
|
|
216
|
+
void Promise.race([answered, limit]).then(() => {
|
|
217
|
+
clearTimeout(limitTimer);
|
|
218
|
+
this.inFlight = false;
|
|
219
|
+
this.runWaiting();
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
runWaiting() {
|
|
223
|
+
const record = this.waiting;
|
|
224
|
+
this.waiting = null;
|
|
225
|
+
if (record) {
|
|
226
|
+
void this.runCheck(record);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
/** The answer, or null when it did not come within the budget. */
|
|
230
|
+
async withinBudget(answered) {
|
|
231
|
+
let budgetTimer;
|
|
232
|
+
const overBudget = new Promise(resolve => {
|
|
233
|
+
budgetTimer = setTimeout(() => resolve(null), DUPLICATE_ENTRY_CHECK_BUDGET_MS);
|
|
234
|
+
});
|
|
235
|
+
try {
|
|
236
|
+
return await Promise.race([answered, overBudget]);
|
|
237
|
+
}
|
|
238
|
+
finally {
|
|
239
|
+
clearTimeout(budgetTimer);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Shows what an answer flags. Only `Checked` flags anything; `NotConfigured` and `NotAuthorized`
|
|
244
|
+
* stop later checks of the entity for the session.
|
|
245
|
+
*/
|
|
246
|
+
apply(entityName, result) {
|
|
247
|
+
if (result?.Status === 'NotConfigured' || result?.Status === 'NotAuthorized') {
|
|
248
|
+
this.session.Stop(entityName);
|
|
249
|
+
}
|
|
250
|
+
this.show(result?.Status === 'Checked' ? result.Candidates : []);
|
|
251
|
+
}
|
|
252
|
+
show(candidates) {
|
|
253
|
+
this.candidates = candidates;
|
|
254
|
+
this.changed$.next();
|
|
255
|
+
}
|
|
256
|
+
clearDebounce() {
|
|
257
|
+
if (this.debounceTimer !== null) {
|
|
258
|
+
clearTimeout(this.debounceTimer);
|
|
259
|
+
this.debounceTimer = null;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
//# sourceMappingURL=duplicate-entry-check.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"duplicate-entry-check.js","sourceRoot":"","sources":["../../../src/lib/duplicate-entry-check/duplicate-entry-check.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,OAAO,EAAE,MAAM,MAAM,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAGvD;;;;GAIG;AACH,MAAM,CAAC,MAAM,iCAAiC,GAAG,GAAG,CAAC;AAErD;;;;GAIG;AACH,MAAM,CAAC,MAAM,+BAA+B,GAAG,IAAI,CAAC;AAEpD;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,wCAAwC,GAAG,IAAI,CAAC;AAE7D;;;;GAIG;AACH,MAAM,CAAC,MAAM,2CAA2C,GAAG,GAAG,CAAC;AAuB/D;;;;GAIG;AACH,MAAM,OAAO,0BAA2B,SAAQ,aAAyC;IACpE,OAAO,GAAG,IAAI,GAAG,EAAU,CAAC;IAE7C;QACI,KAAK,EAAE,CAAC;IACZ,CAAC;IAED,iCAAiC;IAC1B,MAAM,KAAK,QAAQ;QACtB,OAAO,KAAK,CAAC,WAAW,EAA8B,CAAC;IAC3D,CAAC;IAED,8EAA8E;IACvE,SAAS,CAAC,UAAkB;QAC/B,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC;IACpD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,MAAM,EAAE,MAAM,KAAK,eAAe,IAAI,MAAM,EAAE,MAAM,KAAK,eAAe,EAAE,CAAC;YAC3E,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAClC,CAAC;QACD,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IACrE,CAAC;IAEO,IAAI,CAAC,UAAqC;QAC9C,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;IACzB,CAAC;IAEO,aAAa;QACjB,IAAI,IAAI,CAAC,aAAa,KAAK,IAAI,EAAE,CAAC;YAC9B,YAAY,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;YACjC,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;QAC9B,CAAC;IACL,CAAC;CACJ","sourcesContent":["import { Observable, Subject } from 'rxjs';\nimport { BaseSingleton } from '@memberjunction/global';\nimport type { DuplicateEntryCandidate, DuplicateEntryCheckResult } from '@memberjunction/graphql-dataprovider';\n\n/**\n * How long the entry-time duplicate check waits after the last field edit before it asks the\n * server, in milliseconds. A newer edit restarts the wait. Calibration will set it from measured\n * typing pauses.\n */\nexport const DUPLICATE_ENTRY_CHECK_DEBOUNCE_MS = 600;\n\n/**\n * How long the form waits for one entry-time duplicate check, in milliseconds. A check that takes\n * longer is abandoned and shows nothing, which is how the form behaves without the check.\n * Calibration will set it from the check's measured p95.\n */\nexport const DUPLICATE_ENTRY_CHECK_BUDGET_MS = 1500;\n\n/**\n * How long one check may keep the form from starting another, in milliseconds. A form has at most\n * one check in flight: edits made meanwhile wait for its answer, then run as one check on the latest\n * values. The server stops a check at its own budget, a little above\n * {@link DUPLICATE_ENTRY_CHECK_BUDGET_MS} (`DUPLICATE_ENTRY_CHECK_SERVER_BUDGET_MS` in\n * `@memberjunction/ai-vector-dupe`, 2000 ms), so a check still unanswered at this point was lost in\n * transport, and no longer holds the next one back.\n */\nexport const DUPLICATE_ENTRY_CHECK_IN_FLIGHT_LIMIT_MS = 3000;\n\n/**\n * The most characters of one field's text a check sends. Longer text is cut, which keeps the request\n * under the server's size limit however long a note is. The server cuts to the same length before\n * the text reaches the template or the decision model.\n */\nexport const DUPLICATE_ENTRY_CHECK_MAX_FIELD_TEXT_LENGTH = 500;\n\n/** Asks the server whether the values being entered for a new record duplicate existing records. */\nexport type DuplicateEntryCheckFunction = (\n entityName: string,\n values: Record<string, DuplicateEntryCheckValue>\n) => Promise<DuplicateEntryCheckResult>;\n\n/** One field of a record, as the entry-time check reads it. A `BaseEntity`'s `EntityField` satisfies it. */\nexport interface DuplicateEntryCheckField {\n readonly Name: string;\n /** The field's current value, of whatever type the field holds. */\n readonly Value: unknown;\n readonly EntityFieldInfo: { readonly IsPrimaryKey: boolean };\n}\n\n/** The parts of a record the entry-time check reads. A `BaseEntity` satisfies it. */\nexport interface DuplicateEntryCheckRecord {\n readonly IsSaved: boolean;\n readonly EntityInfo: { readonly Name: string };\n readonly Fields: ReadonlyArray<DuplicateEntryCheckField>;\n}\n\n/**\n * The entities the entry-time check has stopped asking about this session: those that answered\n * `NotConfigured` (no entity document turns the check on) or `NotAuthorized` (the user may not run\n * it). Held in memory only: it resets when the app reloads and is never persisted.\n */\nexport class DuplicateEntryCheckSession extends BaseSingleton<DuplicateEntryCheckSession> {\n private readonly stopped = new Set<string>();\n\n protected constructor() {\n super();\n }\n\n /** The session-wide instance. */\n public static get Instance(): DuplicateEntryCheckSession {\n return super.getInstance<DuplicateEntryCheckSession>();\n }\n\n /** Whether the check stopped asking about the entity earlier this session. */\n public IsStopped(entityName: string): boolean {\n return this.stopped.has(this.keyOf(entityName));\n }\n\n /** Stops the check for the entity, so no form asks about it again this session. */\n public Stop(entityName: string): void {\n this.stopped.add(this.keyOf(entityName));\n }\n\n private keyOf(entityName: string): string {\n return entityName.trim().toLowerCase();\n }\n}\n\n/** The session state a controller reads and writes. {@link DuplicateEntryCheckSession} provides it. */\nexport type DuplicateEntryCheckSessionState = Pick<DuplicateEntryCheckSession, 'IsStopped' | 'Stop'>;\n\n/** One value an entry-time check sends. */\nexport type DuplicateEntryCheckValue = string | number | boolean;\n\n/**\n * The values an entry-time check sends for a record: every field except primary keys and MJ system\n * fields (`__mj_*`), and only those holding a value. Text is cut to\n * {@link DUPLICATE_ENTRY_CHECK_MAX_FIELD_TEXT_LENGTH} characters and a date is sent as its ISO\n * string; a value of any other kind is not sent, since the server accepts only scalars.\n */\nexport function DuplicateEntryCheckValues(record: DuplicateEntryCheckRecord): Record<string, DuplicateEntryCheckValue> {\n const values: Record<string, DuplicateEntryCheckValue> = {};\n for (const field of record.Fields) {\n if (field.EntityFieldInfo.IsPrimaryKey || field.Name.startsWith('__mj_')) {\n continue;\n }\n const value = toCheckValue(field.Value);\n if (value !== null) {\n values[field.Name] = value;\n }\n }\n return values;\n}\n\n/** A field's value as a check sends it, or null when it sends none: empty, or not a scalar. */\nfunction toCheckValue(value: unknown): DuplicateEntryCheckValue | null {\n if (typeof value === 'string') {\n return value.trim().length === 0 ? null : value.slice(0, DUPLICATE_ENTRY_CHECK_MAX_FIELD_TEXT_LENGTH);\n }\n if (typeof value === 'number' || typeof value === 'boolean') {\n return value;\n }\n if (value instanceof Date) {\n return Number.isNaN(value.getTime()) ? null : value.toISOString();\n }\n return null;\n}\n\n/**\n * Runs the entry-time duplicate check for one form and holds the candidates to flag. Framework-free,\n * so the timing rules are testable without a DOM:\n *\n * - **New records only.** An edit to a saved record, or to an entity the check stopped asking about\n * this session (it answered `NotConfigured` or `NotAuthorized`), starts nothing.\n * - **Debounced.** A check starts {@link DUPLICATE_ENTRY_CHECK_DEBOUNCE_MS} after the last edit, on\n * the record's values at that moment.\n * - **One at a time.** A form has at most one check in flight. A check due meanwhile waits for it to\n * answer (or for {@link DUPLICATE_ENTRY_CHECK_IN_FLIGHT_LIMIT_MS}), and however many edits came in\n * between, runs once, on the latest values. Checks never pile up on the server.\n * - **Within budget.** A check that has not answered within {@link DUPLICATE_ENTRY_CHECK_BUDGET_MS} is\n * abandoned and shows nothing.\n * - **Newest wins.** An answer to a check that newer edits have overtaken is never shown.\n * - **Flag only.** It never blocks a save; once the record is saved the notice goes away.\n */\nexport class DuplicateEntryCheckController {\n private readonly changed$ = new Subject<void>();\n\n /** Emits whenever the candidates or the notice's visibility change. */\n public readonly Changed$: Observable<void> = this.changed$.asObservable();\n\n private candidates: DuplicateEntryCandidate[] = [];\n private readonly dismissedIDs = new Set<string>();\n private debounceTimer: ReturnType<typeof setTimeout> | null = null;\n /** Incremented by every check that starts, and by anything that must void the checks in flight. */\n private sequence = 0;\n private disposed = false;\n /** Whether a check is in flight, so the next one must wait. */\n private inFlight = false;\n /** The record of the check waiting for the one in flight, if any. */\n private waiting: DuplicateEntryCheckRecord | null = null;\n\n /**\n * @param check asks the server about the values being entered\n * @param session where the entities the check stopped for are remembered; the session-wide\n * instance by default\n */\n constructor(\n private readonly check: DuplicateEntryCheckFunction,\n private readonly session: DuplicateEntryCheckSessionState = DuplicateEntryCheckSession.Instance\n ) {}\n\n /** The flagged candidates from the latest answer, most probable first. */\n public get Candidates(): readonly DuplicateEntryCandidate[] {\n return this.candidates;\n }\n\n /** Whether the notice shows: some flagged candidate has not been dismissed. */\n public get IsNoticeVisible(): boolean {\n return this.candidates.some(c => !this.dismissedIDs.has(c.RecordID));\n }\n\n /**\n * A person edited a field of `record`. For a new record this restarts the debounce, after which\n * the check runs on the record's values.\n */\n public RecordEdited(record: DuplicateEntryCheckRecord): void {\n if (!this.canCheck(record)) {\n return;\n }\n this.clearDebounce();\n this.debounceTimer = setTimeout(() => void this.runCheck(record), DUPLICATE_ENTRY_CHECK_DEBOUNCE_MS);\n }\n\n /** The record was saved: the notice goes away, and no pending or in-flight check brings it back. */\n public RecordSaved(): void {\n this.sequence++;\n this.waiting = null;\n this.clearDebounce();\n this.dismissedIDs.clear();\n this.show([]);\n }\n\n /** The person dismissed the notice. It shows again only for a candidate they have not dismissed. */\n public Dismiss(): void {\n this.candidates.forEach(c => this.dismissedIDs.add(c.RecordID));\n this.changed$.next();\n }\n\n /** Stops the debounce and ignores any answer still in flight. Call when the form is destroyed. */\n public Dispose(): void {\n this.disposed = true;\n this.sequence++;\n this.waiting = null;\n this.clearDebounce();\n this.changed$.complete();\n }\n\n private canCheck(record: DuplicateEntryCheckRecord): boolean {\n return !this.disposed && !record.IsSaved && !this.session.IsStopped(record.EntityInfo.Name);\n }\n\n private async runCheck(record: DuplicateEntryCheckRecord): Promise<void> {\n this.debounceTimer = null;\n if (!this.canCheck(record)) {\n return;\n }\n if (this.inFlight) {\n // Wait for the check in flight; its answer is for older values, so it is void.\n this.waiting = record;\n this.sequence++;\n return;\n }\n const call = ++this.sequence;\n const values = DuplicateEntryCheckValues(record);\n if (Object.keys(values).length === 0) {\n this.show([]);\n return;\n }\n const entityName = record.EntityInfo.Name;\n const answered = this.ask(entityName, values);\n this.holdUntilAnswered(answered);\n const result = await this.withinBudget(answered);\n if (call !== this.sequence || this.disposed || record.IsSaved) {\n return;\n }\n this.apply(entityName, result);\n }\n\n /** The check's answer. A rejected check is a failure, so the promise never rejects. */\n private ask(entityName: string, values: Record<string, DuplicateEntryCheckValue>): Promise<DuplicateEntryCheckResult> {\n return this.check(entityName, values).catch((error: unknown): DuplicateEntryCheckResult => ({\n Status: 'Failed',\n ErrorMessage: error instanceof Error ? error.message : String(error),\n Candidates: [],\n }));\n }\n\n /**\n * Marks a check in flight until it answers, or until {@link DUPLICATE_ENTRY_CHECK_IN_FLIGHT_LIMIT_MS}\n * passes, then runs the check that waited for it, if any.\n */\n private holdUntilAnswered(answered: Promise<DuplicateEntryCheckResult>): void {\n this.inFlight = true;\n let limitTimer: ReturnType<typeof setTimeout> | undefined;\n const limit = new Promise<void>(resolve => {\n limitTimer = setTimeout(resolve, DUPLICATE_ENTRY_CHECK_IN_FLIGHT_LIMIT_MS);\n });\n void Promise.race([answered, limit]).then(() => {\n clearTimeout(limitTimer);\n this.inFlight = false;\n this.runWaiting();\n });\n }\n\n private runWaiting(): void {\n const record = this.waiting;\n this.waiting = null;\n if (record) {\n void this.runCheck(record);\n }\n }\n\n /** The answer, or null when it did not come within the budget. */\n private async withinBudget(answered: Promise<DuplicateEntryCheckResult>): Promise<DuplicateEntryCheckResult | null> {\n let budgetTimer: ReturnType<typeof setTimeout> | undefined;\n const overBudget = new Promise<null>(resolve => {\n budgetTimer = setTimeout(() => resolve(null), DUPLICATE_ENTRY_CHECK_BUDGET_MS);\n });\n try {\n return await Promise.race([answered, overBudget]);\n } finally {\n clearTimeout(budgetTimer);\n }\n }\n\n /**\n * Shows what an answer flags. Only `Checked` flags anything; `NotConfigured` and `NotAuthorized`\n * stop later checks of the entity for the session.\n */\n private apply(entityName: string, result: DuplicateEntryCheckResult | null): void {\n if (result?.Status === 'NotConfigured' || result?.Status === 'NotAuthorized') {\n this.session.Stop(entityName);\n }\n this.show(result?.Status === 'Checked' ? result.Candidates : []);\n }\n\n private show(candidates: DuplicateEntryCandidate[]): void {\n this.candidates = candidates;\n this.changed$.next();\n }\n\n private clearDebounce(): void {\n if (this.debounceTimer !== null) {\n clearTimeout(this.debounceTimer);\n this.debounceTimer = null;\n }\n }\n}\n"]}
|
|
@@ -11,7 +11,11 @@ import * as i0 from "@angular/core";
|
|
|
11
11
|
* This component is used by CodeGen for related entity grids in forms.
|
|
12
12
|
*/
|
|
13
13
|
export declare class ExplorerEntityDataGridComponent implements AfterViewInit, OnDestroy {
|
|
14
|
-
|
|
14
|
+
InnerGrid: EntityDataGridComponent;
|
|
15
|
+
/** @deprecated Use {@link InnerGrid}. */
|
|
16
|
+
get innerGrid(): EntityDataGridComponent;
|
|
17
|
+
/** @deprecated Use {@link InnerGrid}. */
|
|
18
|
+
set innerGrid(value: EntityDataGridComponent);
|
|
15
19
|
private elementRef;
|
|
16
20
|
private cdr;
|
|
17
21
|
private ngZone;
|
|
@@ -80,6 +84,8 @@ export declare class ExplorerEntityDataGridComponent implements AfterViewInit, O
|
|
|
80
84
|
private _scrollbarMeasureFrame;
|
|
81
85
|
private _destroyed;
|
|
82
86
|
get ResolvedHeight(): number | 'auto' | 'fit-content';
|
|
87
|
+
get HostHeightStyle(): string;
|
|
88
|
+
/** @deprecated Use {@link HostHeightStyle}. */
|
|
83
89
|
get hostHeightStyle(): string;
|
|
84
90
|
private shouldSizeToRows;
|
|
85
91
|
/**
|
|
@@ -133,8 +139,14 @@ export declare class ExplorerEntityDataGridComponent implements AfterViewInit, O
|
|
|
133
139
|
}>;
|
|
134
140
|
/** Emitted when a row is double-clicked and NavigateOnDoubleClick is true */
|
|
135
141
|
Navigate: EventEmitter<FormNavigationEvent>;
|
|
142
|
+
OnRowDoubleClick(event: AfterRowDoubleClickEventArgs): void;
|
|
143
|
+
/** @deprecated Use {@link OnRowDoubleClick}. */
|
|
136
144
|
onRowDoubleClick(event: AfterRowDoubleClickEventArgs): void;
|
|
145
|
+
OnRowClick(event: AfterRowClickEventArgs): void;
|
|
146
|
+
/** @deprecated Use {@link OnRowClick}. */
|
|
137
147
|
onRowClick(event: AfterRowClickEventArgs): void;
|
|
148
|
+
OnDataLoad(event: AfterDataLoadEventArgs): void;
|
|
149
|
+
/** @deprecated Use {@link OnDataLoad}. */
|
|
138
150
|
onDataLoad(event: AfterDataLoadEventArgs): void;
|
|
139
151
|
private applySizedHeight;
|
|
140
152
|
/**
|
|
@@ -164,6 +176,11 @@ export declare class ExplorerEntityDataGridComponent implements AfterViewInit, O
|
|
|
164
176
|
* SingleRecordComponent) can call NavigationService.OpenNewEntityRecord
|
|
165
177
|
* and pre-populate the foreign-key fields from NewRecordValues.
|
|
166
178
|
*/
|
|
179
|
+
OnNewRecordTabRequested(event: {
|
|
180
|
+
entityInfo: EntityInfo;
|
|
181
|
+
defaultValues: Record<string, unknown>;
|
|
182
|
+
}): void;
|
|
183
|
+
/** @deprecated Use {@link OnNewRecordTabRequested}. */
|
|
167
184
|
onNewRecordTabRequested(event: {
|
|
168
185
|
entityInfo: EntityInfo;
|
|
169
186
|
defaultValues: Record<string, unknown>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"explorer-entity-data-grid.component.d.ts","sourceRoot":"","sources":["../../src/lib/explorer-entity-data-grid.component.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,YAAY,EAAoD,aAAa,EAAE,SAAS,EAAU,MAAM,eAAe,CAAC;AAG3J,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD,OAAO,EACH,uBAAuB,EACvB,4BAA4B,EAC5B,sBAAsB,EACtB,sBAAsB,EACtB,iBAAiB,EACjB,iBAAiB,EAEpB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;;AAGhE;;;;;GAKG;AACH,qBA6Ca,+BAAgC,YAAW,aAAa,EAAE,SAAS;IACpD,SAAS,EAAG,uBAAuB,CAAC;IAE5D,OAAO,CAAC,UAAU,CAAsB;IACxC,OAAO,CAAC,GAAG,CAA6B;IACxC,OAAO,CAAC,MAAM,CAAkB;IAChC,OAAO,CAAC,aAAa,CAA4D;IACjF,OAAO,CAAC,QAAQ,CAAuB;IAG9B,MAAM,EAAE,aAAa,GAAG,IAAI,CAAQ;IACpC,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAM;IAC9C,SAAS,EAAE,OAAO,CAAQ;IAC1B,WAAW,EAAE,OAAO,CAAQ;IAErC;;;;OAIG;IACH,IAAI,oBAAoB,IAAI,OAAO,CAGlC;IAED;;;;OAIG;IACH,OAAO,CAAC,0BAA0B;IAIlC,OAAO,CAAC,sBAAsB;IAW9B,2DAA2D;IAClD,UAAU,EAAE,OAAO,CAAQ;IACpC,2EAA2E;IAClE,aAAa,EAAE,OAAO,CAAQ;IAC9B,iBAAiB,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G;IACM,qBAAqB,EAAE,OAAO,CAAQ;IAGrC,mBAAmB,6CAAoD;IACvE,aAAa,uCAA8C;IAC3D,aAAa,uCAA8C;IAErE;;;;OAIG;IACO,qBAAqB;oBAAkC,UAAU;iBAAW,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE;OAAM;IAErH,6EAA6E;IACnE,QAAQ,oCAA2C;IAE7D,gBAAgB,CAAC,KAAK,EAAE,4BAA4B,GAAG,IAAI;IAoB3D,UAAU,CAAC,KAAK,EAAE,sBAAsB,GAAG,IAAI;IAK/C,UAAU,CAAC,KAAK,EAAE,sBAAsB,GAAG,IAAI;IAgB/C,OAAO,CAAC,gBAAgB;IAIxB;;;;OAIG;IACH,OAAO,CAAC,wBAAwB;IAUhC;;;OAGG;IACH,OAAO,CAAC,wBAAwB;IAqBhC,OAAO,CAAC,yBAAyB;IAiBjC;;;;;;;OAOG;IACH,OAAO,CAAC,4BAA4B;IAiBpC;;;;;OAKG;IACH,uBAAuB,CAAC,KAAK,EAAE;QAAE,UAAU,EAAE,UAAU,CAAC;QAAC,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,GAAG,IAAI;
|
|
1
|
+
{"version":3,"file":"explorer-entity-data-grid.component.d.ts","sourceRoot":"","sources":["../../src/lib/explorer-entity-data-grid.component.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,YAAY,EAAoD,aAAa,EAAE,SAAS,EAAU,MAAM,eAAe,CAAC;AAG3J,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD,OAAO,EACH,uBAAuB,EACvB,4BAA4B,EAC5B,sBAAsB,EACtB,sBAAsB,EACtB,iBAAiB,EACjB,iBAAiB,EAEpB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;;AAGhE;;;;;GAKG;AACH,qB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C,UAAU,CAAC,KAAK,EAAE,sBAAsB,GAAG,IAAI;IAI/C,UAAU,CAAC,KAAK,EAAE,sBAAsB,GAAG,IAAI;IAgB/C,0CAA0C;IAC1C,UAAU,CAAC,KAAK,EAAE,sBAAsB,GAAG,IAAI;IAI/C,OAAO,CAAC,gBAAgB;IAIxB;;;;OAIG;IACH,OAAO,CAAC,wBAAwB;IAUhC;;;OAGG;IACH,OAAO,CAAC,wBAAwB;IAqBhC,OAAO,CAAC,yBAAyB;IAiBjC;;;;;;;OAOG;IACH,OAAO,CAAC,4BAA4B;IAiBpC;;;;;OAKG;IACH,uBAAuB,CAAC,KAAK,EAAE;QAAE,UAAU,EAAE,UAAU,CAAC;QAAC,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,GAAG,IAAI;IAQxG,uDAAuD;IACvD,uBAAuB,CAAC,KAAK,EAAE;QAAE,UAAU,EAAE,UAAU,CAAC;QAAC,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,GAAG,IAAI;yCA7Y/F,+BAA+B;2CAA/B,+BAA+B;CAgZ3C"}
|
|
@@ -14,7 +14,15 @@ const _c0 = ["innerGrid"];
|
|
|
14
14
|
* This component is used by CodeGen for related entity grids in forms.
|
|
15
15
|
*/
|
|
16
16
|
export class ExplorerEntityDataGridComponent {
|
|
17
|
-
|
|
17
|
+
InnerGrid;
|
|
18
|
+
/** @deprecated Use {@link InnerGrid}. */
|
|
19
|
+
get innerGrid() {
|
|
20
|
+
return this.InnerGrid;
|
|
21
|
+
}
|
|
22
|
+
/** @deprecated Use {@link InnerGrid}. */
|
|
23
|
+
set innerGrid(value) {
|
|
24
|
+
this.InnerGrid = value;
|
|
25
|
+
}
|
|
18
26
|
elementRef = inject(ElementRef);
|
|
19
27
|
cdr = inject(ChangeDetectorRef);
|
|
20
28
|
ngZone = inject(NgZone);
|
|
@@ -102,9 +110,13 @@ export class ExplorerEntityDataGridComponent {
|
|
|
102
110
|
get ResolvedHeight() {
|
|
103
111
|
return this.shouldSizeToRows() ? this.sizedHeightPx : this.Height;
|
|
104
112
|
}
|
|
105
|
-
get
|
|
113
|
+
get HostHeightStyle() {
|
|
106
114
|
return this.shouldSizeToRows() ? `${this.sizedHeightPx}px` : '100%';
|
|
107
115
|
}
|
|
116
|
+
/** @deprecated Use {@link HostHeightStyle}. */
|
|
117
|
+
get hostHeightStyle() {
|
|
118
|
+
return this.HostHeightStyle;
|
|
119
|
+
}
|
|
108
120
|
shouldSizeToRows() {
|
|
109
121
|
return this.Height === 'fit-content' || this.isInsideRelatedEntityPanel();
|
|
110
122
|
}
|
|
@@ -167,7 +179,7 @@ export class ExplorerEntityDataGridComponent {
|
|
|
167
179
|
* button and by the parent-form refresh broadcast.
|
|
168
180
|
*/
|
|
169
181
|
async Refresh() {
|
|
170
|
-
await this.
|
|
182
|
+
await this.InnerGrid?.Refresh();
|
|
171
183
|
}
|
|
172
184
|
subscribeToFormRefresh() {
|
|
173
185
|
this.recordRefresh?.Refreshed$.pipe(takeUntil(this.destroy$)).subscribe(() => {
|
|
@@ -214,13 +226,13 @@ export class ExplorerEntityDataGridComponent {
|
|
|
214
226
|
MergeRecordsRequested = new EventEmitter();
|
|
215
227
|
/** Emitted when a row is double-clicked and NavigateOnDoubleClick is true */
|
|
216
228
|
Navigate = new EventEmitter();
|
|
217
|
-
|
|
229
|
+
OnRowDoubleClick(event) {
|
|
218
230
|
// Re-emit the event for any consumers
|
|
219
231
|
this.AfterRowDoubleClick.emit(event);
|
|
220
232
|
// Emit navigation event if enabled
|
|
221
233
|
if (this.NavigateOnDoubleClick && event.row) {
|
|
222
234
|
// Use the inner grid's resolved EntityInfo - works for both ViewID and EntityName params
|
|
223
|
-
const entityInfo = this.
|
|
235
|
+
const entityInfo = this.InnerGrid?.EntityInfo;
|
|
224
236
|
if (!entityInfo)
|
|
225
237
|
return;
|
|
226
238
|
const pkey = buildCompositeKey(event.row, entityInfo);
|
|
@@ -231,11 +243,19 @@ export class ExplorerEntityDataGridComponent {
|
|
|
231
243
|
});
|
|
232
244
|
}
|
|
233
245
|
}
|
|
234
|
-
|
|
246
|
+
/** @deprecated Use {@link OnRowDoubleClick}. */
|
|
247
|
+
onRowDoubleClick(event) {
|
|
248
|
+
return this.OnRowDoubleClick(event);
|
|
249
|
+
}
|
|
250
|
+
OnRowClick(event) {
|
|
235
251
|
// Re-emit the event for any consumers
|
|
236
252
|
this.AfterRowClick.emit(event);
|
|
237
253
|
}
|
|
238
|
-
|
|
254
|
+
/** @deprecated Use {@link OnRowClick}. */
|
|
255
|
+
onRowClick(event) {
|
|
256
|
+
return this.OnRowClick(event);
|
|
257
|
+
}
|
|
258
|
+
OnDataLoad(event) {
|
|
239
259
|
this.AfterDataLoad.emit(event);
|
|
240
260
|
if (!this.shouldSizeToRows()) {
|
|
241
261
|
return;
|
|
@@ -250,6 +270,10 @@ export class ExplorerEntityDataGridComponent {
|
|
|
250
270
|
// rows/columns out, so the measurement has to follow the load, not accompany it.
|
|
251
271
|
this.scheduleScrollbarMeasure();
|
|
252
272
|
}
|
|
273
|
+
/** @deprecated Use {@link OnDataLoad}. */
|
|
274
|
+
onDataLoad(event) {
|
|
275
|
+
return this.OnDataLoad(event);
|
|
276
|
+
}
|
|
253
277
|
applySizedHeight() {
|
|
254
278
|
this.sizedHeightPx = RelatedGridHeightPx(this.sizedRowCount, this.MaxHeight, this.scrollbarPx);
|
|
255
279
|
}
|
|
@@ -337,19 +361,23 @@ export class ExplorerEntityDataGridComponent {
|
|
|
337
361
|
* SingleRecordComponent) can call NavigationService.OpenNewEntityRecord
|
|
338
362
|
* and pre-populate the foreign-key fields from NewRecordValues.
|
|
339
363
|
*/
|
|
340
|
-
|
|
364
|
+
OnNewRecordTabRequested(event) {
|
|
341
365
|
this.Navigate.emit({
|
|
342
366
|
Kind: 'new-record',
|
|
343
367
|
EntityName: event.entityInfo.Name,
|
|
344
368
|
DefaultValues: event.defaultValues,
|
|
345
369
|
});
|
|
346
370
|
}
|
|
371
|
+
/** @deprecated Use {@link OnNewRecordTabRequested}. */
|
|
372
|
+
onNewRecordTabRequested(event) {
|
|
373
|
+
return this.OnNewRecordTabRequested(event);
|
|
374
|
+
}
|
|
347
375
|
static ɵfac = function ExplorerEntityDataGridComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || ExplorerEntityDataGridComponent)(); };
|
|
348
376
|
static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: ExplorerEntityDataGridComponent, selectors: [["mj-explorer-entity-data-grid"]], viewQuery: function ExplorerEntityDataGridComponent_Query(rf, ctx) { if (rf & 1) {
|
|
349
377
|
i0.ɵɵviewQuery(_c0, 5);
|
|
350
378
|
} if (rf & 2) {
|
|
351
379
|
let _t;
|
|
352
|
-
i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.
|
|
380
|
+
i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.InnerGrid = _t.first);
|
|
353
381
|
} }, hostVars: 2, hostBindings: function ExplorerEntityDataGridComponent_HostBindings(rf, ctx) { if (rf & 2) {
|
|
354
382
|
i0.ɵɵstyleProp("height", ctx.hostHeightStyle);
|
|
355
383
|
} }, inputs: { Params: "Params", NewRecordValues: "NewRecordValues", AllowLoad: "AllowLoad", ShowToolbar: "ShowToolbar", ShowSearch: "ShowSearch", ShowNewButton: "ShowNewButton", ShowRefreshButton: "ShowRefreshButton", ShowExportButton: "ShowExportButton", ShowDeleteButton: "ShowDeleteButton", ShowCompareButton: "ShowCompareButton", ShowMergeButton: "ShowMergeButton", ShowAddToListButton: "ShowAddToListButton", ShowDuplicateSearchButton: "ShowDuplicateSearchButton", ShowCommunicationButton: "ShowCommunicationButton", ShowRecycleBin: "ShowRecycleBin", Height: "Height", MaxHeight: "MaxHeight", ToolbarConfig: "ToolbarConfig", SelectionMode: "SelectionMode", DeferLoadUntilVisible: "DeferLoadUntilVisible", NavigateOnDoubleClick: "NavigateOnDoubleClick" }, outputs: { AfterRowDoubleClick: "AfterRowDoubleClick", AfterRowClick: "AfterRowClick", AfterDataLoad: "AfterDataLoad", MergeRecordsRequested: "MergeRecordsRequested", Navigate: "Navigate" }, standalone: false, decls: 2, vars: 19, consts: [["innerGrid", ""], [3, "AfterRowDoubleClick", "AfterRowClick", "AfterDataLoad", "MergeRecordsRequested", "NewRecordTabRequested", "Params", "NewRecordValues", "AllowLoad", "ShowToolbar", "ShowSearch", "ShowNewButton", "ShowRefreshButton", "ShowExportButton", "ShowDeleteButton", "ShowCompareButton", "ShowMergeButton", "ShowAddToListButton", "ShowDuplicateSearchButton", "ShowCommunicationButton", "ShowRecycleBin", "Height", "ToolbarConfig", "SelectionMode", "AllowColumnToggle"]], template: function ExplorerEntityDataGridComponent_Template(rf, ctx) { if (rf & 1) {
|
|
@@ -395,7 +423,7 @@ export class ExplorerEntityDataGridComponent {
|
|
|
395
423
|
`, host: {
|
|
396
424
|
'[style.height]': 'hostHeightStyle',
|
|
397
425
|
}, styles: ["\n :host {\n display: block;\n height: 100%;\n width: 100%;\n }\n "] }]
|
|
398
|
-
}], null, {
|
|
426
|
+
}], null, { InnerGrid: [{
|
|
399
427
|
type: ViewChild,
|
|
400
428
|
args: ['innerGrid']
|
|
401
429
|
}], Params: [{
|