From: Bill Erickson Date: Tue, 24 Apr 2018 16:00:07 +0000 (-0400) Subject: LP#1626157 op-change; toast wip X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=4638a97b4d64a3e59f7fec783194f8f39fe0ea0a;p=working%2FEvergreen.git LP#1626157 op-change; toast wip Signed-off-by: Bill Erickson --- 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.component.html deleted file mode 100644 index 66266086d8..0000000000 --- a/Open-ILS/src/eg2/src/app/staff/share/bib-summary.component.html +++ /dev/null @@ -1,66 +0,0 @@ - -
- -
-
    -
  • -
    -
    Title:
    -
    {{summary.title}}
    -
    Edition:
    -
    {{summary.edition}}
    -
    TCN:
    -
    {{summary.tcn_value}}
    -
    Created By:
    -
    - {{summary.creator.usrname()}} -
    -
    -
  • -
  • -
    -
    Author:
    -
    {{summary.author}}
    -
    Pubdate:
    -
    {{summary.pubdate}}
    -
    Database ID:
    -
    {{summary.id}}
    -
    Last Edited By:
    -
    - {{summary.editor.usrname()}} -
    -
    -
  • -
  • -
    -
    Bib Call #:
    -
    {{summary.callNumber}}
    -
    Record Owner:
    -
    TODO
    -
    Created On:
    -
    {{summary.create_date | date:'shortDate'}}
    -
    Last Edited On:
    -
    {{summary.edit_date | date:'shortDate'}}
    -
    -
  • -
-
-
- 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.component.ts deleted file mode 100644 index c672adda2c..0000000000 --- a/Open-ILS/src/eg2/src/app/staff/share/bib-summary.component.ts +++ /dev/null @@ -1,76 +0,0 @@ -import {Component, OnInit, Input} from '@angular/core'; -import {EgNetService} from '@eg/core/net.service'; -import {EgPcrudService} from '@eg/core/pcrud.service'; -import {EgCatalogService} from '@eg/share/catalog/catalog.service'; - -@Component({ - selector: 'eg-bib-summary', - templateUrl: 'bib-summary.component.html' -}) -export class EgBibSummaryComponent implements OnInit { - - initDone: boolean = false; - - // If provided, the record will be fetched by the component. - @Input() recordId: number; - - // Otherwise, we'll use the provided bib summary object. - summary: any; - @Input() set bibSummary(s: any) { - this.summary = s; - if (this.initDone) this.fetchBibCallNumber(); - } - - expandDisplay: boolean = true; - - constructor( - private cat: EgCatalogService, - private net: EgNetService, - private pcrud: EgPcrudService - ) {} - - ngOnInit() { - this.initDone = true; - if (this.summary) { - this.fetchBibCallNumber(); - } else { - if (this.recordId) this.loadSummary(); - } - } - - loadSummary(): void { - this.cat.getBibSummary(this.recordId).then(summary => { - this.summary = summary; - this.fetchBibCallNumber(); - - // Flesh the user data - this.pcrud.search('au', {id: [summary.creator, summary.editor]}) - .subscribe(user => { - if (user.id() == summary.creator) - summary.creator = user; - if (user.id() == summary.editor) - summary.editor = user; - }) - }); - } - - fetchBibCallNumber(): void { - if (!this.summary || this.summary.callNumber) return; - - // TODO labelClass = cat.default_classification_scheme YAOUS - let labelClass = 1; - - this.net.request( - 'open-ils.cat', - 'open-ils.cat.biblio.record.marc_cn.retrieve', - this.summary.id, labelClass - ).subscribe(cnArray => { - if (cnArray && cnArray.length > 0) { - let key1 = Object.keys(cnArray[0])[0]; - this.summary.callNumber = cnArray[0][key1]; - } - }); - } -} - - diff --git a/Open-ILS/src/eg2/src/app/staff/share/bib-summary/bib-summary.component.html b/Open-ILS/src/eg2/src/app/staff/share/bib-summary/bib-summary.component.html new file mode 100644 index 0000000000..66266086d8 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/share/bib-summary/bib-summary.component.html @@ -0,0 +1,66 @@ + +
+
+
+ Record Summary +
+
+ +
+
+
    +
  • +
    +
    Title:
    +
    {{summary.title}}
    +
    Edition:
    +
    {{summary.edition}}
    +
    TCN:
    +
    {{summary.tcn_value}}
    +
    Created By:
    +
    + {{summary.creator.usrname()}} +
    +
    +
  • +
  • +
    +
    Author:
    +
    {{summary.author}}
    +
    Pubdate:
    +
    {{summary.pubdate}}
    +
    Database ID:
    +
    {{summary.id}}
    +
    Last Edited By:
    +
    + {{summary.editor.usrname()}} +
    +
    +
  • +
  • +
    +
    Bib Call #:
    +
    {{summary.callNumber}}
    +
    Record Owner:
    +
    TODO
    +
    Created On:
    +
    {{summary.create_date | date:'shortDate'}}
    +
    Last Edited On:
    +
    {{summary.edit_date | date:'shortDate'}}
    +
    +
  • +
+
+
+ diff --git a/Open-ILS/src/eg2/src/app/staff/share/bib-summary/bib-summary.component.ts b/Open-ILS/src/eg2/src/app/staff/share/bib-summary/bib-summary.component.ts new file mode 100644 index 0000000000..c672adda2c --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/share/bib-summary/bib-summary.component.ts @@ -0,0 +1,76 @@ +import {Component, OnInit, Input} from '@angular/core'; +import {EgNetService} from '@eg/core/net.service'; +import {EgPcrudService} from '@eg/core/pcrud.service'; +import {EgCatalogService} from '@eg/share/catalog/catalog.service'; + +@Component({ + selector: 'eg-bib-summary', + templateUrl: 'bib-summary.component.html' +}) +export class EgBibSummaryComponent implements OnInit { + + initDone: boolean = false; + + // If provided, the record will be fetched by the component. + @Input() recordId: number; + + // Otherwise, we'll use the provided bib summary object. + summary: any; + @Input() set bibSummary(s: any) { + this.summary = s; + if (this.initDone) this.fetchBibCallNumber(); + } + + expandDisplay: boolean = true; + + constructor( + private cat: EgCatalogService, + private net: EgNetService, + private pcrud: EgPcrudService + ) {} + + ngOnInit() { + this.initDone = true; + if (this.summary) { + this.fetchBibCallNumber(); + } else { + if (this.recordId) this.loadSummary(); + } + } + + loadSummary(): void { + this.cat.getBibSummary(this.recordId).then(summary => { + this.summary = summary; + this.fetchBibCallNumber(); + + // Flesh the user data + this.pcrud.search('au', {id: [summary.creator, summary.editor]}) + .subscribe(user => { + if (user.id() == summary.creator) + summary.creator = user; + if (user.id() == summary.editor) + summary.editor = user; + }) + }); + } + + fetchBibCallNumber(): void { + if (!this.summary || this.summary.callNumber) return; + + // TODO labelClass = cat.default_classification_scheme YAOUS + let labelClass = 1; + + this.net.request( + 'open-ils.cat', + 'open-ils.cat.biblio.record.marc_cn.retrieve', + this.summary.id, labelClass + ).subscribe(cnArray => { + if (cnArray && cnArray.length > 0) { + let key1 = Object.keys(cnArray[0])[0]; + this.summary.callNumber = cnArray[0][key1]; + } + }); + } +} + + 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()"> + +