mirror of
https://github.com/xuthus83/pigallery2.git
synced 2025-01-14 14:43:17 +08:00
Making random query builder to use search query builder
This commit is contained in:
parent
fc854f7295
commit
682c2e5c11
@ -32,19 +32,12 @@
|
||||
</div>
|
||||
<hr/>
|
||||
<form #searchPanelForm="ngForm" class="form-horizontal">
|
||||
<app-gallery-search-field [(ngModel)]="rawSearchText"
|
||||
(ngModelChange)="validateRawSearchText()"
|
||||
name="form-search-field">
|
||||
|
||||
</app-gallery-search-field>
|
||||
|
||||
<app-gallery-search-query-entry
|
||||
<app-gallery-search-query-builder
|
||||
id="album-search-query-builder"
|
||||
name="album-search-query-builder"
|
||||
[(ngModel)]="searchQueryDTO"
|
||||
(change)="onQueryChange()"
|
||||
name="search-root"
|
||||
(delete)="resetQuery()">
|
||||
|
||||
</app-gallery-search-query-entry>
|
||||
(change)="onQueryChange()" >
|
||||
</app-gallery-search-query-builder>
|
||||
|
||||
|
||||
</form>
|
||||
|
@ -20,8 +20,7 @@ import {SearchQueryParserService} from '../search/search-query-parser.service';
|
||||
})
|
||||
export class RandomQueryBuilderGalleryComponent implements OnInit, OnDestroy {
|
||||
|
||||
public searchQueryDTO: SearchQueryDTO;
|
||||
public rawSearchText: string;
|
||||
public searchQueryDTO: SearchQueryDTO = {type: SearchQueryTypes.any_text, text: ''} as TextSearch;
|
||||
enabled = true;
|
||||
url = '';
|
||||
|
||||
@ -37,7 +36,6 @@ export class RandomQueryBuilderGalleryComponent implements OnInit, OnDestroy {
|
||||
private searchQueryParserService: SearchQueryParserService,
|
||||
private route: ActivatedRoute,
|
||||
private modalService: BsModalService) {
|
||||
this.resetQuery();
|
||||
|
||||
this.subscription = this.route.params.subscribe((params: Params) => {
|
||||
if (!params[QueryParams.gallery.search.query]) {
|
||||
@ -55,17 +53,8 @@ export class RandomQueryBuilderGalleryComponent implements OnInit, OnDestroy {
|
||||
return JSON.stringify(this.searchQueryDTO);
|
||||
}
|
||||
|
||||
validateRawSearchText(): void {
|
||||
try {
|
||||
this.searchQueryDTO = this.searchQueryParserService.parse(this.rawSearchText);
|
||||
this.url = NetworkService.buildUrl(Config.Client.publicUrl + '/api/gallery/random/' + this.HTMLSearchQuery);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
onQueryChange(): void {
|
||||
this.rawSearchText = this.searchQueryParserService.stringify(this.searchQueryDTO);
|
||||
this.url = NetworkService.buildUrl(Config.Client.publicUrl + '/api/gallery/random/' + this.HTMLSearchQuery);
|
||||
}
|
||||
|
||||
@ -114,9 +103,4 @@ export class RandomQueryBuilderGalleryComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
|
||||
resetQuery(): void {
|
||||
this.searchQueryDTO = {text: '', type: SearchQueryTypes.any_text} as TextSearch;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -40,7 +40,6 @@
|
||||
name="search-query-builder"
|
||||
[(ngModel)]="searchQueryDTO"
|
||||
(change)="onQueryChange()"
|
||||
(ngModelChange)="onQueryChange()"
|
||||
(search)="Search()">
|
||||
</app-gallery-search-query-builder>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user