lp1840287-floating-groups-extend user/mrisher/lp1840287-floating-groups-extend
authorMike Risher <mrisher@catalyte.io>
Tue, 10 Sep 2019 17:45:30 +0000 (17:45 +0000)
committerMike Risher <mrisher@catalyte.io>
Tue, 10 Sep 2019 17:45:30 +0000 (17:45 +0000)
Signed-off-by: Mike Risher <mrisher@catalyte.io>
Open-ILS/src/eg2/src/app/staff/admin/server/edit-floating-group.component.ts

index bd7370e..369254e 100644 (file)
@@ -1,33 +1,56 @@
-import {Component, Input} from '@angular/core';
-import {Router} from '@angular/router';
+import {Component, Input, ViewChild} from '@angular/core';
+import {Router, Routes} from '@angular/router';
 import {GridDataSource} from '@eg/share/grid/grid';
 import {Pager} from '@eg/share/util/pager';
 import {PcrudService} from '@eg/core/pcrud.service';
+import {FmRecordEditorComponent} from '@eg/share/fm-editor/fm-editor.component';
+import {StringComponent} from '@eg/share/string/string.component';
+import {ToastService} from '@eg/share/toast/toast.service';
+import {GridComponent} from '@eg/share/grid/grid.component';
+import {AdminPageComponent} from '@eg/staff/share/admin-page/admin-page.component';
+import {OrgService} from '@eg/core/org.service';
+import {PermService} from '@eg/core/perm.service';
+import {AuthService} from '@eg/core/auth.service';
+import {IdlService, IdlObject} from '@eg/core/idl.service';
 
  @Component({
      templateUrl: './edit-floating-group.component.html'
  })
 
- export class EditFloatingGroupComponent {
+ export class EditFloatingGroupComponent extends AdminPageComponent {
 
     @Input() idlClass = 'cfgm';
     @Input() sortField: string;
     @Input() dataSource: GridDataSource;
     @Input() dialogSize: 'sm' | 'lg' = 'lg';
-    
+    @ViewChild('grid') grid: GridComponent;
+    @ViewChild('editDialog') editDialog: FmRecordEditorComponent;
+    @ViewChild('createString') createString: StringComponent;
+
+
     // This is the ID of the floating group being edited currently
     currentId: string;
+    translatableFields: string[];
+    createNew: () => void;
 
     constructor(
-        private pcrud: PcrudService,
-        private router: Router
+         pcrud: PcrudService,
+         toast: ToastService,
+         idl: IdlService,
+         org: OrgService,
+         auth: AuthService,
+         perm: PermService,
+         private router: Router,
     ) {
+        super( idl, org, auth, pcrud, perm, toast )
+        
     }
 
     ngOnInit() {
-        let url = this.router.routerState.snapshot.url;
-        let slash = url.lastIndexOf('/');
-        this.currentId = url.substring(slash+1);
+        // super.ngOnInit();
+        let currentUrl = this.router.routerState.snapshot.url;
+        let slash = currentUrl.lastIndexOf('/');
+        this.currentId = currentUrl.substring(slash+1);
         this.dataSource = new GridDataSource();
         this.dataSource.getRows = (pager: Pager, sort: any[]) => {
             const searchOps = {
@@ -37,5 +60,20 @@ import {PcrudService} from '@eg/core/pcrud.service';
             };            
             return this.pcrud.search(this.idlClass, {floating_group: this.currentId}, searchOps);
         };
+
+        this.createNew = () => {
+            // super.createNew();
+            console.log("create new")
+            this.editDialog.mode = 'create';
+            // this.editDialog.open({size: this.dialogSize}).then(
+            //     ok => {
+            //         this.createString.current()
+            //             .then(str => this.toast.success(str));
+            //         this.grid.reload();
+            //     },
+            //     err => {}
+            // );
+        };
+
     }
  }
\ No newline at end of file