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

Recherche ajout loupe #1183

Closed
wants to merge 24 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
2339991
fix(measure): fix measure state layer init
PhilippeLafreniere18 Oct 26, 2022
44ad966
fix(poi-button): fix css select placeholder
PhilippeLafreniere18 Oct 26, 2022
44702ee
find_first_element_onbutton_glass_keydownEnter
karengeo Feb 14, 2023
3dd2ade
Merge remote-tracking branch 'origin/next' into recherche-ajout-loupe
karengeo Mar 1, 2023
b00339e
corections_pull_1183
karengeo Mar 1, 2023
23b3bc9
remove unused output / take first element of all store
PhilippeLafreniere18 Mar 2, 2023
7d9baf0
last_changes_recherche_loupe
karengeo Mar 3, 2023
53c8e94
last_changes_recherche_loupe
karengeo Mar 3, 2023
0c00e1d
mis-a-jour-branche
karengeo Mar 21, 2023
ad3e96d
modif_choix_de_recherche
karengeo Mar 21, 2023
0b9a000
Merge remote-tracking branch 'origin/next' into recherche-ajout-loupe
karengeo Mar 22, 2023
f71ae28
Merge remote-tracking branch 'origin/next' into recherche-ajout-loupe
karengeo Apr 11, 2023
ba6aeb1
package-lock_mis_a_jour
karengeo Apr 11, 2023
009ec78
correction_of_research_of_firstElement
karengeo Apr 12, 2023
0d3f91c
package-lock_nouveau
karengeo Apr 12, 2023
8d3cb3a
package_from_next
karengeo Apr 12, 2023
12f41b8
Merge remote-tracking branch 'origin/next' into recherche-ajout-loupe
pelord May 5, 2023
3c586cf
Merge remote-tracking branch 'origin/next' into recherche-ajout-loupe
karengeo May 8, 2023
9a40db3
Merge remote-tracking branch 'origin/next' into recherche-ajout-loupe
karengeo May 11, 2023
808e512
Merge remote-tracking branch 'origin/minorFix' into recherche-ajout-l…
karengeo May 11, 2023
c74cd96
modification_to_the_fonction_selectFirstElement
karengeo May 11, 2023
6e4634a
Merge branch 'recherche-ajout-loupe' of https://github.com/infra-geo-…
karengeo May 11, 2023
4bcbb51
Merge remote-tracking branch 'origin/next' into recherche-ajout-loupe
karengeo May 11, 2023
81c5528
modif2_to_the_fonction_selectFirstElement
karengeo May 11, 2023
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
3 changes: 2 additions & 1 deletion demo/src/app/geo/search/search.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { MatCardModule } from '@angular/material/card';
import { MatIconModule } from '@angular/material/icon';
import { MatTooltipModule } from '@angular/material/tooltip';

import { IgoMessageModule } from '@igo2/core';
import { IgoMessageModule, IgoLanguageModule, } from '@igo2/core';

import {
IgoPanelModule,
Expand Down Expand Up @@ -49,6 +49,7 @@ import { AppSearchRoutingModule } from './search-routing.module';
IgoAppSearchModule,
IgoActionbarModule,
IgoContextMenuModule,
IgoLanguageModule,
IgoFeatureModule
],
exports: [AppSearchComponent],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
[disabled]="disabled$ | async"
[placeholder]="placeholder ? placeholder : (placeholder$ | async) ? (placeholder$.value | translate) : undefined"
[value]="term$ | async"
(keydown.enter)="selectFirstElement()"
(keyup)="onKeyup($event)"
(touchend)="onKeyup($event)">
</mat-form-field>
Expand All @@ -19,12 +20,14 @@
[color]="color"
(click)="onClearButtonClick()"
[matTooltip]="'igo.geo.search.clearSearch' | translate">
<mat-icon svgIcon="close"></mat-icon>
<mat-icon svgIcon="close"></mat-icon>
</button>

<button *ngIf="showSearchButton"
mat-icon-button
[color]="color">
[color]="color"
(click)="selectFirstElement()"
[matTooltip]="'igo.geo.search.search' | translate">
<mat-icon svgIcon="magnify"></mat-icon>
</button>

Expand Down
35 changes: 32 additions & 3 deletions packages/geo/src/lib/search/search-bar/search-bar.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export class SearchBarComponent implements OnInit, OnDestroy {
* whether to show search button or not
*/

public showSearchButton: boolean = false;
public showSearchButton: boolean = true;

/**
* List of available search types
Expand Down Expand Up @@ -178,7 +178,7 @@ export class SearchBarComponent implements OnInit, OnDestroy {
/**
* Debounce time between each keystroke
*/
@Input() debounce = 200;
@Input() debounce = 400;

/**
* Minimum term length required to trigger a research
Expand Down Expand Up @@ -275,7 +275,7 @@ export class SearchBarComponent implements OnInit, OnDestroy {
.subscribe((searchType: string) => this.onSetSearchType(searchType));

const configValue = this.configService.getConfig("searchBar.showSearchButton");
this.showSearchButton = configValue !== undefined ? configValue : false;
this.showSearchButton = configValue !== undefined ? configValue : true;
}

/**
Expand Down Expand Up @@ -476,4 +476,33 @@ export class SearchBarComponent implements OnInit, OnDestroy {
this.store.updateMany(newResults);
}
}

/**
* When the user clicks on the magnifying glass and
* this find the first object on the map otherwise the
* coordinate it will be the second option to be focused in the map
*/

selectFirstElement(){

//Find the max value of scores
const maxScore = Math.max(...this.store.all().map(result => result.meta.score));

//Filter values who have the maxScore
const result = this.store.all().find(result => result.meta.score === maxScore);
//If the value has not a first maxScore it has to take the title
const coordInv=this.store.all().find(result => result.meta.title);

//Function to reverse the value of the parameter
function reverseString(coordReInv) {
return coordReInv;
Copy link
Contributor

Choose a reason for hiding this comment

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

The function returns coordReInv which is what is provided to the function. Necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, because the changes on design tool makes a slight change to the coordinate order. For this reason, when a search was performed, it was not executed. By reversing the coordinate values IGO can clearly understand that they are coordinates and focus them properly as desired.

}
//Condition to evaluate if the result has a maxScore if not it is going to take the value of coordinate
if(result){
this.store.state.update(result,{focused:true,selected:true},true);
}else{
reverseString(coordInv);
Copy link
Contributor

@LAMM26 LAMM26 May 31, 2023

Choose a reason for hiding this comment

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

Necessary? See comment above

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, because when a coordinate search is performed we will not have a list of options with score , the value will be exact. For this reason, I proposed it this way, if there is any way to improve it, ideas are welcome

this.store.state.update(coordInv,{focused:true,selected:true},true);
}
}
}
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 @@ -446,6 +446,7 @@
"layer.placeholder": "Search for a layer",
"ichercheReverse.name": "Search by coordinates",
"clearSearch": "Clear search",
"search":"Search",
"addToLayer": "Add to layer",
"ilayer": {
"name": "Layers",
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 @@ -445,6 +445,7 @@
"layer.placeholder": "Rechercher une couche de données.",
"ichercheReverse.name": "Recherche par coordonnées",
"clearSearch": "Effacer la recherche",
"search": "Faire une recherche",
"addToLayer": "Ajouter à une couche",
"ilayer": {
"name": "Couches",
Expand Down