From 59225ac15b26a82c6ed03125bb9a1e45d49ae567 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Fri, 15 May 2020 15:11:06 -0400 Subject: [PATCH] LP1879335 Manage Authorities Angular WIP Signed-off-by: Bill Erickson --- Open-ILS/examples/fm_IDL.xml | 1 + .../app/staff/cat/authority/authority.module.ts | 4 +- .../app/staff/cat/authority/manage.component.html | 10 +++ .../app/staff/cat/authority/manage.component.ts | 64 +++++++++++++++++++ .../src/app/staff/cat/authority/routing.module.ts | 4 ++ .../lib/OpenILS/Application/Search/Authority.pm | 72 ++++++++++++++++++++++ 6 files changed, 154 insertions(+), 1 deletion(-) create mode 100644 Open-ILS/src/eg2/src/app/staff/cat/authority/manage.component.html create mode 100644 Open-ILS/src/eg2/src/app/staff/cat/authority/manage.component.ts diff --git a/Open-ILS/examples/fm_IDL.xml b/Open-ILS/examples/fm_IDL.xml index 560d372eab..95db05ca97 100644 --- a/Open-ILS/examples/fm_IDL.xml +++ b/Open-ILS/examples/fm_IDL.xml @@ -2768,6 +2768,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + 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 ded954a9c7..c6b8d6e245 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,10 +4,12 @@ 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 {ManageAuthorityComponent} from './manage.component'; @NgModule({ declarations: [ - AuthorityMarcEditComponent + AuthorityMarcEditComponent, + ManageAuthorityComponent ], imports: [ StaffCommonModule, 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 new file mode 100644 index 0000000000..ab508f81c8 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/cat/authority/manage.component.html @@ -0,0 +1,10 @@ + + + + + + + + + + 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 new file mode 100644 index 0000000000..f0f7a3e503 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/cat/authority/manage.component.ts @@ -0,0 +1,64 @@ +import {Component, OnInit, ViewChild} from '@angular/core'; +import {Observable} 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 {GridContext, GridDataSource} from '@eg/share/grid/grid'; +import {ComboboxEntry} from '@eg/share/combobox/combobox.component'; + +/* Find, merge, and edit authority records */ + +@Component({ + templateUrl: 'manage.component.html' +}) +export class ManageAuthorityComponent implements OnInit { + + authorityAxis: string; + authorityAxes: ComboboxEntry[]; + dataSource: GridDataSource; + + constructor( + private net: NetService, + private pcrud: PcrudService + ) { + } + + ngOnInit() { + + // TODO fetch axes + + this.dataSource = new GridDataSource(); + + this.dataSource.getRows = (pager: Pager, sort: any): Observable => { + return this.loadAuthorities(pager, sort); + } + } + + loadAuthorities(pager: Pager, sort: any): Observable { + + return this.net.request( + 'open-ils.supercat', + 'open-ils.supercat.authority.browse.by_axis', + 'subject', 'g', pager.limit, pager.offset + + ).pipe(switchMap(authIds => { + return this.net.request( + 'open-ils.search', + 'open-ils.search.authority.main_entry', authIds + ); + + })).pipe(map(authMeta => { + return { + id: authMeta.authority_id, + link_count: authMeta.linked_bibs.length, + heading: authMeta.heading.value(), + control_set: authMeta.control_set.name(), + thesaurus: authMeta.heading.thesaurus() + }; + })); + } +} + + 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 cd6b3a138f..cd688a86cd 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 {ManageAuthorityComponent} from './manage.component'; const routes: Routes = [{ path: 'edit', @@ -8,6 +9,9 @@ const routes: Routes = [{ }, { path: 'edit/:id', component: AuthorityMarcEditComponent + }, { + path: 'manage', + component: ManageAuthorityComponent }]; @NgModule({ diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Authority.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Authority.pm index 2e90ae23b3..c8e99cb29e 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Authority.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Authority.pm @@ -338,6 +338,78 @@ sub crossref_authority_batch2 { return $response; } +__PACKAGE__->register_method( + method => "authority_main_entry", + api_name => "open-ils.search.authority.main_entry", + stream => 1, + signature => { + desc => q/ + Returns the main entry details for one or more authority + records plus a few other details. + /, + params => [ + {desc => 'Authority IDs', type => 'number or array'} + ], + return => { + desc => q/ + Stream of authority metadata objects. + { authority_id: $id, + heading: $main_entry_heading, # fleshed atag + control_set: $control_set, + linked_bibs: [$id1, $id2, ...] + } + /, + type => 'object' + } + } +); + +sub authority_main_entry { + my ($self, $client, $auth_ids) = @_; + + $auth_ids = [$auth_ids] unless ref $auth_ids; + + my $e = new_editor(); + + for my $auth_id (@$auth_ids) { + + my $rec = $e->retrieve_authority_record_entry([ + $auth_id, { + flesh => 1, + flesh_fields => {are => [qw/control_set bib_links/]} + } + ]) or return $e->event; + + my $main_entry = $e->json_query({ + select => {ash => [qw/id/]}, + from => {ash => 'acsaf'}, + where => { + '+ash' => {record => $auth_id}, + '+acsaf' => {main_entry => undef} + }, + limit => 1 + })->[0]; + + my $response = { + authority_id => $auth_id, + control_set => $rec->control_set, + linked_bibs => [ map {$_->bib} @{$rec->bib_links} ] + }; + + if ($main_entry) { + $response->{heading} = + $e->search_authority_simple_heading([ + {id => $main_entry->{id}}, + {flesh => 1, flesh_fields => {ash => [qw/atag/]}} + ])->[0]; + } + + $client->respond($response); + } + + return undef; +} + 1; -- 2.11.0