* router.navigate(..., {queryParams:...}).
* No navigation is performed within.
*/
- toUrl(): any {
- let query = {};
+ toUrlParams(): any {
+ let query = {query : ['piano']}; // TODO
return query;
}
* Absorbs URL values from the active route and applies them to
* this search context instance.
*/
- fromUrl(params: Params): void {
- //queryParamMap
+ fromUrlParams(params: Params): void {
+ console.log('checking params with query ' + params.query);
}
}
<!-- search form sits atop every catalog page -->
<eg-catalog-search-form></eg-catalog-search-form>
+<!-- search results, record details, etc. -->
<router-outlet></router-outlet>
import {Component, OnInit} from '@angular/core';
import {Observable} from 'rxjs/Rx';
import {ActivatedRoute} from '@angular/router';
+import {EgCatalogService} from '@eg/share/catalog/catalog.service';
+import {CatalogSearchContext} from '@eg/share/catalog/search-context';
@Component({
templateUrl: 'catalog.component.html'
})
export class EgCatalogComponent implements OnInit {
- constructor(private route: ActivatedRoute) {}
+ searchContext: CatalogSearchContext;
+
+ constructor(
+ private route: ActivatedRoute,
+ private cat: EgCatalogService
+ ) {}
ngOnInit() {
+
+ // TODO: MOVE THIS OUT OF THE CAT SERVICE
+ // and pass it down to each child component that needs
+ // it via @Input.
+ this.searchContext = this.cat.searchContext;
+
+ // Sync the context with the load-time URL params.
+ this.searchContext.fromUrlParams(this.route.snapshot.queryParams);
}
}
import {Component, OnInit, Input} from '@angular/core';
+import {ActivatedRoute} from '@angular/router';
import {EgCatalogService} from '@eg/share/catalog/catalog.service';
import {CatalogSearchContext} from '@eg/share/catalog/search-context';
+import {EgOrgService} from '@eg/core/org';
+
@Component({
selector: 'eg-catalog-results',
styleUrls: ['results.component.css'],
searchContext: CatalogSearchContext;
constructor(
+ private org: EgOrgService,
private cat: EgCatalogService
) {}
ngOnInit() {
this.searchContext = this.cat.searchContext;
+ this.searchByUrl();
+ }
+
+ searchByUrl(): void {
+ // skip searching when there's no query, etc.
+
+ this.searchContext.searchOrg = this.org.get(4); // TODO: testing
+
+ if (!this.searchContext.query[0]) return;
+
+ this.cat.search(this.searchContext).then(ok => {
+ console.debug('search complete');
+ });
+
}
}
import {Component, OnInit} from '@angular/core';
-import {ActivatedRoute} from '@angular/router';
+import {Router, ActivatedRoute} from '@angular/router';
import {EgIdlObject} from '@eg/core/idl';
import {EgOrgService} from '@eg/core/org';
import {EgCatalogService} from '@eg/share/catalog/catalog.service';
showAdvancedSearch: boolean = false;
constructor(
+ private router: Router,
private route: ActivatedRoute,
private org: EgOrgService,
private cat: EgCatalogService
this.ccvmMap = this.cat.ccvmMap;
this.cmfMap = this.cat.cmfMap;
this.searchContext = this.cat.searchContext;
-
- // Sync the context with the load-time URL params and launch
- // a new search if necessary.
- this.searchContext.fromUrl(this.route.snapshot.queryParams);
- this.searchByUrl();
}
addSearchRow(index: number): void {
return index;
}
+ /**
+ * Redirect to the search results page while propagating the current
+ * search paramters into the URL. Let the search results component
+ * execute the actual search.
+ */
searchByForm(): void {
this.searchContext.searchOrg = this.org.get(4); // TODO: TEST BR1
- this.cat.search(this.searchContext).then(ok => {
- console.debug('search complete');
- });
- }
-
- searchByUrl(): void {
+ this.router.navigate(
+ ['/staff/catalog/search'],
+ {queryParams: this.searchContext.toUrlParams()}
+ )
}
}