LP#1849212 Create, Edit and Delete Functionality
authorZavier Banks <zbanks@catalyte.io>
Thu, 24 Oct 2019 22:08:24 +0000 (22:08 +0000)
committerJane Sandberg <sandbej@linnbenton.edu>
Wed, 26 Aug 2020 17:55:49 +0000 (10:55 -0700)
Added the create, edit, and delete functionality.

Signed-off-by: Zavier Banks <zbanks@catalyte.io>
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

index e48c240..471a94e 100644 (file)
@@ -2,6 +2,7 @@
 </eg-staff-banner>
 
 <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 #flairTooltip i18n-text text="Limited Editing"></eg-string>
@@ -18,7 +19,7 @@
     </eg-grid-toolbar-button>
     <eg-grid-toolbar-action label="Edit Selected" i18n-label (onClick)="editSelected($event)">
     </eg-grid-toolbar-action>
-    <eg-grid-toolbar-action label="Delete Selected" i18n-label>
+    <eg-grid-toolbar-action label="Delete Selected" i18n-label (onClick)="deleteSelected($event)">
     </eg-grid-toolbar-action>
   </eg-grid>
 </div>
index bd72c52..9e4bb40 100644 (file)
@@ -37,15 +37,15 @@ export class CourseListComponent implements OnInit {
     ){}
 
     ngOnInit() {
-      this.getSource();
-      this.rowFlair();
+        this.getSource();
+        this.rowFlair();
     }
 
     /**
      * Gets the data, specified by the class, that is available.
      */
     getSource() {
-      this.grid_source.getRows = (pager: Pager, sort: any[]) => {
+        this.grid_source.getRows = (pager: Pager, sort: any[]) => {
             const orderBy: any = {};
             if (sort.length) {
                 // Sort specified from grid
@@ -120,14 +120,30 @@ export class CourseListComponent implements OnInit {
         );
     }
 
-    editSelected(standingPenaltyFields: IdlObject[]) {
+    editSelected(fields: IdlObject[]) {
         // Edit each IDL thing one at a time
-        const editOneThing = (standingPenalty: IdlObject) => {
-            if (!standingPenalty) { return; }
-            this.showEditDialog(standingPenalty).then(
-                () => editOneThing(standingPenaltyFields.shift()));
+        const editOneThing = (field_object: IdlObject) => {
+            if (!field_object) { return; }
+            this.showEditDialog(field_object).then(
+                () => editOneThing(fields.shift()));
         };
-        editOneThing(standingPenaltyFields.shift());
+        editOneThing(fields.shift());
     }
+
+    deleteSelected(idl_object: IdlObject[]) {
+            idl_object.forEach(idl_object => idl_object.isdeleted(true));
+            this.pcrud.autoApply(idl_object).subscribe(
+                val => {
+                    console.debug('deleted: ' + val);
+                    this.deleteSuccessString.current()
+                        .then(str => this.toast.success(str));
+                },
+                err => {
+                    this.deleteFailedString.current()
+                        .then(str => this.toast.danger(str));
+                },
+                ()  => this.grid.reload()
+            );
+        };
 }