From 6bcd7db69ffaca2bb5fa0c0b80f61f1072223d51 Mon Sep 17 00:00:00 2001 From: Jane Sandberg Date: Fri, 14 Aug 2020 16:55:02 -0700 Subject: [PATCH] LP1849212: display course information in catalog for record-only acmcm entries Signed-off-by: Jane Sandberg Signed-off-by: Michele Morgan Signed-off-by: Galen Charlton --- .../app/staff/catalog/result/record.component.html | 36 +++++++++++----------- .../app/staff/catalog/result/record.component.ts | 9 ++---- .../share/bib-summary/bib-summary.component.html | 8 ++--- .../share/bib-summary/bib-summary.component.ts | 12 +++----- .../src/eg2/src/app/staff/share/course.service.ts | 30 +++++++----------- .../perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm | 2 +- .../perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm | 2 +- 7 files changed, 43 insertions(+), 56 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/result/record.component.html b/Open-ILS/src/eg2/src/app/staff/catalog/result/record.component.html index 4600a35a55..602d768485 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/result/record.component.html +++ b/Open-ILS/src/eg2/src/app/staff/catalog/result/record.component.html @@ -42,14 +42,14 @@ - - @@ -59,7 +59,7 @@ @@ -81,14 +81,14 @@
-
Phys. Desc.: - Phys. Desc.: +
-
Edition: - Edition: +
@@ -101,31 +101,31 @@
-
Pub Date: +
Pub Date:
-
ISBN: - ISBN: +
-
UPC: - UPC: +
-
ISSN: - ISSN: +
- +
Associated Courses: @@ -139,7 +139,7 @@
-
@@ -169,7 +169,7 @@
Created {{summary.record.create_date() | date:'shortDate'}} by - {{summary.record.creator().usrname()}} @@ -182,7 +182,7 @@
Edited {{summary.record.edit_date() | date:'shortDate'}} by - {{summary.record.editor().usrname()}} diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/result/record.component.ts b/Open-ILS/src/eg2/src/app/staff/catalog/result/record.component.ts index fec6a9ee58..9f0f266735 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/result/record.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/catalog/result/record.component.ts @@ -30,7 +30,7 @@ export class ResultRecordComponent implements OnInit, OnDestroy { searchContext: CatalogSearchContext; isRecordSelected: boolean; basketSub: Subscription; - has_course: boolean; + hasCourse = false; courses: any[] = []; constructor( @@ -61,17 +61,14 @@ export class ResultRecordComponent implements OnInit, OnDestroy { } loadCourseInformation(recordId) { - console.log("Entering loadCourseInformation"); this.course.isOptedIn().then(res => { if (res) { - this.course.fetchCopiesInCourseFromRecord(recordId).then(course_list => { + this.course.fetchCoursesForRecord(recordId).then(course_list => { Object.keys(course_list).forEach(key => { this.courses.push(course_list[key]); }); - this.has_course = true; + this.hasCourse = true; }); - } else { - this.has_course = false; } }); } diff --git a/Open-ILS/src/eg2/src/app/staff/share/bib-summary/bib-summary.component.html b/Open-ILS/src/eg2/src/app/staff/share/bib-summary/bib-summary.component.html index a8e39532d3..16426c22ec 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/bib-summary/bib-summary.component.html +++ b/Open-ILS/src/eg2/src/app/staff/share/bib-summary/bib-summary.component.html @@ -15,12 +15,12 @@
- +
@@ -91,7 +91,7 @@
{{summary.record.edit_date() | date:'short'}}
- +
  • Associated Courses
    diff --git a/Open-ILS/src/eg2/src/app/staff/share/bib-summary/bib-summary.component.ts b/Open-ILS/src/eg2/src/app/staff/share/bib-summary/bib-summary.component.ts index a227c078a3..ec3ba57878 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/bib-summary/bib-summary.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/share/bib-summary/bib-summary.component.ts @@ -14,7 +14,7 @@ import {CatalogService} from '@eg/share/catalog/catalog.service'; export class BibSummaryComponent implements OnInit { initDone = false; - has_course = false; + hasCourse = false; courses: any; // True / false if the display is vertically expanded @@ -77,15 +77,13 @@ export class BibSummaryComponent implements OnInit { }); } - loadCourseInformation(record_id) { + loadCourseInformation(recordId) { this.org.settings('circ.course_materials_opt_in').then(setting => { if (setting['circ.course_materials_opt_in']) { - this.course.fetchCopiesInCourseFromRecord(record_id).then(course_list => { - this.courses = course_list; - this.has_course = true; + this.course.fetchCoursesForRecord(recordId).then(courseList => { + this.courses = courseList; + this.hasCourse = true; }); - } else { - this.has_course = false; } }); } diff --git a/Open-ILS/src/eg2/src/app/staff/share/course.service.ts b/Open-ILS/src/eg2/src/app/staff/share/course.service.ts index 2aa18b7823..2a81455a99 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/course.service.ts +++ b/Open-ILS/src/eg2/src/app/staff/share/course.service.ts @@ -1,4 +1,5 @@ -import { Observable } from 'rxjs'; +import {Observable} from 'rxjs'; +import {tap} from 'rxjs/operators'; import {Injectable} from '@angular/core'; import {AuthService} from '@eg/core/auth.service'; import {EventService} from '@eg/core/event.service'; @@ -82,24 +83,15 @@ export class CourseService { }); } - fetchCopiesInCourseFromRecord(record_id) { - const cp_list = []; - return new Promise((resolve, reject) => { - this.net.request( - 'open-ils.cat', - 'open-ils.cat.asset.copy_tree.global.retrieve', - this.auth.token(), record_id - ).subscribe(copy_tree => { - copy_tree.forEach(cn => { - cn.copies().forEach(cp => { - cp_list.push(cp.id()); - }); - }); - }, err => reject(err), - () => { - resolve(this.getCoursesFromMaterial(cp_list)); - }); - }); + fetchCoursesForRecord(recordId) { + const courseIds = []; + return this.pcrud.search( + 'acmcm', {record: recordId}, {atomic: false} + ).pipe(tap(material => { + if (courseIds.indexOf(material.course()) === -1) { + courseIds.push(material.course()); + } + })).toPromise().then(() => this.getCourses(courseIds)); } // Creating a new acmcm Entry diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm index 494ddedd6f..f5fada4808 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm @@ -119,7 +119,7 @@ sub load_record { if ($ctx->{course_module_opt_in}) { $copy->{course_materials} = $U->simplereq( 'open-ils.courses', - 'open-ils.courses.course_materials.retrieve', + 'open-ils.courses.course_materials.retrieve.atomic', {item => $copy->{id}} ); my %course_ids; diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm index adcff2ad9f..d0860bc24e 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm @@ -580,7 +580,7 @@ sub load_rresults { if ($course_module_opt_in) { $rec->{course_materials} = $U->simplereq( 'open-ils.courses', - 'open-ils.courses.course_materials.retrieve', + 'open-ils.courses.course_materials.retrieve.atomic', {record => $rec->{id}} ); my %course_ids; -- 2.11.0