clear search after query toggle

This commit is contained in:
Jason Wall 2020-08-06 16:47:04 -04:00
parent b1014aae7d
commit 32699e552f
6 changed files with 22 additions and 7 deletions

View File

@ -54,8 +54,6 @@ To get more help on the Angular CLI use `ng help` or go check out the [Angular C
- Custom Colors for Light/Dark modes - Custom Colors for Light/Dark modes
- Dark / Light / NightLight Mode - Dark / Light / NightLight Mode
- Sync Card across Devices - Sync Card across Devices
- Clear Search after Query
- Strongs as modal not implemented yet
- Merge saved pages lists when unlogged in -> login - Merge saved pages lists when unlogged in -> login
- Incorporate Jacob's Geo Work - Incorporate Jacob's Geo Work
- Android and IOS mobile apps with Ionic Capactor - Android and IOS mobile apps with Ionic Capactor

View File

@ -1,5 +1,12 @@
<mat-toolbar>Search Settings</mat-toolbar> <mat-toolbar>Search Settings</mat-toolbar>
<mat-nav-list> <mat-nav-list>
<mat-list-item>
<mat-slide-toggle
[checked]="this.displaySettings.clearSearchAfterQuery"
(change)="toggleClearSearchAfterQuery($event)"
>Clear Search Bar after Query</mat-slide-toggle
>
</mat-list-item>
<mat-list-item> <mat-list-item>
<mat-slide-toggle <mat-slide-toggle
[checked]="this.displaySettings.showStrongsAsModal" [checked]="this.displaySettings.showStrongsAsModal"
@ -14,7 +21,6 @@
>Append Results Below</mat-slide-toggle >Append Results Below</mat-slide-toggle
> >
</mat-list-item> </mat-list-item>
<mat-list-item> <mat-list-item>
<mat-slide-toggle <mat-slide-toggle
[checked]="this.displaySettings.insertCardNextToItem" [checked]="this.displaySettings.insertCardNextToItem"
@ -33,7 +39,6 @@
>Show Paragraphs</mat-slide-toggle >Show Paragraphs</mat-slide-toggle
> >
</mat-list-item> </mat-list-item>
<mat-list-item> <mat-list-item>
<mat-slide-toggle <mat-slide-toggle
[checked]="this.displaySettings.showParagraphHeadings" [checked]="this.displaySettings.showParagraphHeadings"
@ -41,7 +46,6 @@
>Show Paragraph Headings</mat-slide-toggle >Show Paragraph Headings</mat-slide-toggle
> >
</mat-list-item> </mat-list-item>
<mat-list-item> <mat-list-item>
<mat-slide-toggle <mat-slide-toggle
[checked]="this.displaySettings.showVerseNumbers" [checked]="this.displaySettings.showVerseNumbers"
@ -49,7 +53,6 @@
>Show Verse Numbers</mat-slide-toggle >Show Verse Numbers</mat-slide-toggle
> >
</mat-list-item> </mat-list-item>
<mat-list-item> <mat-list-item>
<mat-slide-toggle <mat-slide-toggle
[checked]="this.displaySettings.showVersesOnNewLine" [checked]="this.displaySettings.showVersesOnNewLine"

View File

@ -44,6 +44,12 @@ export class SettingsComponent extends SubscriberComponent {
}); });
} }
toggleClearSearchAfterQuery(toggle: MatSlideToggleChange) {
this.appService.updateDisplaySettings({
...this.displaySettings,
clearSearchAfterQuery: toggle.checked,
});
}
//#endregion //#endregion
//#region Passage Settings //#region Passage Settings

View File

@ -31,6 +31,7 @@ export interface DisplaySettings {
readonly showStrongsAsModal: boolean; readonly showStrongsAsModal: boolean;
readonly appendCardToBottom: boolean; readonly appendCardToBottom: boolean;
readonly insertCardNextToItem: boolean; readonly insertCardNextToItem: boolean;
readonly clearSearchAfterQuery: boolean;
readonly fontSize: number; readonly fontSize: number;
readonly fontFamily: string; readonly fontFamily: string;

View File

@ -24,6 +24,7 @@ export class SearchPage extends SubscriberComponent implements OnInit {
suggestions$ = this.appService.select((state) => state.autocomplete); suggestions$ = this.appService.select((state) => state.autocomplete);
savedPagedLoaded = false; savedPagedLoaded = false;
clearSearchAfterQuery = true;
searchControl = new FormControl(); searchControl = new FormControl();
@ -45,6 +46,8 @@ export class SearchPage extends SubscriberComponent implements OnInit {
this.addSubscription( this.addSubscription(
this.appService.state$.subscribe((state) => { this.appService.state$.subscribe((state) => {
this.savedPagedLoaded = state.savedPagesLoaded; this.savedPagedLoaded = state.savedPagesLoaded;
this.clearSearchAfterQuery =
state.displaySettings.clearSearchAfterQuery;
}) })
); );
} }
@ -108,7 +111,10 @@ export class SearchPage extends SubscriberComponent implements OnInit {
async search(search: string) { async search(search: string) {
// clear search box. // clear search box.
this.searchControl.setValue(''); if (this.clearSearchAfterQuery) {
this.searchControl.setValue('');
}
if (this.autoCompleteTrigger) { if (this.autoCompleteTrigger) {
this.autoCompleteTrigger.closePanel(); this.autoCompleteTrigger.closePanel();
} }

View File

@ -56,6 +56,7 @@ const initialState: AppState = {
showStrongsAsModal: false, showStrongsAsModal: false,
appendCardToBottom: true, appendCardToBottom: true,
insertCardNextToItem: true, insertCardNextToItem: true,
clearSearchAfterQuery: true,
fontSize: 12, fontSize: 12,
fontFamily: 'PT Serif', fontFamily: 'PT Serif',
showVersesOnNewLine: false, showVersesOnNewLine: false,