From: Zavier Banks Date: Thu, 21 Nov 2019 22:54:46 +0000 (+0000) Subject: LP#1849212 Angular Search Course Material Facet X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=93bd1ccf2ccc64165275df75b3f3cb85c2783cbb;p=working%2FEvergreen.git LP#1849212 Angular Search Course Material Facet I added a course material facet that allows you to filter the records of a library, based on if they are associated with a course. Signed-off-by: Zavier Banks --- diff --git a/Open-ILS/src/eg2/src/app/share/catalog/catalog-url.service.ts b/Open-ILS/src/eg2/src/app/share/catalog/catalog-url.service.ts index 4c45a4e3c7..b4d0ad519b 100644 --- a/Open-ILS/src/eg2/src/app/share/catalog/catalog-url.service.ts +++ b/Open-ILS/src/eg2/src/app/share/catalog/catalog-url.service.ts @@ -82,7 +82,7 @@ export class CatalogUrlService { params.matchOp = []; ['format', 'available', 'hasBrowseEntry', 'date1', - 'date2', 'dateOp', 'groupByMetarecord', 'fromMetarecord'] + 'date2', 'dateOp', 'groupByMetarecord', 'fromMetarecord', 'isCourseFiltered'] .forEach(field => { if (ts[field]) { params[field] = ts[field]; @@ -223,6 +223,18 @@ export class CatalogUrlService { } }); + //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); @@ -245,6 +257,4 @@ export class CatalogUrlService { } } } -} - - +} \ No newline at end of file diff --git a/Open-ILS/src/eg2/src/app/share/catalog/catalog.service.ts b/Open-ILS/src/eg2/src/app/share/catalog/catalog.service.ts index 2aaaf1f3ae..8af653e23f 100644 --- a/Open-ILS/src/eg2/src/app/share/catalog/catalog.service.ts +++ b/Open-ILS/src/eg2/src/app/share/catalog/catalog.service.ts @@ -26,6 +26,7 @@ export class CatalogService { // Allow anyone to watch for completed searches. onSearchComplete: EventEmitter; + course_filtered_query: any; constructor( private idl: IdlService, @@ -37,12 +38,12 @@ export class CatalogService { private basket: BasketService ) { this.onSearchComplete = new EventEmitter(); - + this.retrieveCourseMaterials(); } search(ctx: CatalogSearchContext): Promise { ctx.searchState = CatalogSearchState.SEARCHING; - + if (ctx.showBasket) { return this.basketSearch(ctx); } else if (ctx.marcSearch.isSearchable()) { @@ -109,10 +110,8 @@ export class CatalogService { } termSearch(ctx: CatalogSearchContext): Promise { - let method = 'open-ils.search.biblio.multiclass.query'; let fullQuery; - if (ctx.identSearch.isSearchable()) { fullQuery = ctx.compileIdentSearchQuery(); @@ -128,13 +127,19 @@ export class CatalogService { 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 { return new Promise((resolve, reject) => { this.net.request( 'open-ils.search', method, { @@ -142,14 +147,34 @@ export class CatalogService { 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. diff --git a/Open-ILS/src/eg2/src/app/share/catalog/search-context.ts b/Open-ILS/src/eg2/src/app/share/catalog/search-context.ts index 041d710a4b..5f6c77011b 100644 --- a/Open-ILS/src/eg2/src/app/share/catalog/search-context.ts +++ b/Open-ILS/src/eg2/src/app/share/catalog/search-context.ts @@ -189,6 +189,7 @@ export class CatalogTermContext { 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; @@ -215,6 +216,7 @@ export class CatalogTermContext { this.date2 = null; this.dateOp = 'is'; this.fromMetarecord = null; + this.isCourseFiltered = false; // Apply empty string values for each ccvm filter this.ccvmFilters = {}; @@ -235,6 +237,7 @@ export class CatalogTermContext { ctx.date2 = this.date2; ctx.dateOp = this.dateOp; ctx.fromMetarecord = this.fromMetarecord; + ctx.isCourseFiltered =this.isCourseFiltered; ctx.facetFilters = this.facetFilters.map(f => f.clone()); diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/search-form.component.html b/Open-ILS/src/eg2/src/app/staff/catalog/search-form.component.html index d032f3d08f..a2ef565d6c 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/search-form.component.html +++ b/Open-ILS/src/eg2/src/app/staff/catalog/search-form.component.html @@ -123,6 +123,14 @@ TODO focus search input Results from All Libraries +
+ + + +