From e0b6729cf1c4ff67951717ae1dbdb371d6a27380 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 --- 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 +++++++++- Open-ILS/src/sql/Pg/040.schema.asset.sql | 14 +++++ .../XXXX.schema.course-materials-module.sql | 14 +++++ 7 files changed, 165 insertions(+), 22 deletions(-) diff --git a/Open-ILS/examples/fm_IDL.xml b/Open-ILS/examples/fm_IDL.xml index 5e36471b0a..e3c2969920 100644 --- a/Open-ILS/examples/fm_IDL.xml +++ b/Open-ILS/examples/fm_IDL.xml @@ -3059,11 +3059,13 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + + @@ -3138,6 +3140,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/sql/Pg/040.schema.asset.sql b/Open-ILS/src/sql/Pg/040.schema.asset.sql index bf515940e4..9d7444faf9 100644 --- a/Open-ILS/src/sql/Pg/040.schema.asset.sql +++ b/Open-ILS/src/sql/Pg/040.schema.asset.sql @@ -1136,6 +1136,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 +); + CREATE OR REPLACE FUNCTION asset.update_course_reserves_facet(old_bib_id BIGINT, new_bib_id BIGINT) RETURNS VOID AS $func$ DECLARE facet_field INT; 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 c8f4cff66c..e6be2a7081 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 ( 620, -- 2.11.0