Skip to content

Commit 93fdcbd

Browse files
bodnaraHejdaJakub
authored andcommitted
fix: do not filter attributes with empy value
Implicit filtering of attributes with empty values from table was removed. It was added as an filtering option that can be toggled on/off.
1 parent 3d95de8 commit 93fdcbd

File tree

7 files changed

+48
-35
lines changed

7 files changed

+48
-35
lines changed

apps/admin-gui/src/app/shared/components/dialogs/create-attribute-dialog/create-attribute-dialog.component.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ <h1 class="page-subtitle">{{'DIALOGS.CREATE_ATTRIBUTE.SET_NEW' | translate}}</h1
2121
[emptyListText]="'SHARED_LIB.PERUN.COMPONENTS.ATTRIBUTES_LIST.EMPTY_ATTRIBUTES'"
2222
[attributes]="attributes"
2323
[filterValue]="filterValue"
24-
[inDialog]="true"
2524
[selection]="selected"
2625
[tableId]="tableId">
2726
</perun-web-apps-attributes-list>

apps/admin-gui/src/app/shared/components/one-entity-attribute-page/one-entity-attribute-page.component.html

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,40 +5,44 @@
55
color="accent"
66
data-cy="add-attributes"
77
mat-flat-button>
8-
{{'USER_DETAIL.SETTINGS.ATTRIBUTES.CREATE' | translate}}
8+
{{'ATTRIBUTE_PAGE.CREATE' | translate}}
99
</button>
10-
1110
<button
1211
(click)="onSave()"
1312
class="me-2"
1413
color="accent"
1514
[disabled]="selection.selected.length === 0"
1615
mat-flat-button>
17-
{{'USER_DETAIL.SETTINGS.ATTRIBUTES.SAVE' | translate}}
16+
{{'ATTRIBUTE_PAGE.SAVE' | translate}}
1817
</button>
19-
2018
<button
2119
(click)="onDelete()"
2220
[disabled]="selection.selected.length === 0"
2321
class="me-2"
2422
color="warn"
2523
data-cy="remove-attributes"
2624
mat-flat-button>
27-
{{'USER_DETAIL.SETTINGS.ATTRIBUTES.DELETE' | translate}}
25+
{{'ATTRIBUTE_PAGE.DELETE' | translate}}
2826
</button>
2927
<perun-web-apps-debounce-filter
3028
(filter)="applyFilter($event)"
31-
[placeholder]="'SHARED_LIB.PERUN.COMPONENTS.ATTRIBUTES_LIST.FILTER'"></perun-web-apps-debounce-filter>
29+
[placeholder]="'ATTRIBUTE_PAGE.FILTER'"
30+
class="me-2">
31+
</perun-web-apps-debounce-filter>
32+
<mat-slide-toggle [(ngModel)]="filterEmpty" labelPosition="before">
33+
{{'ATTRIBUTE_PAGE.FILTER_EMPTY' | translate}}
34+
</mat-slide-toggle>
3235

3336
<ng-template #spinner>
3437
<perun-web-apps-loading-table></perun-web-apps-loading-table>
3538
</ng-template>
3639
<div class="position-relative">
3740
<perun-web-apps-attributes-list
41+
#list
3842
*perunWebAppsLoader="loading; indicator: spinner"
3943
[attributes]="attributes"
40-
#list
4144
[filterValue]="filterValue"
45+
[filterEmpty]="filterEmpty"
4246
[selection]="selection"
4347
[tableId]="tableId">
4448
</perun-web-apps-attributes-list>

apps/admin-gui/src/app/shared/components/one-entity-attribute-page/one-entity-attribute-page.component.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,13 @@ import { TABLE_ATTRIBUTES_SETTINGS } from '@perun-web-apps/config/table-config';
1515
styleUrls: ['./one-entity-attribute-page.component.css'],
1616
})
1717
export class OneEntityAttributePageComponent implements OnInit {
18-
@Input()
19-
entity: string;
20-
@Input()
21-
entityId: number;
22-
@ViewChild('list')
23-
list: AttributesListComponent;
18+
@Input() entity: string;
19+
@Input() entityId: number;
20+
@ViewChild('list') list: AttributesListComponent;
2421
attributes: Attribute[] = [];
2522
selection = new SelectionModel<Attribute>(true, []);
2623
filterValue = '';
24+
filterEmpty = true;
2725
tableId = TABLE_ATTRIBUTES_SETTINGS;
2826
loading = false;
2927

apps/admin-gui/src/app/shared/components/two-entity-attribute-page/two-entity-attribute-page.component.html

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
class="me-2 action-button"
5050
color="accent"
5151
mat-flat-button>
52-
{{'MEMBER_DETAIL.SETTINGS.ATTRIBUTES.CREATE' | translate}}
52+
{{'ATTRIBUTE_PAGE.CREATE' | translate}}
5353
</button>
5454

5555
<button
@@ -58,7 +58,7 @@
5858
color="accent"
5959
[disabled]="selection.selected.length === 0"
6060
mat-flat-button>
61-
{{'MEMBER_DETAIL.SETTINGS.ATTRIBUTES.SAVE' | translate}}
61+
{{'ATTRIBUTE_PAGE.SAVE' | translate}}
6262
</button>
6363

6464
<button
@@ -67,11 +67,16 @@
6767
[disabled]="selection.selected.length === 0"
6868
class="me-2"
6969
mat-flat-button>
70-
{{'MEMBER_DETAIL.SETTINGS.ATTRIBUTES.DELETE' | translate}}
70+
{{'ATTRIBUTE_PAGE.DELETE' | translate}}
7171
</button>
7272
<perun-web-apps-debounce-filter
7373
(filter)="applyFilter($event)"
74-
[placeholder]="'SHARED_LIB.PERUN.COMPONENTS.ATTRIBUTES_LIST.FILTER'"></perun-web-apps-debounce-filter>
74+
[placeholder]="'ATTRIBUTE_PAGE.FILTER'"
75+
class="me-2">
76+
</perun-web-apps-debounce-filter>
77+
<mat-slide-toggle [(ngModel)]="filterEmpty" labelPosition="before">
78+
{{'ATTRIBUTE_PAGE.FILTER_EMPTY' | translate}}
79+
</mat-slide-toggle>
7580
<ng-template #spinner>
7681
<perun-web-apps-loading-table></perun-web-apps-loading-table>
7782
</ng-template>
@@ -81,6 +86,7 @@
8186
*perunWebAppsLoader="innerLoading; indicator: spinner"
8287
[attributes]="attributes"
8388
[filterValue]="filterValue"
89+
[filterEmpty]="filterEmpty"
8490
[selection]="selection">
8591
</perun-web-apps-attributes-list>
8692
</div>

apps/admin-gui/src/app/shared/components/two-entity-attribute-page/two-entity-attribute-page.component.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,10 @@ import { GroupWithStatus, ResourceWithStatus } from '@perun-web-apps/perun/model
2828
styleUrls: ['./two-entity-attribute-page.component.scss'],
2929
})
3030
export class TwoEntityAttributePageComponent implements OnInit {
31-
@ViewChild('list')
32-
list: AttributesListComponent;
33-
@Input()
34-
firstEntityId: number;
35-
@Input()
36-
firstEntity: string;
37-
@Input()
38-
secondEntity: string;
31+
@ViewChild('list') list: AttributesListComponent;
32+
@Input() firstEntityId: number;
33+
@Input() firstEntity: string;
34+
@Input() secondEntity: string;
3935
entityValues: Resource[] | Facility[] | Group[] | RichMember[] | User[] = [];
4036
attributes: Attribute[] = [];
4137
selection = new SelectionModel<Attribute>(true, []);
@@ -44,6 +40,7 @@ export class TwoEntityAttributePageComponent implements OnInit {
4440
loading = false;
4541
innerLoading = false;
4642
filterValue = '';
43+
filterEmpty = true;
4744
noEntityMessage: string;
4845

4946
constructor(

apps/admin-gui/src/assets/i18n/en.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2696,6 +2696,13 @@
26962696
"FILTER": "Filter by name, id or description"
26972697
}
26982698
},
2699+
"ATTRIBUTE_PAGE": {
2700+
"CREATE": "Create",
2701+
"SAVE": "Save",
2702+
"DELETE": "Delete",
2703+
"FILTER": "Filter attributes by Id, name, value or description",
2704+
"FILTER_EMPTY": "Filter empty attributes"
2705+
},
26992706
"SHARED": {
27002707
"COMPONENTS": {
27012708
"RESOURCES_TAGS_LIST": {

libs/perun/components/src/lib/attributes-list/attributes-list.component.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ export class AttributesListComponent implements OnChanges, AfterViewInit {
3535
@Input() attributes: Attribute[] = [];
3636
@Input() selection = new SelectionModel<Attribute>(true, []);
3737
@Input() displayedColumns: string[] = ['select', 'id', 'displayName', 'value', 'description'];
38-
@Input() inDialog = false;
3938
@Input() filterValue = '';
39+
@Input() filterEmpty = false;
4040
@Input() tableId: string;
4141
@Input() readonly = false;
4242
@Input() hiddenColumns: string[] = [];
@@ -82,15 +82,17 @@ export class AttributesListComponent implements OnChanges, AfterViewInit {
8282
this.displayedColumns = this.displayedColumns.filter((column) => column !== 'id');
8383
}
8484

85-
const attributesWithoutEmptyObjects = this.attributes.filter((attribute) => {
86-
if (typeof attribute.value === 'object') {
87-
return Object.keys((attribute.value ?? '') as object).length > 0;
88-
}
89-
return true;
90-
});
91-
92-
const filteredAttributes = filterCoreAttributes(attributesWithoutEmptyObjects);
85+
let filteredAttributes = this.attributes;
86+
if (this.filterEmpty) {
87+
filteredAttributes = filteredAttributes.filter((attribute) => {
88+
if (typeof attribute.value === 'object') {
89+
return Object.keys((attribute.value ?? '') as object).length > 0;
90+
}
91+
return true;
92+
});
93+
}
9394

95+
filteredAttributes = filterCoreAttributes(filteredAttributes);
9496
this.dataSource = new MatTableDataSource<Attribute>(filteredAttributes);
9597
this.setDataSource();
9698
}

0 commit comments

Comments
 (0)