From eab293a7cf75338ab7fdbc91b7c1261826b1e860 Mon Sep 17 00:00:00 2001 From: Jane Sandberg Date: Sat, 15 Aug 2020 08:21:46 -0700 Subject: [PATCH] LP 1849212: Add course term functionality Signed-off-by: Jane Sandberg Signed-off-by: Michele Morgan Signed-off-by: Galen Charlton --- Open-ILS/examples/fm_IDL.xml | 52 ++++++++++++++++++ .../course-reserves/course-list.component.html | 61 +++++++++++++++------- .../local/course-reserves/course-list.component.ts | 7 +++ .../course-reserves/course-page.component.html | 11 ++++ .../local/course-reserves/course-page.component.ts | 28 +++++++++- .../course-reserves/course-reserves.module.ts | 2 + .../course-reserves/course-term-map.component.ts | 28 ++++++++++ .../src/app/staff/admin/local/routing.module.ts | 4 ++ Open-ILS/src/sql/Pg/040.schema.asset.sql | 14 +++++ .../XXXX.schema.course-materials-module.sql | 14 +++++ 10 files changed, 199 insertions(+), 22 deletions(-) create mode 100644 Open-ILS/src/eg2/src/app/staff/admin/local/course-reserves/course-term-map.component.ts diff --git a/Open-ILS/examples/fm_IDL.xml b/Open-ILS/examples/fm_IDL.xml index 87288f5b90..d5e7377ea8 100644 --- a/Open-ILS/examples/fm_IDL.xml +++ b/Open-ILS/examples/fm_IDL.xml @@ -3121,11 +3121,13 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + + @@ -3200,6 +3202,56 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Open-ILS/src/eg2/src/app/staff/admin/local/course-reserves/course-list.component.html b/Open-ILS/src/eg2/src/app/staff/admin/local/course-reserves/course-list.component.html index 54d0c7d420..e8e470ad9e 100644 --- a/Open-ILS/src/eg2/src/app/staff/admin/local/course-reserves/course-list.component.html +++ b/Open-ILS/src/eg2/src/app/staff/admin/local/course-reserves/course-list.component.html @@ -9,26 +9,41 @@ -
- - - - - - - - - - - - - - - -
+ +
+ + + + Terms taught + + diff --git a/Open-ILS/src/eg2/src/app/staff/admin/local/course-reserves/course-list.component.ts b/Open-ILS/src/eg2/src/app/staff/admin/local/course-reserves/course-list.component.ts index bc439a4018..8459935c2c 100644 --- a/Open-ILS/src/eg2/src/app/staff/admin/local/course-reserves/course-list.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/admin/local/course-reserves/course-list.component.ts @@ -46,6 +46,7 @@ export class CourseListComponent implements OnInit { currentMaterials: any[] = []; search_value = ''; + constructor( private courseSvc: CourseService, private locale: LocaleService, @@ -60,8 +61,14 @@ export class CourseListComponent implements OnInit { const idToEdit = course.id(); this.navigateToCoursePage(idToEdit); }); + } + acmtcmQueryParams (row: any): {gridFilters: string} { + return {gridFilters: '{"course":' + row.id() + '}'}; + } + + /** * Gets the data, specified by the class, that is available. */ diff --git a/Open-ILS/src/eg2/src/app/staff/admin/local/course-reserves/course-page.component.html b/Open-ILS/src/eg2/src/app/staff/admin/local/course-reserves/course-page.component.html index 39397d5792..9d57bc0fbf 100644 --- a/Open-ILS/src/eg2/src/app/staff/admin/local/course-reserves/course-page.component.html +++ b/Open-ILS/src/eg2/src/app/staff/admin/local/course-reserves/course-page.component.html @@ -61,6 +61,17 @@ + + +
  • + Course terms + + + + +
  • diff --git a/Open-ILS/src/eg2/src/app/staff/admin/local/course-reserves/course-page.component.ts b/Open-ILS/src/eg2/src/app/staff/admin/local/course-reserves/course-page.component.ts index df7a41a0b9..07d5cbf7fa 100644 --- a/Open-ILS/src/eg2/src/app/staff/admin/local/course-reserves/course-page.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/admin/local/course-reserves/course-page.component.ts @@ -1,12 +1,14 @@ -import {Component, Input, ViewChild, OnInit, TemplateRef} from '@angular/core'; +import {Component, ViewChild, OnInit} from '@angular/core'; import {ActivatedRoute} from '@angular/router'; import {PcrudService} from '@eg/core/pcrud.service'; import {IdlObject, IdlService} from '@eg/core/idl.service'; +import {GridDataSource} from '@eg/share/grid/grid'; import {StringComponent} from '@eg/share/string/string.component'; import {ToastService} from '@eg/share/toast/toast.service'; import {CourseService} from '@eg/staff/share/course.service'; import {CourseAssociateUsersComponent} from './course-associate-users.component'; import {CourseAssociateMaterialComponent} from './course-associate-material.component'; +import {Pager} from '@eg/share/util/pager'; @Component({ selector: 'eg-course-page', @@ -18,6 +20,7 @@ export class CoursePageComponent implements OnInit { currentCourse: IdlObject; courseId: any; + // Materials Tab @ViewChild('courseMaterialDialog', {static: true}) private courseMaterialDialog: CourseAssociateMaterialComponent; @ViewChild('courseUserDialog', {static: true}) @@ -29,10 +32,13 @@ export class CoursePageComponent implements OnInit { @ViewChild('archiveSuccessString', { static: true }) archiveSuccessString: StringComponent; - // Materials Tab + // Course Tab + termsDataSource: GridDataSource = new GridDataSource(); + defaultNewAcmtcm: IdlObject; constructor( private course: CourseService, + private idl: IdlService, private pcrud: PcrudService, private route: ActivatedRoute, private toast: ToastService @@ -44,6 +50,24 @@ export class CoursePageComponent implements OnInit { this.course.getCourses([this.courseId]).then(course => { this.currentCourse = course[0]; }); + + this.defaultNewAcmtcm = this.idl.create('acmtcm'); + this.defaultNewAcmtcm.course(this.courseId); + + this.termsDataSource.getRows = (pager: Pager, sort: any[]) => { + const orderBy: any = {}; + if (sort.length) { + orderBy.acmtcm = sort[0].name + ' ' + sort[0].dir; + } + const searchOps = { + offset: pager.offset, + limit: pager.limit, + order_by: orderBy + }; + + return this.pcrud.search('acmtcm', {course: this.courseId}, + searchOps, {fleshSelectors: true}); + }; } // Edit Tab diff --git a/Open-ILS/src/eg2/src/app/staff/admin/local/course-reserves/course-reserves.module.ts b/Open-ILS/src/eg2/src/app/staff/admin/local/course-reserves/course-reserves.module.ts index 96802cf7af..30c7651e78 100644 --- a/Open-ILS/src/eg2/src/app/staff/admin/local/course-reserves/course-reserves.module.ts +++ b/Open-ILS/src/eg2/src/app/staff/admin/local/course-reserves/course-reserves.module.ts @@ -9,6 +9,7 @@ import {CourseAssociateUsersComponent} from './course-associate-users.component' import {CourseReservesRoutingModule} from './routing.module'; import {ItemLocationSelectModule} from '@eg/share/item-location-select/item-location-select.module'; import {MarcSimplifiedEditorModule} from '@eg/staff/share/marc-edit/simplified-editor/simplified-editor.module'; +import {CourseTermMapComponent} from './course-term-map.component'; @NgModule({ declarations: [ @@ -16,6 +17,7 @@ import {MarcSimplifiedEditorModule} from '@eg/staff/share/marc-edit/simplified-e CoursePageComponent, CourseAssociateMaterialComponent, CourseAssociateUsersComponent, + CourseTermMapComponent ], imports: [ StaffCommonModule, diff --git a/Open-ILS/src/eg2/src/app/staff/admin/local/course-reserves/course-term-map.component.ts b/Open-ILS/src/eg2/src/app/staff/admin/local/course-reserves/course-term-map.component.ts new file mode 100644 index 0000000000..7fb460d4cb --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/admin/local/course-reserves/course-term-map.component.ts @@ -0,0 +1,28 @@ +import {Component} from '@angular/core'; + +/** + * Very basic page for editing course/term map + */ + +@Component({ + template: ` + + + + + + + ` +}) + +export class CourseTermMapComponent { + +} \ No newline at end of file diff --git a/Open-ILS/src/eg2/src/app/staff/admin/local/routing.module.ts b/Open-ILS/src/eg2/src/app/staff/admin/local/routing.module.ts index e0e5414537..69ba254071 100644 --- a/Open-ILS/src/eg2/src/app/staff/admin/local/routing.module.ts +++ b/Open-ILS/src/eg2/src/app/staff/admin/local/routing.module.ts @@ -5,6 +5,7 @@ import {BasicAdminPageComponent} from '@eg/staff/admin/basic-admin-page.componen import {AddressAlertComponent} from './address-alert.component'; import {AdminCarouselComponent} from './admin-carousel.component'; import {StandingPenaltyComponent} from './standing-penalty.component'; +import {CourseTermMapComponent} from './course-reserves/course-term-map.component'; const routes: Routes = [{ path: 'splash', @@ -23,6 +24,9 @@ const routes: Routes = [{ path: 'asset/course_list', loadChildren: '@eg/staff/admin/local/course-reserves/course-reserves.module#CourseReservesModule' }, { + path: 'asset/course_module_term_course_map', + component: CourseTermMapComponent +}, { path: 'config/standing_penalty', component: StandingPenaltyComponent }, { diff --git a/Open-ILS/src/sql/Pg/040.schema.asset.sql b/Open-ILS/src/sql/Pg/040.schema.asset.sql index 0207797284..04f6b90770 100644 --- a/Open-ILS/src/sql/Pg/040.schema.asset.sql +++ b/Open-ILS/src/sql/Pg/040.schema.asset.sql @@ -1136,5 +1136,19 @@ CREATE TABLE asset.course_module_course_materials ( unique (course, item, record) ); +CREATE TABLE asset.course_module_term ( + id SERIAL PRIMARY KEY, + name TEXT UNIQUE NOT NULL, + owning_lib INT REFERENCES actor.org_unit (id), + start_date TIMESTAMP WITH TIME ZONE, + end_date TIMESTAMP WITH TIME ZONE +); + +CREATE TABLE asset.course_module_term_course_map ( + id BIGSERIAL PRIMARY KEY, + term INT NOT NULL REFERENCES asset.course_module_term (id) ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED, + course INT NOT NULL REFERENCES asset.course_module_course (id) ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED +); + COMMIT; diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.course-materials-module.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.course-materials-module.sql index a1fc120b86..26dc6c706e 100644 --- a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.course-materials-module.sql +++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.course-materials-module.sql @@ -33,6 +33,20 @@ CREATE TABLE asset.course_module_course_materials ( unique (course, item, record) ); +CREATE TABLE asset.course_module_term ( + id SERIAL PRIMARY KEY, + name TEXT UNIQUE NOT NULL, + owning_lib INT REFERENCES actor.org_unit (id), + start_date TIMESTAMP WITH TIME ZONE, + end_date TIMESTAMP WITH TIME ZONE +); + +CREATE TABLE asset.course_module_term_course_map ( + id BIGSERIAL PRIMARY KEY, + term INT NOT NULL REFERENCES asset.course_module_term (id) ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED, + course INT NOT NULL REFERENCES asset.course_module_course (id) ON UPDATE CASCADE ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED +); + INSERT INTO permission.perm_list(id, code, description) VALUES ( 624, -- 2.11.0