-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(geo): save search results in layer (#1179)
* feat(geo): save search results in layer * create layer dialog * clean code * code cleaning back with collapsible component with first state * add feature ti layer btn and dialog * start create layer and add feature * edit layer * create layer and add new feature * save feature in layer * add translation and solve lint * solve lintt * solve comments * correct igo-search-layer * solve typo * add searchLayerStores to save new the storest and delete zIndex property from drowinglayer to solve zindex issue * solve lint error * typo * refactor(search-bar): allow queryable / switch to Feature * refactor(search-results-add-button): renamed const * fix/feat(search-results): fix translation/add feature properties --------- Co-authored-by: Philippe Lafreniere <[email protected]> Co-authored-by: Pierre-Étienne Lord <[email protected]>
- Loading branch information
1 parent
0a4f3f3
commit a0d727b
Showing
12 changed files
with
385 additions
and
11 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
packages/geo/src/lib/search/search-results/save-feature-dialog.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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<h1 mat-dialog-title class="mat-typography">{{'igo.geo.layer.saveFeatureInLayer' | translate}}</h1> | ||
|
||
<div mat-dialog-content class="mat-typography"> | ||
<form class="igo-form" [formGroup]="form"> | ||
<igo-list [navigation]="false" [selection]="false"> | ||
<igo-search-results-item | ||
igoListItem | ||
color="accent" | ||
[result]="feature" | ||
showIcons="true"> | ||
</igo-search-results-item> | ||
</igo-list> | ||
|
||
<div class="igo-input-container"> | ||
<mat-form-field> | ||
<input type="text" | ||
placeholder="{{'igo.geo.layer.chooseOrSet' | translate}}" | ||
matInput | ||
[matAutocomplete]="auto" | ||
formControlName="layerName"> | ||
<mat-autocomplete [displayWith]="displayFn" #auto="matAutocomplete"> | ||
<mat-option *ngFor="let layer of filteredLayers | async" [value]="layer"> | ||
<p mat-line>{{layer.title}}</p> | ||
</mat-option> | ||
</mat-autocomplete> | ||
</mat-form-field> | ||
</div> | ||
</form> | ||
</div> | ||
|
||
<div mat-dialog-actions style="justify-content: center"> | ||
<div class="igo-form-button-group create-layer-button-top-padding"> | ||
<button | ||
mat-raised-button | ||
type="button" | ||
(click)="cancel()"> | ||
{{'igo.geo.layer.cancelBtn' | translate}} | ||
</button> | ||
<button | ||
id="createLayerBtnDialog" | ||
mat-raised-button | ||
type="button" | ||
color="primary" | ||
(click)="save()"> | ||
{{'igo.geo.layer.saveBtn' | translate}} | ||
</button> | ||
</div> | ||
</div> |
30 changes: 30 additions & 0 deletions
30
packages/geo/src/lib/search/search-results/save-feature-dialog.component.scss
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
mat-form-field { | ||
width: 100%; | ||
} | ||
|
||
.create-layer-button-top-padding { | ||
padding-top: 25px; | ||
} | ||
|
||
.igo-form { | ||
padding: 10px 5px 5px; | ||
} | ||
|
||
.igo-form-button-group { | ||
text-align: center; | ||
} | ||
|
||
button { | ||
cursor: pointer; | ||
} | ||
|
||
button#createLayerBtnDialog[disabled=true] { | ||
cursor: default; | ||
background-color: rgba(0,0,0,.12); | ||
color: rgba(0,0,0,.26); | ||
} | ||
|
||
.error { | ||
color: red; | ||
} | ||
|
64 changes: 64 additions & 0 deletions
64
packages/geo/src/lib/search/search-results/save-feature-dialog.component.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 |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { LanguageService } from '@igo2/core'; | ||
import { Component, OnInit, Optional, Inject } from '@angular/core'; | ||
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; | ||
import { UntypedFormBuilder, UntypedFormGroup, Validators } from '@angular/forms'; | ||
import { Layer } from '../../layer'; | ||
import { SearchResult } from '../shared'; | ||
import { Observable } from 'rxjs'; | ||
import { map, startWith } from 'rxjs/operators'; | ||
|
||
@Component({ | ||
selector: 'igo-save-feature-dialog', | ||
templateUrl: './save-feature-dialog.component.html', | ||
styleUrls: ['./save-feature-dialog.component.scss'] | ||
}) | ||
export class SaveFeatureDialogComponent implements OnInit { | ||
|
||
public form: UntypedFormGroup; | ||
feature: SearchResult; | ||
layers: Layer[] = []; | ||
filteredLayers: Observable<Layer[]>; | ||
|
||
constructor( | ||
private formBuilder: UntypedFormBuilder, | ||
public languageService: LanguageService, | ||
public dialogRef: MatDialogRef<SaveFeatureDialogComponent>, | ||
@Optional() | ||
@Inject(MAT_DIALOG_DATA) | ||
public data: { feature: SearchResult; layers: Layer[]} | ||
) { | ||
this.form = this.formBuilder.group({ | ||
layerName: ['', [Validators.required]], | ||
}); | ||
} | ||
|
||
ngOnInit() { | ||
this.feature = this.data.feature; | ||
this.layers = this.data.layers; | ||
this.filteredLayers = this.form.controls['layerName'].valueChanges.pipe( | ||
startWith(''), | ||
map(val => this.filter(val)) | ||
); | ||
} | ||
|
||
private filter(val): Layer[] { | ||
if(typeof val !== 'string'){ | ||
return; | ||
} | ||
return this.layers.map(l => l).filter(layer => | ||
layer?.title?.toLowerCase().includes(val.toLowerCase())); | ||
} | ||
|
||
displayFn(layer: Layer): string { | ||
return layer && layer.title ? layer.title: ''; | ||
} | ||
|
||
save() { | ||
const data: {layer: string | Layer, feature: SearchResult} = {layer: this.form.value.layerName, feature: this.feature}; | ||
this.dialogRef.close(data); | ||
} | ||
|
||
cancel() { | ||
this.dialogRef.close(); | ||
} | ||
} |
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
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
Oops, something went wrong.