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

Search #589

Merged
merged 4 commits into from
Mar 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
<mat-menu
#searchSettingsMenu="matMenu"
class="no-border-radius">
<div class="checkAllButton" *ngIf="getSearchSources().length>4">
<button mat-raised-button
(click)="checkUncheckAllSources($event)">{{!searchSourcesAllEnabled ? ('igo.geo.search.searchSources.unselectAll' | translate): ('igo.geo.search.searchSources.selectAll' | translate)}}</button>
</div>
<ng-container *ngFor="let source of getSearchSources()">
<span class="igo-search-settings-search-source">
<mat-checkbox
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import { MediaService } from '@igo2/core';
export class SearchSettingsComponent implements OnInit {

public hasPointerReverseSearchSource: boolean = false;
public searchSourcesAllEnabled: boolean = false;

public buffer = [];
public lastKeyTime = Date.now();
Expand Down Expand Up @@ -88,7 +89,9 @@ export class SearchSettingsComponent implements OnInit {
.getSources()
.filter(sourceCanReverseSearch)
.filter(s => s.available && s.getId() !== 'map' && s.showInSettings);
return textSearchSources.concat(reverseSearchSources);
const sources = textSearchSources.concat(reverseSearchSources);
this.computeSourcesCheckAllBehavior(sources);
return sources;
}

/**
Expand Down Expand Up @@ -119,12 +122,12 @@ export class SearchSettingsComponent implements OnInit {
}

/**
* Defining the action to do for check/uncheck checkboxes
* Defining the action to do for check/uncheck checkboxes (settings)
* return true if all checkbox must be checked
* return false if all checkbox must be unchecked
* @internal
*/
computeCheckAllBehavior(setting: SearchSourceSettings) {
computeSettingCheckAllBehavior(setting: SearchSourceSettings) {
if (setting.allEnabled === undefined) {
if (setting.values.find(settingValue => settingValue.enabled)) {
setting.allEnabled = false;
Expand All @@ -136,20 +139,44 @@ export class SearchSettingsComponent implements OnInit {
}
}

/**
* Defining the action to do for check/uncheck checkboxes (sources)
* return true if all checkbox must be checked
* return false if all checkbox must be unchecked
* @internal
*/
computeSourcesCheckAllBehavior(sources: SearchSource[]) {
const enabledSourcesCnt = sources.filter(source => source.enabled).length;
const disabledSourcesCnt = sources.filter(source => !source.enabled).length;
this.searchSourcesAllEnabled = enabledSourcesCnt >= disabledSourcesCnt ? false : true;
}

/**
* Triggered when the check all / uncheck all type is clicked,
* @internal
*/
checkUncheckAll(event, source: SearchSource, setting: SearchSourceSettings) {
event.stopPropagation();
this.computeCheckAllBehavior(setting);
this.computeSettingCheckAllBehavior(setting);
setting.values.forEach(settingValue => {
settingValue.enabled = setting.allEnabled;
});
source.setParamFromSetting(setting);
this.searchSourceChange.emit(source);
}

/**
* Triggered when the check all / uncheck all type is clicked,
* @internal
*/
checkUncheckAllSources(event) {
event.stopPropagation();
this.getSearchSources().map(source => {
source.enabled = this.searchSourcesAllEnabled;
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/ilayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class ILayerSearchResultFormatter {
constructor(private languageService: LanguageService) {}

formatResult(data: ILayerData): ILayerData {
const allowedKey = ['title', 'abstract', 'groupTitle', 'metadataUrl'];
const allowedKey = ['title', 'abstract', 'groupTitle', 'metadataUrl', 'downloadUrl', 'urlInfo', 'name'];

const property = Object.entries(data.properties)
.filter(([key]) => allowedKey.indexOf(key) !== -1)
Expand Down
7 changes: 6 additions & 1 deletion packages/geo/src/locale/en.geo.json
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,10 @@
"title": "Title",
"type": "Type",
"url": "URL",
"metadataUrl": "Metadata"
"metadataUrl": "Metadata",
"name": "Layer name",
"urlInfo": "URL - WMS/WFS",
"downloadUrl": "Data download"
},
"type": {
"layer": "Layer",
Expand Down Expand Up @@ -294,6 +297,8 @@
"tooltip": "Based on every search source, show the summary of the pointer location. Use F2 to activate/desactivate."
},
"searchSources": {
"selectAll": "Select All",
"unselectAll": "Unselect All",
"settings": {
"results type": "Results type",
"ecmax": "Maximum deviation",
Expand Down
7 changes: 6 additions & 1 deletion packages/geo/src/locale/fr.geo.json
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,10 @@
"title": "Titre",
"type": "Type",
"url": "URL",
"metadataUrl": "Métadonnées"
"metadataUrl": "Métadonnées",
"name": "Nom de la couche",
"urlInfo": "Lien du service web WMS/WFS",
"downloadUrl": "Lien de téléchargement de la données"
},
"type": {
"layer": "Couche",
Expand Down Expand Up @@ -294,6 +297,8 @@
"tooltip": "Afficher les coordonnées du curseur ainsi que d'autres informations sur sa position en fonction des types de résultats activées. Utiliser F2 pour activer / désactiver."
},
"searchSources": {
"selectAll": "Tout sélectionner",
"unselectAll": "Tout désélectionner",
"settings": {
"results type": "Type de résultat",
"ecmax": "Écart maximal",
Expand Down