lp1849212 Display Associated Courses on Search Results
authorKyle Huckins <khuckins@catalyte.io>
Thu, 5 Dec 2019 19:17:27 +0000 (19:17 +0000)
committerJane Sandberg <sandbej@linnbenton.edu>
Sun, 19 Jul 2020 16:27:19 +0000 (09:27 -0700)
- Display associated courses on Search Results UI

Signed-off-by: Kyle Huckins <khuckins@catalyte.io>
 Changes to be committed:
modified:   Open-ILS/src/eg2/src/app/staff/catalog/result/record.component.html
modified:   Open-ILS/src/eg2/src/app/staff/catalog/result/record.component.ts

Open-ILS/src/eg2/src/app/staff/catalog/result/record.component.html
Open-ILS/src/eg2/src/app/staff/catalog/result/record.component.ts

index 65209a0..fa83758 100644 (file)
                     field="issn" joiner=","></eg-bib-display-field>
                 </div>
               </ng-container>
+              <ng-container *ngIf="has_course">
+                <div i18n>Associated Courses:
+                  {{courseNames.join(', ')}}</div>
+              </ng-container>
             </div>
           </div>
         </div>
index 8cb7f03..5e777d5 100644 (file)
@@ -10,6 +10,7 @@ import {CatalogSearchContext} from '@eg/share/catalog/search-context';
 import {CatalogUrlService} from '@eg/share/catalog/catalog-url.service';
 import {StaffCatalogService} from '../catalog.service';
 import {BasketService} from '@eg/share/catalog/basket.service';
+import {CourseService} from '@eg/staff/share/course.service';
 
 @Component({
   selector: 'eg-catalog-result-record',
@@ -29,6 +30,8 @@ export class ResultRecordComponent implements OnInit, OnDestroy {
     searchContext: CatalogSearchContext;
     isRecordSelected: boolean;
     basketSub: Subscription;
+    has_course: boolean;
+    courseNames: any[] = [];
 
     constructor(
         private router: Router,
@@ -38,12 +41,14 @@ export class ResultRecordComponent implements OnInit, OnDestroy {
         private cat: CatalogService,
         private catUrl: CatalogUrlService,
         private staffCat: StaffCatalogService,
-        private basket: BasketService
+        private basket: BasketService,
+        private course: CourseService
     ) {}
 
     ngOnInit() {
         this.searchContext = this.staffCat.searchContext;
         this.summary.getHoldCount();
+        this.loadCourseInformation(this.summary.id)
         this.isRecordSelected = this.basket.hasRecordId(this.summary.id);
 
         // Watch for basket changes caused by other components
@@ -56,6 +61,23 @@ export class ResultRecordComponent implements OnInit, OnDestroy {
         this.basketSub.unsubscribe();
     }
 
+    loadCourseInformation(recordId) {
+        console.log("Entering loadCourseInformation");
+        this.course.isOptedIn().then(res => {
+            if (res) {
+                this.course.fetchCopiesInCourseFromRecord(recordId).then(course_list => {
+                    Object.keys(course_list).forEach(key => {
+                        this.courseNames.push(course_list[key].name() +
+                          "(" + course_list[key].course_number() + ")");
+                    });
+                    this.has_course = true;
+                });
+            } else {
+                this.has_course = false;
+            }
+        });
+    }
+
     orgName(orgId: number): string {
         return this.org.get(orgId).shortname();
     }