lp1923057 Course Materials disassociate Rework user/khuckins/lp1923057-course-materials-disassociate-rework
authorKyle Huckins <khuckins@catalyte.io>
Sun, 13 Mar 2022 05:05:55 +0000 (05:05 +0000)
committerKyle Huckins <khuckins@catalyte.io>
Tue, 22 Mar 2022 19:33:19 +0000 (19:33 +0000)
- Adds a "Currently Associated" boolean and Removal time for course materials
- When disassociating a course material, the time will still show up in the admin grid for course materials, marked as not currently associated.

Signed-off-by: Kyle Huckins <khuckins@catalyte.io>
Open-ILS/examples/fm_IDL.xml
Open-ILS/src/eg2/src/app/staff/admin/local/course-reserves/course-associate-material.component.html
Open-ILS/src/perlmods/lib/OpenILS/Application/Courses.pm
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Course.pm
Open-ILS/src/sql/Pg/040.schema.asset.sql
Open-ILS/src/sql/Pg/upgrade/xxxx.schema.lp1923057-course-material-removal-time.sql [new file with mode: 0644]

index 6712059..43d5ef8 100644 (file)
@@ -3318,10 +3318,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
             <field reporter:label="Original Circ Modifier" name="original_circ_modifier" reporter:datatype="link" />
             <field reporter:label="Original Shelving Location" name="original_location" reporter:datatype="link" />
             <field reporter:label="Original Callnumber" name="original_callnumber" reporter:datatype="link" />
+            <field reporter:label="Associated?" name="is_active" reporter:datatype="bool" />
                        <field reporter:label="Creating User" name="creator" reporter:datatype="link"/>
                        <field reporter:label="Editing User" name="editor" reporter:datatype="link"/>
                        <field reporter:label="Create Time" name="create_time" reporter:datatype="timestamp"/>
                        <field reporter:label="Edit Time" name="edit_time" reporter:datatype="timestamp"/>
+                       <field reporter:label="Remove Time" name="removal_time" reporter:datatype="timestamp"/>
         </fields>
         <links>
             <link field="course" reltype="has_a" key="id" map="" class="acmc" />
index 4581028..a0b149c 100644 (file)
 
       <div class="mt-3" [ngClass]="isDialog() ? 'col-md-12' : 'col-md-8'">
         <eg-grid #materialsGrid [dataSource]="materialsDataSource" [useLocalSort]="true" [disablePaging]="true">
-          <eg-grid-toolbar-action label="Remove Selected" i18n-label (onClick)="deleteSelectedMaterials($event)">
+          <eg-grid-toolbar-action label="Disassociate Selected" i18n-label (onClick)="deleteSelectedMaterials($event)">
           </eg-grid-toolbar-action>
           <eg-grid-toolbar-action label="Edit Selected" i18n-label (onClick)="editSelectedMaterials($event)">
           </eg-grid-toolbar-action>
           <eg-grid-column path="original_location.name" [hidden]="true" label="Original Shelving Location" i18n-label></eg-grid-column>
           <eg-grid-column path="original_status.name" [hidden]="true" label="Original Item Status" i18n-label></eg-grid-column>
           <eg-grid-column path="relationship" label="Relationship" i18n-label></eg-grid-column>
+          <eg-grid-column path="is_active" label="Currently Associated?" datatype="bool" i18n-label></eg-grid-column>
           <eg-grid-column path="create_time" label="Create Time" [hidden]="true" datatype="timestamp" i18n-label></eg-grid-column>
           <eg-grid-column path="edit_time" label="Edit Time" [hidden]="true" datatype="timestamp" i18n-label></eg-grid-column>
+          <eg-grid-column path="removal_time" label="Removal Time" [hidden]="true" datatype="timestamp" i18n-label></eg-grid-column>
           <eg-grid-column path="creator" label="Creator" [hidden]="true" i18n-label></eg-grid-column>
           <eg-grid-column path="editor" label="Editor" [hidden]="true" i18n-label></eg-grid-column>
         </eg-grid>
index 6e7c752..f31e644 100644 (file)
@@ -10,6 +10,12 @@ use base qw/OpenILS::Application/;
 use OpenILS::Utils::CStoreEditor qw/:funcs/;
 use OpenILS::Utils::Fieldmapper;
 use OpenILS::Application::AppUtils;
+
+use DateTime;
+use DateTime::Format::ISO8601;
+
+use OpenILS::Utils::DateTime qw/:datetime/;
+
 my $U = "OpenILS::Application::AppUtils";
 
 use OpenSRF::Utils::Logger qw/$logger/;
@@ -244,9 +250,14 @@ sub detach_material {
     }
     if ($acmcm->item) {
         _resetItemFields($e, $authtoken, $acmcm);
-    } 
+    }
+
+    my $removal_time = OpenILS::Utils::DateTime->clean_ISO8601(DateTime->now);
+
+    $acmcm->removal_time($removal_time);
+    $acmcm->is_active('f');
 
-    $e->delete_asset_course_module_course_materials($acmcm) or return $e->die_event;
+    $e->update_asset_course_module_course_materials($acmcm) or return $e->die_event;
     $e->commit;
     return 1;
 }
@@ -265,7 +276,7 @@ sub _resetItemFields {
     if ($acmcm->original_location) {
         $acp->location($acmcm->original_location);
     }
-    $e->update_asset_copy($acmcm);
+    $e->update_asset_copy($acp);
     if ($acmcm->original_callnumber) {
         my $existing_acn = $e->retrieve_asset_call_number($acp->call_number);
         my $orig_acn = $e->retrieve_asset_call_number($acmcm->original_callnumber);
index 260221f..5caca93 100644 (file)
@@ -36,7 +36,7 @@ sub load_course {
     $ctx->{course_materials} = $U->simplereq(
         'open-ils.courses',
         'open-ils.courses.course_materials.retrieve.fleshed.atomic',
-        {course => $course_id}
+        {course => $course_id, is_active => 't'}
     );
     return Apache2::Const::OK;
 }
index 1b827bd..7601282 100644 (file)
@@ -1143,6 +1143,7 @@ CREATE TABLE asset.course_module_course_materials (
     original_status        INT REFERENCES config.copy_status,
     original_circ_modifier TEXT, --REFERENCES config.circ_modifier
     original_callnumber    INT REFERENCES asset.call_number,
+    is_active      BOOLEAN  NOT NULL DEFAULT true,
        creator        BIGINT   NOT NULL
                                REFERENCES actor.usr (id)
                                DEFERRABLE INITIALLY DEFERRED,
@@ -1151,6 +1152,7 @@ CREATE TABLE asset.course_module_course_materials (
                                DEFERRABLE INITIALLY DEFERRED,
        create_time    TIMESTAMP WITH TIME ZONE    DEFAULT NOW(),
        edit_time      TIMESTAMP WITH TIME ZONE    DEFAULT NOW();
+       removal_time      TIMESTAMP WITH TIME ZONE;
     unique (course, item, record)
 );
 
diff --git a/Open-ILS/src/sql/Pg/upgrade/xxxx.schema.lp1923057-course-material-removal-time.sql b/Open-ILS/src/sql/Pg/upgrade/xxxx.schema.lp1923057-course-material-removal-time.sql
new file mode 100644 (file)
index 0000000..c3a1ff8
--- /dev/null
@@ -0,0 +1,8 @@
+BEGIN;
+
+SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+ALTER TABLE asset.course_module_course_materials
+    ADD COLUMN is_active      BOOL NOT NULL DEFAULT true,
+       ADD COLUMN removal_time      TIMESTAMP WITH TIME ZONE;
+
+COMMIT;
\ No newline at end of file