Skip to content

Commit

Permalink
feat(iCherche): add a config to hide advanced options (#1386)
Browse files Browse the repository at this point in the history
* feat(iCherche): add a config to hide avanced settings
- fix(iCherche): edit translation

* fix env

* remove settings from request params

---------

Co-authored-by: Pierre-Étienne Lord <[email protected]>
  • Loading branch information
alecarn and pelord authored Sep 18, 2023
1 parent c1a1491 commit 0fee36e
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 14 deletions.
3 changes: 2 additions & 1 deletion demo/src/environments/environment.prod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ export const environment: Environment = {
enabled: true,
params: {
limit: '8'
}
},
showAdvancedSettings: true
},
coordinatesreverse: {
showInPointerSummary: true
Expand Down
5 changes: 3 additions & 2 deletions demo/src/environments/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,9 @@ export const environment: Environment = {
order: 2,
enabled: true,
params: {
limit: '8'
}
limit: '8',
},
showAdvancedSettings: true
},
coordinatesreverse: {
showInPointerSummary: true
Expand Down
9 changes: 6 additions & 3 deletions packages/geo/src/lib/search/shared/sources/icherche.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ import { SearchSource } from './source';
import {
SearchSourceOptions,
TextSearchOptions,
ReverseSearchOptions
ReverseSearchOptions,
SearchSourceSettings
} from './source.interfaces';
import {
IChercheData,
Expand Down Expand Up @@ -132,6 +133,8 @@ export class IChercheSearchSource extends SearchSource implements TextSearch {
'lieux'
];

const showAdvancedParams = this.options.showAdvancedSettings ?? true;

return {
title: 'igo.geo.search.icherche.name',
searchUrl: 'https://geoegl.msp.gouv.qc.ca/apis/icherche',
Expand Down Expand Up @@ -302,7 +305,7 @@ export class IChercheSearchSource extends SearchSource implements TextSearch {
}
]
},
{
showAdvancedParams && {
type: 'radiobutton',
title: 'ecmax',
name: 'ecmax',
Expand Down Expand Up @@ -351,7 +354,7 @@ export class IChercheSearchSource extends SearchSource implements TextSearch {
}
]
}
]
].filter(Boolean) as SearchSourceSettings[]
};
}

Expand Down
12 changes: 11 additions & 1 deletion packages/geo/src/lib/search/shared/sources/source.interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ export interface SearchSourceOptions {
enabled?: boolean;
order?: number;
distance?: number;
params?: { [key: string]: string };
params?: ISearchSourceParams;
settings?: SearchSourceSettings[];
showInPointerSummary?: boolean;
showInSettings?: boolean;
/** Default value is true */
showAdvancedSettings?: boolean;
}

export interface SearchSourceSettings {
Expand All @@ -19,6 +21,14 @@ export interface SearchSourceSettings {
allEnabled?: boolean;
}

export interface ISearchSourceParams {
limit?: string;
datasets?: string;
ecmax?: string;
page?: string;
type?: string;
}

export interface SettingOptions {
value: string | number;
enabled: boolean;
Expand Down
5 changes: 3 additions & 2 deletions packages/geo/src/lib/search/shared/sources/source.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ObjectUtils } from '@igo2/utils';
import { StorageService } from '@igo2/core';
import {
ISearchSourceParams,
SearchSourceOptions,
SearchSourceSettings
} from './source.interfaces';
Expand Down Expand Up @@ -96,8 +97,8 @@ export class SearchSource {
/**
* Search query params
*/
get params(): { [key: string]: string } {
return this.options.params === undefined ? {} : this.options.params;
get params(): ISearchSourceParams | null {
return this.options.params;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions packages/geo/src/locale/en.geo.json
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@
},
"restrictExtent": {
"map": "Map extent",
"quebec": "Whole Quebec"
"quebec": "Quebec"
}
},
"coordinates": {
Expand Down Expand Up @@ -552,7 +552,7 @@
"radius": "Search radius",
"results limit": "Number of results",
"multiple object": "Multiple object",
"restrictExtent": "Restrict the extent",
"restrictExtent": "Search limit",
"selectAll": "Select All",
"unselectAll": "Unselect All",
"true": "Yes",
Expand Down
6 changes: 3 additions & 3 deletions packages/geo/src/locale/fr.geo.json
Original file line number Diff line number Diff line change
Expand Up @@ -511,8 +511,8 @@
"cultpatri":"Culture et patrimoine"
},
"restrictExtent": {
"map": "À l'étendue de la carte",
"quebec": "Au Québec"
"map": "Étendue de la carte",
"quebec": "Québec"
}
},
"coordinates": {
Expand Down Expand Up @@ -551,7 +551,7 @@
"radius": "Rayon de recherche",
"results limit": "Nombre de résultats",
"multiple object": "Objet multiple",
"restrictExtent": "Restreins l'étendue",
"restrictExtent": "Limite de recherche",
"selectAll": "Tout sélectionner",
"unselectAll": "Tout désélectionner",
"true": "Oui",
Expand Down

0 comments on commit 0fee36e

Please sign in to comment.