From: Bill Erickson Date: Thu, 14 Dec 2017 17:44:17 +0000 (-0500) Subject: LP#626157 Ang2 experiments X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=8302bbd99e072ce3d5dd1f7da2507b7d9436b950;p=working%2FEvergreen.git LP#626157 Ang2 experiments Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/eg2-src/src/app/core/auth.ts b/Open-ILS/eg2-src/src/app/core/auth.ts index 611797abeb..9052f3a18b 100644 --- a/Open-ILS/eg2-src/src/app/core/auth.ts +++ b/Open-ILS/eg2-src/src/app/core/auth.ts @@ -61,7 +61,7 @@ export class EgAuthService { // - Accessor functions alway refer to the active user. user(): EgIdlObject { - return this.activeUser.user + return this.activeUser ? this.activeUser.user : null; }; // Workstation name. diff --git a/Open-ILS/eg2-src/src/app/share/confirm-dialog.component.ts b/Open-ILS/eg2-src/src/app/share/confirm-dialog.component.ts new file mode 100644 index 0000000000..b9d527dffe --- /dev/null +++ b/Open-ILS/eg2-src/src/app/share/confirm-dialog.component.ts @@ -0,0 +1,71 @@ +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/eg2-src/src/app/staff/admin/workstation/workstations/app.component.html b/Open-ILS/eg2-src/src/app/staff/admin/workstation/workstations/app.component.html index 5b95268e34..1bc1cf084a 100644 --- a/Open-ILS/eg2-src/src/app/staff/admin/workstation/workstations/app.component.html +++ b/Open-ILS/eg2-src/src/app/staff/admin/workstation/workstations/app.component.html @@ -1,3 +1,12 @@ + + + + +
diff --git a/Open-ILS/eg2-src/src/app/staff/admin/workstation/workstations/app.component.ts b/Open-ILS/eg2-src/src/app/staff/admin/workstation/workstations/app.component.ts index b724dc0f2e..43ca664da4 100644 --- a/Open-ILS/eg2-src/src/app/staff/admin/workstation/workstations/app.component.ts +++ b/Open-ILS/eg2-src/src/app/staff/admin/workstation/workstations/app.component.ts @@ -1,10 +1,11 @@ -import {Component, OnInit} from '@angular/core'; +import {Component, OnInit, ViewChild} from '@angular/core'; import {ActivatedRoute} from '@angular/router'; import {EgStoreService} from '@eg/core/store'; import {EgIdlObject} from '@eg/core/idl'; import {EgNetService} from '@eg/core/net'; import {EgAuthService} from '@eg/core/auth'; import {EgOrgService} from '@eg/core/org'; +import {EgConfirmDialogComponent} from '@eg/share/confirm-dialog.component'; // Slim version of the WS that's stored in the cache. interface Workstation { @@ -22,7 +23,10 @@ export class WorkstationsComponent implements OnInit { workstations: Workstation[] = []; removeWorkstation: string; newOwner: EgIdlObject; - newName: String; + newName: string = 'NewTestName'; + + @ViewChild('workstationExistsDialog') + private wsExistsDialog: EgConfirmDialogComponent; // Org selector options. hideOrgs: number[]; @@ -59,7 +63,12 @@ export class WorkstationsComponent implements OnInit { } useNow(): void { - console.debug('using ' + this.selected().name); + //console.debug('using ' + this.selected().name); + + this.wsExistsDialog.open().then( + confirmed => console.log('dialog confirmed'), + dismissed => console.log('dialog dismissed') + ); } setDefault(): void { diff --git a/Open-ILS/eg2-src/src/app/staff/admin/workstation/workstations/app.module.ts b/Open-ILS/eg2-src/src/app/staff/admin/workstation/workstations/app.module.ts index c7051fb759..d0c5db3556 100644 --- a/Open-ILS/eg2-src/src/app/staff/admin/workstation/workstations/app.module.ts +++ b/Open-ILS/eg2-src/src/app/staff/admin/workstation/workstations/app.module.ts @@ -6,12 +6,14 @@ import {WorkstationsComponent} from './app.component'; @NgModule({ declarations: [ - WorkstationsComponent + WorkstationsComponent, ], imports: [ CommonModule, EgStaffModule, WorkstationsRoutingModule + ], + providers: [ ] }) diff --git a/Open-ILS/eg2-src/src/app/staff/app.module.ts b/Open-ILS/eg2-src/src/app/staff/app.module.ts index 7b53d7fc41..3b9418fc3c 100644 --- a/Open-ILS/eg2-src/src/app/staff/app.module.ts +++ b/Open-ILS/eg2-src/src/app/staff/app.module.ts @@ -10,6 +10,8 @@ import {EgStaffNavComponent} from './nav.component'; import {EgStaffLoginComponent} from './login.component'; import {EgStaffSplashComponent} from './splash.component'; import {EgOrgSelectComponent} from '@eg/share/org-select.component'; +import {EgConfirmDialogComponent} from '@eg/share/confirm-dialog.component'; + @NgModule({ declarations: [ @@ -17,7 +19,8 @@ import {EgOrgSelectComponent} from '@eg/share/org-select.component'; EgStaffNavComponent, EgStaffSplashComponent, EgStaffLoginComponent, - EgOrgSelectComponent + EgOrgSelectComponent, + EgConfirmDialogComponent ], imports: [ EgStaffRoutingModule, @@ -27,6 +30,7 @@ import {EgOrgSelectComponent} from '@eg/share/org-select.component'; exports: [ // Components available to all staff/sub modules EgOrgSelectComponent, + EgConfirmDialogComponent, FormsModule, NgbModule ] diff --git a/Open-ILS/eg2-src/src/app/staff/nav.component.ts b/Open-ILS/eg2-src/src/app/staff/nav.component.ts index 62fb605a63..57dcfdaf1f 100644 --- a/Open-ILS/eg2-src/src/app/staff/nav.component.ts +++ b/Open-ILS/eg2-src/src/app/staff/nav.component.ts @@ -16,8 +16,10 @@ export class EgStaffNavComponent implements OnInit { constructor(private auth: EgAuthService) {} ngOnInit() { - this.user = this.auth.user().usrname(); - this.workstation = this.auth.workstation(); + if (this.auth.user()) { + this.user = this.auth.user().usrname(); + this.workstation = this.auth.workstation(); + } } } diff --git a/Open-ILS/eg2-src/src/app/staff/splash.component.ts b/Open-ILS/eg2-src/src/app/staff/splash.component.ts index e113437229..beba23ae83 100644 --- a/Open-ILS/eg2-src/src/app/staff/splash.component.ts +++ b/Open-ILS/eg2-src/src/app/staff/splash.component.ts @@ -10,8 +10,8 @@ export class EgStaffSplashComponent implements OnInit { catSearchQuery: string; constructor( - private renderer: Renderer, - private router: Router + private renderer: Renderer, + private router: Router ) {} ngOnInit() {