From b569f1bfe9a9d37a9225126ef4a032ca387f1f02 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Fri, 6 Apr 2018 20:53:52 +0000 Subject: [PATCH] LP#1626157 Dialog shuffling Signed-off-by: Bill Erickson --- Open-ILS/src/eg2/src/app/common.module.ts | 8 +-- Open-ILS/src/eg2/src/app/migration.module.ts | 12 ++++ .../eg2/src/app/share/confirm-dialog.component.ts | 71 ---------------------- .../src/app/share/dialog/confirm.component.html | 17 ++++++ .../eg2/src/app/share/dialog/confirm.component.ts | 17 ++++++ .../eg2/src/app/share/dialog/dialog.component.ts | 50 +++++++++++++++ .../workstation/workstations/app.component.ts | 6 +- .../app/staff/catalog/result/record.component.html | 4 +- Open-ILS/src/eg2/src/app/staff/common.module.ts | 14 ++++- .../src/templates/staff/circ/checkin/t_checkin.tt2 | 10 +++ .../web/js/ui/default/staff/circ/checkin/app.js | 9 +++ 11 files changed, 132 insertions(+), 86 deletions(-) delete mode 100644 Open-ILS/src/eg2/src/app/share/confirm-dialog.component.ts create mode 100644 Open-ILS/src/eg2/src/app/share/dialog/confirm.component.html create mode 100644 Open-ILS/src/eg2/src/app/share/dialog/confirm.component.ts create mode 100644 Open-ILS/src/eg2/src/app/share/dialog/dialog.component.ts diff --git a/Open-ILS/src/eg2/src/app/common.module.ts b/Open-ILS/src/eg2/src/app/common.module.ts index b6c6ff2310..ea68a75ac5 100644 --- a/Open-ILS/src/eg2/src/app/common.module.ts +++ b/Open-ILS/src/eg2/src/app/common.module.ts @@ -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 ] }) diff --git a/Open-ILS/src/eg2/src/app/migration.module.ts b/Open-ILS/src/eg2/src/app/migration.module.ts index 4502e07516..bf3bd6966a 100644 --- a/Open-ILS/src/eg2/src/app/migration.module.ts +++ b/Open-ILS/src/eg2/src/app/migration.module.ts @@ -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 index b9d527dffe..0000000000 --- a/Open-ILS/src/eg2/src/app/share/confirm-dialog.component.ts +++ /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: ` - - - - - - ` -}) -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; - - // 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 { - 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 index 0000000000..21766cac09 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/share/dialog/confirm.component.html @@ -0,0 +1,17 @@ + + + + + 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 index 0000000000..e00731b233 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/share/dialog/confirm.component.ts @@ -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 index 0000000000..27828058fc --- /dev/null +++ b/Open-ILS/src/eg2/src/app/share/dialog/dialog.component.ts @@ -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: '' +}) +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; + + // The modalRef allows direct control of the modal instance. + private modalRef: NgbModalRef = null; + + constructor(private modalService: NgbModal) {} + + open(): Promise { + + 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; + } +} + + diff --git a/Open-ILS/src/eg2/src/app/staff/admin/workstation/workstations/app.component.ts b/Open-ILS/src/eg2/src/app/staff/admin/workstation/workstations/app.component.ts index 73827a7d8a..2e04c35977 100644 --- a/Open-ILS/src/eg2/src/app/staff/admin/workstation/workstations/app.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/admin/workstation/workstations/app.component.ts @@ -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) ) }); } diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/result/record.component.html b/Open-ILS/src/eg2/src/app/staff/catalog/result/record.component.html index 1625bc5b2a..ea18762be4 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/result/record.component.html +++ b/Open-ILS/src/eg2/src/app/staff/catalog/result/record.component.html @@ -82,7 +82,7 @@ Created {{bibSummary.create_date | date:'shortDate'}} by + href="/eg/staff/circ/patron/{{bibSummary.creator.id()}}/checkout"> {{bibSummary.creator.usrname()}} @@ -95,7 +95,7 @@
Edited {{bibSummary.edit_date | date:'shortDate'}} by + href="/eg/staff/circ/patron/{{bibSummary.editor.id()}}/checkout"> {{bibSummary.editor.usrname()}} ... diff --git a/Open-ILS/src/eg2/src/app/staff/common.module.ts b/Open-ILS/src/eg2/src/app/staff/common.module.ts index 0f5894c218..e49e710119 100644 --- a/Open-ILS/src/eg2/src/app/staff/common.module.ts +++ b/Open-ILS/src/eg2/src/app/staff/common.module.ts @@ -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 */ ] }; } diff --git a/Open-ILS/src/templates/staff/circ/checkin/t_checkin.tt2 b/Open-ILS/src/templates/staff/circ/checkin/t_checkin.tt2 index 42d6e67d60..974f08a402 100644 --- a/Open-ILS/src/templates/staff/circ/checkin/t_checkin.tt2 +++ b/Open-ILS/src/templates/staff/circ/checkin/t_checkin.tt2 @@ -5,6 +5,16 @@
+ + + +
diff --git a/Open-ILS/web/js/ui/default/staff/circ/checkin/app.js b/Open-ILS/web/js/ui/default/staff/circ/checkin/app.js index d6739a4df9..626052d460 100644 --- a/Open-ILS/web/js/ui/default/staff/circ/checkin/app.js +++ b/Open-ILS/web/js/ui/default/staff/circ/checkin/app.js @@ -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(); -- 2.11.0