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);
}
}
}
-}
-
-
+}
\ No newline at end of file
// 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.
ccvmFilters: {[ccvmCode: string]: string[]};
facetFilters: FacetFilter[];
copyLocations: string[]; // ID's, but treated as strings in the UI.
+ isCourseFiltered:boolean;
// True when searching for metarecords
groupByMetarecord: boolean;
this.date2 = null;
this.dateOp = 'is';
this.fromMetarecord = null;
+ this.isCourseFiltered = false;
// Apply empty string values for each ccvm filter
this.ccvmFilters = {};
ctx.date2 = this.date2;
ctx.dateOp = this.dateOp;
ctx.fromMetarecord = this.fromMetarecord;
+ ctx.isCourseFiltered =this.isCourseFiltered;
ctx.facetFilters = this.facetFilters.map(f => f.clone());