<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"/>
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,
--- /dev/null
+<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>
--- /dev/null
+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()
+ };
+ }));
+ }
+}
+
+
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',
}, {
path: 'edit/:id',
component: AuthorityMarcEditComponent
+ }, {
+ path: 'manage',
+ component: ManageAuthorityComponent
}];
@NgModule({
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;