From 4638a97b4d64a3e59f7fec783194f8f39fe0ea0a Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Tue, 24 Apr 2018 12:00:07 -0400 Subject: [PATCH] LP#1626157 op-change; toast wip Signed-off-by: Bill Erickson --- Open-ILS/src/eg2/src/app/core/auth.service.ts | 6 +++++- Open-ILS/src/eg2/src/app/share/README | 5 +++-- .../src/eg2/src/app/share/dialog/dialog.component.ts | 19 +++++++++++++++++-- .../src/eg2/src/app/staff/catalog/catalog.module.ts | 2 +- .../src/app/staff/catalog/record/record.component.ts | 2 +- Open-ILS/src/eg2/src/app/staff/common.module.ts | 19 +++++++++++++------ Open-ILS/src/eg2/src/app/staff/nav.component.html | 11 +++++++++++ Open-ILS/src/eg2/src/app/staff/nav.component.ts | 17 +++++++++++++++++ .../eg2/src/app/staff/sandbox/sandbox.component.html | 3 +++ .../eg2/src/app/staff/sandbox/sandbox.component.ts | 9 ++++++++- .../{ => bib-summary}/bib-summary.component.html | 0 .../share/{ => bib-summary}/bib-summary.component.ts | 0 Open-ILS/src/eg2/src/app/staff/staff.component.html | 2 ++ 13 files changed, 81 insertions(+), 14 deletions(-) rename Open-ILS/src/eg2/src/app/staff/share/{ => bib-summary}/bib-summary.component.html (100%) rename Open-ILS/src/eg2/src/app/staff/share/{ => bib-summary}/bib-summary.component.ts (100%) diff --git a/Open-ILS/src/eg2/src/app/core/auth.service.ts b/Open-ILS/src/eg2/src/app/core/auth.service.ts index 7557da2500..9bd05dcc5a 100644 --- a/Open-ILS/src/eg2/src/app/core/auth.service.ts +++ b/Open-ILS/src/eg2/src/app/core/auth.service.ts @@ -47,7 +47,7 @@ export class EgAuthService { // opChangeUser refers to the user that has been superseded during // an op-change event. opChangeUser resumes its status as the // activeUser once the op-change cycle has completed. - private opChangeUser: EgAuthUser; + private opChangeUser: EgAuthUser = null; workstationState: EgAuthWsState = EgAuthWsState.PENDING; @@ -70,6 +70,10 @@ export class EgAuthService { new BroadcastChannel('eg.auth') : {}; } + // Returns true if we are currently in op-change mode. + opChangeIsActive(): boolean { + return this.opChangeUser !== null; + } // - Accessor functions always refer to the active user. diff --git a/Open-ILS/src/eg2/src/app/share/README b/Open-ILS/src/eg2/src/app/share/README index 9da6f8a11a..8bd93d7a56 100644 --- a/Open-ILS/src/eg2/src/app/share/README +++ b/Open-ILS/src/eg2/src/app/share/README @@ -1,5 +1,6 @@ Shared Angular services, components, directives, and associated classes. -These items are NOT automatically imported to the base module. Import -as needed. +These items are NOT automatically imported to the base module, though some +may already be imported by intermediate modules (e.g. EgStaffCommonModule). +Import as needed. 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 index 0b2cbbcbbe..1f979fcd7e 100644 --- a/Open-ILS/src/eg2/src/app/share/dialog/dialog.component.ts +++ b/Open-ILS/src/eg2/src/app/share/dialog/dialog.component.ts @@ -1,4 +1,4 @@ -import {Component, Input, ViewChild, TemplateRef} from '@angular/core'; +import {Component, Input, OnInit, ViewChild, TemplateRef, EventEmitter} from '@angular/core'; import {NgbModal, NgbModalRef, NgbModalOptions} from '@ng-bootstrap/ng-bootstrap'; /** @@ -11,7 +11,7 @@ import {NgbModal, NgbModalRef, NgbModalOptions} from '@ng-bootstrap/ng-bootstrap selector: 'eg-dialog', template: '' }) -export class EgDialogComponent { +export class EgDialogComponent implements OnInit { // Assume all dialogs support a title attribute. @Input() public dialogTitle: string; @@ -20,11 +20,20 @@ export class EgDialogComponent { @ViewChild('dialogContent') private dialogContent: TemplateRef; + // Emitted after open() is called on the ngbModal. + // Note when overriding open(), this will not fire unless also + // called in the overridding method. + onOpen$ = new EventEmitter(); + // The modalRef allows direct control of the modal instance. private modalRef: NgbModalRef = null; constructor(private modalService: NgbModal) {} + ngOnInit() { + this.onOpen$ = new EventEmitter(); + } + open(options?: NgbModalOptions): Promise { if (this.modalRef !== null) { @@ -33,6 +42,12 @@ export class EgDialogComponent { } this.modalRef = this.modalService.open(this.dialogContent, options); + + if (this.onOpen$) { + // Let the digest cycle complete + setTimeout(() => this.onOpen$.emit(true)); + } + return new Promise( (resolve, reject) => { this.modalRef.result.then( diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/catalog.module.ts b/Open-ILS/src/eg2/src/app/staff/catalog/catalog.module.ts index 4bb63fd33c..635eec1304 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/catalog.module.ts +++ b/Open-ILS/src/eg2/src/app/staff/catalog/catalog.module.ts @@ -9,7 +9,7 @@ import {SearchFormComponent} from './search-form.component'; import {ResultsComponent} from './result/results.component'; import {RecordComponent} from './record/record.component'; import {CopiesComponent} from './record/copies.component'; -import {EgBibSummaryComponent} from '../share/bib-summary.component'; +import {EgBibSummaryComponent} from '@eg/staff/share/bib-summary/bib-summary.component'; import {ResultPaginationComponent} from './result/pagination.component'; import {ResultFacetsComponent} from './result/facets.component'; import {ResultRecordComponent} from './result/record.component'; diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/record/record.component.ts b/Open-ILS/src/eg2/src/app/staff/catalog/record/record.component.ts index 7df0e4a18b..ec9a30215e 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/record/record.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/catalog/record/record.component.ts @@ -6,7 +6,7 @@ import {CatalogSearchContext, CatalogSearchState} from '@eg/share/catalog/search-context'; import {EgCatalogService} from '@eg/share/catalog/catalog.service'; import {StaffCatalogService} from '../catalog.service'; -import {EgBibSummaryComponent} from '../../share/bib-summary.component'; +import {EgBibSummaryComponent} from '@eg/staff/share/bib-summary/bib-summary.component'; @Component({ selector: 'eg-catalog-record', 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 c8aeb1d152..5f479628c0 100644 --- a/Open-ILS/src/eg2/src/app/staff/common.module.ts +++ b/Open-ILS/src/eg2/src/app/staff/common.module.ts @@ -9,6 +9,9 @@ import {EgProgressDialogComponent} from '@eg/share/dialog/progress.component'; import {EgAccessKeyDirective} from '@eg/share/accesskey/accesskey.directive'; import {EgAccessKeyService} from '@eg/share/accesskey/accesskey.service'; import {EgAccessKeyInfoComponent} from '@eg/share/accesskey/accesskey-info.component'; +import {EgOpChangeComponent} from '@eg/staff/share/op-change/op-change.component'; +import {EgToastService} from '@eg/share/toast/toast.service'; +import {EgToastComponent} from '@eg/share/toast/toast.component'; /** * Imports the EG common modules and adds modules common to all staff UI's. @@ -23,7 +26,9 @@ import {EgAccessKeyInfoComponent} from '@eg/share/accesskey/accesskey-info.compo EgPromptDialogComponent, EgProgressDialogComponent, EgAccessKeyDirective, - EgAccessKeyInfoComponent + EgAccessKeyInfoComponent, + EgToastComponent, + EgOpChangeComponent ], imports: [ EgCommonModule @@ -37,7 +42,9 @@ import {EgAccessKeyInfoComponent} from '@eg/share/accesskey/accesskey-info.compo EgPromptDialogComponent, EgProgressDialogComponent, EgAccessKeyDirective, - EgAccessKeyInfoComponent + EgAccessKeyInfoComponent, + EgToastComponent, + EgOpChangeComponent ] }) @@ -45,11 +52,11 @@ export class EgStaffCommonModule { static forRoot(): ModuleWithProviders { return { ngModule: EgStaffCommonModule, - providers: [ - EgAccessKeyService - /* placeholder for exporting staff-wide services */ + providers: [ // Export staff-wide services + EgAccessKeyService, + EgToastService ] }; } - } + diff --git a/Open-ILS/src/eg2/src/app/staff/nav.component.html b/Open-ILS/src/eg2/src/app/staff/nav.component.html index 8ca7cceac1..a56fd1668a 100644 --- a/Open-ILS/src/eg2/src/app/staff/nav.component.html +++ b/Open-ILS/src/eg2/src/app/staff/nav.component.html @@ -198,6 +198,17 @@ list + + + diff --git a/Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.component.ts b/Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.component.ts index 8e3c725378..dae9e12156 100644 --- a/Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/sandbox/sandbox.component.ts @@ -1,5 +1,6 @@ import {Component, OnInit, ViewChild} from '@angular/core'; import {EgProgressDialogComponent} from '@eg/share/dialog/progress.component'; +import {EgToastService} from '@eg/share/toast/toast.service'; @Component({ templateUrl: 'sandbox.component.html' @@ -9,7 +10,9 @@ export class EgSandboxComponent implements OnInit { @ViewChild('progressDialog') private progressDialog: EgProgressDialogComponent; - constructor() {} + constructor( + private toast: EgToastService + ) {} ngOnInit() { } @@ -23,5 +26,9 @@ export class EgSandboxComponent implements OnInit { setTimeout(() => this.progressDialog.update({value: 95}), 4000); setTimeout(() => this.progressDialog.close(), 5000); } + + testToast() { + this.toast.success('HELLO TOAST TEST'); + } } diff --git a/Open-ILS/src/eg2/src/app/staff/share/bib-summary.component.html b/Open-ILS/src/eg2/src/app/staff/share/bib-summary/bib-summary.component.html similarity index 100% rename from Open-ILS/src/eg2/src/app/staff/share/bib-summary.component.html rename to Open-ILS/src/eg2/src/app/staff/share/bib-summary/bib-summary.component.html diff --git a/Open-ILS/src/eg2/src/app/staff/share/bib-summary.component.ts b/Open-ILS/src/eg2/src/app/staff/share/bib-summary/bib-summary.component.ts similarity index 100% rename from Open-ILS/src/eg2/src/app/staff/share/bib-summary.component.ts rename to Open-ILS/src/eg2/src/app/staff/share/bib-summary/bib-summary.component.ts diff --git a/Open-ILS/src/eg2/src/app/staff/staff.component.html b/Open-ILS/src/eg2/src/app/staff/staff.component.html index ac17f7a303..2a2539c067 100644 --- a/Open-ILS/src/eg2/src/app/staff/staff.component.html +++ b/Open-ILS/src/eg2/src/app/staff/staff.component.html @@ -14,4 +14,6 @@ (click)="egAccessKeyInfo.open()"> + + -- 2.11.0