Commit 56d1c4677b787766b684cee633ae9b2932bef212

Authored by ArtemDzhereleiko
1 parent 04317d63

remove reset button form filter panel and add clear filter button to table config

... ... @@ -69,6 +69,13 @@ export class AppComponent implements OnInit {
69 69 );
70 70
71 71 this.matIconRegistry.addSvgIconLiteral(
  72 + 'filter-variant-remove',
  73 + this.domSanitizer.bypassSecurityTrustHtml(
  74 + '<svg viewBox="0 0 24 24"><path d="M21 8H3V6h18v2m-7.19 8H10v2h3.09c.12-.72.37-1.39.72-2M18 11H6v2h12v-2m3.12 4.46L19 17.59l-2.12-2.13-1.41 1.42L17.59 19l-2.12 2.12 1.41 1.42L19 20.41l2.12 2.13 1.42-1.42L20.41 19l2.13-2.12-1.42-1.42z"/></svg>'
  75 + )
  76 + );
  77 +
  78 + this.matIconRegistry.addSvgIconLiteral(
72 79 'google-logo',
73 80 this.domSanitizer.bypassSecurityTrustHtml(
74 81 '<svg viewBox="0 0 48 48"><path fill="#EA4335" d="M24 9.5c3.54 0 6.71 1.22 9.21 3.6l6.85-6.85C35.9 2.38 30.47 0 24 0 14.62 0 6.51 5.38 2.56 13.22l7.98 6.19C12.43 13.72 17.74 9.5 24 9.5z"/><path fill="#4285F4" d="M46.98 24.55c0-1.57-.15-3.09-.38-4.55H24v9.02h12.94c-.58 2.96-2.26 5.48-4.78 7.18l7.73 6c4.51-4.18 7.09-10.36 7.09-17.65z"/><path fill="#FBBC05" d="M10.53 28.59c-.48-1.45-.76-2.99-.76-4.59s.27-3.14.76-4.59l-7.98-6.19C.92 16.46 0 20.12 0 24c0 3.88.92 7.54 2.56 10.78l7.97-6.19z"/><path fill="#34A853" d="M24 48c6.48 0 11.93-2.13 15.89-5.81l-7.73-6c-2.15 1.45-4.92 2.3-8.16 2.3-6.26 0-11.57-4.22-13.47-9.91l-7.98 6.19C6.51 42.62 14.62 48 24 48z"/><path fill="none" d="M0 0h48v48H0z"/></svg>'
... ...
... ... @@ -85,7 +85,8 @@
85 85 matTooltip="{{ actionDescriptor.name }}"
86 86 matTooltipPosition="above"
87 87 (click)="actionDescriptor.onAction($event)">
88   - <mat-icon>{{actionDescriptor.icon}}</mat-icon>
  88 + <mat-icon *ngIf="actionDescriptor.isMdiIcon" [svgIcon]="actionDescriptor.icon"></mat-icon>
  89 + <mat-icon *ngIf="!actionDescriptor.isMdiIcon">{{actionDescriptor.icon}}</mat-icon>
89 90 </button>
90 91 <button mat-icon-button [disabled]="isLoading$ | async" (click)="updateData()"
91 92 matTooltip="{{ 'action.refresh' | translate }}"
... ...
... ... @@ -61,9 +61,8 @@
61 61 <div fxLayout="row" class="tb-panel-actions" fxLayoutAlign="end center">
62 62 <button type="button"
63 63 mat-button
64   - [disabled]="resetButtonDisabled"
65   - (click)="reset()">
66   - {{ 'action.reset' | translate }}
  64 + (click)="cancel()">
  65 + {{ 'action.cancel' | translate }}
67 66 </button>
68 67 <button type="submit"
69 68 mat-raised-button
... ...
... ... @@ -107,21 +107,6 @@ export class EventFilterPanelComponent {
107 107 this.overlayRef.dispose();
108 108 }
109 109
110   - reset() {
111   - const emptyInputValue = {};
112   -
113   - for (const inputValue in this.eventFilterFormGroup.value) {
114   - emptyInputValue[inputValue] = '';
115   - }
116   -
117   - this.eventFilterFormGroup.reset(emptyInputValue);
118   - this.update();
119   - }
120   -
121   - get resetButtonDisabled() {
122   - return isEqual(this.data.filterParams, {});
123   - }
124   -
125 110 changeIsError(value: boolean | string) {
126 111 if (this.conditionError && value === '') {
127 112 this.eventFilterFormGroup.get('error').reset('', {emitEvent: false});
... ...
... ... @@ -120,6 +120,15 @@ export class EventTableConfig extends EntityTableConfig<Event, TimePageLink> {
120 120 this.updateFilterColumns();
121 121
122 122 this.headerActionDescriptors.push({
  123 + name: this.translate.instant('event.clear-filter'),
  124 + icon: 'filter-variant-remove',
  125 + isMdiIcon: true,
  126 + isEnabled: () => !isEqual(this.filterParams, {}),
  127 + onAction: ($event) => {
  128 + this.clearFiter($event);
  129 + }
  130 + },
  131 + {
123 132 name: this.translate.instant('event.events-filter'),
124 133 icon: 'filter_list',
125 134 isEnabled: () => true,
... ... @@ -316,6 +325,16 @@ export class EventTableConfig extends EntityTableConfig<Event, TimePageLink> {
316 325 }
317 326 }
318 327
  328 + private clearFiter($event) {
  329 + if ($event) {
  330 + $event.stopPropagation();
  331 + }
  332 +
  333 + this.filterParams = {};
  334 + this.table.paginator.pageIndex = 0;
  335 + this.table.updateData();
  336 + }
  337 +
319 338 private editEventFilter($event: MouseEvent) {
320 339 if ($event) {
321 340 $event.stopPropagation();
... ...
... ... @@ -73,6 +73,7 @@ export interface GroupActionDescriptor<T extends BaseData<HasId>> {
73 73 export interface HeaderActionDescriptor {
74 74 name: string;
75 75 icon: string;
  76 + isMdiIcon?: boolean;
76 77 isEnabled: () => boolean;
77 78 onAction: ($event: MouseEvent) => void;
78 79 }
... ...
... ... @@ -57,8 +57,7 @@
57 57 "download": "Download",
58 58 "next-with-label": "Next: {{label}}",
59 59 "read-more": "Read more",
60   - "hide": "Hide",
61   - "reset": "Reset"
  60 + "hide": "Hide"
62 61 },
63 62 "aggregation": {
64 63 "aggregation": "Aggregation",
... ... @@ -1823,7 +1822,8 @@
1823 1822 "all-events": "All",
1824 1823 "has-error": "Has error",
1825 1824 "entity-id": "Entity Id",
1826   - "entity-type": "Entity type"
  1825 + "entity-type": "Entity type",
  1826 + "clear-filter": "Clear Filter"
1827 1827 },
1828 1828 "extension": {
1829 1829 "extensions": "Extensions",
... ...