@elite.framework/ng.ui.core 1.0.59 → 1.0.60

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.
@@ -20,6 +20,7 @@ import * as i6 from 'primeng/button';
20
20
  import { ButtonModule } from 'primeng/button';
21
21
  import * as i1 from '@elite.framework/ng.core/services';
22
22
  import { BaseService } from '@elite.framework/ng.core/services';
23
+ import { GenericDialogComponent } from '@elite.framework/ng.ui.core/generic-dialog';
23
24
 
24
25
  class GenericSelectorModule {
25
26
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.8", ngImport: i0, type: GenericSelectorModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
@@ -38,12 +39,12 @@ class GenericSelectorTypeComponent extends FieldType {
38
39
  injector;
39
40
  cdr;
40
41
  autoComp;
42
+ dialog;
41
43
  options_ = [];
42
44
  selectedItem;
43
45
  loading = false;
44
46
  _offlineList = [];
45
47
  api;
46
- dialog;
47
48
  valueChangeSubscription; // Add a subscription to manage the observable
48
49
  constructor(svc, injector, cdr) {
49
50
  super();
@@ -53,7 +54,6 @@ class GenericSelectorTypeComponent extends FieldType {
53
54
  }
54
55
  ngOnInit() {
55
56
  this.api = this.svc;
56
- this.dialog = this.injector.get(DialogService);
57
57
  const to = this.props;
58
58
  this.api.apiName = to['serviceName'];
59
59
  if (to['offline']) {
@@ -159,6 +159,13 @@ class GenericSelectorTypeComponent extends FieldType {
159
159
  });
160
160
  }
161
161
  // New method to handle loading the default value from the API
162
+ afterSave(event) {
163
+ this.onSelectionChange(event.record);
164
+ if (this.props.afterSave) {
165
+ this.props.afterSave(this.field, { item: event.response });
166
+ this.cdr.detectChanges();
167
+ }
168
+ }
162
169
  onSelect(event) {
163
170
  if (this.props.onSelect) {
164
171
  this.props.onSelect(this.field, { item: event.value });
@@ -268,8 +275,21 @@ class GenericSelectorTypeComponent extends FieldType {
268
275
  }
269
276
  return fixedFilters || {};
270
277
  }
278
+ onArrowDown(event) {
279
+ event.preventDefault();
280
+ // this.autoComp.show();
281
+ this.onDropdownButtonClick();
282
+ }
283
+ onEscape(event) {
284
+ this.autoComp.hide();
285
+ }
286
+ onAddNewClick() {
287
+ // your logic for adding a new item
288
+ // e.g. open dialog or emit event
289
+ console.log('Add new item clicked');
290
+ this.dialog.openForm("create");
291
+ }
271
292
  onDropdownButtonClick() {
272
- console.log('Custom dropdown button clicked!');
273
293
  this.search({ query: '' }); // trigger your own search
274
294
  setTimeout(() => this.autoComp.show(), 0); // force dropdown to open
275
295
  }
@@ -353,9 +373,8 @@ class GenericSelectorTypeComponent extends FieldType {
353
373
  this.selectedItem.some((sel) => sel[vf] === item[vf]);
354
374
  }
355
375
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.8", ngImport: i0, type: GenericSelectorTypeComponent, deps: [{ token: i1.BaseService }, { token: i0.Injector }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
356
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.1.8", type: GenericSelectorTypeComponent, isStandalone: true, selector: "formly-generic-selector", providers: [DialogService, BaseService], viewQueries: [{ propertyName: "autoComp", first: true, predicate: ["autoComp"], descendants: true }], usesInheritance: true, ngImport: i0, template: `
357
- <!-- (ngModelChange)="onSelectionChange($event)" -->
358
- <p-inputGroup class="w-full">
376
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.1.8", type: GenericSelectorTypeComponent, isStandalone: true, selector: "formly-generic-selector", providers: [DialogService, BaseService], viewQueries: [{ propertyName: "autoComp", first: true, predicate: ["autoComp"], descendants: true }, { propertyName: "dialog", first: true, predicate: ["dialog"], descendants: true }], usesInheritance: true, ngImport: i0, template: `
377
+ <p-inputGroup class="w-full">
359
378
  <p-autoComplete
360
379
  #autoComp
361
380
  [ngModel]="selectedItem"
@@ -375,25 +394,55 @@ class GenericSelectorTypeComponent extends FieldType {
375
394
  [showEmptyMessage]="true"
376
395
  (onSelect)="onSelect($event)"
377
396
  emptyMessage="{{ getEmptyMessage() | translate }}"
378
- [showTransitionOptions]="'0ms'">
397
+ [showTransitionOptions]="'0ms'"
398
+ [showClear]="false"
399
+
400
+ (keydown.arrowdown)="onArrowDown($event)"
401
+ (keydown.escape)="onEscape($event)"
402
+ >
379
403
  </p-autoComplete>
380
404
 
381
- <!-- 🔘 Custom dropdown addon -->
382
405
  <p-inputGroupAddon>
383
- <p-button [disabled]="!!props.disabled" icon="pi pi-chevron-down" (click)="onDropdownButtonClick()" severity="secondary" />
406
+ <p-button
407
+ tabindex="-1"
408
+ [disabled]="!!props.disabled || loading"
409
+ [icon]="loading ? 'pi pi-spinner pi-spin' : 'pi pi-chevron-down'"
410
+ (click)="onDropdownButtonClick()"
411
+ severity="secondary" />
384
412
  </p-inputGroupAddon>
413
+ <!-- Add new button -->
414
+ @if (props.canAdd && props.formFields) {
415
+ <p-inputGroupAddon>
416
+ <p-button
417
+ tabindex="-1"
418
+ [disabled]="!!props.disabled"
419
+ icon="pi pi-plus"
420
+ (click)="onAddNewClick()"
421
+ severity="primary" />
422
+ </p-inputGroupAddon>
423
+ }
385
424
  </p-inputGroup>
386
425
 
426
+ <!-- [model]="model" -->
427
+ <app-generic-dialog
428
+ #dialog
429
+ [formFields]="props.formFields ?? []"
430
+ [apiName]="props.serviceName"
431
+ [idField]="props.idField ??'id'"
432
+ [displayMode]="props.dialogDisplayMode ?? 'dialog'"
433
+ (afterSave)="afterSave($event)"
434
+ >
435
+ </app-generic-dialog>
387
436
 
388
- `, isInline: true, dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "ngmodule", type: AutoCompleteModule }, { kind: "component", type: i3.AutoComplete, selector: "p-autoComplete, p-autocomplete, p-auto-complete", inputs: ["minLength", "minQueryLength", "delay", "panelStyle", "styleClass", "panelStyleClass", "inputStyle", "inputId", "inputStyleClass", "placeholder", "readonly", "scrollHeight", "lazy", "virtualScroll", "virtualScrollItemSize", "virtualScrollOptions", "autoHighlight", "forceSelection", "type", "autoZIndex", "baseZIndex", "ariaLabel", "dropdownAriaLabel", "ariaLabelledBy", "dropdownIcon", "unique", "group", "completeOnFocus", "showClear", "dropdown", "showEmptyMessage", "dropdownMode", "multiple", "tabindex", "dataKey", "emptyMessage", "showTransitionOptions", "hideTransitionOptions", "autofocus", "autocomplete", "optionGroupChildren", "optionGroupLabel", "overlayOptions", "suggestions", "optionLabel", "optionValue", "id", "searchMessage", "emptySelectionMessage", "selectionMessage", "autoOptionFocus", "selectOnFocus", "searchLocale", "optionDisabled", "focusOnHover", "typeahead", "appendTo"], outputs: ["completeMethod", "onSelect", "onUnselect", "onFocus", "onBlur", "onDropdownClick", "onClear", "onKeyUp", "onShow", "onHide", "onLazyLoad"] }, { kind: "ngmodule", type: CommonModule }, { kind: "ngmodule", type: InputGroupModule }, { kind: "component", type: i4.InputGroup, selector: "p-inputgroup, p-inputGroup, p-input-group", inputs: ["styleClass"] }, { kind: "ngmodule", type: InputGroupAddonModule }, { kind: "component", type: i5.InputGroupAddon, selector: "p-inputgroup-addon, p-inputGroupAddon", inputs: ["style", "styleClass"] }, { kind: "directive", type: FormlyAttributes, selector: "[formlyAttributes]", inputs: ["formlyAttributes", "id"] }, { kind: "ngmodule", type: TranslateModule }, { kind: "ngmodule", type: CheckboxModule }, { kind: "ngmodule", type: ButtonModule }, { kind: "component", type: i6.Button, selector: "p-button", inputs: ["type", "iconPos", "icon", "badge", "label", "disabled", "loading", "loadingIcon", "raised", "rounded", "text", "plain", "severity", "outlined", "link", "tabindex", "size", "variant", "style", "styleClass", "badgeClass", "badgeSeverity", "ariaLabel", "buttonProps", "autofocus", "fluid"], outputs: ["onClick", "onFocus", "onBlur"] }, { kind: "pipe", type: i7.TranslatePipe, name: "translate" }] });
437
+
438
+ `, isInline: true, dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "ngmodule", type: AutoCompleteModule }, { kind: "component", type: i3.AutoComplete, selector: "p-autoComplete, p-autocomplete, p-auto-complete", inputs: ["minLength", "minQueryLength", "delay", "panelStyle", "styleClass", "panelStyleClass", "inputStyle", "inputId", "inputStyleClass", "placeholder", "readonly", "scrollHeight", "lazy", "virtualScroll", "virtualScrollItemSize", "virtualScrollOptions", "autoHighlight", "forceSelection", "type", "autoZIndex", "baseZIndex", "ariaLabel", "dropdownAriaLabel", "ariaLabelledBy", "dropdownIcon", "unique", "group", "completeOnFocus", "showClear", "dropdown", "showEmptyMessage", "dropdownMode", "multiple", "tabindex", "dataKey", "emptyMessage", "showTransitionOptions", "hideTransitionOptions", "autofocus", "autocomplete", "optionGroupChildren", "optionGroupLabel", "overlayOptions", "suggestions", "optionLabel", "optionValue", "id", "searchMessage", "emptySelectionMessage", "selectionMessage", "autoOptionFocus", "selectOnFocus", "searchLocale", "optionDisabled", "focusOnHover", "typeahead", "appendTo"], outputs: ["completeMethod", "onSelect", "onUnselect", "onFocus", "onBlur", "onDropdownClick", "onClear", "onKeyUp", "onShow", "onHide", "onLazyLoad"] }, { kind: "ngmodule", type: CommonModule }, { kind: "ngmodule", type: InputGroupModule }, { kind: "component", type: i4.InputGroup, selector: "p-inputgroup, p-inputGroup, p-input-group", inputs: ["styleClass"] }, { kind: "ngmodule", type: InputGroupAddonModule }, { kind: "component", type: i5.InputGroupAddon, selector: "p-inputgroup-addon, p-inputGroupAddon", inputs: ["style", "styleClass"] }, { kind: "directive", type: FormlyAttributes, selector: "[formlyAttributes]", inputs: ["formlyAttributes", "id"] }, { kind: "ngmodule", type: TranslateModule }, { kind: "ngmodule", type: CheckboxModule }, { kind: "ngmodule", type: ButtonModule }, { kind: "component", type: i6.Button, selector: "p-button", inputs: ["type", "iconPos", "icon", "badge", "label", "disabled", "loading", "loadingIcon", "raised", "rounded", "text", "plain", "severity", "outlined", "link", "tabindex", "size", "variant", "style", "styleClass", "badgeClass", "badgeSeverity", "ariaLabel", "buttonProps", "autofocus", "fluid"], outputs: ["onClick", "onFocus", "onBlur"] }, { kind: "component", type: GenericDialogComponent, selector: "app-generic-dialog", inputs: ["service", "formFields", "model", "apiName", "idField", "dialogMaxWidth", "displayMode", "mode", "forceState", "drawerVisible", "dialogVisible", "isViewMode", "isEditMode", "useConfirmOnSave", "loading", "errorMsg", "errorMessage", "beforeSaveTransform", "hideTable", "autoShowForm"], outputs: ["action", "afterSave", "afterDelete", "beforeSave", "beforeDelete", "formCancel", "formInit", "dataLoaded", "selectionChange", "error", "visibleChange"] }, { kind: "pipe", type: i7.TranslatePipe, name: "translate" }] });
389
439
  }
390
440
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.8", ngImport: i0, type: GenericSelectorTypeComponent, decorators: [{
391
441
  type: Component,
392
442
  args: [{
393
443
  selector: 'formly-generic-selector',
394
444
  template: `
395
- <!-- (ngModelChange)="onSelectionChange($event)" -->
396
- <p-inputGroup class="w-full">
445
+ <p-inputGroup class="w-full">
397
446
  <p-autoComplete
398
447
  #autoComp
399
448
  [ngModel]="selectedItem"
@@ -413,15 +462,46 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.8", ngImpor
413
462
  [showEmptyMessage]="true"
414
463
  (onSelect)="onSelect($event)"
415
464
  emptyMessage="{{ getEmptyMessage() | translate }}"
416
- [showTransitionOptions]="'0ms'">
465
+ [showTransitionOptions]="'0ms'"
466
+ [showClear]="false"
467
+
468
+ (keydown.arrowdown)="onArrowDown($event)"
469
+ (keydown.escape)="onEscape($event)"
470
+ >
417
471
  </p-autoComplete>
418
472
 
419
- <!-- 🔘 Custom dropdown addon -->
420
473
  <p-inputGroupAddon>
421
- <p-button [disabled]="!!props.disabled" icon="pi pi-chevron-down" (click)="onDropdownButtonClick()" severity="secondary" />
474
+ <p-button
475
+ tabindex="-1"
476
+ [disabled]="!!props.disabled || loading"
477
+ [icon]="loading ? 'pi pi-spinner pi-spin' : 'pi pi-chevron-down'"
478
+ (click)="onDropdownButtonClick()"
479
+ severity="secondary" />
422
480
  </p-inputGroupAddon>
481
+ <!-- Add new button -->
482
+ @if (props.canAdd && props.formFields) {
483
+ <p-inputGroupAddon>
484
+ <p-button
485
+ tabindex="-1"
486
+ [disabled]="!!props.disabled"
487
+ icon="pi pi-plus"
488
+ (click)="onAddNewClick()"
489
+ severity="primary" />
490
+ </p-inputGroupAddon>
491
+ }
423
492
  </p-inputGroup>
424
493
 
494
+ <!-- [model]="model" -->
495
+ <app-generic-dialog
496
+ #dialog
497
+ [formFields]="props.formFields ?? []"
498
+ [apiName]="props.serviceName"
499
+ [idField]="props.idField ??'id'"
500
+ [displayMode]="props.dialogDisplayMode ?? 'dialog'"
501
+ (afterSave)="afterSave($event)"
502
+ >
503
+ </app-generic-dialog>
504
+
425
505
 
426
506
  `,
427
507
  providers: [DialogService, BaseService],
@@ -436,12 +516,16 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.8", ngImpor
436
516
  TranslateModule,
437
517
  AutoComplete,
438
518
  CheckboxModule,
439
- ButtonModule
519
+ ButtonModule,
520
+ GenericDialogComponent
440
521
  ]
441
522
  }]
442
523
  }], ctorParameters: () => [{ type: i1.BaseService }, { type: i0.Injector }, { type: i0.ChangeDetectorRef }], propDecorators: { autoComp: [{
443
524
  type: ViewChild,
444
525
  args: ['autoComp']
526
+ }], dialog: [{
527
+ type: ViewChild,
528
+ args: ['dialog']
445
529
  }] } });
446
530
 
447
531
  /**