diff --git a/apps/back-office/src/app/components/view-settings-modal/view-settings-modal.component.html b/apps/back-office/src/app/components/view-settings-modal/view-settings-modal.component.html
index 0317c24789..2c26e860a6 100644
--- a/apps/back-office/src/app/components/view-settings-modal/view-settings-modal.component.html
+++ b/apps/back-office/src/app/components/view-settings-modal/view-settings-modal.component.html
@@ -35,6 +35,15 @@
{{ 'common.settings' | translate }}
'-mb-4': data.type === 'page'
}"
>
+
+
+
+
+
+ {{ 'components.application.pages.settings.geographicContext' | translate }}
+
+
+
diff --git a/apps/back-office/src/app/components/view-settings-modal/view-settings-modal.component.ts b/apps/back-office/src/app/components/view-settings-modal/view-settings-modal.component.ts
index 594cf77ab1..cd5ee437e3 100644
--- a/apps/back-office/src/app/components/view-settings-modal/view-settings-modal.component.ts
+++ b/apps/back-office/src/app/components/view-settings-modal/view-settings-modal.component.ts
@@ -159,6 +159,16 @@ export class ViewSettingsModalComponent
this.onUpdateVisibility(value);
}
});
+
+ if (this.dashboard) {
+ this.settingsForm?.controls.geographicContext?.valueChanges
+ .pipe(takeUntil(this.destroy$))
+ .subscribe((value: boolean | null) => {
+ if (!isNil(value)) {
+ this.onUpdateGeographicContext(value);
+ }
+ });
+ }
}
if (this.dashboard) {
@@ -257,6 +267,13 @@ export class ViewSettingsModalComponent
// initializes icon field with data info
icon: this.fb.control(this.data.icon ?? ''),
visible: this.fb.control(this.data.visible ?? true),
+ ...(this.dashboard &&
+ this.data.canUpdate &&
+ this.data.type === 'page' && {
+ geographicContext: this.fb.control(
+ this.page?.geographicContext?.enabled ?? false
+ ),
+ }),
...(this.dashboard && {
gridOptions: this.fb.group({
minCols: this.fb.control(
@@ -371,4 +388,32 @@ export class ViewSettingsModalComponent
};
this.dashboardService.editGridOptions(gridOptions, callback);
}
+
+ /**
+ * Enable/disable dashboard page geographic context on change.
+ *
+ * @param enabled boolean
+ */
+ private onUpdateGeographicContext(enabled: boolean): void {
+ const geographicContext = {
+ ...this.page?.geographicContext,
+ enabled,
+ };
+ const callback = () => {
+ this.page = {
+ ...this.page,
+ geographicContext,
+ };
+ // Updates parent component
+ const updates = { geographicContext };
+ this.onUpdate.emit(updates);
+ };
+ this.applicationService.updatePageGeographicContext(
+ {
+ id: this.page?.id,
+ geographicContext,
+ },
+ callback
+ );
+ }
}
diff --git a/apps/back-office/src/app/dashboard/pages/dashboard/dashboard.component.html b/apps/back-office/src/app/dashboard/pages/dashboard/dashboard.component.html
index 25cd1d3e34..fb701c338f 100644
--- a/apps/back-office/src/app/dashboard/pages/dashboard/dashboard.component.html
+++ b/apps/back-office/src/app/dashboard/pages/dashboard/dashboard.component.html
@@ -137,6 +137,7 @@
'models.dashboard.context.edition.element' | translate
}}
+
+
+
+
+
+
+
+
+ {{ region.name }}
+
+
+
+
+
+
+
+
+ {{ country.name }}
+
+
+
+
diff --git a/apps/back-office/src/app/dashboard/pages/dashboard/dashboard.component.ts b/apps/back-office/src/app/dashboard/pages/dashboard/dashboard.component.ts
index 9dc8c80428..b3ee5cf14a 100644
--- a/apps/back-office/src/app/dashboard/pages/dashboard/dashboard.component.ts
+++ b/apps/back-office/src/app/dashboard/pages/dashboard/dashboard.component.ts
@@ -28,6 +28,7 @@ import {
DashboardQueryResponse,
EditDashboardMutationResponse,
RecordQueryResponse,
+ PageGeographicContextType,
} from '@oort-front/shared';
import { EDIT_DASHBOARD } from './graphql/mutations';
import {
@@ -54,6 +55,7 @@ import { ContextService, CustomWidgetStyleComponent } from '@oort-front/shared';
import { DOCUMENT } from '@angular/common';
import { Clipboard } from '@angular/cdk/clipboard';
import { GridsterConfig } from 'angular-gridster2';
+import geographicContext from 'assets/geographic-context-data.json';
/** Default number of records fetched per page */
const ITEMS_PER_PAGE = 10;
@@ -117,6 +119,14 @@ export class DashboardComponent
public editionActive = true;
/** Additional grid configuration */
public gridOptions: GridsterConfig = {};
+ /** Regions static list for geographic context */
+ public geographicContextRegions = geographicContext.regions;
+ /** Countries for geographic context */
+ public geographicContextCountries = geographicContext.countries;
+ /** Geographic context country form control */
+ public countryCode = new FormControl('');
+ /** Geographic context region form control */
+ public regionCode = new FormControl('');
/** @returns type of context element */
get contextType() {
@@ -311,6 +321,17 @@ export class DashboardComponent
...this.dashboard?.gridOptions,
scrollToNewItems: false,
};
+ if (this.dashboard.page?.geographicContext?.enabled) {
+ this.countryCode.setValue(
+ this.dashboard.page?.geographicContext?.country
+ );
+ this.regionCode.setValue(
+ this.dashboard.page?.geographicContext?.region
+ );
+ } else {
+ this.countryCode.setValue('');
+ this.regionCode.setValue('');
+ }
this.initContext();
this.updateContextOptions();
this.canUpdate =
@@ -849,4 +870,36 @@ export class DashboardComponent
});
}
}
+
+ /**
+ * Update query based on text search.
+ *
+ * @param value value selected
+ * @param geographicType geographic data type
+ */
+ public onSearchChangeGeographicContext(
+ value: string | string[],
+ geographicType: 'region' | 'country'
+ ): void {
+ const geographicContext = {
+ ...this.dashboard?.page?.geographicContext,
+ ...(value && { [geographicType]: value }),
+ };
+ const callback = () => {
+ this.dashboard = {
+ ...this.dashboard,
+ page: {
+ ...this.dashboard?.page,
+ geographicContext: geographicContext as PageGeographicContextType,
+ },
+ };
+ };
+ this.applicationService.updatePageGeographicContext(
+ {
+ id: this.dashboard?.page?.id,
+ geographicContext: geographicContext as PageGeographicContextType,
+ },
+ callback
+ );
+ }
}
diff --git a/apps/back-office/src/app/dashboard/pages/dashboard/graphql/queries.ts b/apps/back-office/src/app/dashboard/pages/dashboard/graphql/queries.ts
index e42d7b37d2..83ca569585 100644
--- a/apps/back-office/src/app/dashboard/pages/dashboard/graphql/queries.ts
+++ b/apps/back-office/src/app/dashboard/pages/dashboard/graphql/queries.ts
@@ -37,6 +37,7 @@ export const GET_DASHBOARD_BY_ID = gql`
context
content
contentWithContext
+ geographicContext
}
step {
id
diff --git a/apps/back-office/tsconfig.json b/apps/back-office/tsconfig.json
index de370a9e61..906f7cab81 100644
--- a/apps/back-office/tsconfig.json
+++ b/apps/back-office/tsconfig.json
@@ -7,7 +7,8 @@
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": false,
"noImplicitReturns": true,
- "noFallthroughCasesInSwitch": true
+ "noFallthroughCasesInSwitch": true,
+ "resolveJsonModule": true
},
"files": [],
"include": [],
diff --git a/apps/front-office/src/app/application/pages/dashboard/graphql/queries.ts b/apps/front-office/src/app/application/pages/dashboard/graphql/queries.ts
index 4e5afff908..cdb9e6424c 100644
--- a/apps/front-office/src/app/application/pages/dashboard/graphql/queries.ts
+++ b/apps/front-office/src/app/application/pages/dashboard/graphql/queries.ts
@@ -39,6 +39,7 @@ export const GET_DASHBOARD_BY_ID = gql`
context
content
contentWithContext
+ geographicContext
}
}
}
diff --git a/apps/web-widgets/src/app/widgets/app-widget/application/pages/dashboard/graphql/queries.ts b/apps/web-widgets/src/app/widgets/app-widget/application/pages/dashboard/graphql/queries.ts
index 1232a11ed0..e3f7f5e823 100644
--- a/apps/web-widgets/src/app/widgets/app-widget/application/pages/dashboard/graphql/queries.ts
+++ b/apps/web-widgets/src/app/widgets/app-widget/application/pages/dashboard/graphql/queries.ts
@@ -38,6 +38,7 @@ export const GET_DASHBOARD_BY_ID = gql`
context
content
contentWithContext
+ geographicContext
}
}
}
diff --git a/assets/geographic-context-data.json b/assets/geographic-context-data.json
new file mode 100644
index 0000000000..6b19c17377
--- /dev/null
+++ b/assets/geographic-context-data.json
@@ -0,0 +1,1026 @@
+{
+ "regions": [
+ {
+ "code": "AF",
+ "name": "AFRO"
+ },
+ {
+ "code": "AM",
+ "name": "AMRO"
+ },
+ {
+ "code": "EM",
+ "name": "EMRO"
+ },
+ {
+ "code": "EU",
+ "name": "EURO"
+ },
+ {
+ "code": "SE",
+ "name": "SEARO"
+ },
+ {
+ "code": "WP",
+ "name": "WPRO"
+ },
+ {
+ "code": "HQ",
+ "name": "HQ"
+ }
+ ],
+ "countries": [
+ {
+ "code": "AND",
+ "name": "Andorra"
+ },
+ {
+ "code": "ARE",
+ "name": "United Arab Emirates (the)"
+ },
+ {
+ "code": "AFG",
+ "name": "Afghanistan"
+ },
+ {
+ "code": "ATG",
+ "name": "Antigua and Barbuda"
+ },
+ {
+ "code": "ALB",
+ "name": "Albania"
+ },
+ {
+ "code": "ARM",
+ "name": "Armenia"
+ },
+ {
+ "code": "AGO",
+ "name": "Angola"
+ },
+ {
+ "code": "ARG",
+ "name": "Argentina"
+ },
+ {
+ "code": "AUT",
+ "name": "Austria"
+ },
+ {
+ "code": "AUS",
+ "name": "Australia"
+ },
+ {
+ "code": "AZE",
+ "name": "Azerbaijan"
+ },
+ {
+ "code": "BIH",
+ "name": "Bosnia and Herzegovina"
+ },
+ {
+ "code": "BRB",
+ "name": "Barbados"
+ },
+ {
+ "code": "BGD",
+ "name": "Bangladesh"
+ },
+ {
+ "code": "BEL",
+ "name": "Belgium"
+ },
+ {
+ "code": "BFA",
+ "name": "Burkina Faso"
+ },
+ {
+ "code": "BGR",
+ "name": "Bulgaria"
+ },
+ {
+ "code": "BHR",
+ "name": "Bahrain"
+ },
+ {
+ "code": "BDI",
+ "name": "Burundi"
+ },
+ {
+ "code": "BEN",
+ "name": "Benin"
+ },
+ {
+ "code": "BRN",
+ "name": "Brunei Darussalam"
+ },
+ {
+ "code": "BOL",
+ "name": "Bolivia (the Plurinational State of)"
+ },
+ {
+ "code": "BRA",
+ "name": "Brazil"
+ },
+ {
+ "code": "BHS",
+ "name": "Bahamas (the)"
+ },
+ {
+ "code": "BTN",
+ "name": "Bhutan"
+ },
+ {
+ "code": "BWA",
+ "name": "Botswana"
+ },
+ {
+ "code": "BLR",
+ "name": "Belarus"
+ },
+ {
+ "code": "BLZ",
+ "name": "Belize"
+ },
+ {
+ "code": "CAN",
+ "name": "Canada"
+ },
+ {
+ "code": "COD",
+ "name": "Democratic Republic of the Congo (the)"
+ },
+ {
+ "code": "CAF",
+ "name": "Central African Republic (the)"
+ },
+ {
+ "code": "COG",
+ "name": "Congo (the)"
+ },
+ {
+ "code": "CHE",
+ "name": "Switzerland"
+ },
+ {
+ "code": "CIV",
+ "name": "Côte d’Ivoire"
+ },
+ {
+ "code": "COK",
+ "name": "Cook Islands"
+ },
+ {
+ "code": "CHL",
+ "name": "Chile"
+ },
+ {
+ "code": "CMR",
+ "name": "Cameroon"
+ },
+ {
+ "code": "CHN",
+ "name": "China"
+ },
+ {
+ "code": "COL",
+ "name": "Colombia"
+ },
+ {
+ "code": "CRI",
+ "name": "Costa Rica"
+ },
+ {
+ "code": "CUB",
+ "name": "Cuba"
+ },
+ {
+ "code": "CPV",
+ "name": "Cape Verde"
+ },
+ {
+ "code": "CYP",
+ "name": "Cyprus"
+ },
+ {
+ "code": "CZE",
+ "name": "Czechia"
+ },
+ {
+ "code": "DEU",
+ "name": "Germany"
+ },
+ {
+ "code": "DJI",
+ "name": "Djibouti"
+ },
+ {
+ "code": "DNK",
+ "name": "Denmark"
+ },
+ {
+ "code": "DMA",
+ "name": "Dominica"
+ },
+ {
+ "code": "DOM",
+ "name": "Dominican Republic (the)"
+ },
+ {
+ "code": "DZA",
+ "name": "Algeria"
+ },
+ {
+ "code": "ECU",
+ "name": "Ecuador"
+ },
+ {
+ "code": "EST",
+ "name": "Estonia"
+ },
+ {
+ "code": "EGY",
+ "name": "Egypt"
+ },
+ {
+ "code": "ERI",
+ "name": "Eritrea"
+ },
+ {
+ "code": "ESP",
+ "name": "Spain"
+ },
+ {
+ "code": "ETH",
+ "name": "Ethiopia"
+ },
+ {
+ "code": "FIN",
+ "name": "Finland"
+ },
+ {
+ "code": "FJI",
+ "name": "Fiji"
+ },
+ {
+ "code": "FSM",
+ "name": "Micronesia (Federated States of)"
+ },
+ {
+ "code": "FRA",
+ "name": "France"
+ },
+ {
+ "code": "GAB",
+ "name": "Gabon"
+ },
+ {
+ "code": "GBR",
+ "name": "United Kingdom"
+ },
+ {
+ "code": "GRD",
+ "name": "Grenada"
+ },
+ {
+ "code": "GEO",
+ "name": "Georgia"
+ },
+ {
+ "code": "GHA",
+ "name": "Ghana"
+ },
+ {
+ "code": "GMB",
+ "name": "Gambia (the)"
+ },
+ {
+ "code": "GIN",
+ "name": "Guinea"
+ },
+ {
+ "code": "GNQ",
+ "name": "Equatorial Guinea"
+ },
+ {
+ "code": "GRC",
+ "name": "Greece"
+ },
+ {
+ "code": "GTM",
+ "name": "Guatemala"
+ },
+ {
+ "code": "GNB",
+ "name": "Guinea-Bissau"
+ },
+ {
+ "code": "GUY",
+ "name": "Guyana"
+ },
+ {
+ "code": "HND",
+ "name": "Honduras"
+ },
+ {
+ "code": "HRV",
+ "name": "Croatia"
+ },
+ {
+ "code": "HTI",
+ "name": "Haiti"
+ },
+ {
+ "code": "HUN",
+ "name": "Hungary"
+ },
+ {
+ "code": "IDN",
+ "name": "Indonesia"
+ },
+ {
+ "code": "IRL",
+ "name": "Ireland"
+ },
+ {
+ "code": "ISR",
+ "name": "Israel"
+ },
+ {
+ "code": "IND",
+ "name": "India"
+ },
+ {
+ "code": "IRQ",
+ "name": "Iraq"
+ },
+ {
+ "code": "IRN",
+ "name": "Iran (Islamic Republic of)"
+ },
+ {
+ "code": "ISL",
+ "name": "Iceland"
+ },
+ {
+ "code": "ITA",
+ "name": "Italy"
+ },
+ {
+ "code": "JAM",
+ "name": "Jamaica"
+ },
+ {
+ "code": "JOR",
+ "name": "Jordan"
+ },
+ {
+ "code": "JPN",
+ "name": "Japan"
+ },
+ {
+ "code": "KEN",
+ "name": "Kenya"
+ },
+ {
+ "code": "KGZ",
+ "name": "Kyrgyzstan"
+ },
+ {
+ "code": "KHM",
+ "name": "Cambodia"
+ },
+ {
+ "code": "KIR",
+ "name": "Kiribati"
+ },
+ {
+ "code": "COM",
+ "name": "Comoros (the)"
+ },
+ {
+ "code": "KNA",
+ "name": "Saint Kitts and Nevis"
+ },
+ {
+ "code": "PRK",
+ "name": "Democratic People’s Republic of Korea (the)"
+ },
+ {
+ "code": "KOR",
+ "name": "Republic of Korea (the)"
+ },
+ {
+ "code": "KWT",
+ "name": "Kuwait"
+ },
+ {
+ "code": "KAZ",
+ "name": "Kazakhstan"
+ },
+ {
+ "code": "LAO",
+ "name": "Lao People’s Democratic Republic (the)"
+ },
+ {
+ "code": "LBN",
+ "name": "Lebanon"
+ },
+ {
+ "code": "LCA",
+ "name": "Saint Lucia"
+ },
+ {
+ "code": "LIE",
+ "name": "Liechtenstein"
+ },
+ {
+ "code": "LKA",
+ "name": "Sri Lanka"
+ },
+ {
+ "code": "LBR",
+ "name": "Liberia"
+ },
+ {
+ "code": "LSO",
+ "name": "Lesotho"
+ },
+ {
+ "code": "LTU",
+ "name": "Lithuania"
+ },
+ {
+ "code": "LUX",
+ "name": "Luxembourg"
+ },
+ {
+ "code": "LVA",
+ "name": "Latvia"
+ },
+ {
+ "code": "LBY",
+ "name": "Libya"
+ },
+ {
+ "code": "MAR",
+ "name": "Morocco"
+ },
+ {
+ "code": "MCO",
+ "name": "Monaco"
+ },
+ {
+ "code": "MDA",
+ "name": "the Republic of Moldova"
+ },
+ {
+ "code": "MNE",
+ "name": "Montenegro"
+ },
+ {
+ "code": "MDG",
+ "name": "Madagascar"
+ },
+ {
+ "code": "MHL",
+ "name": "Marshall Islands (the)"
+ },
+ {
+ "code": "MKD",
+ "name": "North Macedonia"
+ },
+ {
+ "code": "MLI",
+ "name": "Mali"
+ },
+ {
+ "code": "MMR",
+ "name": "Myanmar"
+ },
+ {
+ "code": "MNG",
+ "name": "Mongolia"
+ },
+ {
+ "code": "MRT",
+ "name": "Mauritania"
+ },
+ {
+ "code": "MLT",
+ "name": "Malta"
+ },
+ {
+ "code": "MUS",
+ "name": "Mauritius"
+ },
+ {
+ "code": "MDV",
+ "name": "Maldives"
+ },
+ {
+ "code": "MWI",
+ "name": "Malawi"
+ },
+ {
+ "code": "MEX",
+ "name": "Mexico"
+ },
+ {
+ "code": "MYS",
+ "name": "Malaysia"
+ },
+ {
+ "code": "MOZ",
+ "name": "Mozambique"
+ },
+ {
+ "code": "NAM",
+ "name": "Namibia"
+ },
+ {
+ "code": "NER",
+ "name": "Niger (the)"
+ },
+ {
+ "code": "NGA",
+ "name": "Nigeria"
+ },
+ {
+ "code": "NIC",
+ "name": "Nicaragua"
+ },
+ {
+ "code": "NLD",
+ "name": "Netherlands (the)"
+ },
+ {
+ "code": "NOR",
+ "name": "Norway"
+ },
+ {
+ "code": "NPL",
+ "name": "Nepal"
+ },
+ {
+ "code": "NRU",
+ "name": "Nauru"
+ },
+ {
+ "code": "NIU",
+ "name": "Niue"
+ },
+ {
+ "code": "NZL",
+ "name": "New Zealand"
+ },
+ {
+ "code": "OMN",
+ "name": "Oman"
+ },
+ {
+ "code": "PAN",
+ "name": "Panama"
+ },
+ {
+ "code": "PER",
+ "name": "Peru"
+ },
+ {
+ "code": "PNG",
+ "name": "Papua New Guinea"
+ },
+ {
+ "code": "PHL",
+ "name": "Philippines (the)"
+ },
+ {
+ "code": "PAK",
+ "name": "Pakistan"
+ },
+ {
+ "code": "POL",
+ "name": "Poland"
+ },
+ {
+ "code": "PRT",
+ "name": "Portugal"
+ },
+ {
+ "code": "PLW",
+ "name": "Palau"
+ },
+ {
+ "code": "PRY",
+ "name": "Paraguay"
+ },
+ {
+ "code": "QAT",
+ "name": "Qatar"
+ },
+ {
+ "code": "ROU",
+ "name": "Romania"
+ },
+ {
+ "code": "SRB",
+ "name": "Serbia"
+ },
+ {
+ "code": "RUS",
+ "name": "Russian Federation (the)"
+ },
+ {
+ "code": "RWA",
+ "name": "Rwanda"
+ },
+ {
+ "code": "SAU",
+ "name": "Saudi Arabia"
+ },
+ {
+ "code": "SLB",
+ "name": "Solomon Islands"
+ },
+ {
+ "code": "SYC",
+ "name": "Seychelles"
+ },
+ {
+ "code": "SDN",
+ "name": "Sudan (the)"
+ },
+ {
+ "code": "SWE",
+ "name": "Sweden"
+ },
+ {
+ "code": "SGP",
+ "name": "Singapore"
+ },
+ {
+ "code": "SVN",
+ "name": "Slovenia"
+ },
+ {
+ "code": "SVK",
+ "name": "Slovakia"
+ },
+ {
+ "code": "SLE",
+ "name": "Sierra Leone"
+ },
+ {
+ "code": "SMR",
+ "name": "San Marino"
+ },
+ {
+ "code": "SEN",
+ "name": "Senegal"
+ },
+ {
+ "code": "SOM",
+ "name": "Somalia"
+ },
+ {
+ "code": "SUR",
+ "name": "Suriname"
+ },
+ {
+ "code": "STP",
+ "name": "Sao Tome and Principe"
+ },
+ {
+ "code": "SLV",
+ "name": "El Salvador"
+ },
+ {
+ "code": "SYR",
+ "name": "Syrian Arab Republic (the)"
+ },
+ {
+ "code": "SWZ",
+ "name": "Eswatini"
+ },
+ {
+ "code": "TCD",
+ "name": "Chad"
+ },
+ {
+ "code": "TGO",
+ "name": "Togo"
+ },
+ {
+ "code": "THA",
+ "name": "Thailand"
+ },
+ {
+ "code": "TJK",
+ "name": "Tajikistan"
+ },
+ {
+ "code": "TLS",
+ "name": "Timor-Leste"
+ },
+ {
+ "code": "TKM",
+ "name": "Turkmenistan"
+ },
+ {
+ "code": "TUN",
+ "name": "Tunisia"
+ },
+ {
+ "code": "TON",
+ "name": "Tonga"
+ },
+ {
+ "code": "TUR",
+ "name": "Türkiye"
+ },
+ {
+ "code": "TTO",
+ "name": "Trinidad and Tobago"
+ },
+ {
+ "code": "TUV",
+ "name": "Tuvalu"
+ },
+ {
+ "code": "TZA",
+ "name": "United Republic of Tanzania (the)"
+ },
+ {
+ "code": "UKR",
+ "name": "Ukraine"
+ },
+ {
+ "code": "UGA",
+ "name": "Uganda"
+ },
+ {
+ "code": "USA",
+ "name": "United States of America (the)"
+ },
+ {
+ "code": "URY",
+ "name": "Uruguay"
+ },
+ {
+ "code": "UZB",
+ "name": "Uzbekistan"
+ },
+ {
+ "code": "VCT",
+ "name": "Saint Vincent and the Grenadines"
+ },
+ {
+ "code": "VEN",
+ "name": "Venezuela (Bolivarian Republic of)"
+ },
+ {
+ "code": "VNM",
+ "name": "Viet Nam"
+ },
+ {
+ "code": "VUT",
+ "name": "Vanuatu"
+ },
+ {
+ "code": "WSM",
+ "name": "Samoa"
+ },
+ {
+ "code": "YEM",
+ "name": "Yemen"
+ },
+ {
+ "code": "ZAF",
+ "name": "South Africa"
+ },
+ {
+ "code": "ZMB",
+ "name": "Zambia"
+ },
+ {
+ "code": "ZWE",
+ "name": "Zimbabwe"
+ },
+ {
+ "code": "SSD",
+ "name": "South Sudan"
+ },
+ {
+ "code": "PSE",
+ "name": "West Bank and Gaza Strip"
+ },
+ {
+ "code": "EX",
+ "name": "Exercise Maranisk"
+ },
+ {
+ "code": "VA",
+ "name": "Holy See"
+ },
+ {
+ "code": "AIA",
+ "name": "Anguilla"
+ },
+ {
+ "code": "ANT",
+ "name": "Netherlands Antilles"
+ },
+ {
+ "code": "ASM",
+ "name": "American Samoa"
+ },
+ {
+ "code": "ABW",
+ "name": "Aruba"
+ },
+ {
+ "code": "BMU",
+ "name": "Bermuda"
+ },
+ {
+ "code": "GUF",
+ "name": "French Guiana"
+ },
+ {
+ "code": "GLP",
+ "name": "Guadeloupe"
+ },
+ {
+ "code": "GUM",
+ "name": "Guam"
+ },
+ {
+ "code": "CYM",
+ "name": "Cayman Islands"
+ },
+ {
+ "code": "MTQ",
+ "name": "Martinique"
+ },
+ {
+ "code": "MSR",
+ "name": "Montserrat"
+ },
+ {
+ "code": "NCL",
+ "name": "New Caledonia"
+ },
+ {
+ "code": "PYF",
+ "name": "French Polynesia"
+ },
+ {
+ "code": "PCN",
+ "name": "Pitcairn Islands"
+ },
+ {
+ "code": "PRI",
+ "name": "Puerto Rico"
+ },
+ {
+ "code": "TCA",
+ "name": "Turks and Caicos Islands"
+ },
+ {
+ "code": "TKL",
+ "name": "Tokelau"
+ },
+ {
+ "code": "VGB",
+ "name": "British Virgin Islands"
+ },
+ {
+ "code": "VIR",
+ "name": "United States Virgin Islands"
+ },
+ {
+ "code": "WLF",
+ "name": "Wallis And Futuna"
+ },
+ {
+ "code": "MNP",
+ "name": "Northern Mariana Islands"
+ },
+ {
+ "code": "CX",
+ "name": "Christmas Island"
+ },
+ {
+ "code": "FK",
+ "name": "Falkland Islands (Malvinas)"
+ },
+ {
+ "code": "FO",
+ "name": "Faroe Islands"
+ },
+ {
+ "code": "GI",
+ "name": "Gibraltar"
+ },
+ {
+ "code": "GL",
+ "name": "Greenland"
+ },
+ {
+ "code": "HK",
+ "name": "China (Hong Kong SAR)"
+ },
+ {
+ "code": "IM",
+ "name": "Isle of Man"
+ },
+ {
+ "code": "KO",
+ "name": "Kosovo"
+ },
+ {
+ "code": "MO",
+ "name": "China (Macao SAR)"
+ },
+ {
+ "code": "NF",
+ "name": "Norfolk Island"
+ },
+ {
+ "code": "PM",
+ "name": "Saint Pierre and Miquelon"
+ },
+ {
+ "code": "RE",
+ "name": "Reunion"
+ },
+ {
+ "code": "SJ",
+ "name": "Svalbard and Jan Mayen Islands"
+ },
+ {
+ "code": "TW",
+ "name": "China (Province of Taiwan)"
+ },
+ {
+ "code": "YT",
+ "name": "Mayotte"
+ },
+ {
+ "code": "XH",
+ "name": "Guernsey"
+ },
+ {
+ "code": "XK",
+ "name": "Jersey"
+ },
+ {
+ "code": "XR",
+ "name": "Johnston Atoll"
+ },
+ {
+ "code": "XS",
+ "name": "Midway Islands"
+ },
+ {
+ "code": "GS",
+ "name": "South Georgia and the South Sandwich Islands"
+ },
+ {
+ "code": "BL",
+ "name": "Saint Barthelemy"
+ },
+ {
+ "code": "MF",
+ "name": "Saint Martin"
+ },
+ {
+ "code": "IO",
+ "name": "British Indian Ocean Territory"
+ },
+ {
+ "code": "SH",
+ "name": "Saint Helena"
+ },
+ {
+ "code": "CW",
+ "name": "Curacao"
+ },
+ {
+ "code": "SX",
+ "name": "Sint Maarten"
+ },
+ {
+ "code": "BQ",
+ "name": "Bonaire, Sint Eustatius and Saba"
+ },
+ {
+ "code": "test00000",
+ "name": "test00000"
+ },
+ {
+ "code": "TSCTRY",
+ "name": "Test SEARO Country"
+ }
+ ]
+}
diff --git a/libs/shared/src/i18n/en.json b/libs/shared/src/i18n/en.json
index c987cee8ba..6af7eb8cdf 100644
--- a/libs/shared/src/i18n/en.json
+++ b/libs/shared/src/i18n/en.json
@@ -577,6 +577,7 @@
},
"settings": {
"actions": "Actions",
+ "geographicContext": "Enable geographic context",
"selectIcon": "Select an icon",
"tooltip": {
"autoSave": "Changes are automatically saved"
diff --git a/libs/shared/src/i18n/fr.json b/libs/shared/src/i18n/fr.json
index 016fb5f99e..a921ce83e2 100644
--- a/libs/shared/src/i18n/fr.json
+++ b/libs/shared/src/i18n/fr.json
@@ -583,6 +583,7 @@
},
"settings": {
"actions": "Actions",
+ "geographicContext": "Activer le contexte géographique",
"selectIcon": "Sélectionnez une icône",
"tooltip": {
"autoSave": "Les modifications sont automatiquement enregistrées"
diff --git a/libs/shared/src/i18n/test.json b/libs/shared/src/i18n/test.json
index c05ed1720f..b0bc3bf8d0 100644
--- a/libs/shared/src/i18n/test.json
+++ b/libs/shared/src/i18n/test.json
@@ -577,6 +577,7 @@
},
"settings": {
"actions": "******",
+ "geographicContext": "******",
"selectIcon": "******",
"tooltip": {
"autoSave": "******"
diff --git a/libs/shared/src/lib/models/page.model.ts b/libs/shared/src/lib/models/page.model.ts
index f8a11d5f59..a495d14d24 100644
--- a/libs/shared/src/lib/models/page.model.ts
+++ b/libs/shared/src/lib/models/page.model.ts
@@ -32,6 +32,13 @@ export type PageContextT = (
displayField: string;
};
+/** Page geographic context interface */
+export interface PageGeographicContextType {
+ enabled: boolean;
+ region?: string;
+ country?: string;
+}
+
/**
* Available content types.
*/
@@ -89,6 +96,7 @@ export interface Page {
) & {
content: string;
})[];
+ geographicContext?: PageGeographicContextType;
autoDeletedAt?: Date;
}
diff --git a/libs/shared/src/lib/services/application/application.service.ts b/libs/shared/src/lib/services/application/application.service.ts
index 1254728e42..d506e9e1df 100644
--- a/libs/shared/src/lib/services/application/application.service.ts
+++ b/libs/shared/src/lib/services/application/application.service.ts
@@ -2066,4 +2066,56 @@ export class ApplicationService {
});
}
}
+
+ /**
+ * Update page geographic context
+ *
+ * @param page page to update
+ * @param callback callback method
+ */
+ updatePageGeographicContext(page: Page, callback?: any): void {
+ const application = this.application.getValue();
+ if (application && this.isUnlocked) {
+ this.apollo
+ .mutate({
+ mutation: EDIT_PAGE,
+ variables: {
+ id: page.id,
+ geographicContext: page.geographicContext,
+ },
+ })
+ .subscribe({
+ next: ({ errors, data }) => {
+ this.handleEditionMutationResponse(
+ errors,
+ this.translate.instant('common.page.one')
+ );
+ if (!errors && data) {
+ const newApplication = {
+ ...application,
+ pages: application.pages?.map((x) => {
+ if (x.id === page.id) {
+ x = {
+ ...x,
+ geographicContext: data.editPage.geographicContext,
+ };
+ }
+ return x;
+ }),
+ };
+ this.application.next(newApplication);
+ if (callback) {
+ callback();
+ }
+ }
+ },
+ error: (errors: any) => {
+ this.handleEditionMutationResponse(
+ errors,
+ this.translate.instant('common.page.one')
+ );
+ },
+ });
+ }
+ }
}
diff --git a/libs/shared/src/lib/services/application/graphql/mutations.ts b/libs/shared/src/lib/services/application/graphql/mutations.ts
index d8e244cd2d..b2128480a5 100644
--- a/libs/shared/src/lib/services/application/graphql/mutations.ts
+++ b/libs/shared/src/lib/services/application/graphql/mutations.ts
@@ -81,6 +81,7 @@ export const EDIT_PAGE = gql`
$icon: String
$permissions: JSON
$visible: Boolean
+ $geographicContext: PageGeographicContextInputType
) {
editPage(
id: $id
@@ -88,6 +89,7 @@ export const EDIT_PAGE = gql`
icon: $icon
permissions: $permissions
visible: $visible
+ geographicContext: $geographicContext
) {
id
name