lp1849212: Archive Courses
authorKyle Huckins <khuckins@catalyte.io>
Wed, 20 Nov 2019 22:30:06 +0000 (22:30 +0000)
committerGalen Charlton <gmc@equinoxinitiative.org>
Mon, 14 Sep 2020 22:16:22 +0000 (18:16 -0400)
- Implement functionality to archive a course via the
admin course reserves list UI.
- Disassociate all items from a course and reinstate
their original fields if temporary fields were applied,
upon course archival.

Signed-off-by: Kyle Huckins <khuckins@catalyte.io>
Signed-off-by: Jane Sandberg <sandbej@linnbenton.edu>

 Changes to be committed:
modified:   Open-ILS/examples/fm_IDL.xml
modified:   Open-ILS/src/eg2/src/app/staff/admin/server/course-reserves/course-list.component.html
modified:   Open-ILS/src/eg2/src/app/staff/admin/server/course-reserves/course-list.component.ts
modified:   Open-ILS/src/sql/Pg/040.schema.asset.sql
modified:   Open-ILS/src/sql/Pg/upgrade/XXXX.schema.course-materials-module.sql

Signed-off-by: Michele Morgan <mmorgan@noblenet.org>
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>

Open-ILS/examples/fm_IDL.xml
Open-ILS/src/eg2/src/app/staff/admin/server/course-reserves/course-list.component.html
Open-ILS/src/eg2/src/app/staff/admin/server/course-reserves/course-list.component.ts
Open-ILS/src/sql/Pg/040.schema.asset.sql
Open-ILS/src/sql/Pg/upgrade/XXXX.schema.course-materials-module.sql

index 4e678b4..3bd715d 100644 (file)
@@ -3121,6 +3121,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
             <field reporter:label="Course Members" name="members" oils_persist:virtual="true" reporter:datatype="link" />
             <field reporter:label="Course Materials" name="materials" oils_persist:virtual="true" reporter:datatype="link" />
             <field reporter:label="Non-Cataloged Course Materials" name="non_cat_materials" oils_persist:virtual="true" reporter:datatype="link" />
+            <field reporter:label="Is Archived?" name="is_archived" reporter:datatype="boolean" />
         </fields>
         <links>
             <link field="owning_lib" reltype="has_a" key="id" map="" class="aou" />
index eb01af8..d31f440 100644 (file)
@@ -4,7 +4,9 @@
 <eg-string #successString i18n-text text="{{table_name}} Update Succeeded"></eg-string>
 <eg-string #createString i18n-text text="{{table_name}} Was Created Successfully"></eg-string>
 <eg-string #deleteFailedString i18n-text text="Delete of {{table_name}} failed or was not allowed"></eg-string>
-<eg-string #deleteSuccessString i18n-text text="Delete of {{table_name}} succeeded"></eg-string>
+<eg-string #deleteSucailedString i18n-text text="Delete of {{table_name}} failed or was not allowed"></eg-string>
+<eg-string #archiveFailedString i18n-text text="Archival of {{table_name}} failed or was not allowed"></eg-string>
+<eg-string #archiveSuccessString i18n-text text="Archival of {{table_name}} succeeded"></eg-string>
 <eg-string #flairTooltip i18n-text text="Limited Editing"></eg-string>
 
 <eg-course-associate-material-dialog #courseMaterialDialog>
     </eg-grid-toolbar-action>
     <eg-grid-toolbar-action label="Delete Selected" i18n-label (onClick)="deleteSelected($event)">
     </eg-grid-toolbar-action>
+    <eg-grid-toolbar-action label="Archive Selected" i18n-label (onClick)="archiveSelected($event)">
+    </eg-grid-toolbar-action>
   </eg-grid>
 </div>
 
 <eg-fm-record-editor #editDialog
   idlClass={{idl_class}}
-  [preloadLinkedValues]="true">
+  [preloadLinkedValues]="true"
+  hiddenFields="is_archived,id">
 </eg-fm-record-editor>
index ea5dc2f..ab9cd3b 100644 (file)
@@ -29,6 +29,8 @@ export class CourseListComponent implements OnInit {
     @ViewChild('updateFailedString', { static: false }) updateFailedString: StringComponent;
     @ViewChild('deleteFailedString', { static: true }) deleteFailedString: StringComponent;
     @ViewChild('deleteSuccessString', { static: true }) deleteSuccessString: StringComponent;
+    @ViewChild('archiveFailedString', { static: true }) archiveFailedString: StringComponent;
+    @ViewChild('archiveSuccessString', { static: true }) archiveSuccessString: StringComponent;
     @ViewChild('courseMaterialDialog', {static: true})
         private courseMaterialDialog: CourseAssociateMaterialComponent;
     @Input() sort_field: string;
@@ -123,9 +125,29 @@ export class CourseListComponent implements OnInit {
         editOneThing(fields.shift());
     }
 
+    archiveSelected(course: IdlObject[]) {
+        this.courseSvc.disassociateMaterials(course).then(res => {
+            course.forEach(course => {
+                console.log(course);
+                course.is_archived(true);
+            });
+            this.pcrud.update(course).subscribe(
+                val => {
+                    console.debug('archived: ' + val);
+                    this.archiveSuccessString.current()
+                        .then(str => this.toast.success(str));
+                }, err => {
+                    this.archiveFailedString.current()
+                        .then(str => this.toast.danger(str));
+                }, () => {
+                    this.grid.reload();
+                }
+            );
+        });
+    }
+
     deleteSelected(idl_object: IdlObject[]) {
         this.courseSvc.disassociateMaterials(idl_object).then(res => {
-            console.log(res);
             idl_object.forEach(idl_object => {
                 idl_object.isdeleted(true)
             });
index 2091a69..262a689 100644 (file)
@@ -1110,7 +1110,8 @@ CREATE TABLE asset.course_module_course (
     name            TEXT NOT NULL,
     course_number   TEXT NOT NULL,
     section_number  TEXT,
-    owning_lib      INT REFERENCES actor.org_unit (id)
+    owning_lib      INT REFERENCES actor.org_unit (id),
+    is_archived        BOOLEAN DEFAULT false
 );
 
 CREATE TABLE asset.course_module_course_users (
index 8f813f2..eb4807e 100644 (file)
@@ -7,7 +7,8 @@ CREATE TABLE asset.course_module_course (
     name            TEXT NOT NULL,
     course_number   TEXT NOT NULL,
     section_number  TEXT,
-    owning_lib      INT REFERENCES actor.org_unit (id)
+    owning_lib      INT REFERENCES actor.org_unit (id),
+    is_archived        BOOLEAN NOT NULL DEFAULT false;
 );
 
 CREATE TABLE asset.course_module_course_users (