From b243a78cde8319c20a9694d381649f7d240a1403 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Mon, 18 May 2020 12:49:21 -0400 Subject: [PATCH] LP1879335 Manage Authorities Angular WIP Signed-off-by: Bill Erickson --- .../app/staff/cat/authority/authority.module.ts | 6 +- .../app/staff/cat/authority/browse.component.html | 69 ++++++++++++++ .../app/staff/cat/authority/browse.component.ts | 102 +++++++++++++++++++++ .../app/staff/cat/authority/manage.component.html | 73 ++++----------- .../app/staff/cat/authority/manage.component.ts | 92 ++++++++----------- .../src/app/staff/cat/authority/routing.module.ts | 9 +- .../staff/share/bib-list/bib-list.component.html | 16 ++++ .../app/staff/share/bib-list/bib-list.component.ts | 75 +++++++++++++++ .../app/staff/share/bib-list/bib-list.module.ts | 20 ++++ 9 files changed, 352 insertions(+), 110 deletions(-) create mode 100644 Open-ILS/src/eg2/src/app/staff/cat/authority/browse.component.html create mode 100644 Open-ILS/src/eg2/src/app/staff/cat/authority/browse.component.ts create mode 100644 Open-ILS/src/eg2/src/app/staff/share/bib-list/bib-list.component.html create mode 100644 Open-ILS/src/eg2/src/app/staff/share/bib-list/bib-list.component.ts create mode 100644 Open-ILS/src/eg2/src/app/staff/share/bib-list/bib-list.module.ts 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 c6b8d6e245..ef2acbe770 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 @@ -4,18 +4,22 @@ import {CommonWidgetsModule} from '@eg/share/common-widgets.module'; import {AuthorityRoutingModule} from './routing.module'; 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 {BibListModule} from '@eg/staff/share/bib-list/bib-list.module'; @NgModule({ declarations: [ AuthorityMarcEditComponent, + BrowseAuthorityComponent, ManageAuthorityComponent ], imports: [ StaffCommonModule, CommonWidgetsModule, MarcEditModule, - AuthorityRoutingModule + AuthorityRoutingModule, + BibListModule ], providers: [ ] 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 new file mode 100644 index 0000000000..6c0794a018 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/cat/authority/browse.component.html @@ -0,0 +1,69 @@ + + + +
+
+
+
+ Search Term +
+ +
+
+
+
+
+ Authority Type +
+ + + +
+
+
+
+
+ + + + +
+
+
+ + + + {{row.heading}} + + + + + + + + + + + + + + + + + diff --git a/Open-ILS/src/eg2/src/app/staff/cat/authority/browse.component.ts b/Open-ILS/src/eg2/src/app/staff/cat/authority/browse.component.ts new file mode 100644 index 0000000000..072423193a --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/cat/authority/browse.component.ts @@ -0,0 +1,102 @@ +import {Component, OnInit, ViewChild} from '@angular/core'; +import {Observable, empty} from 'rxjs'; +import {map, switchMap} from 'rxjs/operators'; +import {IdlObject} from '@eg/core/idl.service'; +import {Pager} from '@eg/share/util/pager'; +import {NetService} from '@eg/core/net.service'; +import {PcrudService} from '@eg/core/pcrud.service'; +import {OrgService} from '@eg/core/org.service'; +import {GridComponent} from '@eg/share/grid/grid.component'; +import {GridContext, GridDataSource, GridCellTextGenerator} from '@eg/share/grid/grid'; +import {ComboboxEntry} from '@eg/share/combobox/combobox.component'; + +/* Find, merge, and edit authority records */ + +@Component({ + templateUrl: 'browse.component.html', + styles: [`#offset-input { width: 4em; }`] +}) +export class BrowseAuthorityComponent implements OnInit { + + // Grid paging is disabled in this UI to support browsing in + // both directions. Define our own paging trackers. + pageSize = 15; + searchOffset = 0; + + searchTerm: string; + authorityAxis: ComboboxEntry; + authorityAxes: ComboboxEntry[]; + dataSource: GridDataSource; + cellTextGenerator: GridCellTextGenerator; + + @ViewChild('grid', {static: false}) grid: GridComponent; + + constructor( + private net: NetService, + private org: OrgService, + private pcrud: PcrudService + ) { + } + + ngOnInit() { + + this.pcrud.retrieveAll('aba', {}, {atomic: true}) + .subscribe(axes => { + this.authorityAxes = axes + .map(axis => ({id: axis.code(), label: axis.name()})) + .sort((a1, a2) => a1.label < a2.label ? -1 : 1); + }); + + this.dataSource = new GridDataSource(); + + this.dataSource.getRows = (pager: Pager, sort: any): Observable => { + return this.loadAuthorities(); + } + + this.cellTextGenerator = { + heading: row => row.heading + } + } + + loadAuthorities(): Observable { + + if (!this.searchTerm || !this.authorityAxis.id) { + return empty(); + } + + return this.net.request( + 'open-ils.supercat', + 'open-ils.supercat.authority.browse.by_axis', + this.authorityAxis.id, this.searchTerm, + this.pageSize, this.searchOffset + + ).pipe(switchMap(authIds => { + + return this.net.request( + 'open-ils.search', + 'open-ils.search.authority.main_entry', authIds + ); + + })).pipe(map(authMeta => { + + const oOrg = this.org.get(authMeta.authority.owner()); + + return { + authority: authMeta.authority, + link_count: authMeta.linked_bibs.length, + heading: authMeta.heading, + thesaurus: authMeta.thesaurus, + thesaurus_code: authMeta.thesaurus_code, + owner: oOrg ? oOrg.shortname() : '' + }; + })); + } + + search(offset?: number) { + if (offset) { this.searchOffset += offset; } + + this.grid.reload(); + } +} + + 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 bf619be0a7..6fa633fb2a 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,62 +1,23 @@ - + -
-
-
-
- Search Term + + + +
+
- -
-
-
-
-
- Authority Type + + + + +
+ +
- - - -
-
-
-
-
- - - - -
-
-
+ + + - - - - - - - - - - - - - - - diff --git a/Open-ILS/src/eg2/src/app/staff/cat/authority/manage.component.ts b/Open-ILS/src/eg2/src/app/staff/cat/authority/manage.component.ts index 661857d4e5..7ddf38ae49 100644 --- a/Open-ILS/src/eg2/src/app/staff/cat/authority/manage.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/cat/authority/manage.component.ts @@ -1,6 +1,8 @@ import {Component, OnInit, ViewChild} from '@angular/core'; +import {Router, ActivatedRoute, ParamMap} from '@angular/router'; import {Observable, empty} from 'rxjs'; import {map, switchMap} from 'rxjs/operators'; +import {NgbTabset, NgbTabChangeEvent} from '@ng-bootstrap/ng-bootstrap'; import {IdlObject} from '@eg/core/idl.service'; import {Pager} from '@eg/share/util/pager'; import {NetService} from '@eg/core/net.service'; @@ -13,24 +15,20 @@ import {ComboboxEntry} from '@eg/share/combobox/combobox.component'; /* Find, merge, and edit authority records */ @Component({ - templateUrl: 'manage.component.html', - styles: [`#offset-input { width: 4em; }`] + templateUrl: 'manage.component.html' }) export class ManageAuthorityComponent implements OnInit { - // Grid paging is disabled in this UI to support browsing in - // both directions. Define our own paging trackers. - pageSize = 15; - searchOffset = 0; + authId: number; + authTab = 'bibs'; + authMeta: any; - searchTerm: string; - authorityAxis: ComboboxEntry; - authorityAxes: ComboboxEntry[]; - dataSource: GridDataSource; - - @ViewChild('grid', {static: false}) grid: GridComponent; + bibsDataSource: GridDataSource; + @ViewChild('bibsGrid', {static: false}) bibsGrid: GridComponent; constructor( + private router: Router, + private route: ActivatedRoute, private net: NetService, private org: OrgService, private pcrud: PcrudService @@ -39,58 +37,48 @@ export class ManageAuthorityComponent implements OnInit { ngOnInit() { - this.pcrud.retrieveAll('aba', {}, {atomic: true}) - .subscribe(axes => { - this.authorityAxes = axes - .map(axis => ({id: axis.code(), label: axis.name()})) - .sort((a1, a2) => a1.label < a2.label ? -1 : 1); - }); - - this.dataSource = new GridDataSource(); + this.bibsDataSource = new GridDataSource(); - this.dataSource.getRows = (pager: Pager, sort: any): Observable => { - return this.loadAuthorities(); + this.bibsDataSource.getRows = (pager: Pager, sort: any): Observable => { + return this.loadLinkedBibs(); } - } - - loadAuthorities(): Observable { - if (!this.searchTerm || !this.authorityAxis.id) { - return empty(); - } + this.route.paramMap.subscribe((params: ParamMap) => { + this.authTab = params.get('tab') || 'bibs'; + const id = +params.get('id'); - return this.net.request( - 'open-ils.supercat', - 'open-ils.supercat.authority.browse.by_axis', - this.authorityAxis.id, this.searchTerm, - this.pageSize, this.searchOffset + if (id !== this.authId) { + this.authId = id; - ).pipe(switchMap(authIds => { + this.net.request( + 'open-ils.search', + 'open-ils.search.authority.main_entry', this.authId + ).subscribe(meta => this.authMeta = meta); + } + }); + } - return this.net.request( - 'open-ils.search', - 'open-ils.search.authority.main_entry', authIds - ); + // Changing a tab in the UI means changing the route. + // Changing the route ultimately results in changing the tab. + beforeTabChange(evt: NgbTabChangeEvent) { - })).pipe(map(authMeta => { + // prevent tab changing until after route navigation + evt.preventDefault(); - const oOrg = this.org.get(authMeta.authority.owner()); + this.authTab = evt.nextId; + this.routeToTab(); + } - return { - authority: authMeta.authority, - link_count: authMeta.linked_bibs.length, - heading: authMeta.heading, - thesaurus: authMeta.thesaurus, - thesaurus_code: authMeta.thesaurus_code, - owner: oOrg ? oOrg.shortname() : '' - }; - })); + routeToTab() { + const url = + `/staff/cat/authority/manage/${this.authId}/${this.authTab}`; + this.router.navigate([url]); } - search(offset?: number) { - if (offset) { this.searchOffset += offset; } - this.grid.reload(); + loadLinkedBibs(): Observable { + + return empty(); } } diff --git a/Open-ILS/src/eg2/src/app/staff/cat/authority/routing.module.ts b/Open-ILS/src/eg2/src/app/staff/cat/authority/routing.module.ts index cd688a86cd..b3fcf36447 100644 --- a/Open-ILS/src/eg2/src/app/staff/cat/authority/routing.module.ts +++ b/Open-ILS/src/eg2/src/app/staff/cat/authority/routing.module.ts @@ -1,6 +1,7 @@ import {NgModule} from '@angular/core'; import {RouterModule, Routes} from '@angular/router'; import {AuthorityMarcEditComponent} from './marc-edit.component'; +import {BrowseAuthorityComponent} from './browse.component'; import {ManageAuthorityComponent} from './manage.component'; const routes: Routes = [{ @@ -10,7 +11,13 @@ const routes: Routes = [{ path: 'edit/:id', component: AuthorityMarcEditComponent }, { - path: 'manage', + path: 'browse', + component: BrowseAuthorityComponent + }, { + path: 'manage/:id/:tab', + component: ManageAuthorityComponent + }, { + path: 'manage/:id/:tab', component: ManageAuthorityComponent }]; diff --git a/Open-ILS/src/eg2/src/app/staff/share/bib-list/bib-list.component.html b/Open-ILS/src/eg2/src/app/staff/share/bib-list/bib-list.component.html new file mode 100644 index 0000000000..df01a5c31e --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/share/bib-list/bib-list.component.html @@ -0,0 +1,16 @@ + + + {{row.title()}} + + + + + + + + + + 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 new file mode 100644 index 0000000000..84d8a37544 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/share/bib-list/bib-list.component.ts @@ -0,0 +1,75 @@ +import {Component, Input, OnInit, ViewChild} from '@angular/core'; +import {Observable, empty} from 'rxjs'; +import {map, switchMap} from 'rxjs/operators'; +import {IdlObject} from '@eg/core/idl.service'; +import {Pager} from '@eg/share/util/pager'; +import {NetService} from '@eg/core/net.service'; +import {PcrudService} from '@eg/core/pcrud.service'; +import {OrgService} from '@eg/core/org.service'; +import {GridComponent} from '@eg/share/grid/grid.component'; +import {GridContext, GridDataSource, GridCellTextGenerator} from '@eg/share/grid/grid'; +import {ComboboxEntry} from '@eg/share/combobox/combobox.component'; + + +/* List of bib records and associated actions */ + +@Component({ + templateUrl: 'bib-list.component.html', + selector: 'eg-bib-list' +}) +export class BibListComponent implements OnInit { + + // Display bibs linked to this authority record. + @Input() bibIds: number[]; + + @Input() bucketId: number; // TODO + + @Input() gridPersistKey: string; + + dataSource: GridDataSource; + cellTextGenerator: GridCellTextGenerator; + + @ViewChild('grid', {static: false}) grid: GridComponent; + + constructor( + private net: NetService, + private org: OrgService, + private pcrud: PcrudService + ) { + } + + ngOnInit() { + this.dataSource = new GridDataSource(); + + this.dataSource.getRows = (pager: Pager, sort: any): Observable => { + + if (this.bibIds) { + return this.loadIds(pager, sort); + } + + return empty(); + } + + this.cellTextGenerator = { + }; + } + + loadIds(pager: Pager, sort: any): Observable { + if (this.bibIds.length === 0) { + return empty(); + } + + return this.pcrud.search('rmsr', {id: this.bibIds}, { + order_by: {}, /* todo */ + limit: pager.limit, + offset: pager.offset, + flesh: 2, + flesh_fields: { + rmsr: ['bib_record'], + bre: ['creator', 'editor'] + } + }); + } +} + + diff --git a/Open-ILS/src/eg2/src/app/staff/share/bib-list/bib-list.module.ts b/Open-ILS/src/eg2/src/app/staff/share/bib-list/bib-list.module.ts new file mode 100644 index 0000000000..3767156e92 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/share/bib-list/bib-list.module.ts @@ -0,0 +1,20 @@ +import {NgModule} from '@angular/core'; +import {StaffCommonModule} from '@eg/staff/common.module'; +import {BibListComponent} from './bib-list.component'; + +@NgModule({ + declarations: [ + BibListComponent + ], + imports: [ + StaffCommonModule + ], + exports: [ + BibListComponent + ], + providers: [ + ] +}) + +export class BibListModule {} + -- 2.11.0