LP#1626157 Dialog shuffling
authorBill Erickson <berickxx@gmail.com>
Fri, 6 Apr 2018 20:53:52 +0000 (20:53 +0000)
committerBill Erickson <berickxx@gmail.com>
Fri, 6 Apr 2018 20:53:52 +0000 (20:53 +0000)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/eg2/src/app/common.module.ts
Open-ILS/src/eg2/src/app/migration.module.ts
Open-ILS/src/eg2/src/app/share/confirm-dialog.component.ts [deleted file]
Open-ILS/src/eg2/src/app/share/dialog/confirm.component.html [new file with mode: 0644]
Open-ILS/src/eg2/src/app/share/dialog/confirm.component.ts [new file with mode: 0644]
Open-ILS/src/eg2/src/app/share/dialog/dialog.component.ts [new file with mode: 0644]
Open-ILS/src/eg2/src/app/staff/admin/workstation/workstations/app.component.ts
Open-ILS/src/eg2/src/app/staff/catalog/result/record.component.html
Open-ILS/src/eg2/src/app/staff/common.module.ts
Open-ILS/src/templates/staff/circ/checkin/t_checkin.tt2
Open-ILS/web/js/ui/default/staff/circ/checkin/app.js

index b6c6ff2..ea68a75 100644 (file)
@@ -14,13 +14,9 @@ import {EgAuthService} from '@eg/core/auth';
 import {EgPermService} from '@eg/core/perm';
 import {EgPcrudService} from '@eg/core/pcrud';
 import {EgOrgService} from '@eg/core/org';
-import {EgOrgSelectComponent} from '@eg/share/org-select.component';
-import {EgConfirmDialogComponent} from '@eg/share/confirm-dialog.component';
 
 @NgModule({
   declarations: [
-    EgOrgSelectComponent,
-    EgConfirmDialogComponent
   ],
   imports: [
     CommonModule,
@@ -30,9 +26,7 @@ import {EgConfirmDialogComponent} from '@eg/share/confirm-dialog.component';
   exports: [
     CommonModule,
     NgbModule,
-    FormsModule,
-    EgOrgSelectComponent,
-    EgConfirmDialogComponent
+    FormsModule
   ]
 })
 
index 4502e07..bf3bd69 100644 (file)
@@ -30,6 +30,10 @@ import {EgPermService} from '@eg/core/perm';
 import {EgPcrudService} from '@eg/core/pcrud';
 import {EgOrgService} from '@eg/core/org';
 
+// Downgraded components
+//import {EgConfirmDialogComponent} from '@eg/share/confirm-dialog.component';
+import {EgHelloWorldComponent} from '@eg/share/hello-world.component';
+
 declare var angular: any;
 
 @NgModule({
@@ -39,6 +43,11 @@ declare var angular: any;
     NgbModule.forRoot(),
     CookieModule.forRoot(),
     EgCommonModule.forRoot()
+  ],
+  declarations: [EgHelloWorldComponent],
+  entryComponents: [
+    EgHelloWorldComponent,
+    //EgConfirmDialogComponent // declared in EgCommonModule
   ]
 })
 
@@ -66,6 +75,9 @@ export class EgMigrationModule {
             .factory('eg2Pcrud', downgradeInjectable(EgPcrudService))
             .factory('eg2Org',   downgradeInjectable(EgOrgService))
             .factory('ng2Title', downgradeInjectable(Title))
+            .directive('eg2HelloWorld',
+                downgradeComponent({component: EgHelloWorldComponent}))
+
         ;
 
         this.upgrade.bootstrap(document.body, [myWin.ang1PageApp]);
diff --git a/Open-ILS/src/eg2/src/app/share/confirm-dialog.component.ts b/Open-ILS/src/eg2/src/app/share/confirm-dialog.component.ts
deleted file mode 100644 (file)
index b9d527d..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-import {Component, Input, ViewChild, TemplateRef} from '@angular/core';
-import {NgbModal, NgbModalRef} from '@ng-bootstrap/ng-bootstrap';
-
-// TODO: DOCS
-
-@Component({
-  selector: 'eg-confirm-dialog',
-  template: `
-    <ng-template #dialogContent>
-      <div class="modal-header bg-info">
-        <h4 class="modal-title">{{dialogTitle}}</h4>
-        <button type="button" class="close" 
-          i18n-aria-label aria-label="Close" 
-          (click)="dismiss('cross_click')">
-          <span aria-hidden="true">&times;</span>
-        </button>
-      </div>
-      <div class="modal-body"><p>{{dialogBody}}</p></div>
-      <div class="modal-footer">
-        <button type="button" class="btn btn-success" 
-          (click)="close('confirmed')" i18n>Confirm</button>
-        <button type="button" class="btn btn-warning" 
-          (click)="dismiss('canceled')" i18n>Cancel</button>
-      </div>
-    </ng-template>
-    `
-})
-export class EgConfirmDialogComponent {
-
-    // We need a reference to our template so we can pass it
-    // off to the modal service open() call.
-    @ViewChild('dialogContent')
-    private dialogContent: TemplateRef<any>;
-
-    // The modalRef allows direct control of the modal instance.
-    private modalRef: NgbModalRef = null;
-
-    @Input() public dialogTitle: string;
-    @Input() public dialogBody: string;
-
-    constructor(private modalService: NgbModal) {}
-
-    open(): Promise<void> {
-        return new Promise((resolve, reject) => {
-
-            if (this.modalRef !== null) {
-                console.error('Dismissing existing EgConfirmDialog!');
-                this.dismiss();
-            }
-
-            this.modalRef = this.modalService.open(this.dialogContent);
-            this.modalRef.result.then(
-                resolved => resolve(),
-                rejected => reject()
-            )
-        });
-    }
-
-    close(): void {
-        this.modalRef.close();
-        this.modalRef = null;
-    }
-
-    dismiss(): void {
-        this.modalRef.dismiss();
-        this.modalRef = null;
-    }
-
-}
-
-
diff --git a/Open-ILS/src/eg2/src/app/share/dialog/confirm.component.html b/Open-ILS/src/eg2/src/app/share/dialog/confirm.component.html
new file mode 100644 (file)
index 0000000..21766ca
--- /dev/null
@@ -0,0 +1,17 @@
+<ng-template #dialogContent>
+  <div class="modal-header bg-info">
+    <h4 class="modal-title">{{dialogTitle}}</h4>
+    <button type="button" class="close" 
+      i18n-aria-label aria-label="Close" 
+      (click)="dismiss('cross_click')">
+      <span aria-hidden="true">&times;</span>
+    </button>
+  </div>
+  <div class="modal-body"><p>{{dialogBody}}</p></div>
+  <div class="modal-footer">
+    <button type="button" class="btn btn-success" 
+      (click)="close('confirmed')" i18n>Confirm</button>
+    <button type="button" class="btn btn-warning" 
+      (click)="dismiss('canceled')" i18n>Cancel</button>
+  </div>
+</ng-template>
diff --git a/Open-ILS/src/eg2/src/app/share/dialog/confirm.component.ts b/Open-ILS/src/eg2/src/app/share/dialog/confirm.component.ts
new file mode 100644 (file)
index 0000000..e00731b
--- /dev/null
@@ -0,0 +1,17 @@
+import {Component, Input, ViewChild, TemplateRef} from '@angular/core';
+import {EgDialogComponent} from '@eg/share/dialog/dialog.component';
+
+@Component({
+  selector: 'eg-confirm-dialog',
+  templateUrl: './confirm.component.html'
+})
+
+/**
+ * Confirmation dialog that asks a yes/no question.
+ */
+export class EgConfirmDialogComponent extends EgDialogComponent {
+    // What question are we asking?
+    @Input() public dialogBody: string;
+}
+
+
diff --git a/Open-ILS/src/eg2/src/app/share/dialog/dialog.component.ts b/Open-ILS/src/eg2/src/app/share/dialog/dialog.component.ts
new file mode 100644 (file)
index 0000000..2782805
--- /dev/null
@@ -0,0 +1,50 @@
+import {Component, Input, ViewChild, TemplateRef} from '@angular/core';
+import {NgbModal, NgbModalRef} from '@ng-bootstrap/ng-bootstrap';
+
+/** 
+ * Dialog base class.  Handles the ngbModal logic. 
+ * Sub-classed component templates must have a #dialogContent selector 
+ * at the root of the template (see EgConfirmDialogComponent).
+ */ 
+
+@Component({
+    selector: 'eg-component',
+    template: '<ng-template></ng-template>'
+})
+export class EgDialogComponent {
+
+    // Assume all dialogs support a title attribute.
+    @Input() public dialogTitle: string;
+
+    // Pointer to the dialog content template.
+    @ViewChild('dialogContent') 
+    private dialogContent: TemplateRef<any>;
+
+    // The modalRef allows direct control of the modal instance.
+    private modalRef: NgbModalRef = null;
+
+    constructor(private modalService: NgbModal) {}
+
+    open(): Promise<any> {
+
+        if (this.modalRef !== null) {
+            console.error('Dismissing existing dialog!');
+            this.dismiss();
+        }
+
+        this.modalRef = this.modalService.open(this.dialogContent);
+        return this.modalRef.result;
+    }
+
+    close(reason?: any): void {
+        this.modalRef.close(reason);
+        this.modalRef = null;
+    }
+
+    dismiss(reason?: any): void {
+        this.modalRef.dismiss(reason);
+        this.modalRef = null;
+    }
+}
+
+
index 73827a7..2e04c35 100644 (file)
@@ -7,7 +7,7 @@ import {EgPermService} from '@eg/core/perm';
 import {EgAuthService} from '@eg/core/auth';
 import {EgOrgService} from '@eg/core/org';
 import {EgEventService} from '@eg/core/event';
-import {EgConfirmDialogComponent} from '@eg/share/confirm-dialog.component';
+import {EgConfirmDialogComponent} from '@eg/share/dialog/confirm.component';
 
 // Slim version of the WS that's stored in the cache.
 interface Workstation {
@@ -124,10 +124,10 @@ export class WorkstationsComponent implements OnInit {
                 confirmed => {
                     this.registerWorkstationApi(true).then(
                         wsId => resolve(wsId),
-                        notOk => reject()
+                        notOk => reject(notOk)
                     )
                 },
-                dismissed => reject()
+                dismissed => reject(dismissed)
             )
         });
     }
index 1625bc5..ea18762 100644 (file)
@@ -82,7 +82,7 @@
               Created {{bibSummary.create_date | date:'shortDate'}} by
               <!-- creator if fleshed after the initial data set is loaded -->
               <a *ngIf="bibSummary.creator.usrname" target="_self" 
-                href="./staff/circ/patron/{{bibSummary.creator.id()}}/checkout">
+                href="/eg/staff/circ/patron/{{bibSummary.creator.id()}}/checkout">
                   {{bibSummary.creator.usrname()}}
               </a>
               <!-- add a spacer pending data to reduce page shuffle -->
@@ -95,7 +95,7 @@
             <div class="float-right small-text-1">
               Edited {{bibSummary.edit_date | date:'shortDate'}} by
               <a *ngIf="bibSummary.editor.usrname" target="_self" 
-                href="./staff/circ/patron/{{bibSummary.editor.id()}}/checkout">
+                href="/eg/staff/circ/patron/{{bibSummary.editor.id()}}/checkout">
                   {{bibSummary.editor.usrname()}}
               </a>
               <span *ngIf="!bibSummary.editor.usrname"> ... </span>
index 0f5894c..e49e710 100644 (file)
@@ -1,7 +1,9 @@
 import {NgModule, ModuleWithProviders} from '@angular/core';
 import {EgCommonModule} from '@eg/common.module';
 import {EgStaffBannerComponent} from './share/staff-banner.component';
-import {EgConfirmDialogComponent} from '@eg/share/confirm-dialog.component';
+import {EgOrgSelectComponent} from '@eg/share/org-select.component';
+import {EgDialogComponent} from '@eg/share/dialog/dialog.component';
+import {EgConfirmDialogComponent} from '@eg/share/dialog/confirm.component';
 
 /**
  * Imports the EG common modules and adds modules common to all staff UI's.
@@ -10,13 +12,19 @@ import {EgConfirmDialogComponent} from '@eg/share/confirm-dialog.component';
 @NgModule({
   declarations: [
     EgStaffBannerComponent,
+    EgOrgSelectComponent,
+    EgDialogComponent,
+    EgConfirmDialogComponent
   ],
   imports: [
     EgCommonModule
   ],
   exports: [
     EgCommonModule,
-    EgStaffBannerComponent
+    EgStaffBannerComponent,
+    EgOrgSelectComponent,
+    EgDialogComponent,
+    EgConfirmDialogComponent
   ]
 })
 
@@ -25,7 +33,7 @@ export class EgStaffCommonModule {
         return {
             ngModule: EgStaffCommonModule,
             providers: [
-                /* placeholder for exporting staff-only services */
+                /* placeholder for exporting staff-wide services */
             ]
         };
     }
index 42d6e67..974f08a 100644 (file)
@@ -5,6 +5,16 @@
   </div>
 </div>
 
+<!--
+<eg2-confirm-dialog                                                             
+  #testDialog                                                     
+  dialogTitle="Test Dialog"
+  dialogBody='Test Dialog Body'>
+</eg2-confirm-dialog> 
+-->
+
+<eg2-hello-world #testHello message="Look out, I'm testing here!"></eg2-hello-world>
+
 <div class="row">
   <div class="col-md-12">
     <div ng-if="is_backdate()" class="alert-danger pad-all-min">
index d6739a4..626052d 100644 (file)
@@ -47,6 +47,15 @@ function($scope , $q , $window , $location , $timeout , egCore ,
 
     ng2Title.setTitle('Checkin'); // TODO: TESTING
 
+    var testDialog = angular.element(document.querySelector('testHello'));
+    //var testDialog = angular.element();
+    //console.log(testDialog);
+    //console.log(testDialog.controller());
+    console.log(testDialog.controller());
+    console.log(testDialog.controller('eg2HelloWorld'));
+    //testDialog.controller('eg2ConfirmDialog').open();
+    //testDialog.controller('egConfirmDialog').open();
+
     $scope.focusMe = true;
     $scope.checkins = checkinSvc.checkins;
     var today = new Date();