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

feat(geo): Show add results icon only when hovering over the result #1230

Merged
merged 2 commits into from
May 2, 2023
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 @@ -23,6 +23,7 @@
</button>

<button
[id]="(!isMobile) ? 'hide-save-search-result-btn' : ''"
igoStopPropagation
*ngIf="layer.meta.dataType === 'Feature' && saveSearchResultInLayer"
mat-icon-button
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#hide-save-search-result-btn {
display: none;
}

#show-save-search-result-btn {
display: block;
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import OlOverlay from 'ol/Overlay';
import { VectorSourceEvent as OlVectorSourceEvent } from 'ol/source/Vector';
import { default as OlGeometry } from 'ol/geom/Geometry';
import { QueryableDataSourceOptions } from '../../query';
import { Media, MediaService } from '@igo2/core';


@Component({
Expand Down Expand Up @@ -99,16 +100,26 @@ export class SearchResultAddButtonComponent implements OnInit, OnDestroy{
String(layer.id).includes('igo-search-layer')
);
}

private mediaService$$: Subscription;
public isMobile: boolean = false;
constructor(
private layerService: LayerService,
private dialog: MatDialog,
private dataSourceService: DataSourceService) {}
private dataSourceService: DataSourceService,
private mediaService: MediaService) {}

/**
* @internal
*/
ngOnInit(): void {
// check the view if is mobile or not
this.mediaService$$ = this.mediaService.media$.subscribe(
(media: Media) => {
if(media === Media.Mobile) {
this.isMobile = true;
}
}
);
if (this.layer.meta.dataType === 'Layer') {
this.added =
this.map.layers.findIndex(
Expand All @@ -127,6 +138,9 @@ export class SearchResultAddButtonComponent implements OnInit, OnDestroy{
ngOnDestroy() {
this.resolution$$.unsubscribe();
this.layers$$.unsubscribe();
if (this.mediaService$$) {
this.mediaService$$.unsubscribe();
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<mat-list-item>
<mat-list-item (mouseenter)="onMouseEvent($event)" (mouseleave)="onMouseEvent($event)">
<mat-icon *ngIf="icon" mat-list-avatar svgIcon="{{showIcons ? icon : 'blank'}}"></mat-icon>

<h4 matLine *ngIf="titleHtml" [innerHtml]="titleHtml" matTooltipShowDelay="500" [matTooltip]="tooltipHtml" matTooltipClass="search-result-tooltip"></h4>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,27 @@ export class SearchResultsItemComponent {
});
moveToOlFeatures(this.map, [olFeature], FeatureMotion.Default);
}

/**
* On mouse event, mouseenter /mouseleave
* @internal
*/
onMouseEvent(event) {
pelord marked this conversation as resolved.
Show resolved Hide resolved
const element = event.target;
const type = event.type;
switch (type) {
case 'mouseenter':
const hideBtn = element.querySelector('#hide-save-search-result-btn');
(hideBtn) ?
hideBtn.setAttribute('id', 'show-save-search-result-btn') : null;
break;
case 'mouseleave':
const showBtn = element.querySelector('#show-save-search-result-btn');
(showBtn) ?
showBtn.setAttribute('id', 'hide-save-search-result-btn') : null;
break;
default:
break;
}
}
}