lp1939994 Course Details Page Archive Workaround
authorKyle Huckins <khuckins@catalyte.io>
Tue, 15 Mar 2022 03:10:25 +0000 (03:10 +0000)
committerJane Sandberg <sandbergja@gmail.com>
Mon, 5 Sep 2022 16:39:26 +0000 (09:39 -0700)
- Course Page stores is_archived() locally, checking for either the current course being archived, or the locally stored variable.

Signed-off-by: Kyle Huckins <khuckins@catalyte.io>

 Changes to be committed:
modified:   Open-ILS/src/eg2/src/app/staff/admin/local/course-reserves/course-associate-material.component.html
modified:   Open-ILS/src/eg2/src/app/staff/admin/local/course-reserves/course-associate-material.component.ts
modified:   Open-ILS/src/eg2/src/app/staff/admin/local/course-reserves/course-associate-users.component.html
modified:   Open-ILS/src/eg2/src/app/staff/admin/local/course-reserves/course-associate-users.component.ts
modified:   Open-ILS/src/eg2/src/app/staff/admin/local/course-reserves/course-page.component.html
modified:   Open-ILS/src/eg2/src/app/staff/admin/local/course-reserves/course-page.component.ts

Signed-off-by: Jane Sandberg <sandbergja@gmail.com>

Open-ILS/src/eg2/src/app/staff/admin/local/course-reserves/course-associate-material.component.html
Open-ILS/src/eg2/src/app/staff/admin/local/course-reserves/course-associate-material.component.ts
Open-ILS/src/eg2/src/app/staff/admin/local/course-reserves/course-associate-users.component.html
Open-ILS/src/eg2/src/app/staff/admin/local/course-reserves/course-associate-users.component.ts
Open-ILS/src/eg2/src/app/staff/admin/local/course-reserves/course-page.component.html
Open-ILS/src/eg2/src/app/staff/admin/local/course-reserves/course-page.component.ts

index aec9838..94f12ee 100644 (file)
@@ -32,7 +32,7 @@
                     </div>
                     <input type="text" class="flex-grow-1" id="associate-item-barcode"
                       [(ngModel)]="barcodeInput" (click)="$event.target.select()"
-                      [disabled]="currentCourse && currentCourse.is_archived() == 't'"
+                      [disabled]="currentCourse && (courseIsArchived || currentCourse.is_archived()) == 't'"
                       (keyup.enter)="associateItem(barcodeInput, relationshipInput)" />
                   </div>
                 </div>
@@ -42,7 +42,7 @@
                       <span class="input-group-text" i18n>Relationship</span>
                     </div>
                     <input type="text" [(ngModel)]="relationshipInput"
-                      [disabled]="currentCourse && currentCourse.is_archived() == 't'" placeholder-i18n
+                      [disabled]="currentCourse && (courseIsArchived || currentCourse.is_archived()) == 't'" placeholder-i18n
                       placeholder="e.g. Required" class="flex-grow-1" />
                   </div>
                 </div>
                       </div>
                     </div>
                     <input type="text" [(ngModel)]="tempCallNumber" label="associate-item-temp-call-number"
-                      [disabled]="currentCourse && currentCourse.is_archived() == 't'"
+                      [disabled]="currentCourse && (courseIsArchived || currentCourse.is_archived()) == 't'"
                       (input)="isModifyingCallNumber = true" class="flex-grow-1" />
                     <div class="input-group-append">
                       <div class="input-group-text">
                         <input type="checkbox" [(ngModel)]="isModifyingCallNumber"
-                          [disabled]="currentCourse && currentCourse.is_archived() == 't'"
+                          [disabled]="currentCourse && (courseIsArchived || currentCourse.is_archived()) == 't'"
                           aria-label="Checkbox for setting a temporary Call Number" />
                       </div>
                     </div>
                       </div>
                     </div>
                     <eg-combobox i18n-placeholder placeholder="Circulation Modifier..." idlClass="ccm" idlField="name"
-                      [displayTemplate]="idlClassLabel" [disabled]="currentCourse && currentCourse.is_archived() == 't'"
+                      [displayTemplate]="idlClassLabel" [disabled]="currentCourse && (courseIsArchived || currentCourse.is_archived()) == 't'"
                       [asyncSupportsEmptyTermClick]="true" class="flex-grow-1"
                       (onChange)="tempCircMod = $event.id; isModifyingCircMod = true">
                     </eg-combobox>
                     <div class="input-group-append">
                       <div class="input-group-text">
                         <input type="checkbox" [(ngModel)]="isModifyingCircMod"
-                          [disabled]="currentCourse && currentCourse.is_archived() == 't'"
+                          [disabled]="currentCourse && (courseIsArchived || currentCourse.is_archived()) == 't'"
                           aria-label="Checkbox for setting a temporary Circulation Modifier" />
                       </div>
                     </div>
                       </div>
                     </div>
                     <eg-combobox i18n-placeholder placeholder="Item Status..." idlClass="ccs" idlField="name"
-                      [displayTemplate]="idlClassLabel" [disabled]="currentCourse && currentCourse.is_archived() == 't'"
+                      [displayTemplate]="idlClassLabel" [disabled]="currentCourse && (courseIsArchived || currentCourse.is_archived()) == 't'"
                       [asyncSupportsEmptyTermClick]="true" class="flex-grow-1"
                       (onChange)="tempStatus = $event.id; isModifyingStatus = true">
                     </eg-combobox>
                     <div class="input-group-append">
                       <div class="input-group-text">
                         <input type="checkbox" [(ngModel)]="isModifyingStatus"
-                          [disabled]="currentCourse && currentCourse.is_archived() == 't'"
+                          [disabled]="currentCourse && (courseIsArchived || currentCourse.is_archived()) == 't'"
                           aria-label="Checkbox for setting a temporary Item Status" />
                       </div>
                     </div>
                       </div>
                     </div>
                     <eg-item-location-select permFilter="MANAGE_RESERVES" class="flex-grow-1"
-                      [disabled]="currentCourse && currentCourse.is_archived() == 't'" [(ngModel)]="tempLocation"
+                      [disabled]="currentCourse && (courseIsArchived || currentCourse.is_archived()) == 't'" [(ngModel)]="tempLocation"
                       (valueChange)="isModifyingLocation = true">
                     </eg-item-location-select>
                     <div class="input-group-append">
                       <div class="input-group-text">
                         <input type="checkbox" [(ngModel)]="isModifyingLocation"
-                          [disabled]="currentCourse && currentCourse.is_archived() == 't'"
+                          [disabled]="currentCourse && (courseIsArchived || currentCourse.is_archived()) == 't'"
                           aria-label="Checkbox for setting a temporary Shelving Location" />
                       </div>
                     </div>
               </div>
               <div class="row mt-3">
                 <div class="col-lg-12 text-right">
-                  <button class="btn btn-primary" [disabled]="currentCourse && currentCourse.is_archived() == 't'"
+                  <button class="btn btn-primary" [disabled]="currentCourse && (courseIsArchived || currentCourse.is_archived()) == 't'"
                     (click)="associateItem(barcodeInput, relationshipInput)" i18n [disabled]="!barcodeInput">
                     Add Material
                   </button>
                     <span class="input-group-text" i18n>Relationship</span>
                   </div>
                   <input type="text" [(ngModel)]="relationshipInput"
-                    [disabled]="currentCourse && currentCourse.is_archived() == 't'" placeholder-i18n
+                    [disabled]="currentCourse && (courseIsArchived || currentCourse.is_archived()) == 't'" placeholder-i18n
                     placeholder="e.g. Required" class="flex-grow-1" />
                 </div>
               </div>
                       <label for="bib-id" class="input-group-text" i18n>Bibliographic Record ID</label>
                     </div>
                     <input type="text" [(ngModel)]="bibId" id="bib-id"
-                      [disabled]="currentCourse && currentCourse.is_archived() == 't'" class="flex-grow-1" />
+                      [disabled]="currentCourse && (courseIsArchived || currentCourse.is_archived()) == 't'" class="flex-grow-1" />
                   </div>
                 </div>
                 <div class="d-flex" [ngClass]="isDialog() ? 'col-md-6' : 'col-md-12 mt-3'">
                       <span class="input-group-text" i18n>Relationship</span>
                     </div>
                     <input type="text" [(ngModel)]="relationshipInput"
-                      [disabled]="currentCourse && currentCourse.is_archived() == 't'" class="flex-grow-1" />
+                      [disabled]="currentCourse && (courseIsArchived || currentCourse.is_archived()) == 't'" class="flex-grow-1" />
                   </div>
                 </div>
               </div>
               <div class="row mt-3">
                 <div class="col-lg-12 text-right">
                   <button class="btn btn-primary" i18n (click)="associateElectronicBibRecord()"
-                    [disabled]="currentCourse && currentCourse.is_archived() == 't'">
+                    [disabled]="currentCourse && (courseIsArchived || currentCourse.is_archived()) == 't'">
                     Add Material
                   </button>
                 </div>
index 9a8264c..27c8ecf 100644 (file)
@@ -25,6 +25,7 @@ import {CourseService} from '@eg/staff/share/course.service';
 export class CourseAssociateMaterialComponent extends DialogComponent implements OnInit {
     @Input() currentCourse: IdlObject;
     @Input() courseId: any;
+    @Input() courseIsArchived: String;
     @Input() displayMode: String;
     materials: any[] = [];
     @ViewChild('editDialog', { static: true }) editDialog: FmRecordEditorComponent;
index d323638..f7187a5 100644 (file)
@@ -30,7 +30,7 @@
             </div>
             <input type="text" class="flex-grow-1" id="associate-user-barcode"
               [(ngModel)]="userBarcode" (click)="$event.target.select()"
-              [disabled]="currentCourse && currentCourse.is_archived() == 't'"
+              [disabled]="currentCourse && (courseIsArchived || currentCourse.is_archived()) == 't'"
               (keyup.enter)="associateUser(userBarcode)" />
             <button class="btn btn-outline-dark btn-sm" (click)="searchPatrons()">
               <span class="material-icons mat-icon-in-button align-middle"
@@ -45,7 +45,7 @@
               <label for="associate-user-role" class="input-group-text" i18n>Role</label>
             </div>
             <eg-combobox idlClass="acmr" [(ngModel)]="userRoleInput"
-            [disabled]="currentCourse && currentCourse.is_archived() == 't'">
+            [disabled]="currentCourse && (courseIsArchived || currentCourse.is_archived()) == 't'">
             </eg-combobox>
           </div>
         </div>
@@ -53,7 +53,7 @@
       <div class="row mt-3">
         <div class="text-right" [ngClass]="isDialog() ? 'col-md-2' : 'col-md-6'">
           <button class="btn btn-primary"
-            [disabled]="currentCourse && currentCourse.is_archived() == 't'"
+            [disabled]="currentCourse && (courseIsArchived || currentCourse.is_archived()) == 't'"
             i18n [disabled]="!userBarcode" (click)="associateUser(userBarcode)">
             Add User
           </button>
index d9985fa..772f023 100644 (file)
@@ -23,6 +23,7 @@ import {ComboboxEntry} from '@eg/share/combobox/combobox.component';
 export class CourseAssociateUsersComponent extends DialogComponent implements OnInit {
     @Input() currentCourse: IdlObject;
     @Input() courseId: number;
+    @Input() courseIsArchived: String;
     @Input() displayMode: String;
     users: any[] = [];
     @ViewChild('editDialog', { static: true }) editDialog: FmRecordEditorComponent;
index 4936a97..c2177f8 100644 (file)
@@ -1,16 +1,16 @@
 <eg-staff-banner
   bannerText=" {{currentCourse.course_number()}}: {{currentCourse.name()}}"
   i18n-bannerText class="mb-3" *ngIf="currentCourse"
-  [bannerStyle]="currentCourse.is_archived() == 't' ? 'alert-secondary' : null"
-  [bannerIcon]="currentCourse.is_archived() == 't' ? 'lock' : null">
+  [bannerStyle]="(courseIsArchived || currentCourse.is_archived()) == 't' ? 'alert-secondary' : null"
+  [bannerIcon]="(courseIsArchived || currentCourse.is_archived()) == 't' ? 'lock' : null">
 </eg-staff-banner>
 
 <div class="row">
   <div class="col text-right">
     <button class="btn btn-danger"
-      (click)="archiveCourse()" [disabled]="currentCourse && currentCourse.is_archived() == 't'">
+      (click)="archiveCourse()" [disabled]="currentCourse && (courseIsArchived || currentCourse.is_archived()) == 't' ">
       <i class="material-icons align-middle"
-        *ngIf="currentCourse && currentCourse.is_archived() == 't'">block</i>
+        *ngIf="currentCourse && (courseIsArchived || currentCourse.is_archived()) == 't'">block</i>
       <span class="align-middle">Archive Course</span>
     </button>
     <a class="btn btn-warning ml-3" routerLink="/staff/admin/local/asset/course_list" i18n>
@@ -47,7 +47,8 @@
     <a ngbNavLink i18n>Course materials</a>
     <ng-template ngbNavContent>
       <eg-course-associate-material-dialog [courseId]="courseId"
-        [currentCourse]="currentCourse" displayMode="inline">
+        [currentCourse]="currentCourse" displayMode="inline"
+        [courseIsArchived]="courseIsArchived">
       </eg-course-associate-material-dialog>
     </ng-template>
   </li>
@@ -57,7 +58,8 @@
     <a ngbNavLink i18n>Course users</a>
     <ng-template ngbNavContent>
       <eg-course-associate-users-dialog [courseId]="courseId"
-        [currentCourse]="currentCourse" displayMode="inline">
+        [currentCourse]="currentCourse" displayMode="inline"
+        [courseIsArchived]="courseIsArchived">
       </eg-course-associate-users-dialog>
     </ng-template>
   </li>
index 1bbc487..9ae7709 100644 (file)
@@ -17,6 +17,7 @@ export class CoursePageComponent implements OnInit {
 
     currentCourse: IdlObject;
     courseId: any;
+    courseIsArchived: String;
 
     // Materials Tab
     @ViewChild('courseMaterialDialog', {static: true})
@@ -42,6 +43,8 @@ export class CoursePageComponent implements OnInit {
         this.courseId = +this.route.snapshot.paramMap.get('id');
         this.course.getCourses([this.courseId]).then(course => {
             this.currentCourse = course[0];
+            this.courseIsArchived = course[0].is_archived();
+            console.log(this.courseIsArchived);
         });
     }
 
@@ -50,6 +53,7 @@ export class CoursePageComponent implements OnInit {
         this.course.disassociateMaterials([this.currentCourse]).then(res => {
             this.currentCourse.is_archived('t');
             this.pcrud.update(this.currentCourse).subscribe(val => {
+                this.courseIsArchived = 't';
                 console.debug('archived: ' + val);
                 this.archiveSuccessString.current()
                     .then(str => this.toast.success(str));