LP1879335 Manage Authorities Angular WIP
authorBill Erickson <berickxx@gmail.com>
Fri, 15 May 2020 19:11:06 +0000 (15:11 -0400)
committerBill Erickson <berickxx@gmail.com>
Mon, 18 May 2020 14:25:15 +0000 (10:25 -0400)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/examples/fm_IDL.xml
Open-ILS/src/eg2/src/app/staff/cat/authority/authority.module.ts
Open-ILS/src/eg2/src/app/staff/cat/authority/manage.component.html [new file with mode: 0644]
Open-ILS/src/eg2/src/app/staff/cat/authority/manage.component.ts [new file with mode: 0644]
Open-ILS/src/eg2/src/app/staff/cat/authority/routing.module.ts
Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Authority.pm

index 560d372..95db05c 100644 (file)
@@ -2768,6 +2768,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
                        <field name="record" reporter:datatype="link" />
                        <field name="atag" reporter:datatype="link" />
                        <field name="value" reporter:datatype="text" />
+                       <field name="thesaurus" reporter:datatype="text" />
                </fields>
                <links>
                        <link field="record" reltype="has_a" key="id" map="" class="are"/>
index ded954a..c6b8d6e 100644 (file)
@@ -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 (file)
index 0000000..ab508f8
--- /dev/null
@@ -0,0 +1,10 @@
+<eg-staff-banner bannerText="Manage Authority Records" i18n-bannerText>
+</eg-staff-banner>
+
+<eg-grid #grid [dataSource]="dataSource">
+  <eg-grid-column name="id" label="ID" i18n-label [index]="true"></eg-grid-column>
+  <eg-grid-column name="link_count" label="Linked Bibs" i18n-label></eg-grid-column>
+  <eg-grid-column name="heading" label="Heading" i18n-label></eg-grid-column>
+  <eg-grid-column name="control_set" label="Control Set" i18n-label></eg-grid-column>
+  <eg-grid-column name="thesaurus" label="Thesaurus" i18n-label></eg-grid-column>
+</eg-grid>
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 (file)
index 0000000..f0f7a3e
--- /dev/null
@@ -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<any> => {
+            return this.loadAuthorities(pager, sort);
+        }
+    }
+
+    loadAuthorities(pager: Pager, sort: any): Observable<any> {
+
+        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()
+            };
+        }));
+    }
+}
+
+
index cd6b3a1..cd688a8 100644 (file)
@@ -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({
index 2e90ae2..c8e99cb 100644 (file)
@@ -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;