Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Button default options #1246

Open
wants to merge 44 commits into
base: next
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
fde57fe
Added Default button. First implementation
ThierryNormand Mar 22, 2023
82e0566
lint
ThierryNormand Mar 22, 2023
8be13d1
Default options "recherche par coordonnées"
ThierryNormand Mar 24, 2023
7d6a448
Correcting defaultButton for all settings.
ThierryNormand Mar 27, 2023
aa16282
Made defaultOptions works for RadioButton
ThierryNormand Mar 31, 2023
5b2a613
Lint
ThierryNormand Mar 31, 2023
5bdce71
lint
ThierryNormand Mar 31, 2023
2746eea
Merge branch 'next' of https://github.com/infra-geo-ouverte/igo2-lib …
ThierryNormand Mar 31, 2023
6102c0e
Compatibility with instances of SearchSources
ThierryNormand Apr 3, 2023
4ab2019
Merge branch 'next' of https://github.com/infra-geo-ouverte/igo2-lib …
ThierryNormand Apr 3, 2023
46b13f9
Rebuild libs
ThierryNormand Apr 3, 2023
f19f11e
Re-new package-lock json
ThierryNormand Apr 3, 2023
93b738d
wip
pelord Apr 3, 2023
dd71866
wip
pelord Apr 3, 2023
4e35c6d
Lint
ThierryNormand Apr 3, 2023
80ae099
Corrected (Un)SellectAll button switch
ThierryNormand Apr 4, 2023
6f0d21a
Erased comments
ThierryNormand Apr 4, 2023
0a88b15
Merge tag '1.15.1' into button_DefaultOptions
pelord May 9, 2023
b70f52f
Merge remote-tracking branch 'origin/next' into button_DefaultOptions
pelord Sep 11, 2023
2a9c5b9
wip
pelord Sep 11, 2023
c80c8bf
wip
pelord Sep 11, 2023
7606fea
Merge remote-tracking branch 'origin/next' into button_DefaultOptions
pelord Sep 19, 2023
5b28cf3
Merge remote-tracking branch 'origin/release/16.0.0' into button_Defa…
pelord Sep 19, 2023
b36486c
Added default button in source settings remove global button
ThierryNormand Sep 25, 2023
c5888c1
Merge remote-tracking branch 'origin/release/16.0.0' into button_Defa…
ThierryNormand Sep 25, 2023
c56a3d8
Corrected button display
ThierryNormand Sep 25, 2023
9acf4b9
Deleted obsolete code
ThierryNormand Sep 25, 2023
dcd3a37
Merge remote-tracking branch 'origin/release/16.0.0' into button_Defa…
pelord Oct 13, 2023
a458db7
Merge remote-tracking branch 'origin/next' into button_DefaultOptions
pelord Nov 30, 2023
a3e85a9
Correction of source default button to force Reset for the number of …
ThierryNormand Dec 11, 2023
d96c5bf
Merge remote-tracking branch 'origin/next' into button_DefaultOptions
pelord Jan 31, 2024
117b41c
refactor(search-settings): for loop to map
pelord Jan 31, 2024
884e40e
Started corrections. Commit to merge to correct a bug
ThierryNormand Apr 2, 2024
b0e96e2
Merge branch 'next' of https://github.com/infra-geo-ouverte/igo2-lib …
ThierryNormand Apr 2, 2024
239b73c
Change button to icon button. Added css styles. Cleanup.
ThierryNormand Apr 5, 2024
a3688d2
Corrected typer and css style for button
ThierryNormand Apr 5, 2024
6f72389
Event type caused error
ThierryNormand Apr 5, 2024
c7c7a6f
Added length condition for default selection button, like select all.
ThierryNormand Apr 5, 2024
110860e
Change margin on default button
ThierryNormand Apr 5, 2024
3ccb8bd
Merge remote-tracking branch 'origin/next' into button_DefaultOptions
pelord May 16, 2024
9c60f08
wip
pelord May 16, 2024
0bc962c
Merge remote-tracking branch 'origin/next' into button_DefaultOptions
pelord Nov 25, 2024
f85c57b
Merge remote-tracking branch 'origin/next' into button_DefaultOptions
pelord Nov 27, 2024
5872918
Merge remote-tracking branch 'origin/next' into button_DefaultOptions
pelord Nov 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/geo/src/lib/query/shared/query-search-source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class QuerySearchSource extends SearchSource {
return QuerySearchSource.type;
}

protected getDefaultOptions(): SearchSourceOptions {
getDefaultOptions(): SearchSourceOptions {
return {
title: 'Carte'
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@
</button>
</span>
<mat-menu #sub_menu="matMenu">
<div class="checkMenuDefaultButton">
<button
mat-raised-button
(click)="checkMenuDefaultOptions($event, source)"
>
{{ 'igo.geo.search.searchSources.defaultSettings' | translate }}
</button>
</div>
<ng-container *ngFor="let setting of source.settings">
<button mat-menu-item [matMenuTriggerFor]="test_sub_menu">
{{
Expand Down Expand Up @@ -94,6 +102,16 @@
}}
</button>
</div>
<div class="checkDefaultButton">
<button
mat-raised-button
(click)="checkDefaultOptions($event, source, setting)"
>
{{
'igo.geo.search.searchSources.defaultSettings' | translate
}}
</button>
</div>
<div
class="igo-search-settings-sub-menu"
mat-menu-item
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,19 @@
align-items: center;
}

// This component is projected, the style need to be apply outside is scope
.checkDefaultButton {
text-align: center;
padding: 0 5px;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

En général avec Material design, on essaie de respecter les multiples de 4 ou au moins en nombre paires pour nos espacements (padding/margin).
Voir le Material measurements

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Je me base sur des éléments déjà existants comme le bouton de tout sélectionner qui utilise ce multiple

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Je crois qu'il faut se conformer ici

margin: 5px;
}

// This component is projected, the style need to be apply outside is scope
.checkMenuDefaultButton {
text-align: center;
padding: 0 5px;
}

// This component is projected, the style need to be apply outside is scope
.checkAllButton {
text-align: center;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,50 @@ export class SearchSettingsComponent implements OnInit {
});
}

/**
* Triggered when the default options is clicked
* Only CheckBox type will change
* Default Button of a specified setting
* @internal
*/
checkDefaultOptions(
event,
source: SearchSource,
setting: SearchSourceSettings
) {
event.stopPropagation();
setting.allEnabled = true;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pourquoi mettre le allEnabled à vrai?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sinon, ça crée un état où le bouton de sélection par défaut sélectionnait tout lorsque tout était désélectionné.

this.checkUncheckAll(event, source, setting);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pourquoi faire un uncheck si on repasse tous les settings ci-dessous. Surtout qu'on va générer deux searchSourceChange.emit()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dépendamment de la valeur du bouton de tout sélectionner, un état faisait que le bouton de sélection par défaut ne fonctionnait pas. Ça "reset" en quelque sorte.

source.getDefaultOptions().settings.map((defaultSetting) => {
if (defaultSetting.title === setting.title) {
setting.values.map((value, index) => {
value.enabled = defaultSetting.values[index].enabled;
});
}
});
Comment on lines +248 to +254
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

J'ai l'impression qu'on pourrait optimiser et améliorer la lisibilité? Je n'ai pas testé!

Suggested change
source.getDefaultOptions().settings.map((defaultSetting) => {
if (defaultSetting.title === setting.title) {
setting.values.map((value, index) => {
value.enabled = defaultSetting.values[index].enabled;
});
}
});
const defaultSetting = source.getDefaultOptions().settings.find(category => category.title === setting.title);
setting.values = defaultSetting.values;

this.searchSourceChange.emit(source);
}

/**
* Triggered when the default option is clicked in the specified source
* @internal
*/
checkMenuDefaultOptions(event, source: SearchSource) {
event.stopPropagation();
source.settings.map((setting, index) => {
setting.allEnabled = true;
this.checkUncheckAll(event, source, setting);

setting.values.map((value, settingsIndex) => {
value.enabled =
source.getDefaultOptions(true).settings[index].values[
settingsIndex
].enabled;
});
});
this.searchSourceChange.emit(source);
}

/**
* Triggered when a setting is checked (radiobutton style)
* @internal
Expand Down
2 changes: 1 addition & 1 deletion packages/geo/src/lib/search/shared/sources/cadastre.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export class CadastreSearchSource extends SearchSource implements TextSearch {
/*
* Source : https://wiki.openstreetmap.org/wiki/Key:amenity
*/
protected getDefaultOptions(): SearchSourceOptions {
getDefaultOptions(): SearchSourceOptions {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pourquoi enlever le protected?

return {
title: 'Cadastre (Québec)',
searchUrl: 'https://carto.cptaq.gouv.qc.ca/php/find_lot_v1.php?'
Expand Down
2 changes: 1 addition & 1 deletion packages/geo/src/lib/search/shared/sources/coordinates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export class CoordinatesReverseSearchSource
return CoordinatesReverseSearchSource.type;
}

protected getDefaultOptions(): SearchSourceOptions {
getDefaultOptions(): SearchSourceOptions {
return {
title: 'igo.geo.search.coordinates.name',
order: 1,
Expand Down
13 changes: 6 additions & 7 deletions packages/geo/src/lib/search/shared/sources/icherche.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,16 +115,15 @@ export class IChercheSearchSource extends SearchSource implements TextSearch {
return IChercheSearchSource.type;
}

protected getDefaultOptions(): SearchSourceOptions {
getDefaultOptions(forceReset?: Boolean): SearchSourceOptions {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Erreur de typage

const limit =
this.options.params && this.options.params.limit
? Number(this.options.params.limit)
!forceReset && this.options.params && this.options.params.limit
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pourquoi le forceReset, dans quel scénario on pourrait avoir des résultats par défaut qui sont différent?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

C'est pour le bouton qui remet tous les dépendances par défaut. Ce bouton n'a pas les settings dans son container. Sans le forceReset, les valeurs par défaut des radio button changeaient selon l'option sélectionnée.

? Number(this.options.params.limit)
: undefined;
const ecmax =
this.options.params && this.options.params.ecmax
!forceReset && this.options.params && this.options.params.ecmax
? Number(this.options.params.ecmax)
: undefined;

const types = this.options.params?.type
? this.options.params.type.replace(/\s/g, '').toLowerCase().split(',')
: [
Expand Down Expand Up @@ -715,9 +714,9 @@ export class IChercheReverseSearchSource
return IChercheReverseSearchSource.type;
}

protected getDefaultOptions(): SearchSourceOptions {
getDefaultOptions(forceReset?: Boolean): SearchSourceOptions {
const types =
this.options.params && this.options.params.type
!forceReset && this.options.params && this.options.params.type
? this.options.params.type.replace(/\s/g, '').toLowerCase().split(',')
: ['adresses', 'municipalites', 'mrc', 'regadmin'];

Expand Down
6 changes: 3 additions & 3 deletions packages/geo/src/lib/search/shared/sources/ilayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,13 @@ export class ILayerSearchSource extends SearchSource implements TextSearch {
return ILayerSearchSource.type;
}

protected getDefaultOptions(): ILayerSearchSourceOptions {
getDefaultOptions(forceReset?: Boolean): ILayerSearchSourceOptions {
const limit =
this.options.params && this.options.params.limit
!forceReset && this.options.params && this.options.params.limit
? Number(this.options.params.limit)
: undefined;
const ecmax =
this.options.params && this.options.params.ecmax
!forceReset && this.options.params && this.options.params.ecmax
? Number(this.options.params.ecmax)
: undefined;

Expand Down
2 changes: 1 addition & 1 deletion packages/geo/src/lib/search/shared/sources/nominatim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export class NominatimSearchSource extends SearchSource implements TextSearch {
/*
* Source : https://wiki.openstreetmap.org/wiki/Key:amenity
*/
protected getDefaultOptions(): SearchSourceOptions {
getDefaultOptions(): SearchSourceOptions {
return {
title: 'Nominatim (OSM)',
searchUrl: 'https://nominatim.openstreetmap.org/search',
Expand Down
2 changes: 1 addition & 1 deletion packages/geo/src/lib/search/shared/sources/source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export class SearchSource {
* Get search source's default options
* @returns Search source default options
*/
protected getDefaultOptions(): SearchSourceOptions {
getDefaultOptions(forceReset?: Boolean): SearchSourceOptions {
throw new Error('You have to implement the method "getDefaultOptions".');
}

Expand Down
4 changes: 2 additions & 2 deletions packages/geo/src/lib/search/shared/sources/storedqueries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ export class StoredQueriesSearchSource
return StoredQueriesSearchSource.type;
}

protected getDefaultOptions(): SearchSourceOptions {
getDefaultOptions(): SearchSourceOptions {
return {
title: 'Stored Queries',
searchUrl: 'https://ws.mapserver.transports.gouv.qc.ca/swtq'
Expand Down Expand Up @@ -451,7 +451,7 @@ export class StoredQueriesReverseSearchSource
return StoredQueriesReverseSearchSource.type;
}

protected getDefaultOptions(): SearchSourceOptions {
getDefaultOptions(): SearchSourceOptions {
return {
title: 'Stored Queries (reverse)',
searchUrl: 'https://ws.mapserver.transports.gouv.qc.ca/swtq'
Expand Down
2 changes: 1 addition & 1 deletion packages/geo/src/lib/search/shared/sources/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export class WorkspaceSearchSource extends SearchSource implements TextSearch {
return WorkspaceSearchSource.type;
}

protected getDefaultOptions(): SearchSourceOptions {
getDefaultOptions(): SearchSourceOptions {
const limit: Number = 5;

return {
Expand Down
1 change: 1 addition & 0 deletions packages/geo/src/locale/en.geo.json
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,7 @@
"searchSources": {
"selectAll": "Select All",
"unselectAll": "Unselect All",
"defaultSettings": "Default Settings",
"settings": {
"datasets": "Datasets",
"results type": "Results type",
Expand Down
1 change: 1 addition & 0 deletions packages/geo/src/locale/fr.geo.json
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,7 @@
"searchSources": {
"selectAll": "Tout sélectionner",
"unselectAll": "Tout désélectionner",
"defaultSettings": "Sélection par défaut",
"settings": {
"datasets": "Jeu de données",
"results type": "Type de résultat",
Expand Down
Loading