Skip to content

Commit 127575f

Browse files
Merge branch 'feat/AB#80876-add-geographic-context-in-page' of github.com-relief:ReliefApplications/ems-frontend into feat/AB#80877_add_logic_to_create_edit_load_page_with_geographic_context
2 parents c7b2f72 + 1408080 commit 127575f

File tree

51 files changed

+2396
-1447
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+2396
-1447
lines changed

CHANGELOG.md

Lines changed: 269 additions & 1 deletion
Large diffs are not rendered by default.

CHANGELOG/CHANGELOG_alpha.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
# [2.2.0-alpha.3](https://github.com/ReliefApplications/ems-frontend/compare/v2.2.0-alpha.2...v2.2.0-alpha.3) (2023-12-07)
2+
3+
4+
### Bug Fixes
5+
6+
* editing widgets could sometimes scroll to top of dashboard ([#2135](https://github.com/ReliefApplications/ems-frontend/issues/2135)) ([da6dd93](https://github.com/ReliefApplications/ems-frontend/commit/da6dd93460ada1446233159ed5988484bd2f9530))
7+
* few issues with templating & reference data ([c504e92](https://github.com/ReliefApplications/ems-frontend/commit/c504e922e1f73a6f8030b1388f066b6853a0dd4c))
8+
* incorrect sorting on api configuration ([#2125](https://github.com/ReliefApplications/ems-frontend/issues/2125)) ([5acf213](https://github.com/ReliefApplications/ems-frontend/commit/5acf213d1c7e3880ae69be8a6b62e2de98f09aa2))
9+
* incorrectly sized columns ([#2127](https://github.com/ReliefApplications/ems-frontend/issues/2127)) ([c0be7b1](https://github.com/ReliefApplications/ems-frontend/commit/c0be7b1e30ac4b71f659b97845caf2f79adf8edd))
10+
* pull jobs would not be editable ([cc9d685](https://github.com/ReliefApplications/ems-frontend/commit/cc9d685c3620450a38bd3f0cbbaf38d697dcac6d))
11+
* remove code information in url after login ([bcfb603](https://github.com/ReliefApplications/ems-frontend/commit/bcfb603b2a74a03437ae6a236451de22c343ca3d))
12+
* sorting in ref data table not working ([#2126](https://github.com/ReliefApplications/ems-frontend/issues/2126)) ([1ae1e27](https://github.com/ReliefApplications/ems-frontend/commit/1ae1e276a7eef1682ab73bfa2ac645bb30ad0dea))
13+
* text widget edition would lose widget display configuration ([7f3b18b](https://github.com/ReliefApplications/ems-frontend/commit/7f3b18ba98fded73b0a90681a6019fbc86504707))
14+
15+
16+
### Features
17+
18+
* allow text & summary card widgets to use record edition when using resource & layout ([#2134](https://github.com/ReliefApplications/ems-frontend/issues/2134)) ([a0f0ca0](https://github.com/ReliefApplications/ems-frontend/commit/a0f0ca0be44bb0c4e908d8317f08abe835592ff8))
19+
* allow to edit / add reference data fields ([#2128](https://github.com/ReliefApplications/ems-frontend/issues/2128)) ([c7f047b](https://github.com/ReliefApplications/ems-frontend/commit/c7f047b654235516d42cb9f5e645b33b2fc9d715))
20+
121
# [2.2.0-alpha.2](https://github.com/ReliefApplications/ems-frontend/compare/v2.2.0-alpha.1...v2.2.0-alpha.2) (2023-12-05)
222

323

CHANGELOG/CHANGELOG_beta.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,47 @@
1+
# [2.2.0-beta.16](https://github.com/ReliefApplications/ems-frontend/compare/v2.2.0-beta.15...v2.2.0-beta.16) (2023-12-08)
2+
3+
4+
### Bug Fixes
5+
6+
* prevent aggregation fields to be fetched before query builder is ready ([#2139](https://github.com/ReliefApplications/ems-frontend/issues/2139)) ([3bee583](https://github.com/ReliefApplications/ems-frontend/commit/3bee5837c221a799d9e479e91cab0131afb3c259))
7+
* toggle of archived records would create incorrect list ([#2132](https://github.com/ReliefApplications/ems-frontend/issues/2132)) ([f1abf81](https://github.com/ReliefApplications/ems-frontend/commit/f1abf811189f67841a8770ac5e6cc35af0bf745c))
8+
9+
10+
### Features
11+
12+
* add filter input & output in app-widget ([4d94cef](https://github.com/ReliefApplications/ems-frontend/commit/4d94cefd8718f0b382679e2d0fc79e6242bb49e7))
13+
* allow fields from ref data linked to a resource to be used ([#1575](https://github.com/ReliefApplications/ems-frontend/issues/1575)) ([cb8b30c](https://github.com/ReliefApplications/ems-frontend/commit/cb8b30ca36074c1544bf3d95796a6553f1de1b55))
14+
15+
# [2.2.0-beta.15](https://github.com/ReliefApplications/ems-frontend/compare/v2.2.0-beta.14...v2.2.0-beta.15) (2023-12-07)
16+
17+
18+
### Bug Fixes
19+
20+
* editing widgets could sometimes scroll to top of dashboard ([#2135](https://github.com/ReliefApplications/ems-frontend/issues/2135)) ([da6dd93](https://github.com/ReliefApplications/ems-frontend/commit/da6dd93460ada1446233159ed5988484bd2f9530))
21+
* few issues with templating & reference data ([c504e92](https://github.com/ReliefApplications/ems-frontend/commit/c504e922e1f73a6f8030b1388f066b6853a0dd4c))
22+
* incorrectly sized columns ([#2127](https://github.com/ReliefApplications/ems-frontend/issues/2127)) ([c0be7b1](https://github.com/ReliefApplications/ems-frontend/commit/c0be7b1e30ac4b71f659b97845caf2f79adf8edd))
23+
* pull jobs would not be editable ([cc9d685](https://github.com/ReliefApplications/ems-frontend/commit/cc9d685c3620450a38bd3f0cbbaf38d697dcac6d))
24+
* remove code information in url after login ([bcfb603](https://github.com/ReliefApplications/ems-frontend/commit/bcfb603b2a74a03437ae6a236451de22c343ca3d))
25+
* text widget edition would lose widget display configuration ([7f3b18b](https://github.com/ReliefApplications/ems-frontend/commit/7f3b18ba98fded73b0a90681a6019fbc86504707))
26+
27+
# [2.2.0-beta.14](https://github.com/ReliefApplications/ems-frontend/compare/v2.2.0-beta.13...v2.2.0-beta.14) (2023-12-05)
28+
29+
30+
### Bug Fixes
31+
32+
* Changing form locale duplicates some questions ([#2124](https://github.com/ReliefApplications/ems-frontend/issues/2124)) ([ed9bbe6](https://github.com/ReliefApplications/ems-frontend/commit/ed9bbe66421f7fe19bae89aa3580d0a059c29f57))
33+
* incorrect sorting on api configuration ([#2125](https://github.com/ReliefApplications/ems-frontend/issues/2125)) ([5acf213](https://github.com/ReliefApplications/ems-frontend/commit/5acf213d1c7e3880ae69be8a6b62e2de98f09aa2))
34+
* reference data would appear as object object in grid ([b9b1910](https://github.com/ReliefApplications/ems-frontend/commit/b9b191032ef2bf74a4fbeec9459d973c99e1b835))
35+
* reset default button not available in front-office ([#2122](https://github.com/ReliefApplications/ems-frontend/issues/2122)) ([ab81073](https://github.com/ReliefApplications/ems-frontend/commit/ab810737f245ea4b527d4f477dd77ff09819c1e1))
36+
* some fields would not be accessible in map popup ([48f98aa](https://github.com/ReliefApplications/ems-frontend/commit/48f98aaa83ad05520b21638068254ec171656e43))
37+
* sorting in ref data table not working ([#2126](https://github.com/ReliefApplications/ems-frontend/issues/2126)) ([1ae1e27](https://github.com/ReliefApplications/ems-frontend/commit/1ae1e276a7eef1682ab73bfa2ac645bb30ad0dea))
38+
39+
40+
### Features
41+
42+
* add possibility to fetch nested fields in ref data ([efbcc1d](https://github.com/ReliefApplications/ems-frontend/commit/efbcc1db4e278f346966952fb3411dae3e4c3d9a))
43+
* allow to edit / add reference data fields ([#2128](https://github.com/ReliefApplications/ems-frontend/issues/2128)) ([c7f047b](https://github.com/ReliefApplications/ems-frontend/commit/c7f047b654235516d42cb9f5e645b33b2fc9d715))
44+
145
# [2.2.0-beta.13](https://github.com/ReliefApplications/ems-frontend/compare/v2.2.0-beta.12...v2.2.0-beta.13) (2023-12-02)
246

347

apps/back-office/src/app/dashboard/pages/api-configurations/api-configurations.component.html

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<app-api-configuration-filter
44
#filter
55
(filter)="applyFilter($event)"
6-
[loading]="loading"
6+
[loading]="updating"
77
>
88
</app-api-configuration-filter>
99
<!-- Actions -->
@@ -29,7 +29,7 @@
2929
cdk-table
3030
uiTableWrapper
3131
(sortChange)="onSort($event)"
32-
[dataSource]="filteredDataSources"
32+
[dataSource]="dataSource"
3333
>
3434
<ng-container cdkColumnDef="name">
3535
<th uiTableHeaderSort="name" uiCellHeader *cdkHeaderCellDef>
@@ -47,7 +47,7 @@
4747
</ng-container>
4848

4949
<ng-container cdkColumnDef="status">
50-
<th uiTableHeaderSort="status" uiCellHeader *cdkHeaderCellDef>
50+
<th uiCellHeader *cdkHeaderCellDef>
5151
<span class="headerTitle">
5252
{{ 'common.status' | translate }}
5353
</span>
@@ -60,7 +60,7 @@
6060
</ng-container>
6161

6262
<ng-container cdkColumnDef="authType">
63-
<th uiTableHeaderSort="authType" uiCellHeader *cdkHeaderCellDef>
63+
<th uiCellHeader *cdkHeaderCellDef>
6464
<span class="headerTitle">
6565
{{ 'models.apiConfiguration.authType' | translate }}
6666
</span>
@@ -114,7 +114,8 @@
114114
</div>
115115
</div>
116116
<ui-paginator
117-
[disabled]="loading"
117+
[disabled]="loading || updating"
118+
[pageIndex]="pageInfo.pageIndex"
118119
[pageSize]="pageInfo.pageSize"
119120
[pageSizeOptions]="[10, 25, 50]"
120121
[totalItems]="pageInfo.length"

apps/back-office/src/app/dashboard/pages/api-configurations/api-configurations.component.ts

Lines changed: 19 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -47,20 +47,22 @@ export class ApiConfigurationsComponent
4747
{
4848
// === DATA ===
4949
public loading = true;
50+
public updating = false;
5051
private apiConfigurationsQuery!: QueryRef<ApiConfigurationsQueryResponse>;
5152
displayedColumns = ['name', 'status', 'authType', 'actions'];
5253
dataSource = new Array<ApiConfiguration>();
53-
filteredDataSources = new Array<ApiConfiguration>();
5454
public cachedApiConfigurations: ApiConfiguration[] = [];
5555

5656
// === SORTING ===
57-
sort?: TableSort;
57+
private sort!: TableSort;
5858

5959
// === FILTERS ===
60+
public filter: any = {
61+
filters: [],
62+
logic: 'and',
63+
};
6064
form = this.fb.group({});
6165
public showFilters = false;
62-
public searchText = '';
63-
public statusFilter = '';
6466

6567
public pageInfo = {
6668
pageIndex: 0,
@@ -102,14 +104,19 @@ export class ApiConfigurationsComponent
102104
variables: {
103105
first: ITEMS_PER_PAGE,
104106
afterCursor: this.pageInfo.endCursor,
107+
filter: this.filter,
108+
sortField: this.sort?.sortDirection && this.sort.active,
109+
sortOrder: this.sort?.sortDirection,
105110
},
106111
});
107112

108113
this.apiConfigurationsQuery.valueChanges
109114
.pipe(takeUntil(this.destroy$))
110-
.subscribe((results) => {
111-
this.updateValues(results.data, results.loading);
112-
});
115+
.subscribe(
116+
(results: ApolloQueryResult<ApiConfigurationsQueryResponse>) => {
117+
this.updateValues(results.data, results.loading);
118+
}
119+
);
113120
// Initializing sort to an empty one
114121
this.sort = {
115122
active: '',
@@ -130,44 +137,19 @@ export class ApiConfigurationsComponent
130137
);
131138
if (cachedData && cachedData.length === this.pageInfo.pageSize) {
132139
this.dataSource = cachedData;
133-
this.filteredDataSources = this.dataSource;
134140
} else {
135141
this.fetchApiConfigurations();
136142
}
137143
}
138144

139-
/**
140-
* Frontend filtering.
141-
*/
142-
private filterPredicate(): void {
143-
this.filteredDataSources = this.dataSource.filter(
144-
(data: any) =>
145-
(this.searchText.trim().length === 0 ||
146-
(this.searchText.trim().length > 0 &&
147-
data.name.toLowerCase().includes(this.searchText.trim()))) &&
148-
(this.statusFilter.trim().length === 0 ||
149-
(this.statusFilter.trim().length > 0 &&
150-
data.status.toLowerCase().includes(this.statusFilter.trim())))
151-
);
152-
}
153-
154145
/**
155146
* Applies the filter to the data source.
156147
*
157148
* @param event event value of the filter.
158149
*/
159150
applyFilter(event: any): void {
160-
if (event.statusFilter) {
161-
this.statusFilter = event.statusFilter;
162-
} else {
163-
this.statusFilter = '';
164-
}
165-
if (event.search) {
166-
this.searchText = event.search.toLowerCase();
167-
} else {
168-
this.searchText = '';
169-
}
170-
this.filterPredicate();
151+
this.filter = event;
152+
this.fetchApiConfigurations(true);
171153
}
172154

173155
/**
@@ -269,7 +251,6 @@ export class ApiConfigurationsComponent
269251
this.dataSource = this.dataSource.filter(
270252
(x) => x.id !== element.id
271253
);
272-
this.filteredDataSources = this.dataSource;
273254
} else {
274255
this.snackBar.openSnackBar(
275256
this.translate.instant(
@@ -316,7 +297,7 @@ export class ApiConfigurationsComponent
316297
this.pageInfo.length = data.apiConfigurations.totalCount;
317298
this.pageInfo.endCursor = data.apiConfigurations.pageInfo.endCursor;
318299
this.loading = loading;
319-
this.filterPredicate();
300+
this.updating = false;
320301
}
321302

322303
/**
@@ -336,10 +317,11 @@ export class ApiConfigurationsComponent
336317
* @param refetch erase previous query results
337318
*/
338319
private fetchApiConfigurations(refetch?: boolean): void {
339-
this.loading = true;
320+
this.updating = true;
340321
const variables = {
341322
first: this.pageInfo.pageSize,
342323
afterCursor: refetch ? null : this.pageInfo.endCursor,
324+
filter: this.filter,
343325
sortField: this.sort?.sortDirection && this.sort.active,
344326
sortOrder: this.sort?.sortDirection,
345327
};

apps/back-office/src/app/dashboard/pages/api-configurations/filter/filter.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
>
1818
<label>{{ 'common.status' | translate }}</label>
1919
<ui-select-menu
20-
formControlName="statusFilter"
20+
formControlName="status"
2121
[placeholder]="'common.selectStatus' | translate"
2222
>
2323
<ui-select-option>-</ui-select-option>

apps/back-office/src/app/dashboard/pages/api-configurations/filter/filter.component.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export class FilterComponent extends UnsubscribeComponent implements OnInit {
4444
expandedFilter!: TemplateRef<any>;
4545

4646
public form = this.fb.group({
47-
statusFilter: [''],
47+
status: [''],
4848
});
4949
public show = false;
5050

@@ -75,7 +75,22 @@ export class FilterComponent extends UnsubscribeComponent implements OnInit {
7575
* @param value Value to be emitted.
7676
*/
7777
private emitFilter(value: any): void {
78-
this.filter.emit(value);
78+
const filters: any[] = [];
79+
if (value.search) {
80+
filters.push({
81+
field: 'name',
82+
operator: 'contains',
83+
value: value.search,
84+
});
85+
}
86+
if (value.status) {
87+
filters.push({ field: 'status', operator: 'eq', value: value.status });
88+
}
89+
const filter = {
90+
logic: 'and',
91+
filters,
92+
};
93+
this.filter.emit(filter);
7994
}
8095

8196
/**

apps/back-office/src/app/dashboard/pages/api-configurations/graphql/queries.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,20 @@ import { gql } from 'apollo-angular';
44

55
/** Graphql query for getting multiple api configurations object with a cursor */
66
export const GET_API_CONFIGURATIONS = gql`
7-
query GetApiConfigurations($first: Int, $afterCursor: ID) {
8-
apiConfigurations(first: $first, afterCursor: $afterCursor) {
7+
query GetApiConfigurations(
8+
$first: Int
9+
$afterCursor: ID
10+
$filter: JSON
11+
$sortField: String
12+
$sortOrder: String
13+
) {
14+
apiConfigurations(
15+
first: $first
16+
afterCursor: $afterCursor
17+
filter: $filter
18+
sortField: $sortField
19+
sortOrder: $sortOrder
20+
) {
921
edges {
1022
node {
1123
id

apps/back-office/src/app/dashboard/pages/dashboard/dashboard.component.html

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -189,11 +189,9 @@ <h1 class="!m-0 overflow-hidden text-ellipsis">
189189
<span *ngIf="dashboard.page?.geographicContext?.enabled">
190190
<!-- Regions -->
191191
<div uiFormFieldDirective [outline]="false">
192-
<label>{{
193-
'components.user.summary.region' | translate
194-
}}</label>
192+
<label>{{ 'components.user.summary.region' | translate }}</label>
195193
<ui-select-menu
196-
(selectedOption)="onSearchChangeGeographicContext({ region: $any($event) })"
194+
(selectedOption)="onSearchChangeGeographicContext($event, 'region')"
197195
[filterable]="true"
198196
[formControl]="regionCode"
199197
>
@@ -207,12 +205,12 @@ <h1 class="!m-0 overflow-hidden text-ellipsis">
207205
</div>
208206
<!-- Countries -->
209207
<div uiFormFieldDirective [outline]="false">
210-
<label>{{
211-
'components.user.summary.country' | translate
212-
}}</label>
213-
<ui-select-menu
208+
<label>{{ 'components.user.summary.country' | translate }}</label>
209+
<ui-select-menu
214210
[formControl]="countryCode"
215-
(selectedOption)="onSearchChangeGeographicContext({ country: $any($event) })"
211+
(selectedOption)="
212+
onSearchChangeGeographicContext($event, 'country')
213+
"
216214
[filterable]="true"
217215
>
218216
<ui-select-option

0 commit comments

Comments
 (0)