From: Bill Erickson Date: Mon, 18 May 2020 20:35:56 +0000 (-0400) Subject: LP1879335 Manage Authorities Angular WIP X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=059a2e08ce695a6d748ccadfab0239476c8207cd;p=working%2FEvergreen.git LP1879335 Manage Authorities Angular WIP Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/src/eg2/src/app/staff/cat/authority/authority.module.ts b/Open-ILS/src/eg2/src/app/staff/cat/authority/authority.module.ts index 8686b1aa5c..f29b20c6f4 100644 --- a/Open-ILS/src/eg2/src/app/staff/cat/authority/authority.module.ts +++ b/Open-ILS/src/eg2/src/app/staff/cat/authority/authority.module.ts @@ -6,6 +6,7 @@ import {MarcEditModule} from '@eg/staff/share/marc-edit/marc-edit.module'; import {AuthorityMarcEditComponent} from './marc-edit.component'; import {BrowseAuthorityComponent} from './browse.component'; import {ManageAuthorityComponent} from './manage.component'; +import {AuthorityMergeDialogComponent} from './merge-dialog.component'; import {BrowseService} from './browse.service'; import {BibListModule} from '@eg/staff/share/bib-list/bib-list.module'; @@ -13,7 +14,8 @@ import {BibListModule} from '@eg/staff/share/bib-list/bib-list.module'; declarations: [ AuthorityMarcEditComponent, BrowseAuthorityComponent, - ManageAuthorityComponent + ManageAuthorityComponent, + AuthorityMergeDialogComponent ], imports: [ StaffCommonModule, diff --git a/Open-ILS/src/eg2/src/app/staff/cat/authority/browse.component.html b/Open-ILS/src/eg2/src/app/staff/cat/authority/browse.component.html index 237a844b2e..7846e8dd64 100644 --- a/Open-ILS/src/eg2/src/app/staff/cat/authority/browse.component.html +++ b/Open-ILS/src/eg2/src/app/staff/cat/authority/browse.component.html @@ -3,6 +3,8 @@ + +
@@ -64,6 +66,9 @@ + + row.heading - } + }; this.rowFlairCallback = (row: any): GridRowFlairEntry => { const flair = {icon: null, title: null}; @@ -75,13 +79,13 @@ export class BrowseAuthorityComponent implements OnInit { flair.title = this.rowSelected.text; } return flair; - } + }; } markForMerge(rows: any[]) { rows.forEach(row => - this.browse.markedForMerge[row.authority.id()] = true); + this.browse.markedForMerge[row.authority.id()] = row); } unMarkForMerge(rows: any[]) { @@ -99,6 +103,19 @@ export class BrowseAuthorityComponent implements OnInit { } this.grid.reload(); } + + openMergeDialog() { + const rows = Object.values(this.browse.markedForMerge); + if (rows.length > 0) { + this.mergeDialog.authData = rows; + this.mergeDialog.open({size: 'lg'}).subscribe(success => { + if (success) { + this.clearMergeSelection(); + this.search(); + } + }); + } + } } diff --git a/Open-ILS/src/eg2/src/app/staff/cat/authority/manage.component.html b/Open-ILS/src/eg2/src/app/staff/cat/authority/manage.component.html index 2eb475964b..37bb7ecf02 100644 --- a/Open-ILS/src/eg2/src/app/staff/cat/authority/manage.component.html +++ b/Open-ILS/src/eg2/src/app/staff/cat/authority/manage.component.html @@ -1,4 +1,4 @@ - +
@@ -17,7 +17,8 @@
- +
diff --git a/Open-ILS/src/eg2/src/app/staff/cat/authority/merge-dialog.component.html b/Open-ILS/src/eg2/src/app/staff/cat/authority/merge-dialog.component.html new file mode 100644 index 0000000000..cccf2eee0b --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/cat/authority/merge-dialog.component.html @@ -0,0 +1,42 @@ + + + + + + + + + + diff --git a/Open-ILS/src/eg2/src/app/staff/cat/authority/merge-dialog.component.ts b/Open-ILS/src/eg2/src/app/staff/cat/authority/merge-dialog.component.ts new file mode 100644 index 0000000000..526121e46a --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/cat/authority/merge-dialog.component.ts @@ -0,0 +1,74 @@ +import {Component, OnInit, Input, ViewChild} from '@angular/core'; +import {NetService} from '@eg/core/net.service'; +import {EventService} from '@eg/core/event.service'; +import {ToastService} from '@eg/share/toast/toast.service'; +import {AuthService} from '@eg/core/auth.service'; +import {DialogComponent} from '@eg/share/dialog/dialog.component'; +import {NgbModal} from '@ng-bootstrap/ng-bootstrap'; +import {StringComponent} from '@eg/share/string/string.component'; + +/** + * Dialog for merging authority records. + */ + +@Component({ + selector: 'eg-authority-merge-dialog', + templateUrl: 'merge-dialog.component.html' +}) + +export class AuthorityMergeDialogComponent + extends DialogComponent implements OnInit { + + // Rows passed from the authority browse grid. + @Input() authData: any[] = []; + + leadRecord: number; + + @ViewChild('successMsg', {static: true}) + private successMsg: StringComponent; + + @ViewChild('errorMsg', {static: true}) + private errorMsg: StringComponent; + + constructor( + private modal: NgbModal, // required for passing to parent + private toast: ToastService, + private net: NetService, + private evt: EventService, + private auth: AuthService) { + super(modal); // required for subclassing + } + + ngOnInit() { + this.onOpen$.subscribe(_ => { + if (this.authData.length > 0) { + this.leadRecord = this.authData[0].authority.id(); + } + }); + } + + merge() { + + const list = this.authData + .map(data => data.authority.id()) + .filter(id => id !== this.leadRecord); + + this.net.request('open-ils.cat', + 'open-ils.cat.authority.records.merge', + this.auth.token(), this.leadRecord, list) + .subscribe(resp => { + const evt = this.evt.parse(resp); + + if (evt) { + this.errorMsg.current().then(str => this.toast.warning(str)); + this.close(false); + } else { + this.successMsg.current().then(str => this.toast.success(str)); + this.close(true); + } + }); + } +} + + + diff --git a/Open-ILS/src/eg2/src/app/staff/share/bib-list/bib-list.component.ts b/Open-ILS/src/eg2/src/app/staff/share/bib-list/bib-list.component.ts index 8c6b7fcc01..19faff39b1 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/bib-list/bib-list.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/share/bib-list/bib-list.component.ts @@ -45,7 +45,7 @@ export class BibListComponent implements OnInit { } return empty(); - } + }; this.cellTextGenerator = { title: row => row.title