params.matchOp = [];
['format', 'available', 'hasBrowseEntry', 'date1',
- 'date2', 'dateOp', 'groupByMetarecord', 'fromMetarecord']
+ 'date2', 'dateOp', 'groupByMetarecord', 'fromMetarecord', 'isCourseFiltered']
.forEach(field => {
if (ts[field]) {
params[field] = ts[field];
}
});
+ //Booleans
+ ['isCourseFiltered'].forEach(field =>{
+ if(params.has(field)){
+ if(params.get(field) == "true" || params.get(field)){
+ ts[field] = true;
+ }
+ if(params.get(field) == "false" || !params.get(field)){
+ ts[field] = false;
+ }
+ }
+ });
+
// Arrays
['query', 'fieldClass', 'joinOp', 'matchOp'].forEach(field => {
const arr = params.getAll(field);
// Allow anyone to watch for completed searches.
onSearchComplete: EventEmitter<CatalogSearchContext>;
+ course_filtered_query: any;
constructor(
private idl: IdlService,
private basket: BasketService
) {
this.onSearchComplete = new EventEmitter<CatalogSearchContext>();
-
+ this.retrieveCourseMaterials();
}
search(ctx: CatalogSearchContext): Promise<void> {
ctx.searchState = CatalogSearchState.SEARCHING;
-
+
if (ctx.showBasket) {
return this.basketSearch(ctx);
} else if (ctx.marcSearch.isSearchable()) {
}
termSearch(ctx: CatalogSearchContext): Promise<void> {
-
let method = 'open-ils.search.biblio.multiclass.query';
let fullQuery;
-
if (ctx.identSearch.isSearchable()) {
fullQuery = ctx.compileIdentSearchQuery();
this.fetchBrowseEntry(ctx);
}
}
-
console.debug(`search query: ${fullQuery}`);
if (ctx.isStaff) {
method += '.staff';
}
+ if(ctx.termSearch.isCourseFiltered){
+ return this.netRequest(ctx, method, fullQuery + this.course_filtered_query +")");//Pass the course filter, combined with the full query
+ }else{
+ return this.netRequest(ctx, method, fullQuery);
+ }
+
+ }
+ netRequest(ctx, method, fullQuery): Promise<void> {
return new Promise((resolve, reject) => {
this.net.request(
'open-ils.search', method, {
offset : ctx.pager.offset
}, fullQuery, true
).subscribe(result => {
- this.applyResultData(ctx, result);
+ if(ctx.termSearch.isCourseFiltered){
+ this.applyResultData(ctx, result)
+ }
+ else{
+ this.applyResultData(ctx, result)
+ }
ctx.searchState = CatalogSearchState.COMPLETE;
this.onSearchComplete.emit(ctx);
resolve();
});
});
-
}
+
+ /**
+ * Retrieves course materials info, and adds the ids of the course books to a filter.
+ */
+ retrieveCourseMaterials(){
+ this.course_filtered_query = " (";
+ var index = 0;
+ this.pcrud.retrieveAll("acmcm").subscribe(result =>{
+ if(index==0){
+ this.course_filtered_query += '(id:'+ result.item()+')'
+ }
+ this.course_filtered_query += ' || (id:'+ result.item()+')'
+ index++;
+ });
+ }
+
// When showing titles linked to a browse entry, fetch
// the entry data as well so the UI can display it.
this.catUrl.applyUrlParams(this.searchContext, params);
if (this.searchContext.isSearchable()) {
-
this.cat.search(this.searchContext)
.then(ok => {
this.cat.fetchFacets(this.searchContext);
// To reduce page display shuffling, avoid showing the list of
// records until the first few are ready to render.
shouldStartRendering(): boolean {
-
if (this.searchHasResults()) {
const pageCount = this.searchContext.currentResultIds().length;
switch (pageCount) {
&& this.searchContext.result.records[1];
}
}
-
return false;
}