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',
searchContext: CatalogSearchContext;
isRecordSelected: boolean;
basketSub: Subscription;
+ has_course: boolean;
+ courseNames: any[] = [];
constructor(
private router: Router,
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
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();
}