-
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(search): add Searchsource settings (#370)
* issue #349 * add setting nominatim * ajout de conf pour les services, stop propagation click, fix lint * ajout d'une distance pour la recherche * ajout traduction setting * typing and dusting * feat(geo.search) new compoenent search-settings * style(geo.search.search-selector) lint * style(geo.search.search-selector) moved to search-setting * style(geo.search) improve code
- Loading branch information
1 parent
5ff9239
commit 0a01898
Showing
19 changed files
with
549 additions
and
32 deletions.
There are no files selected for viewing
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
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
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
63 changes: 63 additions & 0 deletions
63
packages/geo/src/lib/search/search-settings/search-settings.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,63 @@ | ||
<div class="igo-search-settings"> | ||
|
||
<button | ||
mat-icon-button | ||
class="igo-search-settings-button" | ||
color="primary" | ||
tooltip-position="below" | ||
matTooltipShowDelay="500" | ||
[matTooltip]="'igo.geo.search.menu.tooltip' | translate" | ||
[matMenuTriggerFor]="searchSettingsMenu"> | ||
<mat-icon svgIcon="settings"></mat-icon> | ||
</button> | ||
<mat-menu | ||
#searchSettingsMenu="matMenu" | ||
class="no-border-radius"> | ||
<ng-container *ngFor="let source of getSearchSources()"> | ||
<button *ngIf="source.settings.length > 0" | ||
[matMenuTriggerFor]="sub_menu" | ||
mat-menu-item>{{source.title}} | ||
</button> | ||
<mat-menu #sub_menu="matMenu" | ||
xPosition="before" | ||
yPosition="above" | ||
> | ||
<ng-container *ngFor="let setting of source.settings"> | ||
<button | ||
mat-menu-item | ||
[matMenuTriggerFor]="test_sub_menu"> | ||
{{'igo.geo.search.searchSources.settings.'+ setting.title | translate}} | ||
</button> | ||
<mat-menu #test_sub_menu="matMenu" | ||
[ngSwitch]="setting.type" | ||
xPosition="before" | ||
yPosition="above"> | ||
<span *ngSwitchCase="'radiobutton'"> | ||
<mat-radio-group | ||
class="igo-search-settings-radio-group" | ||
[value]="setting"> | ||
<mat-radio-button *ngFor="let settingValue of setting.values" | ||
[value]="settingValue" | ||
[checked]="settingValue.enabled" | ||
(click)="$event.stopPropagation()" | ||
(change)="settingsValueCheckedRadioButton($event, source, setting, settingValue)"> | ||
{{settingValue.title}} | ||
</mat-radio-button> | ||
</mat-radio-group> | ||
</span> | ||
<span *ngSwitchCase="'checkbox'"> | ||
<mat-checkbox class="igo-search-settings-radio-group" | ||
class="mat-menu-item" | ||
[checked]="settingValue.enabled" | ||
[value]="setting" | ||
(click)="$event.stopPropagation()" | ||
(change)="settingsValueCheckedCheckbox($event, source, setting, settingValue)" | ||
*ngFor="let settingValue of setting.values">{{settingValue.title}} | ||
</mat-checkbox> | ||
</span> | ||
</mat-menu> | ||
</ng-container> | ||
</mat-menu> | ||
</ng-container> | ||
</mat-menu> | ||
</div> |
14 changes: 14 additions & 0 deletions
14
packages/geo/src/lib/search/search-settings/search-settings.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,14 @@ | ||
@import '../../../../../core/src/style/partial/core.variables'; | ||
|
||
.igo-search-settings-button ::ng-deep div.mat-button-ripple-round { | ||
border-radius: 0; | ||
} | ||
|
||
.igo-search-settings-radio-group { | ||
display: inline-flex; | ||
flex-direction: column; | ||
} | ||
|
||
.igo-search-settings-radio-group mat-radio-button { | ||
margin: $igo-margin; | ||
} |
25 changes: 25 additions & 0 deletions
25
packages/geo/src/lib/search/search-settings/search-settings.component.spec.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,25 @@ | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { SearchSettingsComponent } from './search-settings.component'; | ||
|
||
describe('SearchSettingsComponent', () => { | ||
let component: SearchSettingsComponent; | ||
let fixture: ComponentFixture<SearchSettingsComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ SearchSettingsComponent ] | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(SearchSettingsComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
81 changes: 81 additions & 0 deletions
81
packages/geo/src/lib/search/search-settings/search-settings.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,81 @@ | ||
import {MatCheckboxChange, MatRadioChange } from '@angular/material'; | ||
|
||
import { | ||
Component, | ||
Input, | ||
Output, | ||
EventEmitter, | ||
OnInit, | ||
ChangeDetectionStrategy | ||
} from '@angular/core'; | ||
|
||
import { SearchSourceService } from '../shared/search-source.service'; | ||
import { SearchSource } from '../shared/sources/source'; | ||
import { SearchSourceSettings, SettingOptions } from '../shared/sources/source.interfaces'; | ||
|
||
/** | ||
* This component allows a user to select a search type yo enable. In it's | ||
* current version, only one search type can be selected at once (radio). If | ||
* this component were to support more than one search source enabled (checkbox), | ||
* the searchbar component would require a small change to it's | ||
* placeholder getter. The search source service already supports having | ||
* more than one search source enabled. | ||
*/ | ||
@Component({ | ||
selector: 'igo-search-settings', | ||
templateUrl: './search-settings.component.html', | ||
styleUrls: ['./search-settings.component.scss'], | ||
changeDetection: ChangeDetectionStrategy.OnPush | ||
}) | ||
export class SearchSettingsComponent { | ||
|
||
/** | ||
* Event emitted when the enabled search type changes | ||
*/ | ||
@Output() change = new EventEmitter<string>(); | ||
|
||
constructor(private searchSourceService: SearchSourceService) {} | ||
|
||
/** | ||
* Get all search sources | ||
* @internal | ||
*/ | ||
getSearchSources(): SearchSource[] { | ||
return this.searchSourceService.getSources(); | ||
} | ||
|
||
/** | ||
* Triggered when a setting is checked (checkbox style) | ||
* @internal | ||
*/ | ||
settingsValueCheckedCheckbox( | ||
event: MatCheckboxChange, | ||
source: SearchSource, | ||
setting: SearchSourceSettings, | ||
settingValue: SettingOptions | ||
) { | ||
settingValue.enabled = event.checked; | ||
source.setParamFromSetting(setting); | ||
} | ||
|
||
/** | ||
* Triggered when a setting is checked (radiobutton style) | ||
* @internal | ||
*/ | ||
settingsValueCheckedRadioButton( | ||
event: MatRadioChange, | ||
source: SearchSource, | ||
setting: SearchSourceSettings, | ||
settingValue: SettingOptions | ||
) { | ||
setting.values.forEach( conf => { | ||
if (conf.value !== settingValue.value) { | ||
conf.enabled = !event.source.checked; | ||
} else { | ||
conf.enabled = event.source.checked; | ||
} | ||
}); | ||
source.setParamFromSetting(setting); | ||
} | ||
|
||
} |
35 changes: 35 additions & 0 deletions
35
packages/geo/src/lib/search/search-settings/search-settings.module.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,35 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { CommonModule } from '@angular/common'; | ||
import { SearchSettingsComponent } from './search-settings.component'; | ||
import { | ||
MatTooltipModule, | ||
MatIconModule, | ||
MatButtonModule, | ||
MatMenuModule, | ||
MatRadioModule, | ||
MatCheckboxModule | ||
} from '@angular/material'; | ||
|
||
import { IgoLanguageModule } from '@igo2/core'; | ||
|
||
import { IgoSearchSelectorModule } from '../search-selector/search-selector.module'; | ||
|
||
/** | ||
* @ignore | ||
*/ | ||
@NgModule({ | ||
declarations: [SearchSettingsComponent], | ||
imports: [ | ||
CommonModule, | ||
MatTooltipModule, | ||
MatIconModule, | ||
MatButtonModule, | ||
MatMenuModule, | ||
MatRadioModule, | ||
MatCheckboxModule, | ||
IgoSearchSelectorModule, | ||
IgoLanguageModule | ||
], | ||
exports: [SearchSettingsComponent] | ||
}) | ||
export class IgoSearchSettingsModule { } |
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.