@mj-biz-apps/common-ng 5.55.0 → 5.56.0
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/components/party-field/__tests__/party-field.component.test.d.ts +2 -0
- package/dist/lib/components/party-field/__tests__/party-field.component.test.d.ts.map +1 -0
- package/dist/lib/components/party-field/__tests__/party-field.component.test.js +266 -0
- package/dist/lib/components/party-field/__tests__/party-field.component.test.js.map +1 -0
- package/dist/lib/components/party-field/__tests__/party-lookup-term.test.d.ts +2 -0
- package/dist/lib/components/party-field/__tests__/party-lookup-term.test.d.ts.map +1 -0
- package/dist/lib/components/party-field/__tests__/party-lookup-term.test.js +41 -0
- package/dist/lib/components/party-field/__tests__/party-lookup-term.test.js.map +1 -0
- package/dist/lib/components/party-field/party-field.component.d.ts +92 -0
- package/dist/lib/components/party-field/party-field.component.d.ts.map +1 -0
- package/dist/lib/components/party-field/party-field.component.js +351 -0
- package/dist/lib/components/party-field/party-field.component.js.map +1 -0
- package/dist/lib/components/party-field/party-lookup-term.d.ts +21 -0
- package/dist/lib/components/party-field/party-lookup-term.d.ts.map +1 -0
- package/dist/lib/components/party-field/party-lookup-term.js +42 -0
- package/dist/lib/components/party-field/party-lookup-term.js.map +1 -0
- package/dist/lib/generated/Entities/mjBizAppsCommonOrganization/mjbizappscommonorganization.form.component.js +37 -35
- package/dist/lib/generated/Entities/mjBizAppsCommonOrganization/mjbizappscommonorganization.form.component.js.map +1 -1
- package/dist/lib/generated/Entities/mjBizAppsCommonPerson/mjbizappscommonperson.form.component.js +43 -41
- package/dist/lib/generated/Entities/mjBizAppsCommonPerson/mjbizappscommonperson.form.component.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 +2 -0
- package/dist/public-api.js.map +1 -1
- package/package.json +6 -4
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, EventEmitter, Input, Output, ViewChild, inject, } from '@angular/core';
|
|
2
|
+
import { FormsModule } from '@angular/forms';
|
|
3
|
+
import { LogError, Metadata, RunQuery, RunView } from '@memberjunction/core';
|
|
4
|
+
import { EscapeSQLString } from '@memberjunction/global';
|
|
5
|
+
import { BaseFormsModule } from '@memberjunction/ng-base-forms';
|
|
6
|
+
import { MJComboboxComponent } from '@memberjunction/ng-ui-components';
|
|
7
|
+
import { Subject, debounceTime, from, switchMap } from 'rxjs';
|
|
8
|
+
import { PARTY_LOOKUP_QUERIES, PartyLookupParamsFor } from './party-lookup-term';
|
|
9
|
+
import * as i0 from "@angular/core";
|
|
10
|
+
import * as i1 from "@memberjunction/ng-base-forms";
|
|
11
|
+
import * as i2 from "@angular/forms";
|
|
12
|
+
function PartyFieldComponent_Conditional_0_Conditional_1_Template(rf, ctx) { if (rf & 1) {
|
|
13
|
+
i0.ɵɵelementStart(0, "label", 4);
|
|
14
|
+
i0.ɵɵtext(1);
|
|
15
|
+
i0.ɵɵelementEnd();
|
|
16
|
+
} if (rf & 2) {
|
|
17
|
+
const ctx_r1 = i0.ɵɵnextContext(2);
|
|
18
|
+
i0.ɵɵadvance();
|
|
19
|
+
i0.ɵɵtextInterpolate(ctx_r1.Label);
|
|
20
|
+
} }
|
|
21
|
+
function PartyFieldComponent_Conditional_0_ng_template_3_Conditional_3_Template(rf, ctx) { if (rf & 1) {
|
|
22
|
+
i0.ɵɵelementStart(0, "span", 8);
|
|
23
|
+
i0.ɵɵtext(1);
|
|
24
|
+
i0.ɵɵelementEnd();
|
|
25
|
+
} if (rf & 2) {
|
|
26
|
+
const item_r3 = i0.ɵɵnextContext().$implicit;
|
|
27
|
+
i0.ɵɵadvance();
|
|
28
|
+
i0.ɵɵtextInterpolate(item_r3.Detail);
|
|
29
|
+
} }
|
|
30
|
+
function PartyFieldComponent_Conditional_0_ng_template_3_Template(rf, ctx) { if (rf & 1) {
|
|
31
|
+
i0.ɵɵelementStart(0, "div", 7)(1, "span");
|
|
32
|
+
i0.ɵɵtext(2);
|
|
33
|
+
i0.ɵɵelementEnd();
|
|
34
|
+
i0.ɵɵconditionalCreate(3, PartyFieldComponent_Conditional_0_ng_template_3_Conditional_3_Template, 2, 1, "span", 8);
|
|
35
|
+
i0.ɵɵelementEnd();
|
|
36
|
+
} if (rf & 2) {
|
|
37
|
+
const item_r3 = ctx.$implicit;
|
|
38
|
+
i0.ɵɵadvance(2);
|
|
39
|
+
i0.ɵɵtextInterpolate(item_r3.Name);
|
|
40
|
+
i0.ɵɵadvance();
|
|
41
|
+
i0.ɵɵconditional(item_r3.Detail ? 3 : -1);
|
|
42
|
+
} }
|
|
43
|
+
function PartyFieldComponent_Conditional_0_Conditional_5_Template(rf, ctx) { if (rf & 1) {
|
|
44
|
+
i0.ɵɵelementStart(0, "div", 6);
|
|
45
|
+
i0.ɵɵtext(1, "Search failed. Try again.");
|
|
46
|
+
i0.ɵɵelementEnd();
|
|
47
|
+
} }
|
|
48
|
+
function PartyFieldComponent_Conditional_0_Template(rf, ctx) { if (rf & 1) {
|
|
49
|
+
const _r1 = i0.ɵɵgetCurrentView();
|
|
50
|
+
i0.ɵɵelementStart(0, "div", 3);
|
|
51
|
+
i0.ɵɵlistener("focusout", function PartyFieldComponent_Conditional_0_Template_div_focusout_0_listener() { i0.ɵɵrestoreView(_r1); const ctx_r1 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r1.OnFocusOut()); });
|
|
52
|
+
i0.ɵɵconditionalCreate(1, PartyFieldComponent_Conditional_0_Conditional_1_Template, 2, 1, "label", 4);
|
|
53
|
+
i0.ɵɵelementStart(2, "mj-combobox", 5);
|
|
54
|
+
i0.ɵɵlistener("FilterChange", function PartyFieldComponent_Conditional_0_Template_mj_combobox_FilterChange_2_listener($event) { i0.ɵɵrestoreView(_r1); const ctx_r1 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r1.OnFilterChange($event)); })("ValueChange", function PartyFieldComponent_Conditional_0_Template_mj_combobox_ValueChange_2_listener($event) { i0.ɵɵrestoreView(_r1); const ctx_r1 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r1.OnSelect($event)); });
|
|
55
|
+
i0.ɵɵtemplate(3, PartyFieldComponent_Conditional_0_ng_template_3_Template, 4, 2, "ng-template", null, 0, i0.ɵɵtemplateRefExtractor);
|
|
56
|
+
i0.ɵɵelementEnd();
|
|
57
|
+
i0.ɵɵconditionalCreate(5, PartyFieldComponent_Conditional_0_Conditional_5_Template, 2, 0, "div", 6);
|
|
58
|
+
i0.ɵɵelementEnd();
|
|
59
|
+
} if (rf & 2) {
|
|
60
|
+
const ctx_r1 = i0.ɵɵnextContext();
|
|
61
|
+
i0.ɵɵadvance();
|
|
62
|
+
i0.ɵɵconditional(ctx_r1.ShowLabel ? 1 : -1);
|
|
63
|
+
i0.ɵɵadvance();
|
|
64
|
+
i0.ɵɵproperty("Data", ctx_r1.Options)("ValuePrimitive", true)("Filterable", false)("ngModel", ctx_r1.CurrentID);
|
|
65
|
+
i0.ɵɵadvance(3);
|
|
66
|
+
i0.ɵɵconditional(ctx_r1.SearchFailed ? 5 : -1);
|
|
67
|
+
} }
|
|
68
|
+
function PartyFieldComponent_Conditional_1_Template(rf, ctx) { if (rf & 1) {
|
|
69
|
+
const _r4 = i0.ɵɵgetCurrentView();
|
|
70
|
+
i0.ɵɵelementStart(0, "mj-form-field", 9);
|
|
71
|
+
i0.ɵɵlistener("Navigate", function PartyFieldComponent_Conditional_1_Template_mj_form_field_Navigate_0_listener($event) { i0.ɵɵrestoreView(_r4); const ctx_r1 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r1.Navigate.emit($event)); });
|
|
72
|
+
i0.ɵɵelementEnd();
|
|
73
|
+
} if (rf & 2) {
|
|
74
|
+
const ctx_r1 = i0.ɵɵnextContext();
|
|
75
|
+
i0.ɵɵproperty("Record", ctx_r1.Record)("ShowLabel", ctx_r1.ShowLabel)("FieldName", ctx_r1.FieldName)("EditMode", false)("FormContext", ctx_r1.FormContext);
|
|
76
|
+
} }
|
|
77
|
+
const DEBOUNCE_MS = 250;
|
|
78
|
+
/**
|
|
79
|
+
* `bizapps-party-field` — a Person or Organization foreign key that searches as you type.
|
|
80
|
+
*
|
|
81
|
+
* The stock form field lists rows on focus, matches `LIKE '%q%'` on one view column and counts
|
|
82
|
+
* every full page, which takes seconds on a party file of a million people. This one lists nothing
|
|
83
|
+
* until two characters are typed, then runs one parameterized query (prefix match on indexed base
|
|
84
|
+
* columns, TOP 20, no count). People match last name, display name, email or email domain;
|
|
85
|
+
* organizations match name, legal name or website domain.
|
|
86
|
+
*
|
|
87
|
+
* Read mode is the stock `mj-form-field`, so labels, links and navigation stay the platform's.
|
|
88
|
+
* An app whose foreign key points at a subtype (Sales Contacts, Sales Accounts) passes its own
|
|
89
|
+
* `QueryName` with the same result contract (ID, Name, Detail; parameters Term, Domain).
|
|
90
|
+
*/
|
|
91
|
+
export class PartyFieldComponent {
|
|
92
|
+
cdr = inject(ChangeDetectorRef);
|
|
93
|
+
Record;
|
|
94
|
+
FieldName;
|
|
95
|
+
Kind;
|
|
96
|
+
/** Overrides the Kind's default query; pair with CategoryPath. */
|
|
97
|
+
QueryName;
|
|
98
|
+
CategoryPath;
|
|
99
|
+
EditMode = false;
|
|
100
|
+
ShowLabel = true;
|
|
101
|
+
FormContext;
|
|
102
|
+
/** The shape mj-form-field emits, so handlers written for it keep working. */
|
|
103
|
+
ValueChange = new EventEmitter();
|
|
104
|
+
Navigate = new EventEmitter();
|
|
105
|
+
/** What the dropdown lists: search results, or just the current value when not searching. */
|
|
106
|
+
Options = [];
|
|
107
|
+
SearchFailed = false;
|
|
108
|
+
/** The current value as a one-item list (empty when unset): what the list goes back to. */
|
|
109
|
+
current = [];
|
|
110
|
+
terms = new Subject();
|
|
111
|
+
subscription;
|
|
112
|
+
combobox;
|
|
113
|
+
ngOnInit() {
|
|
114
|
+
this.seedCurrent();
|
|
115
|
+
this.subscription = this.terms
|
|
116
|
+
.pipe(debounceTime(DEBOUNCE_MS), switchMap((term) => from(this.optionsFor(term))))
|
|
117
|
+
.subscribe((options) => {
|
|
118
|
+
this.SearchFailed = options === null;
|
|
119
|
+
this.Options = options ?? [];
|
|
120
|
+
this.cdr.markForCheck();
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Code can change the value after load (Deal's FillContactsFromAccount, a cancelled edit
|
|
125
|
+
* reverting the record). Re-seed when the record no longer holds the value this field shows.
|
|
126
|
+
*/
|
|
127
|
+
ngDoCheck() {
|
|
128
|
+
const shown = this.current[0]?.ID ?? null;
|
|
129
|
+
if (this.subscription && this.CurrentID?.toLowerCase() !== shown?.toLowerCase()) {
|
|
130
|
+
this.seedCurrent();
|
|
131
|
+
this.RefreshComboboxText();
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
ngOnDestroy() {
|
|
135
|
+
this.subscription?.unsubscribe();
|
|
136
|
+
}
|
|
137
|
+
get Label() {
|
|
138
|
+
return this.fieldInfo()?.DisplayNameOrName ?? this.FieldName;
|
|
139
|
+
}
|
|
140
|
+
get CurrentID() {
|
|
141
|
+
const value = this.Record?.Get(this.FieldName);
|
|
142
|
+
return value ? String(value) : null;
|
|
143
|
+
}
|
|
144
|
+
OnFilterChange(text) {
|
|
145
|
+
this.terms.next(text);
|
|
146
|
+
}
|
|
147
|
+
/** Picked (an ID) or cleared (null). */
|
|
148
|
+
OnSelect(value) {
|
|
149
|
+
const oldValue = this.Record.Get(this.FieldName);
|
|
150
|
+
const newValue = value ? String(value) : null;
|
|
151
|
+
const picked = this.Options.find((option) => option.ID === newValue);
|
|
152
|
+
this.Record.Set(this.FieldName, newValue);
|
|
153
|
+
this.current = picked ? [picked] : [];
|
|
154
|
+
this.Options = this.current;
|
|
155
|
+
this.ValueChange.emit({ FieldName: this.FieldName, OldValue: oldValue, NewValue: newValue });
|
|
156
|
+
this.cdr.markForCheck();
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Leaving the field mid-search puts the current value back in the list, so the combobox can
|
|
160
|
+
* show its name rather than a raw ID, and cancels any search still pending.
|
|
161
|
+
*/
|
|
162
|
+
OnFocusOut() {
|
|
163
|
+
this.terms.next('');
|
|
164
|
+
this.Options = this.current;
|
|
165
|
+
this.cdr.markForCheck();
|
|
166
|
+
}
|
|
167
|
+
/** The RunQuery call. Throws on failure; a test seam. */
|
|
168
|
+
async runSearch(params) {
|
|
169
|
+
const query = this.QueryName
|
|
170
|
+
? { QueryName: this.QueryName, CategoryPath: this.CategoryPath }
|
|
171
|
+
: PARTY_LOOKUP_QUERIES[this.Kind];
|
|
172
|
+
const parameters = { Term: params.Term };
|
|
173
|
+
if (params.Domain) {
|
|
174
|
+
parameters['Domain'] = params.Domain;
|
|
175
|
+
}
|
|
176
|
+
const result = await new RunQuery().RunQuery({ ...query, Parameters: parameters });
|
|
177
|
+
if (!result.Success) {
|
|
178
|
+
throw new Error(`${query.QueryName} failed: ${result.ErrorMessage ?? 'unknown error'}`);
|
|
179
|
+
}
|
|
180
|
+
return result.Results.map((row) => ({ ID: row.ID, Name: row.Name, Detail: row.Detail ?? null }));
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* mj-combobox re-reads its text from Data only while the text is empty, so a name that arrives
|
|
184
|
+
* after the ID was shown has to be pushed: Data first, then the value. A test seam.
|
|
185
|
+
*/
|
|
186
|
+
RefreshComboboxText() {
|
|
187
|
+
if (this.combobox) {
|
|
188
|
+
this.combobox.Data = this.Options;
|
|
189
|
+
this.combobox.writeValue(this.CurrentID);
|
|
190
|
+
}
|
|
191
|
+
this.cdr.markForCheck();
|
|
192
|
+
}
|
|
193
|
+
seedCurrent() {
|
|
194
|
+
this.current = this.currentOption();
|
|
195
|
+
this.Options = this.current;
|
|
196
|
+
if (this.needsNameLookup()) {
|
|
197
|
+
void this.resolveCurrentName();
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
/** The options to list, or null when the search failed (logged). */
|
|
201
|
+
async optionsFor(term) {
|
|
202
|
+
const params = PartyLookupParamsFor(this.Kind, term);
|
|
203
|
+
if (!params) {
|
|
204
|
+
return term ? [] : this.current;
|
|
205
|
+
}
|
|
206
|
+
try {
|
|
207
|
+
return await this.runSearch(params);
|
|
208
|
+
}
|
|
209
|
+
catch (error) {
|
|
210
|
+
LogError(`bizapps-party-field: ${error instanceof Error ? error.message : String(error)}`);
|
|
211
|
+
return null;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* The current value as an option, named from the record's related-name view column. That
|
|
216
|
+
* column is empty, or stale, when code set the foreign key after load (Deal's
|
|
217
|
+
* FillContactsFromAccount); the ID stands in until resolveCurrentName replaces it.
|
|
218
|
+
*/
|
|
219
|
+
currentOption() {
|
|
220
|
+
const id = this.CurrentID;
|
|
221
|
+
if (!id) {
|
|
222
|
+
return [];
|
|
223
|
+
}
|
|
224
|
+
const name = this.needsNameLookup() ? null : this.recordName();
|
|
225
|
+
return [{ ID: id, Name: name ?? id, Detail: null }];
|
|
226
|
+
}
|
|
227
|
+
recordName() {
|
|
228
|
+
const nameField = this.fieldInfo()?.RelatedEntityNameFieldMap;
|
|
229
|
+
const name = nameField ? this.Record.Get(nameField) : null;
|
|
230
|
+
return name ? String(name) : null;
|
|
231
|
+
}
|
|
232
|
+
needsNameLookup() {
|
|
233
|
+
if (!this.CurrentID) {
|
|
234
|
+
return false;
|
|
235
|
+
}
|
|
236
|
+
return !this.recordName() || this.Record.GetFieldByName(this.FieldName)?.Dirty === true;
|
|
237
|
+
}
|
|
238
|
+
/** One read of the related record's name field. A failure is logged and the ID stays as the label. */
|
|
239
|
+
async resolveCurrentName() {
|
|
240
|
+
const id = this.CurrentID;
|
|
241
|
+
const field = this.fieldInfo();
|
|
242
|
+
const nameField = field ? Metadata.Provider.EntityByName(field.RelatedEntity)?.NameField?.Name : undefined;
|
|
243
|
+
if (!id || !field || !nameField) {
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
const result = await RunView.FromMetadataProvider(Metadata.Provider).RunView({
|
|
247
|
+
EntityName: field.RelatedEntity,
|
|
248
|
+
ExtraFilter: `${field.RelatedEntityFieldName}='${EscapeSQLString(id)}'`,
|
|
249
|
+
Fields: [field.RelatedEntityFieldName, nameField],
|
|
250
|
+
ResultType: 'simple',
|
|
251
|
+
MaxRows: 1,
|
|
252
|
+
});
|
|
253
|
+
const name = result.Success ? result.Results[0]?.[nameField] : null;
|
|
254
|
+
if (!result.Success) {
|
|
255
|
+
LogError(`bizapps-party-field: could not read the name of ${field.RelatedEntity} ${id}: ${result.ErrorMessage}`);
|
|
256
|
+
}
|
|
257
|
+
if (name && this.CurrentID === id) {
|
|
258
|
+
this.current = [{ ID: id, Name: String(name), Detail: null }];
|
|
259
|
+
this.Options = this.current;
|
|
260
|
+
this.RefreshComboboxText();
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
fieldInfo() {
|
|
264
|
+
return this.Record?.EntityInfo?.Fields.find((field) => field.Name === this.FieldName);
|
|
265
|
+
}
|
|
266
|
+
static ɵfac = function PartyFieldComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || PartyFieldComponent)(); };
|
|
267
|
+
static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: PartyFieldComponent, selectors: [["bizapps-party-field"]], viewQuery: function PartyFieldComponent_Query(rf, ctx) { if (rf & 1) {
|
|
268
|
+
i0.ɵɵviewQuery(MJComboboxComponent, 5);
|
|
269
|
+
} if (rf & 2) {
|
|
270
|
+
let _t;
|
|
271
|
+
i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.combobox = _t.first);
|
|
272
|
+
} }, inputs: { Record: "Record", FieldName: "FieldName", Kind: "Kind", QueryName: "QueryName", CategoryPath: "CategoryPath", EditMode: "EditMode", ShowLabel: "ShowLabel", FormContext: "FormContext" }, outputs: { ValueChange: "ValueChange", Navigate: "Navigate" }, decls: 2, vars: 1, consts: [["mjComboboxItem", ""], [1, "bizapps-party-field"], ["Type", "textbox", "LinkType", "Record", 3, "Record", "ShowLabel", "FieldName", "EditMode", "FormContext"], [1, "bizapps-party-field", 3, "focusout"], [1, "bizapps-party-field-label"], ["TextField", "Name", "ValueField", "ID", "Placeholder", "Type 2+ characters to search", 3, "FilterChange", "ValueChange", "Data", "ValuePrimitive", "Filterable", "ngModel"], [1, "bizapps-party-field-hint"], [1, "bizapps-party-option"], [1, "bizapps-party-option-detail"], ["Type", "textbox", "LinkType", "Record", 3, "Navigate", "Record", "ShowLabel", "FieldName", "EditMode", "FormContext"]], template: function PartyFieldComponent_Template(rf, ctx) { if (rf & 1) {
|
|
273
|
+
i0.ɵɵconditionalCreate(0, PartyFieldComponent_Conditional_0_Template, 6, 6, "div", 1)(1, PartyFieldComponent_Conditional_1_Template, 1, 5, "mj-form-field", 2);
|
|
274
|
+
} if (rf & 2) {
|
|
275
|
+
i0.ɵɵconditional(ctx.EditMode ? 0 : 1);
|
|
276
|
+
} }, dependencies: [BaseFormsModule, i1.MjFormFieldComponent, MJComboboxComponent, FormsModule, i2.NgControlStatus, i2.NgModel], styles: [".bizapps-party-field[_ngcontent-%COMP%] {\n display: flex;\n flex-direction: column;\n gap: var(--mj-space-1);\n }\n .bizapps-party-field-label[_ngcontent-%COMP%] {\n font-size: var(--mj-text-sm);\n font-weight: var(--mj-font-medium);\n color: var(--mj-text-secondary);\n }\n .bizapps-party-option[_ngcontent-%COMP%] {\n display: flex;\n flex-direction: column;\n min-width: 0;\n }\n .bizapps-party-option-detail[_ngcontent-%COMP%] {\n font-size: var(--mj-text-xs);\n color: var(--mj-text-muted);\n }\n .bizapps-party-field-hint[_ngcontent-%COMP%] {\n font-size: var(--mj-text-xs);\n color: var(--mj-status-error);\n }"], changeDetection: 0 });
|
|
277
|
+
}
|
|
278
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(PartyFieldComponent, [{
|
|
279
|
+
type: Component,
|
|
280
|
+
args: [{ selector: 'bizapps-party-field', standalone: true, imports: [BaseFormsModule, MJComboboxComponent, FormsModule], changeDetection: ChangeDetectionStrategy.OnPush, template: `
|
|
281
|
+
@if (EditMode) {
|
|
282
|
+
<div class="bizapps-party-field" (focusout)="OnFocusOut()">
|
|
283
|
+
@if (ShowLabel) {
|
|
284
|
+
<label class="bizapps-party-field-label">{{ Label }}</label>
|
|
285
|
+
}
|
|
286
|
+
<mj-combobox
|
|
287
|
+
[Data]="Options"
|
|
288
|
+
TextField="Name"
|
|
289
|
+
ValueField="ID"
|
|
290
|
+
[ValuePrimitive]="true"
|
|
291
|
+
[Filterable]="false"
|
|
292
|
+
Placeholder="Type 2+ characters to search"
|
|
293
|
+
[ngModel]="CurrentID"
|
|
294
|
+
(FilterChange)="OnFilterChange($event)"
|
|
295
|
+
(ValueChange)="OnSelect($event)"
|
|
296
|
+
>
|
|
297
|
+
<ng-template #mjComboboxItem let-item>
|
|
298
|
+
<div class="bizapps-party-option">
|
|
299
|
+
<span>{{ item.Name }}</span>
|
|
300
|
+
@if (item.Detail) {
|
|
301
|
+
<span class="bizapps-party-option-detail">{{ item.Detail }}</span>
|
|
302
|
+
}
|
|
303
|
+
</div>
|
|
304
|
+
</ng-template>
|
|
305
|
+
</mj-combobox>
|
|
306
|
+
@if (SearchFailed) {
|
|
307
|
+
<div class="bizapps-party-field-hint">Search failed. Try again.</div>
|
|
308
|
+
}
|
|
309
|
+
</div>
|
|
310
|
+
} @else {
|
|
311
|
+
<mj-form-field
|
|
312
|
+
[Record]="Record"
|
|
313
|
+
[ShowLabel]="ShowLabel"
|
|
314
|
+
[FieldName]="FieldName"
|
|
315
|
+
Type="textbox"
|
|
316
|
+
LinkType="Record"
|
|
317
|
+
[EditMode]="false"
|
|
318
|
+
[FormContext]="FormContext"
|
|
319
|
+
(Navigate)="Navigate.emit($event)"
|
|
320
|
+
></mj-form-field>
|
|
321
|
+
}
|
|
322
|
+
`, styles: ["\n .bizapps-party-field {\n display: flex;\n flex-direction: column;\n gap: var(--mj-space-1);\n }\n .bizapps-party-field-label {\n font-size: var(--mj-text-sm);\n font-weight: var(--mj-font-medium);\n color: var(--mj-text-secondary);\n }\n .bizapps-party-option {\n display: flex;\n flex-direction: column;\n min-width: 0;\n }\n .bizapps-party-option-detail {\n font-size: var(--mj-text-xs);\n color: var(--mj-text-muted);\n }\n .bizapps-party-field-hint {\n font-size: var(--mj-text-xs);\n color: var(--mj-status-error);\n }\n "] }]
|
|
323
|
+
}], null, { Record: [{
|
|
324
|
+
type: Input,
|
|
325
|
+
args: [{ required: true }]
|
|
326
|
+
}], FieldName: [{
|
|
327
|
+
type: Input,
|
|
328
|
+
args: [{ required: true }]
|
|
329
|
+
}], Kind: [{
|
|
330
|
+
type: Input,
|
|
331
|
+
args: [{ required: true }]
|
|
332
|
+
}], QueryName: [{
|
|
333
|
+
type: Input
|
|
334
|
+
}], CategoryPath: [{
|
|
335
|
+
type: Input
|
|
336
|
+
}], EditMode: [{
|
|
337
|
+
type: Input
|
|
338
|
+
}], ShowLabel: [{
|
|
339
|
+
type: Input
|
|
340
|
+
}], FormContext: [{
|
|
341
|
+
type: Input
|
|
342
|
+
}], ValueChange: [{
|
|
343
|
+
type: Output
|
|
344
|
+
}], Navigate: [{
|
|
345
|
+
type: Output
|
|
346
|
+
}], combobox: [{
|
|
347
|
+
type: ViewChild,
|
|
348
|
+
args: [MJComboboxComponent]
|
|
349
|
+
}] }); })();
|
|
350
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(PartyFieldComponent, { className: "PartyFieldComponent", filePath: "lib/components/party-field/party-field.component.ts", lineNumber: 121 }); })();
|
|
351
|
+
//# sourceMappingURL=party-field.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"party-field.component.js","sourceRoot":"","sources":["../../../../src/lib/components/party-field/party-field.component.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,uBAAuB,EACvB,iBAAiB,EACjB,SAAS,EAET,YAAY,EACZ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,IAAI,CAAC,mBAAmB,EAAE,CAAC;QAC/B,CAAC;IACL,CAAC;IAEO,SAAS;QACb,OAAO,IAAI,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,SAAS,CAAC,CAAC;IAC1F,CAAC;6GArMQ,mBAAmB;6DAAnB,mBAAmB;2BAyBjB,mBAAmB;;;;;YAlExB,AA7BF,qFAAgB,yEA6BP;;YA7BT,sCAwCC;4BA3CK,eAAe,2BAAE,mBAAmB,EAAE,WAAW;;iFAyElD,mBAAmB;cA5E/B,SAAS;2BACI,qBAAqB,cACnB,IAAI,WACP,CAAC,eAAe,EAAE,mBAAmB,EAAE,WAAW,CAAC,mBAC3C,uBAAuB,CAAC,MAAM,YACrC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA0CT;;kBAgCA,KAAK;mBAAC,EAAE,QAAQ,EAAE,IAAI,EAAE;;kBACxB,KAAK;mBAAC,EAAE,QAAQ,EAAE,IAAI,EAAE;;kBACxB,KAAK;mBAAC,EAAE,QAAQ,EAAE,IAAI,EAAE;;kBAExB,KAAK;;kBACL,KAAK;;kBACL,KAAK;;kBACL,KAAK;;kBACL,KAAK;;kBAEL,MAAM;;kBACN,MAAM;;kBAWN,SAAS;mBAAC,mBAAmB;;kFAzBrB,mBAAmB"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export type PartyKind = 'Person' | 'Organization';
|
|
2
|
+
/** Template parameters of every party lookup query. `Domain` is omitted from the call when null. */
|
|
3
|
+
export interface PartyLookupParams {
|
|
4
|
+
Term: string;
|
|
5
|
+
Domain: string | null;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* The query each kind searches by default. An app that stores a subtype ID (Sales Contacts,
|
|
9
|
+
* Sales Accounts) passes its own query honouring the same contract: columns ID, Name, Detail;
|
|
10
|
+
* parameters Term and Domain.
|
|
11
|
+
*/
|
|
12
|
+
export declare const PARTY_LOOKUP_QUERIES: Record<PartyKind, {
|
|
13
|
+
QueryName: string;
|
|
14
|
+
CategoryPath: string;
|
|
15
|
+
}>;
|
|
16
|
+
/**
|
|
17
|
+
* What to search for, or null under two non-blank characters (the picker then shows nothing and
|
|
18
|
+
* sends nothing). No escaping here: the query's `sqlLikeBegins` filter escapes.
|
|
19
|
+
*/
|
|
20
|
+
export declare function PartyLookupParamsFor(kind: PartyKind, raw: string): PartyLookupParams | null;
|
|
21
|
+
//# sourceMappingURL=party-lookup-term.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"party-lookup-term.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/party-field/party-lookup-term.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,cAAc,CAAC;AAElD,oGAAoG;AACpG,MAAM,WAAW,iBAAiB;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB;AAED;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,EAAE,MAAM,CAAC,SAAS,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,CAG/F,CAAC;AAIF;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,GAAG,iBAAiB,GAAG,IAAI,CAO3F"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The query each kind searches by default. An app that stores a subtype ID (Sales Contacts,
|
|
3
|
+
* Sales Accounts) passes its own query honouring the same contract: columns ID, Name, Detail;
|
|
4
|
+
* parameters Term and Domain.
|
|
5
|
+
*/
|
|
6
|
+
export const PARTY_LOOKUP_QUERIES = {
|
|
7
|
+
Person: { QueryName: 'Common: Party Lookup People', CategoryPath: 'Common' },
|
|
8
|
+
Organization: { QueryName: 'Common: Party Lookup Organizations', CategoryPath: 'Common' },
|
|
9
|
+
};
|
|
10
|
+
const MIN_TERM_LENGTH = 2;
|
|
11
|
+
/**
|
|
12
|
+
* What to search for, or null under two non-blank characters (the picker then shows nothing and
|
|
13
|
+
* sends nothing). No escaping here: the query's `sqlLikeBegins` filter escapes.
|
|
14
|
+
*/
|
|
15
|
+
export function PartyLookupParamsFor(kind, raw) {
|
|
16
|
+
const term = raw.trim();
|
|
17
|
+
if (!longEnough(term)) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
const domain = kind === 'Person' ? emailDomainOf(term) : websiteDomainOf(term);
|
|
21
|
+
return { Term: term, Domain: domain && longEnough(domain) ? domain : null };
|
|
22
|
+
}
|
|
23
|
+
/** `%` does not count: sqlLikeBegins strips boundary wildcards, so "%%" would match every row. */
|
|
24
|
+
function longEnough(text) {
|
|
25
|
+
return text.replace(/%/g, '').length >= MIN_TERM_LENGTH;
|
|
26
|
+
}
|
|
27
|
+
/** `@aqha.com` → `aqha.com`. Only a term that looks like part of an address gets a domain. */
|
|
28
|
+
function emailDomainOf(term) {
|
|
29
|
+
if (!term.includes('@') && !term.includes('.')) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
return term.replace(/^@/, '').toLowerCase();
|
|
33
|
+
}
|
|
34
|
+
/** Same steps as the Organization.WebsiteDomain column: lower-case, drop scheme and `www.`, cut at `/`. */
|
|
35
|
+
function websiteDomainOf(term) {
|
|
36
|
+
if (!term.includes('.')) {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
const host = term.toLowerCase().replace(/^https?:\/\//, '').replace(/^www\./, '');
|
|
40
|
+
return host.split('/')[0];
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=party-lookup-term.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"party-lookup-term.js","sourceRoot":"","sources":["../../../../src/lib/components/party-field/party-lookup-term.ts"],"names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