-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
143 additions
and
40 deletions.
There are no files selected for viewing
48 changes: 33 additions & 15 deletions
48
...es/portal/panels/panels-handler/panels/search-results/search-results-panel.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,33 @@ | ||
<igo-search-results | ||
[store]="searchState.store" | ||
showIcons="true" | ||
[term]="searchState.searchTerm$ | async" | ||
placeholder="false" | ||
(searchTermChange)="onSearchTermChange($event)" | ||
(featureSelected)="close()" | ||
(resultFocus)="onResult(searchResultActions.Focus, $event)" | ||
(resultSelect)="onResult(searchResultActions.Select, $event)" | ||
(resultUnfocus)="onResult(searchResultActions.Unfocus, $event)" | ||
(resultMouseenter)="onResult(searchResultActions.Focus, $event)" | ||
(resultMouseleave)="onResult(searchResultActions.Unfocus, $event)" | ||
(moreResults)="onResult(searchResultActions.Search, $event)" | ||
> | ||
</igo-search-results> | ||
@if (searchState.store.empty$ | async) { | ||
<div style="margin: 20px"> | ||
<section> | ||
<h5> | ||
{{ 'igo.integration.searchResultsTool.noResults' | translate }} | ||
</h5> | ||
<h6> | ||
{{ 'igo.integration.searchResultsTool.doSearch' | translate }} | ||
</h6> | ||
<p | ||
[innerHTML]="'igo.integration.searchResultsTool.examples' | translate" | ||
></p> | ||
</section> | ||
</div> | ||
} | ||
<!-- todo necessaire mais je ne comprends pas pourquoi --> | ||
@if ((searchState.store.empty$ | async) === false) { | ||
<igo-search-results | ||
[map]="map" | ||
[store]="searchState.store" | ||
showIcons="true" | ||
[term]="searchState.searchTerm$ | async" | ||
placeholder="false" | ||
(searchTermChange)="onSearchTermChange($event)" | ||
(resultFocus)="onResult(searchResultActions.Focus, $event)" | ||
(resultSelect)="onResult(searchResultActions.Select, $event)" | ||
(resultUnfocus)="onResult(searchResultActions.Unfocus, $event)" | ||
(resultMouseenter)="onResult(searchResultActions.Focus, $event)" | ||
(resultMouseleave)="onResult(searchResultActions.Unfocus, $event)" | ||
(moreResults)="onMoreResults($event)" | ||
> | ||
</igo-search-results> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 69 additions & 10 deletions
79
...pp/pages/portal/panels/panels-handler/panels/search-results/search-results-panel.utils.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,71 @@ | ||
export function onResultFocus() { | ||
console.log('onResultFocus'); | ||
import { | ||
FEATURE, | ||
Feature, | ||
FeatureMotion, | ||
IgoMap, | ||
SearchResult, | ||
getCommonVectorSelectedStyle | ||
} from '@igo2/geo'; | ||
import { SearchState } from '@igo2/integration'; | ||
|
||
import olFeature from 'ol/Feature'; | ||
import type { default as OlGeometry } from 'ol/geom/Geometry'; | ||
|
||
export function onResultSelectOrFocus( | ||
result: SearchResult, | ||
map: IgoMap, | ||
searchState: SearchState, | ||
options?: { featureMotion?: FeatureMotion } | ||
) { | ||
if (result.meta.dataType === FEATURE && result.data.geometry) { | ||
result.data.meta.style = getCommonVectorSelectedStyle( | ||
Object.assign( | ||
{}, | ||
{ feature: result.data as Feature | olFeature<OlGeometry> }, | ||
searchState.searchOverlayStyleFocus, | ||
result.style?.focus ? result.style.focus : {} | ||
) | ||
); | ||
|
||
const feature = map.searchResultsOverlay.dataSource.ol.getFeatureById( | ||
result.meta.id | ||
); | ||
if (feature) { | ||
feature.setStyle(result.data.meta.style); | ||
return; | ||
} | ||
map.searchResultsOverlay.addFeature( | ||
result.data as Feature, | ||
options?.featureMotion | ||
); | ||
} | ||
} | ||
export function onResultSelect() { | ||
console.log('onResultSelect'); | ||
} | ||
export function onResultUnfocus() { | ||
console.log('onResultUnfocus'); | ||
} | ||
export function onSearch() { | ||
console.log('onSearch'); | ||
|
||
export function onResultUnfocus( | ||
result: SearchResult, | ||
map: IgoMap, | ||
searchState: SearchState | ||
) { | ||
if (result.meta.dataType !== FEATURE) { | ||
return; | ||
} | ||
|
||
if (searchState.store.state.get(result).selected) { | ||
const feature = map.searchResultsOverlay.dataSource.ol.getFeatureById( | ||
result.meta.id | ||
); | ||
if (feature) { | ||
const style = getCommonVectorSelectedStyle( | ||
Object.assign( | ||
{}, | ||
{ feature: result.data as Feature | olFeature<OlGeometry> }, | ||
searchState.searchOverlayStyleFocus, | ||
result.style?.focus ? result.style.focus : {} | ||
) | ||
); | ||
feature.setStyle(style); | ||
} | ||
return; | ||
} | ||
map.searchResultsOverlay.removeFeature(result.data as Feature); | ||
} |