Skip to content

Commit 1408080

Browse files
feat/AB#80876-add-geographic-context-in-page refactor: region and country assignation in the html template without the $any cast refactor: move region list to the countries.json file in order to keep all geographic context related in the same place. Renamed countries.json file to geographic-context-data.json
1 parent 1c8a149 commit 1408080

File tree

5 files changed

+1074
-1065
lines changed

5 files changed

+1074
-1065
lines changed

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

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

Lines changed: 10 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ import { ContextService, CustomWidgetStyleComponent } from '@oort-front/shared';
5555
import { DOCUMENT } from '@angular/common';
5656
import { Clipboard } from '@angular/cdk/clipboard';
5757
import { GridsterConfig } from 'angular-gridster2';
58-
import countries from 'assets/countries.json';
58+
import geographicContext from 'assets/geographic-context-data.json';
5959

6060
/** Default number of records fetched per page */
6161
const ITEMS_PER_PAGE = 10;
@@ -120,38 +120,9 @@ export class DashboardComponent
120120
/** Additional grid configuration */
121121
public gridOptions: GridsterConfig = {};
122122
/** Regions static list for geographic context */
123-
public geographicContextRegions = [
124-
{
125-
code: 'AF',
126-
name: 'AFRO',
127-
},
128-
{
129-
code: 'AM',
130-
name: 'AMRO',
131-
},
132-
{
133-
code: 'EM',
134-
name: 'EMRO',
135-
},
136-
{
137-
code: 'EU',
138-
name: 'EURO',
139-
},
140-
{
141-
code: 'SE',
142-
name: 'SEARO',
143-
},
144-
{
145-
code: 'WP',
146-
name: 'WPRO',
147-
},
148-
{
149-
code: 'HQ',
150-
name: 'HQ',
151-
},
152-
];
123+
public geographicContextRegions = geographicContext.regions;
153124
/** Countries for geographic context */
154-
public geographicContextCountries = countries;
125+
public geographicContextCountries = geographicContext.countries;
155126
/** Geographic context country form control */
156127
public countryCode = new FormControl<string | undefined>('');
157128
/** Geographic context region form control */
@@ -903,18 +874,16 @@ export class DashboardComponent
903874
/**
904875
* Update query based on text search.
905876
*
906-
* @param update values to update in the page geographicContext
907-
* @param update.region region selected
908-
* @param update.country country selected
877+
* @param value value selected
878+
* @param geographicType geographic data type
909879
*/
910-
public onSearchChangeGeographicContext(update: {
911-
region?: string;
912-
country?: string;
913-
}): void {
880+
public onSearchChangeGeographicContext(
881+
value: string | string[],
882+
geographicType: 'region' | 'country'
883+
): void {
914884
const geographicContext = {
915885
...this.dashboard?.page?.geographicContext,
916-
...(update.region && { region: update.region }),
917-
...(update.country && { country: update.country }),
886+
...(value && { [geographicType]: value }),
918887
};
919888
const callback = () => {
920889
this.dashboard = {

0 commit comments

Comments
 (0)