@praxisui/table 8.0.0-beta.26 → 8.0.0-beta.28

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.
@@ -10,6 +10,8 @@ import * as i15 from '@angular/material/progress-bar';
10
10
  import { MatProgressBarModule } from '@angular/material/progress-bar';
11
11
  import * as i5 from '@angular/material/icon';
12
12
  import { MatIconModule } from '@angular/material/icon';
13
+ import * as i10 from '@angular/material/tooltip';
14
+ import { MatTooltipModule } from '@angular/material/tooltip';
13
15
  import { PraxisFilterForm } from '@praxisui/dynamic-form';
14
16
 
15
17
  class FilterFormDialogHostComponent {
@@ -20,6 +22,7 @@ class FilterFormDialogHostComponent {
20
22
  lastValue = {};
21
23
  formGroup = null;
22
24
  canSave = false;
25
+ saving = false;
23
26
  constructor(data, ref) {
24
27
  this.data = data;
25
28
  this.ref = ref;
@@ -32,10 +35,10 @@ class FilterFormDialogHostComponent {
32
35
  ev.formGroup.patchValue(dto, { emitEvent: false });
33
36
  }
34
37
  this.lastValue = this.formGroup?.getRawValue?.() ?? this.lastValue;
35
- this.updateCanSave();
36
38
  }
37
39
  catch { }
38
40
  this.ready = true;
41
+ this.updateCanSave();
39
42
  }
40
43
  onChange(ev) {
41
44
  this.lastValue = ev?.formData ?? {};
@@ -64,20 +67,42 @@ class FilterFormDialogHostComponent {
64
67
  }
65
68
  buildDtoForSave() {
66
69
  const base = this.data?.initialDto || {};
67
- const merged = { ...base, ...(this.lastValue || {}) };
70
+ const current = this.formGroup?.getRawValue?.() ?? this.lastValue ?? {};
71
+ const merged = { ...base, ...current };
68
72
  return this.clean(merged);
69
73
  }
70
74
  updateCanSave() {
71
- this.canSave = Object.keys(this.buildDtoForSave() || {}).length > 0;
75
+ this.canSave =
76
+ this.ready &&
77
+ this.valid &&
78
+ Object.keys(this.buildDtoForSave() || {}).length > 0;
79
+ }
80
+ saveShortcutTooltip() {
81
+ if (this.saving) {
82
+ return this.data.i18n?.shortcutSaving || 'Salvando atalho...';
83
+ }
84
+ if (!this.valid) {
85
+ return this.data.i18n?.shortcutInvalid || 'Corrija os filtros antes de salvar o atalho.';
86
+ }
87
+ if (!Object.keys(this.buildDtoForSave() || {}).length) {
88
+ return this.data.i18n?.shortcutRequiresFilter || 'Preencha ao menos um filtro para salvar um atalho.';
89
+ }
90
+ return '';
72
91
  }
73
92
  saveShortcut() {
93
+ if (!this.canSave || this.saving)
94
+ return;
95
+ const dto = this.buildDtoForSave();
96
+ if (!Object.keys(dto).length)
97
+ return;
98
+ this.saving = true;
74
99
  try {
75
- const dto = this.buildDtoForSave();
76
- if (!Object.keys(dto).length)
77
- return;
78
100
  this.data?.onSaveShortcut?.(dto);
79
101
  }
80
- catch { }
102
+ finally {
103
+ this.saving = false;
104
+ this.updateCanSave();
105
+ }
81
106
  }
82
107
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.17", ngImport: i0, type: FilterFormDialogHostComponent, deps: [{ token: MAT_DIALOG_DATA }, { token: i1.MatDialogRef }], target: i0.ɵɵFactoryTarget.Component });
83
108
  static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.17", type: FilterFormDialogHostComponent, isStandalone: true, selector: "praxis-filter-form-dialog-host", ngImport: i0, template: `
@@ -116,10 +141,14 @@ class FilterFormDialogHostComponent {
116
141
  <p *ngIf="!data?.config && !data?.schemaLoading" class="pfx-empty-state">{{ data.i18n?.noData || 'Nenhum dado' }}</p>
117
142
  </mat-dialog-content>
118
143
  <mat-dialog-actions align="end" class="pfx-dialog-actions">
119
- <button mat-button type="button"
144
+ <button mat-stroked-button type="button"
145
+ class="pfx-save-shortcut-button"
120
146
  *ngIf="data?.allowSaveTags"
121
- [disabled]="!canSave"
147
+ [disabled]="!canSave || saving"
148
+ [matTooltip]="saveShortcutTooltip()"
149
+ [matTooltipDisabled]="canSave && !saving"
122
150
  (click)="saveShortcut()">
151
+ <mat-icon aria-hidden="true">{{ saving ? 'hourglass_empty' : 'bookmark_add' }}</mat-icon>
123
152
  {{ data.i18n?.saveAsShortcut || 'Salvar como atalho' }}
124
153
  </button>
125
154
  <button mat-stroked-button type="button" (click)="close()">{{ data.i18n?.cancel || 'Cancelar' }}</button>
@@ -127,11 +156,11 @@ class FilterFormDialogHostComponent {
127
156
  {{ data.i18n?.apply || 'Aplicar' }}
128
157
  </button>
129
158
  </mat-dialog-actions>
130
- `, isInline: true, styles: [".pfx-dialog-title{display:flex;align-items:center;justify-content:space-between;gap:12px;padding-right:8px}.pfx-dialog-title-text{display:inline-flex;align-items:center;gap:8px;font-weight:600;color:var(--mdc-dialog-subhead-color, var(--md-sys-color-on-surface))}.pfx-dialog-close{margin-left:auto}.pfx-filter-dialog-content{display:flex;flex-direction:column;gap:12px;padding-top:8px}.pfx-empty-state{margin:8px 0 0;color:var(--mdc-dialog-supporting-text-color, var(--md-sys-color-on-surface-variant))}.pfx-dialog-loading{display:flex;flex-direction:column;gap:10px;min-height:128px;justify-content:center;color:var(--mdc-dialog-supporting-text-color, var(--md-sys-color-on-surface-variant));font-size:.875rem}.pfx-form-pending{height:0;overflow:hidden;visibility:hidden;pointer-events:none}.pfx-dialog-actions{padding:var(--pdx-dialog-actions-padding, 12px 24px 16px);border-top:1px solid var(--md-sys-color-outline-variant);background:transparent;display:flex;align-items:center;gap:8px}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "ngmodule", type: MatDialogModule }, { kind: "directive", type: i1.MatDialogTitle, selector: "[mat-dialog-title], [matDialogTitle]", inputs: ["id"], exportAs: ["matDialogTitle"] }, { kind: "directive", type: i1.MatDialogActions, selector: "[mat-dialog-actions], mat-dialog-actions, [matDialogActions]", inputs: ["align"] }, { kind: "directive", type: i1.MatDialogContent, selector: "[mat-dialog-content], mat-dialog-content, [matDialogContent]" }, { kind: "ngmodule", type: MatButtonModule }, { kind: "component", type: i3.MatButton, selector: " button[matButton], a[matButton], button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button], a[mat-button], a[mat-raised-button], a[mat-flat-button], a[mat-stroked-button] ", inputs: ["matButton"], exportAs: ["matButton", "matAnchor"] }, { kind: "component", type: i3.MatIconButton, selector: "button[mat-icon-button], a[mat-icon-button], button[matIconButton], a[matIconButton]", exportAs: ["matButton", "matAnchor"] }, { kind: "ngmodule", type: MatProgressBarModule }, { kind: "component", type: i15.MatProgressBar, selector: "mat-progress-bar", inputs: ["color", "value", "bufferValue", "mode"], outputs: ["animationEnd"], exportAs: ["matProgressBar"] }, { kind: "ngmodule", type: MatIconModule }, { kind: "component", type: i5.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "component", type: PraxisFilterForm, selector: "praxis-filter-form", inputs: ["config", "formId", "resourcePath", "mode"], outputs: ["formReady", "valueChange", "submit", "requestSearch", "validityChange"] }] });
159
+ `, isInline: true, styles: [".pfx-dialog-title{display:flex;align-items:center;justify-content:space-between;gap:12px;padding-right:8px}.pfx-dialog-title-text{display:inline-flex;align-items:center;gap:8px;font-weight:600;color:var(--mdc-dialog-subhead-color, var(--md-sys-color-on-surface))}.pfx-dialog-close{margin-left:auto}.pfx-filter-dialog-content{display:flex;flex-direction:column;gap:12px;padding-top:8px}.pfx-empty-state{margin:8px 0 0;color:var(--mdc-dialog-supporting-text-color, var(--md-sys-color-on-surface-variant))}.pfx-dialog-loading{display:flex;flex-direction:column;gap:10px;min-height:128px;justify-content:center;color:var(--mdc-dialog-supporting-text-color, var(--md-sys-color-on-surface-variant));font-size:.875rem}.pfx-form-pending{height:0;overflow:hidden;visibility:hidden;pointer-events:none}.pfx-dialog-actions{padding:var(--pdx-dialog-actions-padding, 12px 24px 16px);border-top:1px solid var(--md-sys-color-outline-variant);background:transparent;display:flex;align-items:center;gap:8px}.pfx-save-shortcut-button{margin-right:auto}.pfx-save-shortcut-button mat-icon{margin-right:6px;width:18px;height:18px;font-size:18px}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "ngmodule", type: MatDialogModule }, { kind: "directive", type: i1.MatDialogTitle, selector: "[mat-dialog-title], [matDialogTitle]", inputs: ["id"], exportAs: ["matDialogTitle"] }, { kind: "directive", type: i1.MatDialogActions, selector: "[mat-dialog-actions], mat-dialog-actions, [matDialogActions]", inputs: ["align"] }, { kind: "directive", type: i1.MatDialogContent, selector: "[mat-dialog-content], mat-dialog-content, [matDialogContent]" }, { kind: "ngmodule", type: MatButtonModule }, { kind: "component", type: i3.MatButton, selector: " button[matButton], a[matButton], button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button], a[mat-button], a[mat-raised-button], a[mat-flat-button], a[mat-stroked-button] ", inputs: ["matButton"], exportAs: ["matButton", "matAnchor"] }, { kind: "component", type: i3.MatIconButton, selector: "button[mat-icon-button], a[mat-icon-button], button[matIconButton], a[matIconButton]", exportAs: ["matButton", "matAnchor"] }, { kind: "ngmodule", type: MatProgressBarModule }, { kind: "component", type: i15.MatProgressBar, selector: "mat-progress-bar", inputs: ["color", "value", "bufferValue", "mode"], outputs: ["animationEnd"], exportAs: ["matProgressBar"] }, { kind: "ngmodule", type: MatIconModule }, { kind: "component", type: i5.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "ngmodule", type: MatTooltipModule }, { kind: "directive", type: i10.MatTooltip, selector: "[matTooltip]", inputs: ["matTooltipPosition", "matTooltipPositionAtOrigin", "matTooltipDisabled", "matTooltipShowDelay", "matTooltipHideDelay", "matTooltipTouchGestures", "matTooltip", "matTooltipClass"], exportAs: ["matTooltip"] }, { kind: "component", type: PraxisFilterForm, selector: "praxis-filter-form", inputs: ["config", "formId", "resourcePath", "mode"], outputs: ["formReady", "valueChange", "submit", "requestSearch", "validityChange"] }] });
131
160
  }
132
161
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.17", ngImport: i0, type: FilterFormDialogHostComponent, decorators: [{
133
162
  type: Component,
134
- args: [{ selector: 'praxis-filter-form-dialog-host', standalone: true, imports: [CommonModule, MatDialogModule, MatButtonModule, MatProgressBarModule, MatIconModule, PraxisFilterForm], template: `
163
+ args: [{ selector: 'praxis-filter-form-dialog-host', standalone: true, imports: [CommonModule, MatDialogModule, MatButtonModule, MatProgressBarModule, MatIconModule, MatTooltipModule, PraxisFilterForm], template: `
135
164
  <div mat-dialog-title class="pfx-dialog-title" id="filterDialogTitle">
136
165
  <div class="pfx-dialog-title-text">
137
166
  <mat-icon>tune</mat-icon>
@@ -167,10 +196,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.17", ngImpo
167
196
  <p *ngIf="!data?.config && !data?.schemaLoading" class="pfx-empty-state">{{ data.i18n?.noData || 'Nenhum dado' }}</p>
168
197
  </mat-dialog-content>
169
198
  <mat-dialog-actions align="end" class="pfx-dialog-actions">
170
- <button mat-button type="button"
199
+ <button mat-stroked-button type="button"
200
+ class="pfx-save-shortcut-button"
171
201
  *ngIf="data?.allowSaveTags"
172
- [disabled]="!canSave"
202
+ [disabled]="!canSave || saving"
203
+ [matTooltip]="saveShortcutTooltip()"
204
+ [matTooltipDisabled]="canSave && !saving"
173
205
  (click)="saveShortcut()">
206
+ <mat-icon aria-hidden="true">{{ saving ? 'hourglass_empty' : 'bookmark_add' }}</mat-icon>
174
207
  {{ data.i18n?.saveAsShortcut || 'Salvar como atalho' }}
175
208
  </button>
176
209
  <button mat-stroked-button type="button" (click)="close()">{{ data.i18n?.cancel || 'Cancelar' }}</button>
@@ -178,7 +211,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.17", ngImpo
178
211
  {{ data.i18n?.apply || 'Aplicar' }}
179
212
  </button>
180
213
  </mat-dialog-actions>
181
- `, styles: [".pfx-dialog-title{display:flex;align-items:center;justify-content:space-between;gap:12px;padding-right:8px}.pfx-dialog-title-text{display:inline-flex;align-items:center;gap:8px;font-weight:600;color:var(--mdc-dialog-subhead-color, var(--md-sys-color-on-surface))}.pfx-dialog-close{margin-left:auto}.pfx-filter-dialog-content{display:flex;flex-direction:column;gap:12px;padding-top:8px}.pfx-empty-state{margin:8px 0 0;color:var(--mdc-dialog-supporting-text-color, var(--md-sys-color-on-surface-variant))}.pfx-dialog-loading{display:flex;flex-direction:column;gap:10px;min-height:128px;justify-content:center;color:var(--mdc-dialog-supporting-text-color, var(--md-sys-color-on-surface-variant));font-size:.875rem}.pfx-form-pending{height:0;overflow:hidden;visibility:hidden;pointer-events:none}.pfx-dialog-actions{padding:var(--pdx-dialog-actions-padding, 12px 24px 16px);border-top:1px solid var(--md-sys-color-outline-variant);background:transparent;display:flex;align-items:center;gap:8px}\n"] }]
214
+ `, styles: [".pfx-dialog-title{display:flex;align-items:center;justify-content:space-between;gap:12px;padding-right:8px}.pfx-dialog-title-text{display:inline-flex;align-items:center;gap:8px;font-weight:600;color:var(--mdc-dialog-subhead-color, var(--md-sys-color-on-surface))}.pfx-dialog-close{margin-left:auto}.pfx-filter-dialog-content{display:flex;flex-direction:column;gap:12px;padding-top:8px}.pfx-empty-state{margin:8px 0 0;color:var(--mdc-dialog-supporting-text-color, var(--md-sys-color-on-surface-variant))}.pfx-dialog-loading{display:flex;flex-direction:column;gap:10px;min-height:128px;justify-content:center;color:var(--mdc-dialog-supporting-text-color, var(--md-sys-color-on-surface-variant));font-size:.875rem}.pfx-form-pending{height:0;overflow:hidden;visibility:hidden;pointer-events:none}.pfx-dialog-actions{padding:var(--pdx-dialog-actions-padding, 12px 24px 16px);border-top:1px solid var(--md-sys-color-outline-variant);background:transparent;display:flex;align-items:center;gap:8px}.pfx-save-shortcut-button{margin-right:auto}.pfx-save-shortcut-button mat-icon{margin-right:6px;width:18px;height:18px;font-size:18px}\n"] }]
182
215
  }], ctorParameters: () => [{ type: undefined, decorators: [{
183
216
  type: Inject,
184
217
  args: [MAT_DIALOG_DATA]