@rxap/form-system 19.0.0-dev.1 → 19.0.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/CHANGELOG.md +8 -0
- package/README.md +1 -1
- package/compodoc/changelog.html +45 -0
- package/compodoc/classes/ExtractFunctionMixin.html +466 -0
- package/compodoc/classes/ExtractFunctionsMixin.html +434 -0
- package/compodoc/classes/ExtractIsValueFunctionMixin.html +407 -0
- package/compodoc/classes/ExtractToDisplayFunctionMixin.html +407 -0
- package/compodoc/dependencies.html +16 -16
- package/compodoc/directives/AutocompleteOptionsFromMethodDirective.html +162 -181
- package/compodoc/directives/OptionsFromMethodDirective.html +20 -19
- package/compodoc/index.html +1 -1
- package/compodoc/injectables/NoopResolveMethod.html +622 -0
- package/compodoc/interfaces/AutocompleteOptionsFromMethodDirectiveParameters.html +95 -18
- package/compodoc/interfaces/AutocompleteOptionsFromMethodDirectiveSettings.html +95 -18
- package/compodoc/interfaces/AutocompleteOptionsFromRemoteMethodTemplateContext.html +95 -18
- package/compodoc/interfaces/OptionsFromMethodDirectiveSettings.html +2 -1
- package/compodoc/interfaces/OptionsFromMethodTemplateContext.html +2 -1
- package/compodoc/interfaces/UseFunctionConfig.html +360 -0
- package/compodoc/interfaces/UseFunctionDefinition.html +399 -0
- package/compodoc/js/menu-wc.js +21 -0
- package/compodoc/js/menu-wc_es5.js +2 -2
- package/compodoc/js/search/search_index.js +2 -2
- package/compodoc/miscellaneous/functions.html +738 -30
- package/compodoc/miscellaneous/typealiases.html +59 -0
- package/compodoc/miscellaneous/variables.html +96 -0
- package/compodoc/overview.html +3 -3
- package/compodoc/properties.html +1 -1
- package/docs/assets/navigation.js +1 -1
- package/docs/assets/search.js +1 -1
- package/docs/classes/AutocompleteOptionsFromMethodDirective.html +44 -0
- package/docs/classes/ControlDataSource.html +12 -12
- package/docs/classes/ControlHideShowDirective.html +2 -2
- package/docs/classes/ExtractControlFromParentMixin.html +2 -2
- package/docs/classes/ExtractControlMixin.html +2 -2
- package/docs/classes/ExtractDataSourcesMixin.html +2 -2
- package/docs/classes/ExtractFormDefinitionMixin.html +2 -2
- package/docs/classes/ExtractFunctionMixin.html +5 -0
- package/docs/classes/ExtractFunctionsMixin.html +3 -0
- package/docs/classes/ExtractIsValueFunctionMixin.html +11 -0
- package/docs/classes/ExtractMethodMixin.html +2 -2
- package/docs/classes/ExtractMethodsMixin.html +2 -2
- package/docs/classes/ExtractOptionsDataSourceMixin.html +2 -2
- package/docs/classes/ExtractOptionsMethodMixin.html +2 -2
- package/docs/classes/ExtractRemoteMethodsMixin.html +2 -2
- package/docs/classes/ExtractResolveMethodMixin.html +2 -2
- package/docs/classes/ExtractToDisplayFunctionMixin.html +11 -0
- package/docs/classes/ForFormArrayItemsDirective.html +2 -2
- package/docs/classes/FormArrayAddItemButtonDirective.html +2 -2
- package/docs/classes/FormArrayItemButton.html +3 -2
- package/docs/classes/FormArrayItemRemoveButtonDirective.html +7 -2
- package/docs/classes/FormArrayItemRestoreButtonDirective.html +3 -2
- package/docs/classes/FormArrayRemovableDirective.html +3 -3
- package/docs/classes/FormSystemControlDirective.html +3 -3
- package/docs/classes/FormSystemDirectivesModule.html +1 -1
- package/docs/classes/InputSelectOptionsDirective.html +3 -3
- package/docs/classes/IsEqualToDirective.html +3 -3
- package/docs/classes/IsSelectableValueDirective.html +2 -2
- package/docs/classes/NoopResolveMethod.html +3 -0
- package/docs/classes/OptionsFromMethodDirective.html +3 -3
- package/docs/classes/OptionsFromRemoteMethodDirective.html +3 -3
- package/docs/classes/RxapFormSystemError.html +5 -15
- package/docs/classes/SubmitContextFormAdapter.html +9 -9
- package/docs/classes/TestNgControl.html +24 -24
- package/docs/documentation.json +17918 -8072
- package/docs/enums/FormSystemMetadataKeys.html +2 -2
- package/docs/functions/ApplyUseFunctionAdapters.html +1 -0
- package/docs/functions/ApplyUseMethodAdapters.html +1 -1
- package/docs/functions/ComposeOptionsTransformers.html +1 -1
- package/docs/functions/FormContextFromActivatedRouteFactory.html +1 -1
- package/docs/functions/ResolveByUuidParameter.html +1 -1
- package/docs/functions/ResolveByUuidResultFactory.html +1 -1
- package/docs/functions/SubmitContextFormAdapterFactory.html +1 -1
- package/docs/functions/UseAutocompleteIsValueFunction.html +1 -0
- package/docs/functions/UseAutocompleteOptionsMethod.html +1 -0
- package/docs/functions/UseAutocompleteResolveMethod.html +1 -0
- package/docs/functions/UseAutocompleteToDisplayFunction.html +1 -0
- package/docs/functions/UseComponent.html +1 -1
- package/docs/functions/UseDataSource.html +1 -1
- package/docs/functions/UseFormComponent.html +1 -1
- package/docs/functions/UseFunction.html +1 -0
- package/docs/functions/UseHideFunction.html +1 -1
- package/docs/functions/UseIsValueFunction.html +1 -0
- package/docs/functions/UseMethod.html +1 -1
- package/docs/functions/UseOptionsDataSource.html +1 -1
- package/docs/functions/UseOptionsMethod.html +1 -1
- package/docs/functions/UseOptionsRemoteMethod.html +1 -1
- package/docs/functions/UseRemoteMethod.html +1 -1
- package/docs/functions/UseResolveMethod.html +1 -1
- package/docs/functions/UseShowFunction.html +1 -1
- package/docs/functions/UseToDisplayFunction.html +1 -0
- package/docs/functions/controlDataSource-1.html +1 -1
- package/docs/hierarchy.html +1 -1
- package/docs/index.html +1 -1
- package/docs/interfaces/AutocompleteOptionsFromMethodDirectiveParameters.html +2 -0
- package/docs/interfaces/AutocompleteOptionsFromMethodDirectiveSettings.html +2 -0
- package/docs/interfaces/AutocompleteOptionsFromRemoteMethodTemplateContext.html +2 -0
- package/docs/interfaces/ControlHideShowOptions.html +2 -2
- package/docs/interfaces/ControlWithDataSource.html +2 -2
- package/docs/interfaces/ForFormArrayItemsDirectiveContext.html +2 -2
- package/docs/interfaces/InputSelectOptionsSettings.html +4 -4
- package/docs/interfaces/InputSelectOptionsTemplateContext.html +2 -2
- package/docs/interfaces/OptionsFromMethodDirectiveSettings.html +1 -1
- package/docs/interfaces/OptionsFromMethodTemplateContext.html +2 -2
- package/docs/interfaces/OptionsFromRemoteMethodTemplateContext.html +2 -2
- package/docs/interfaces/UseDataSourceSettings.html +2 -2
- package/docs/interfaces/UseDataSourceValue.html +3 -3
- package/docs/interfaces/UseFunctionConfig.html +2 -0
- package/docs/interfaces/UseFunctionDefinition.html +3 -0
- package/docs/interfaces/UseMethodConfig.html +2 -2
- package/docs/interfaces/UseMethodDefinition.html +2 -2
- package/docs/modules.html +28 -3
- package/docs/types/ControlHideShowFunction.html +1 -1
- package/docs/types/FunctionParameterAdapterFunction.html +1 -0
- package/docs/types/FunctionResultAdapterFunction.html +1 -0
- package/docs/types/MethodParameterAdapterFunction.html +1 -1
- package/docs/types/MethodResultAdapterFunction.html +1 -1
- package/docs/types/UseFunctionType.html +1 -0
- package/docs/types/UseOptionsDataSourceSettings.html +1 -1
- package/docs/variables/DATA_SOURCE_NAME.html +1 -1
- package/docs/variables/IS_VALUE_FUNCTION_NAME.html +1 -0
- package/docs/variables/OPTIONS_METHOD_NAME.html +1 -1
- package/docs/variables/REMOTE_METHOD_NAME.html +1 -1
- package/docs/variables/RESOLVE_METHOD_NAME.html +1 -1
- package/docs/variables/RXAP_FORM_CONTROL_SOURCE.html +1 -1
- package/docs/variables/RXAP_FORM_SYSTEM_HIDE_METADATA.html +1 -1
- package/docs/variables/RXAP_FORM_SYSTEM_HIDE_SHOW_OPTIONS.html +1 -1
- package/docs/variables/RXAP_FORM_SYSTEM_SHOW_METADATA.html +1 -1
- package/docs/variables/RXAP_USE_FUNCTION.html +1 -0
- package/docs/variables/RXAP_USE_METHOD.html +1 -1
- package/docs/variables/RXAP_USE_REMOTE_METHOD.html +1 -1
- package/docs/variables/SUBMIT_CONTEXT_FORM_ADAPTER_METHOD.html +1 -1
- package/docs/variables/TO_DISPLAY_FUNCTION_NAME.html +1 -0
- package/package.json +42 -43
- package/theme.css +177 -1
|
@@ -206,7 +206,46 @@
|
|
|
206
206
|
</div>
|
|
207
207
|
|
|
208
208
|
<div class="tab-pane fade " id="readme">
|
|
209
|
-
<p><h1>
|
|
209
|
+
<p><h1>Autocomplete Table Select</h1>
|
|
210
|
+
<h1>With Rxap form System</h1>
|
|
211
|
+
<b>Example :</b><div><pre class="line-numbers"><code class="language-angular2html">
|
|
212
|
+
<mat-form-field>
|
|
213
|
+
<mat-label>Company</mat-label>
|
|
214
|
+
<input type="text"
|
|
215
|
+
placeholder="Enter Company Name"
|
|
216
|
+
matInput
|
|
217
|
+
formControlName="company"
|
|
218
|
+
[matAutocomplete]="auto">
|
|
219
|
+
<!-- The autocomplete input -->
|
|
220
|
+
<mat-autocomplete #auto="matAutocomplete">
|
|
221
|
+
<mat-option *rxapAutocompleteOptionsFromMethod="let option; matAutocomplete: auto"
|
|
222
|
+
[value]="option.value">{{ option.display }}
|
|
223
|
+
</mat-option>
|
|
224
|
+
</mat-autocomplete>
|
|
225
|
+
<button mat-icon-button rxapInputClearButton matSuffix>
|
|
226
|
+
<mat-icon>clear</mat-icon>
|
|
227
|
+
</button>
|
|
228
|
+
</mat-form-field></code></pre></div><b>Example :</b><div><pre class="line-numbers"><code class="language-typescript">@Injectable()
|
|
229
|
+
@RxapForm('form')
|
|
230
|
+
export class Form {
|
|
231
|
+
|
|
232
|
+
// ensure the table data source is provided - in root or in the form component
|
|
233
|
+
@UseAutocompleteOptionsMethod(SearchCompanyMethod)
|
|
234
|
+
// ensure the table data source is provided - in root or in the form component
|
|
235
|
+
@UseAutocompleteResolveMethod(GetCompanyMethod)
|
|
236
|
+
@UseFormControl()
|
|
237
|
+
company!: RxapFromControl<Company>;
|
|
238
|
+
|
|
239
|
+
}</code></pre></div><p>The DataSource <code>CompanyGuiTableDataSource</code> is used to populate the table in the selection window. Ensure that this DataSource is of the type <code>AbstractTableDataSource</code>.</p>
|
|
240
|
+
<p>The Method <code>SearchCompanyMethod</code> is used by the autocomplete control to search for a list of matching selection options. The Method must accept a string as the first argument and return a list of <code>ControlOption</code> objects.</p>
|
|
241
|
+
<p>The Method <code>GetCompanyMethod</code> is used to resolve the selected value. The Method must accept a the value of the form control as the first argument and return a <code>ControlOption</code> object.</p>
|
|
242
|
+
<b>Example :</b><div><pre class="line-numbers"><code class="language-typescript">export class SearchCompanyMethod implements Method<ControlOptions, { parameters: { search?: string | null } }> { ... }
|
|
243
|
+
export class GetCompanyMethod implements Method<ControlOption, { parameters: { value: string } }> { ... }</code></pre></div><h1>Method Parameter Adopter</h1>
|
|
244
|
+
<p>By default the following adopter function is used by the <code>@UseAutocompleteOptionsMethod</code> and <code>@UseAutocompleteResolveMethod</code> decorators.</p>
|
|
245
|
+
<b>Example :</b><div><pre class="line-numbers"><code class="language-typescript">(parameters) => ({parameters})</code></pre></div><p>To override this default adopter function use the second argument of the decorator.</p>
|
|
246
|
+
<b>Example :</b><div><pre class="line-numbers"><code class="language-typescript">@UseAutocompleteOptionsMethod(SearchCompanyMethod, { adapter: { parameter: (parameters) => ({ search: parameters.search }) } })</code></pre></div><blockquote>
|
|
247
|
+
<p>The adapter function are called in an injection context, so it is possible to use the <code>inject</code> function</p>
|
|
248
|
+
</blockquote>
|
|
210
249
|
</p>
|
|
211
250
|
</div>
|
|
212
251
|
|
|
@@ -215,6 +254,7 @@
|
|
|
215
254
|
AfterViewInit,
|
|
216
255
|
Directive,
|
|
217
256
|
inject,
|
|
257
|
+
Injectable,
|
|
218
258
|
Injector,
|
|
219
259
|
INJECTOR,
|
|
220
260
|
Input,
|
|
@@ -231,12 +271,23 @@ import { Mixin } from '@rxap/mixin';
|
|
|
231
271
|
import { NgControl } from '@angular/forms';
|
|
232
272
|
import { MatFormField } from '@angular/material/form-field';
|
|
233
273
|
import { isDefined } from '@rxap/rxjs';
|
|
274
|
+
import { ExtractControlMixin } from '../mixins/extract-control.mixin';
|
|
275
|
+
import { ExtractFormDefinitionMixin } from '../mixins/extract-form-definition.mixin';
|
|
276
|
+
import {
|
|
277
|
+
ExtractIsValueFunctionMixin,
|
|
278
|
+
UseIsValueFunction,
|
|
279
|
+
} from '../mixins/extract-is-value-function.mixin';
|
|
280
|
+
import { ExtractMethodMixin } from '../mixins/extract-method.mixin';
|
|
234
281
|
import { UseMethodConfig } from '../mixins/extract-methods.mixin';
|
|
235
282
|
import { UseOptionsMethod } from '../mixins/extract-options-method.mixin';
|
|
236
283
|
import {
|
|
237
284
|
ExtractResolveMethodMixin,
|
|
238
285
|
UseResolveMethod,
|
|
239
286
|
} from '../mixins/extract-resolve-method.mixin';
|
|
287
|
+
import {
|
|
288
|
+
ExtractToDisplayFunctionMixin,
|
|
289
|
+
UseToDisplayFunction,
|
|
290
|
+
} from '../mixins/extract-to-display-function.mixin';
|
|
240
291
|
import { OptionsFromMethodDirective, OptionsFromMethodDirectiveSettings } from './options-from-method.directive';
|
|
241
292
|
import { OpenApiRemoteMethodParameter } from '@rxap/open-api/remote-method';
|
|
242
293
|
import { controlValueChanges$ } from '@rxap/forms';
|
|
@@ -269,6 +320,18 @@ export function UseAutocompleteResolveMethod<Value = unknown>(
|
|
|
269
320
|
return UseResolveMethod(method, config);
|
|
270
321
|
}
|
|
271
322
|
|
|
323
|
+
export function UseAutocompleteIsValueFunction(
|
|
324
|
+
isValue: (value: any) => boolean,
|
|
325
|
+
): any {
|
|
326
|
+
return UseIsValueFunction(isValue);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
export function UseAutocompleteToDisplayFunction(
|
|
330
|
+
toDisplay: (value: any) => string,
|
|
331
|
+
): any {
|
|
332
|
+
return UseToDisplayFunction(toDisplay);
|
|
333
|
+
}
|
|
334
|
+
|
|
272
335
|
export interface AutocompleteOptionsFromRemoteMethodTemplateContext {
|
|
273
336
|
$implicit: ControlOption;
|
|
274
337
|
}
|
|
@@ -283,10 +346,19 @@ export interface AutocompleteOptionsFromMethodDirectiveParameters<Value =
|
|
|
283
346
|
|
|
284
347
|
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
|
285
348
|
export interface AutocompleteOptionsFromMethodDirective<Value = any, Parameters extends AutocompleteOptionsFromMethodDirectiveParameters<Value> = AutocompleteOptionsFromMethodDirectiveParameters<Value>>
|
|
286
|
-
extends ExtractResolveMethodMixin, AfterViewInit, OnDestroy {
|
|
349
|
+
extends ExtractResolveMethodMixin, ExtractIsValueFunctionMixin, ExtractToDisplayFunctionMixin, AfterViewInit, OnDestroy {
|
|
287
350
|
}
|
|
288
351
|
|
|
289
|
-
@
|
|
352
|
+
@Injectable({ providedIn: 'root' })
|
|
353
|
+
export class NoopResolveMethod<Value> implements Method<ControlOption, { value: Value }> {
|
|
354
|
+
|
|
355
|
+
call({ value } : { value: Value }): Promise<ControlOption> {
|
|
356
|
+
return Promise.resolve({ value, display: value + '' });
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
@Mixin(ExtractResolveMethodMixin, ExtractIsValueFunctionMixin, ExtractToDisplayFunctionMixin)
|
|
290
362
|
@Directive({
|
|
291
363
|
// eslint-disable-next-line @angular-eslint/directive-selector
|
|
292
364
|
selector: '[rxapAutocompleteOptionsFromMethod]',
|
|
@@ -315,6 +387,13 @@ export class AutocompleteOptionsFromMethodDirective<Value = any, Paramet
|
|
|
315
387
|
// eslint-disable-next-line @angular-eslint/no-input-rename
|
|
316
388
|
@Input('rxapAutocompleteOptionsFromMethodResolve')
|
|
317
389
|
public resolveMethod?: MethodWithParameters<ControlOption, { value: Value } & Parameters>;
|
|
390
|
+
|
|
391
|
+
@Input('rxapAutocompleteOptionsFromMethodIsValue')
|
|
392
|
+
public isValue?: (value: any) => boolean;
|
|
393
|
+
|
|
394
|
+
@Input('rxapAutocompleteOptionsFromMethodToDisplay')
|
|
395
|
+
public toDisplay?: (value: any) => string;
|
|
396
|
+
|
|
318
397
|
protected override ngControl: NgControl | null = null;
|
|
319
398
|
protected override matFormField: MatFormField | null = null;
|
|
320
399
|
protected override injector: Injector = inject(INJECTOR);
|
|
@@ -336,12 +415,22 @@ export class AutocompleteOptionsFromMethodDirective<Value = any, Paramet
|
|
|
336
415
|
|
|
337
416
|
public override async ngAfterViewInit() {
|
|
338
417
|
if (this.matAutocomplete) {
|
|
339
|
-
this.matAutocomplete.displayWith = this.toDisplay.bind(this);
|
|
340
418
|
this.settings ??= {};
|
|
341
419
|
this.settings.filteredOptions ??= true;
|
|
342
420
|
}
|
|
343
421
|
await super.ngAfterViewInit();
|
|
344
422
|
this.resolveMethod ??= this.extractResolveMethod();
|
|
423
|
+
this.isValue ??= this.extractIsValueFunction((value: any) => typeof value === 'string' && isUUID(value));
|
|
424
|
+
this.toDisplay ??= this.extractToDisplayFunction((value: any): string => {
|
|
425
|
+
if (!value) {
|
|
426
|
+
return '';
|
|
427
|
+
}
|
|
428
|
+
const option = this.findOptionByValue(value);
|
|
429
|
+
return option?.display ?? (isDevMode() ? 'to display error' : '...');
|
|
430
|
+
});
|
|
431
|
+
if (this.matAutocomplete) {
|
|
432
|
+
this.matAutocomplete.displayWith = this.toDisplay.bind(this);
|
|
433
|
+
}
|
|
345
434
|
if (!this.control) {
|
|
346
435
|
throw new Error('The control is not yet defined');
|
|
347
436
|
}
|
|
@@ -354,32 +443,20 @@ export class AutocompleteOptionsFromMethodDirective<Value = any, Paramet
|
|
|
354
443
|
distinctUntilChanged(),
|
|
355
444
|
tap(async value => {
|
|
356
445
|
this.setOptions(await this.loadOptions(this.parameters));
|
|
357
|
-
if (this.isValue(value)) {
|
|
446
|
+
if (this.isValue?.(value)) {
|
|
358
447
|
this.triggerAutocompleteToDisplay();
|
|
359
448
|
}
|
|
360
449
|
}),
|
|
361
450
|
).subscribe();
|
|
362
451
|
}
|
|
363
452
|
|
|
364
|
-
public toDisplay(value: any): string {
|
|
365
|
-
if (!value) {
|
|
366
|
-
return '';
|
|
367
|
-
}
|
|
368
|
-
const option = this.findOptionByValue(value);
|
|
369
|
-
return option?.display ?? (isDevMode() ? 'to display error' : '...');
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
public isValue(value: any): boolean {
|
|
373
|
-
return typeof value === 'string' && isUUID(value);
|
|
374
|
-
}
|
|
375
|
-
|
|
376
453
|
protected override loadOptions(parameters: Parameters = {} as Parameters): Promise<ControlOptions | null> {
|
|
377
454
|
if (!this.control) {
|
|
378
455
|
throw new Error('The control is not yet defined');
|
|
379
456
|
}
|
|
380
457
|
const value = this.control?.value;
|
|
381
458
|
const c_parameters = {...parameters};
|
|
382
|
-
if (this.isValue(value)) {
|
|
459
|
+
if (this.isValue?.(value)) {
|
|
383
460
|
return this.resolveValue(value, c_parameters);
|
|
384
461
|
} else {
|
|
385
462
|
c_parameters.search ??= value;
|
|
@@ -212,7 +212,46 @@
|
|
|
212
212
|
</div>
|
|
213
213
|
|
|
214
214
|
<div class="tab-pane fade " id="readme">
|
|
215
|
-
<p><h1>
|
|
215
|
+
<p><h1>Autocomplete Table Select</h1>
|
|
216
|
+
<h1>With Rxap form System</h1>
|
|
217
|
+
<b>Example :</b><div><pre class="line-numbers"><code class="language-angular2html">
|
|
218
|
+
<mat-form-field>
|
|
219
|
+
<mat-label>Company</mat-label>
|
|
220
|
+
<input type="text"
|
|
221
|
+
placeholder="Enter Company Name"
|
|
222
|
+
matInput
|
|
223
|
+
formControlName="company"
|
|
224
|
+
[matAutocomplete]="auto">
|
|
225
|
+
<!-- The autocomplete input -->
|
|
226
|
+
<mat-autocomplete #auto="matAutocomplete">
|
|
227
|
+
<mat-option *rxapAutocompleteOptionsFromMethod="let option; matAutocomplete: auto"
|
|
228
|
+
[value]="option.value">{{ option.display }}
|
|
229
|
+
</mat-option>
|
|
230
|
+
</mat-autocomplete>
|
|
231
|
+
<button mat-icon-button rxapInputClearButton matSuffix>
|
|
232
|
+
<mat-icon>clear</mat-icon>
|
|
233
|
+
</button>
|
|
234
|
+
</mat-form-field></code></pre></div><b>Example :</b><div><pre class="line-numbers"><code class="language-typescript">@Injectable()
|
|
235
|
+
@RxapForm('form')
|
|
236
|
+
export class Form {
|
|
237
|
+
|
|
238
|
+
// ensure the table data source is provided - in root or in the form component
|
|
239
|
+
@UseAutocompleteOptionsMethod(SearchCompanyMethod)
|
|
240
|
+
// ensure the table data source is provided - in root or in the form component
|
|
241
|
+
@UseAutocompleteResolveMethod(GetCompanyMethod)
|
|
242
|
+
@UseFormControl()
|
|
243
|
+
company!: RxapFromControl<Company>;
|
|
244
|
+
|
|
245
|
+
}</code></pre></div><p>The DataSource <code>CompanyGuiTableDataSource</code> is used to populate the table in the selection window. Ensure that this DataSource is of the type <code>AbstractTableDataSource</code>.</p>
|
|
246
|
+
<p>The Method <code>SearchCompanyMethod</code> is used by the autocomplete control to search for a list of matching selection options. The Method must accept a string as the first argument and return a list of <code>ControlOption</code> objects.</p>
|
|
247
|
+
<p>The Method <code>GetCompanyMethod</code> is used to resolve the selected value. The Method must accept a the value of the form control as the first argument and return a <code>ControlOption</code> object.</p>
|
|
248
|
+
<b>Example :</b><div><pre class="line-numbers"><code class="language-typescript">export class SearchCompanyMethod implements Method<ControlOptions, { parameters: { search?: string | null } }> { ... }
|
|
249
|
+
export class GetCompanyMethod implements Method<ControlOption, { parameters: { value: string } }> { ... }</code></pre></div><h1>Method Parameter Adopter</h1>
|
|
250
|
+
<p>By default the following adopter function is used by the <code>@UseAutocompleteOptionsMethod</code> and <code>@UseAutocompleteResolveMethod</code> decorators.</p>
|
|
251
|
+
<b>Example :</b><div><pre class="line-numbers"><code class="language-typescript">(parameters) => ({parameters})</code></pre></div><p>To override this default adopter function use the second argument of the decorator.</p>
|
|
252
|
+
<b>Example :</b><div><pre class="line-numbers"><code class="language-typescript">@UseAutocompleteOptionsMethod(SearchCompanyMethod, { adapter: { parameter: (parameters) => ({ search: parameters.search }) } })</code></pre></div><blockquote>
|
|
253
|
+
<p>The adapter function are called in an injection context, so it is possible to use the <code>inject</code> function</p>
|
|
254
|
+
</blockquote>
|
|
216
255
|
</p>
|
|
217
256
|
</div>
|
|
218
257
|
|
|
@@ -221,6 +260,7 @@
|
|
|
221
260
|
AfterViewInit,
|
|
222
261
|
Directive,
|
|
223
262
|
inject,
|
|
263
|
+
Injectable,
|
|
224
264
|
Injector,
|
|
225
265
|
INJECTOR,
|
|
226
266
|
Input,
|
|
@@ -237,12 +277,23 @@ import { Mixin } from '@rxap/mixin';
|
|
|
237
277
|
import { NgControl } from '@angular/forms';
|
|
238
278
|
import { MatFormField } from '@angular/material/form-field';
|
|
239
279
|
import { isDefined } from '@rxap/rxjs';
|
|
280
|
+
import { ExtractControlMixin } from '../mixins/extract-control.mixin';
|
|
281
|
+
import { ExtractFormDefinitionMixin } from '../mixins/extract-form-definition.mixin';
|
|
282
|
+
import {
|
|
283
|
+
ExtractIsValueFunctionMixin,
|
|
284
|
+
UseIsValueFunction,
|
|
285
|
+
} from '../mixins/extract-is-value-function.mixin';
|
|
286
|
+
import { ExtractMethodMixin } from '../mixins/extract-method.mixin';
|
|
240
287
|
import { UseMethodConfig } from '../mixins/extract-methods.mixin';
|
|
241
288
|
import { UseOptionsMethod } from '../mixins/extract-options-method.mixin';
|
|
242
289
|
import {
|
|
243
290
|
ExtractResolveMethodMixin,
|
|
244
291
|
UseResolveMethod,
|
|
245
292
|
} from '../mixins/extract-resolve-method.mixin';
|
|
293
|
+
import {
|
|
294
|
+
ExtractToDisplayFunctionMixin,
|
|
295
|
+
UseToDisplayFunction,
|
|
296
|
+
} from '../mixins/extract-to-display-function.mixin';
|
|
246
297
|
import { OptionsFromMethodDirective, OptionsFromMethodDirectiveSettings } from './options-from-method.directive';
|
|
247
298
|
import { OpenApiRemoteMethodParameter } from '@rxap/open-api/remote-method';
|
|
248
299
|
import { controlValueChanges$ } from '@rxap/forms';
|
|
@@ -275,6 +326,18 @@ export function UseAutocompleteResolveMethod<Value = unknown>(
|
|
|
275
326
|
return UseResolveMethod(method, config);
|
|
276
327
|
}
|
|
277
328
|
|
|
329
|
+
export function UseAutocompleteIsValueFunction(
|
|
330
|
+
isValue: (value: any) => boolean,
|
|
331
|
+
): any {
|
|
332
|
+
return UseIsValueFunction(isValue);
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
export function UseAutocompleteToDisplayFunction(
|
|
336
|
+
toDisplay: (value: any) => string,
|
|
337
|
+
): any {
|
|
338
|
+
return UseToDisplayFunction(toDisplay);
|
|
339
|
+
}
|
|
340
|
+
|
|
278
341
|
export interface AutocompleteOptionsFromRemoteMethodTemplateContext {
|
|
279
342
|
$implicit: ControlOption;
|
|
280
343
|
}
|
|
@@ -289,10 +352,19 @@ export interface AutocompleteOptionsFromMethodDirectiveParameters<Value =
|
|
|
289
352
|
|
|
290
353
|
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
|
291
354
|
export interface AutocompleteOptionsFromMethodDirective<Value = any, Parameters extends AutocompleteOptionsFromMethodDirectiveParameters<Value> = AutocompleteOptionsFromMethodDirectiveParameters<Value>>
|
|
292
|
-
extends ExtractResolveMethodMixin, AfterViewInit, OnDestroy {
|
|
355
|
+
extends ExtractResolveMethodMixin, ExtractIsValueFunctionMixin, ExtractToDisplayFunctionMixin, AfterViewInit, OnDestroy {
|
|
293
356
|
}
|
|
294
357
|
|
|
295
|
-
@
|
|
358
|
+
@Injectable({ providedIn: 'root' })
|
|
359
|
+
export class NoopResolveMethod<Value> implements Method<ControlOption, { value: Value }> {
|
|
360
|
+
|
|
361
|
+
call({ value } : { value: Value }): Promise<ControlOption> {
|
|
362
|
+
return Promise.resolve({ value, display: value + '' });
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
@Mixin(ExtractResolveMethodMixin, ExtractIsValueFunctionMixin, ExtractToDisplayFunctionMixin)
|
|
296
368
|
@Directive({
|
|
297
369
|
// eslint-disable-next-line @angular-eslint/directive-selector
|
|
298
370
|
selector: '[rxapAutocompleteOptionsFromMethod]',
|
|
@@ -321,6 +393,13 @@ export class AutocompleteOptionsFromMethodDirective<Value = any, Paramet
|
|
|
321
393
|
// eslint-disable-next-line @angular-eslint/no-input-rename
|
|
322
394
|
@Input('rxapAutocompleteOptionsFromMethodResolve')
|
|
323
395
|
public resolveMethod?: MethodWithParameters<ControlOption, { value: Value } & Parameters>;
|
|
396
|
+
|
|
397
|
+
@Input('rxapAutocompleteOptionsFromMethodIsValue')
|
|
398
|
+
public isValue?: (value: any) => boolean;
|
|
399
|
+
|
|
400
|
+
@Input('rxapAutocompleteOptionsFromMethodToDisplay')
|
|
401
|
+
public toDisplay?: (value: any) => string;
|
|
402
|
+
|
|
324
403
|
protected override ngControl: NgControl | null = null;
|
|
325
404
|
protected override matFormField: MatFormField | null = null;
|
|
326
405
|
protected override injector: Injector = inject(INJECTOR);
|
|
@@ -342,12 +421,22 @@ export class AutocompleteOptionsFromMethodDirective<Value = any, Paramet
|
|
|
342
421
|
|
|
343
422
|
public override async ngAfterViewInit() {
|
|
344
423
|
if (this.matAutocomplete) {
|
|
345
|
-
this.matAutocomplete.displayWith = this.toDisplay.bind(this);
|
|
346
424
|
this.settings ??= {};
|
|
347
425
|
this.settings.filteredOptions ??= true;
|
|
348
426
|
}
|
|
349
427
|
await super.ngAfterViewInit();
|
|
350
428
|
this.resolveMethod ??= this.extractResolveMethod();
|
|
429
|
+
this.isValue ??= this.extractIsValueFunction((value: any) => typeof value === 'string' && isUUID(value));
|
|
430
|
+
this.toDisplay ??= this.extractToDisplayFunction((value: any): string => {
|
|
431
|
+
if (!value) {
|
|
432
|
+
return '';
|
|
433
|
+
}
|
|
434
|
+
const option = this.findOptionByValue(value);
|
|
435
|
+
return option?.display ?? (isDevMode() ? 'to display error' : '...');
|
|
436
|
+
});
|
|
437
|
+
if (this.matAutocomplete) {
|
|
438
|
+
this.matAutocomplete.displayWith = this.toDisplay.bind(this);
|
|
439
|
+
}
|
|
351
440
|
if (!this.control) {
|
|
352
441
|
throw new Error('The control is not yet defined');
|
|
353
442
|
}
|
|
@@ -360,32 +449,20 @@ export class AutocompleteOptionsFromMethodDirective<Value = any, Paramet
|
|
|
360
449
|
distinctUntilChanged(),
|
|
361
450
|
tap(async value => {
|
|
362
451
|
this.setOptions(await this.loadOptions(this.parameters));
|
|
363
|
-
if (this.isValue(value)) {
|
|
452
|
+
if (this.isValue?.(value)) {
|
|
364
453
|
this.triggerAutocompleteToDisplay();
|
|
365
454
|
}
|
|
366
455
|
}),
|
|
367
456
|
).subscribe();
|
|
368
457
|
}
|
|
369
458
|
|
|
370
|
-
public toDisplay(value: any): string {
|
|
371
|
-
if (!value) {
|
|
372
|
-
return '';
|
|
373
|
-
}
|
|
374
|
-
const option = this.findOptionByValue(value);
|
|
375
|
-
return option?.display ?? (isDevMode() ? 'to display error' : '...');
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
public isValue(value: any): boolean {
|
|
379
|
-
return typeof value === 'string' && isUUID(value);
|
|
380
|
-
}
|
|
381
|
-
|
|
382
459
|
protected override loadOptions(parameters: Parameters = {} as Parameters): Promise<ControlOptions | null> {
|
|
383
460
|
if (!this.control) {
|
|
384
461
|
throw new Error('The control is not yet defined');
|
|
385
462
|
}
|
|
386
463
|
const value = this.control?.value;
|
|
387
464
|
const c_parameters = {...parameters};
|
|
388
|
-
if (this.isValue(value)) {
|
|
465
|
+
if (this.isValue?.(value)) {
|
|
389
466
|
return this.resolveValue(value, c_parameters);
|
|
390
467
|
} else {
|
|
391
468
|
c_parameters.search ??= value;
|
|
@@ -200,7 +200,46 @@
|
|
|
200
200
|
</div>
|
|
201
201
|
|
|
202
202
|
<div class="tab-pane fade " id="readme">
|
|
203
|
-
<p><h1>
|
|
203
|
+
<p><h1>Autocomplete Table Select</h1>
|
|
204
|
+
<h1>With Rxap form System</h1>
|
|
205
|
+
<b>Example :</b><div><pre class="line-numbers"><code class="language-angular2html">
|
|
206
|
+
<mat-form-field>
|
|
207
|
+
<mat-label>Company</mat-label>
|
|
208
|
+
<input type="text"
|
|
209
|
+
placeholder="Enter Company Name"
|
|
210
|
+
matInput
|
|
211
|
+
formControlName="company"
|
|
212
|
+
[matAutocomplete]="auto">
|
|
213
|
+
<!-- The autocomplete input -->
|
|
214
|
+
<mat-autocomplete #auto="matAutocomplete">
|
|
215
|
+
<mat-option *rxapAutocompleteOptionsFromMethod="let option; matAutocomplete: auto"
|
|
216
|
+
[value]="option.value">{{ option.display }}
|
|
217
|
+
</mat-option>
|
|
218
|
+
</mat-autocomplete>
|
|
219
|
+
<button mat-icon-button rxapInputClearButton matSuffix>
|
|
220
|
+
<mat-icon>clear</mat-icon>
|
|
221
|
+
</button>
|
|
222
|
+
</mat-form-field></code></pre></div><b>Example :</b><div><pre class="line-numbers"><code class="language-typescript">@Injectable()
|
|
223
|
+
@RxapForm('form')
|
|
224
|
+
export class Form {
|
|
225
|
+
|
|
226
|
+
// ensure the table data source is provided - in root or in the form component
|
|
227
|
+
@UseAutocompleteOptionsMethod(SearchCompanyMethod)
|
|
228
|
+
// ensure the table data source is provided - in root or in the form component
|
|
229
|
+
@UseAutocompleteResolveMethod(GetCompanyMethod)
|
|
230
|
+
@UseFormControl()
|
|
231
|
+
company!: RxapFromControl<Company>;
|
|
232
|
+
|
|
233
|
+
}</code></pre></div><p>The DataSource <code>CompanyGuiTableDataSource</code> is used to populate the table in the selection window. Ensure that this DataSource is of the type <code>AbstractTableDataSource</code>.</p>
|
|
234
|
+
<p>The Method <code>SearchCompanyMethod</code> is used by the autocomplete control to search for a list of matching selection options. The Method must accept a string as the first argument and return a list of <code>ControlOption</code> objects.</p>
|
|
235
|
+
<p>The Method <code>GetCompanyMethod</code> is used to resolve the selected value. The Method must accept a the value of the form control as the first argument and return a <code>ControlOption</code> object.</p>
|
|
236
|
+
<b>Example :</b><div><pre class="line-numbers"><code class="language-typescript">export class SearchCompanyMethod implements Method<ControlOptions, { parameters: { search?: string | null } }> { ... }
|
|
237
|
+
export class GetCompanyMethod implements Method<ControlOption, { parameters: { value: string } }> { ... }</code></pre></div><h1>Method Parameter Adopter</h1>
|
|
238
|
+
<p>By default the following adopter function is used by the <code>@UseAutocompleteOptionsMethod</code> and <code>@UseAutocompleteResolveMethod</code> decorators.</p>
|
|
239
|
+
<b>Example :</b><div><pre class="line-numbers"><code class="language-typescript">(parameters) => ({parameters})</code></pre></div><p>To override this default adopter function use the second argument of the decorator.</p>
|
|
240
|
+
<b>Example :</b><div><pre class="line-numbers"><code class="language-typescript">@UseAutocompleteOptionsMethod(SearchCompanyMethod, { adapter: { parameter: (parameters) => ({ search: parameters.search }) } })</code></pre></div><blockquote>
|
|
241
|
+
<p>The adapter function are called in an injection context, so it is possible to use the <code>inject</code> function</p>
|
|
242
|
+
</blockquote>
|
|
204
243
|
</p>
|
|
205
244
|
</div>
|
|
206
245
|
|
|
@@ -209,6 +248,7 @@
|
|
|
209
248
|
AfterViewInit,
|
|
210
249
|
Directive,
|
|
211
250
|
inject,
|
|
251
|
+
Injectable,
|
|
212
252
|
Injector,
|
|
213
253
|
INJECTOR,
|
|
214
254
|
Input,
|
|
@@ -225,12 +265,23 @@ import { Mixin } from '@rxap/mixin';
|
|
|
225
265
|
import { NgControl } from '@angular/forms';
|
|
226
266
|
import { MatFormField } from '@angular/material/form-field';
|
|
227
267
|
import { isDefined } from '@rxap/rxjs';
|
|
268
|
+
import { ExtractControlMixin } from '../mixins/extract-control.mixin';
|
|
269
|
+
import { ExtractFormDefinitionMixin } from '../mixins/extract-form-definition.mixin';
|
|
270
|
+
import {
|
|
271
|
+
ExtractIsValueFunctionMixin,
|
|
272
|
+
UseIsValueFunction,
|
|
273
|
+
} from '../mixins/extract-is-value-function.mixin';
|
|
274
|
+
import { ExtractMethodMixin } from '../mixins/extract-method.mixin';
|
|
228
275
|
import { UseMethodConfig } from '../mixins/extract-methods.mixin';
|
|
229
276
|
import { UseOptionsMethod } from '../mixins/extract-options-method.mixin';
|
|
230
277
|
import {
|
|
231
278
|
ExtractResolveMethodMixin,
|
|
232
279
|
UseResolveMethod,
|
|
233
280
|
} from '../mixins/extract-resolve-method.mixin';
|
|
281
|
+
import {
|
|
282
|
+
ExtractToDisplayFunctionMixin,
|
|
283
|
+
UseToDisplayFunction,
|
|
284
|
+
} from '../mixins/extract-to-display-function.mixin';
|
|
234
285
|
import { OptionsFromMethodDirective, OptionsFromMethodDirectiveSettings } from './options-from-method.directive';
|
|
235
286
|
import { OpenApiRemoteMethodParameter } from '@rxap/open-api/remote-method';
|
|
236
287
|
import { controlValueChanges$ } from '@rxap/forms';
|
|
@@ -263,6 +314,18 @@ export function UseAutocompleteResolveMethod<Value = unknown>(
|
|
|
263
314
|
return UseResolveMethod(method, config);
|
|
264
315
|
}
|
|
265
316
|
|
|
317
|
+
export function UseAutocompleteIsValueFunction(
|
|
318
|
+
isValue: (value: any) => boolean,
|
|
319
|
+
): any {
|
|
320
|
+
return UseIsValueFunction(isValue);
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
export function UseAutocompleteToDisplayFunction(
|
|
324
|
+
toDisplay: (value: any) => string,
|
|
325
|
+
): any {
|
|
326
|
+
return UseToDisplayFunction(toDisplay);
|
|
327
|
+
}
|
|
328
|
+
|
|
266
329
|
export interface AutocompleteOptionsFromRemoteMethodTemplateContext {
|
|
267
330
|
$implicit: ControlOption;
|
|
268
331
|
}
|
|
@@ -277,10 +340,19 @@ export interface AutocompleteOptionsFromMethodDirectiveParameters<Value =
|
|
|
277
340
|
|
|
278
341
|
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
|
279
342
|
export interface AutocompleteOptionsFromMethodDirective<Value = any, Parameters extends AutocompleteOptionsFromMethodDirectiveParameters<Value> = AutocompleteOptionsFromMethodDirectiveParameters<Value>>
|
|
280
|
-
extends ExtractResolveMethodMixin, AfterViewInit, OnDestroy {
|
|
343
|
+
extends ExtractResolveMethodMixin, ExtractIsValueFunctionMixin, ExtractToDisplayFunctionMixin, AfterViewInit, OnDestroy {
|
|
281
344
|
}
|
|
282
345
|
|
|
283
|
-
@
|
|
346
|
+
@Injectable({ providedIn: 'root' })
|
|
347
|
+
export class NoopResolveMethod<Value> implements Method<ControlOption, { value: Value }> {
|
|
348
|
+
|
|
349
|
+
call({ value } : { value: Value }): Promise<ControlOption> {
|
|
350
|
+
return Promise.resolve({ value, display: value + '' });
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
@Mixin(ExtractResolveMethodMixin, ExtractIsValueFunctionMixin, ExtractToDisplayFunctionMixin)
|
|
284
356
|
@Directive({
|
|
285
357
|
// eslint-disable-next-line @angular-eslint/directive-selector
|
|
286
358
|
selector: '[rxapAutocompleteOptionsFromMethod]',
|
|
@@ -309,6 +381,13 @@ export class AutocompleteOptionsFromMethodDirective<Value = any, Paramet
|
|
|
309
381
|
// eslint-disable-next-line @angular-eslint/no-input-rename
|
|
310
382
|
@Input('rxapAutocompleteOptionsFromMethodResolve')
|
|
311
383
|
public resolveMethod?: MethodWithParameters<ControlOption, { value: Value } & Parameters>;
|
|
384
|
+
|
|
385
|
+
@Input('rxapAutocompleteOptionsFromMethodIsValue')
|
|
386
|
+
public isValue?: (value: any) => boolean;
|
|
387
|
+
|
|
388
|
+
@Input('rxapAutocompleteOptionsFromMethodToDisplay')
|
|
389
|
+
public toDisplay?: (value: any) => string;
|
|
390
|
+
|
|
312
391
|
protected override ngControl: NgControl | null = null;
|
|
313
392
|
protected override matFormField: MatFormField | null = null;
|
|
314
393
|
protected override injector: Injector = inject(INJECTOR);
|
|
@@ -330,12 +409,22 @@ export class AutocompleteOptionsFromMethodDirective<Value = any, Paramet
|
|
|
330
409
|
|
|
331
410
|
public override async ngAfterViewInit() {
|
|
332
411
|
if (this.matAutocomplete) {
|
|
333
|
-
this.matAutocomplete.displayWith = this.toDisplay.bind(this);
|
|
334
412
|
this.settings ??= {};
|
|
335
413
|
this.settings.filteredOptions ??= true;
|
|
336
414
|
}
|
|
337
415
|
await super.ngAfterViewInit();
|
|
338
416
|
this.resolveMethod ??= this.extractResolveMethod();
|
|
417
|
+
this.isValue ??= this.extractIsValueFunction((value: any) => typeof value === 'string' && isUUID(value));
|
|
418
|
+
this.toDisplay ??= this.extractToDisplayFunction((value: any): string => {
|
|
419
|
+
if (!value) {
|
|
420
|
+
return '';
|
|
421
|
+
}
|
|
422
|
+
const option = this.findOptionByValue(value);
|
|
423
|
+
return option?.display ?? (isDevMode() ? 'to display error' : '...');
|
|
424
|
+
});
|
|
425
|
+
if (this.matAutocomplete) {
|
|
426
|
+
this.matAutocomplete.displayWith = this.toDisplay.bind(this);
|
|
427
|
+
}
|
|
339
428
|
if (!this.control) {
|
|
340
429
|
throw new Error('The control is not yet defined');
|
|
341
430
|
}
|
|
@@ -348,32 +437,20 @@ export class AutocompleteOptionsFromMethodDirective<Value = any, Paramet
|
|
|
348
437
|
distinctUntilChanged(),
|
|
349
438
|
tap(async value => {
|
|
350
439
|
this.setOptions(await this.loadOptions(this.parameters));
|
|
351
|
-
if (this.isValue(value)) {
|
|
440
|
+
if (this.isValue?.(value)) {
|
|
352
441
|
this.triggerAutocompleteToDisplay();
|
|
353
442
|
}
|
|
354
443
|
}),
|
|
355
444
|
).subscribe();
|
|
356
445
|
}
|
|
357
446
|
|
|
358
|
-
public toDisplay(value: any): string {
|
|
359
|
-
if (!value) {
|
|
360
|
-
return '';
|
|
361
|
-
}
|
|
362
|
-
const option = this.findOptionByValue(value);
|
|
363
|
-
return option?.display ?? (isDevMode() ? 'to display error' : '...');
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
public isValue(value: any): boolean {
|
|
367
|
-
return typeof value === 'string' && isUUID(value);
|
|
368
|
-
}
|
|
369
|
-
|
|
370
447
|
protected override loadOptions(parameters: Parameters = {} as Parameters): Promise<ControlOptions | null> {
|
|
371
448
|
if (!this.control) {
|
|
372
449
|
throw new Error('The control is not yet defined');
|
|
373
450
|
}
|
|
374
451
|
const value = this.control?.value;
|
|
375
452
|
const c_parameters = {...parameters};
|
|
376
|
-
if (this.isValue(value)) {
|
|
453
|
+
if (this.isValue?.(value)) {
|
|
377
454
|
return this.resolveValue(value, c_parameters);
|
|
378
455
|
} else {
|
|
379
456
|
c_parameters.search ??= value;
|
|
@@ -140,6 +140,7 @@
|
|
|
140
140
|
ChangeDetectorRef,
|
|
141
141
|
Directive,
|
|
142
142
|
inject,
|
|
143
|
+
InjectFlags,
|
|
143
144
|
INJECTOR,
|
|
144
145
|
Injector,
|
|
145
146
|
Input,
|
|
@@ -211,7 +212,7 @@ export class OptionsFromMethodDirective<Value = any, Parameters = a
|
|
|
211
212
|
|
|
212
213
|
public async ngAfterViewInit() {
|
|
213
214
|
this.matFormField = this.injector.get(MatFormField, null);
|
|
214
|
-
this.ngControl = this.injector.get(NgControl,
|
|
215
|
+
this.ngControl = this.matFormField?._control.ngControl ?? this.injector.get(NgControl, null);
|
|
215
216
|
this.control = (this.ngControl?.control as RxapFormControl) ?? undefined;
|
|
216
217
|
this.method ??= this.extractOptionsMethod();
|
|
217
218
|
// ensure that the options are loaded. It is possible that the ngOnChange is triggered before the ngAfterViewInit
|
|
@@ -200,6 +200,7 @@
|
|
|
200
200
|
ChangeDetectorRef,
|
|
201
201
|
Directive,
|
|
202
202
|
inject,
|
|
203
|
+
InjectFlags,
|
|
203
204
|
INJECTOR,
|
|
204
205
|
Injector,
|
|
205
206
|
Input,
|
|
@@ -271,7 +272,7 @@ export class OptionsFromMethodDirective<Value = any, Parameters = a
|
|
|
271
272
|
|
|
272
273
|
public async ngAfterViewInit() {
|
|
273
274
|
this.matFormField = this.injector.get(MatFormField, null);
|
|
274
|
-
this.ngControl = this.injector.get(NgControl,
|
|
275
|
+
this.ngControl = this.matFormField?._control.ngControl ?? this.injector.get(NgControl, null);
|
|
275
276
|
this.control = (this.ngControl?.control as RxapFormControl) ?? undefined;
|
|
276
277
|
this.method ??= this.extractOptionsMethod();
|
|
277
278
|
// ensure that the options are loaded. It is possible that the ngOnChange is triggered before the ngAfterViewInit
|