Skip to content

Commit

Permalink
Making random query builder to use search query builder
Browse files Browse the repository at this point in the history
  • Loading branch information
bpatrik committed May 28, 2021
1 parent fc854f7 commit 682c2e5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,12 @@ <h5 class="modal-title" i18n>Random Link creator</h5>
</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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '';

Expand All @@ -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]) {
Expand All @@ -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);
}

Expand Down Expand Up @@ -114,9 +103,4 @@ export class RandomQueryBuilderGalleryComponent implements OnInit, OnDestroy {
}


resetQuery(): void {
this.searchQueryDTO = {text: '', type: SearchQueryTypes.any_text} as TextSearch;
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ <h5 class="modal-title" i18n>Search</h5>
name="search-query-builder"
[(ngModel)]="searchQueryDTO"
(change)="onQueryChange()"
(ngModelChange)="onQueryChange()"
(search)="Search()">
</app-gallery-search-query-builder>

Expand Down

0 comments on commit 682c2e5

Please sign in to comment.