From 05d131857f417ffb828050abce6160fd963b7f6b Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Thu, 27 Jun 2019 17:18:44 -0400 Subject: [PATCH] angular flat marc edit Signed-off-by: Bill Erickson --- .../staff/share/marc-edit/editor.component.html | 7 +++++ .../app/staff/share/marc-edit/editor.component.ts | 31 +++++++++++++++++----- .../share/marc-edit/flat-editor.component.html | 2 +- .../staff/share/marc-edit/flat-editor.component.ts | 9 +++++++ .../app/staff/share/marc-edit/marc-edit.module.ts | 4 +-- 5 files changed, 44 insertions(+), 9 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/staff/share/marc-edit/editor.component.html b/Open-ILS/src/eg2/src/app/staff/share/marc-edit/editor.component.html index 4b1171a255..5b8de510cf 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/marc-edit/editor.component.html +++ b/Open-ILS/src/eg2/src/app/staff/share/marc-edit/editor.component.html @@ -2,6 +2,13 @@
+
+ + +
diff --git a/Open-ILS/src/eg2/src/app/staff/share/marc-edit/editor.component.ts b/Open-ILS/src/eg2/src/app/staff/share/marc-edit/editor.component.ts index f0ec986e1d..e2a91f47a9 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/marc-edit/editor.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/share/marc-edit/editor.component.ts @@ -1,4 +1,4 @@ -import {Component, Input, Output, OnInit, EventEmitter} from '@angular/core'; +import {Component, Input, Output, OnInit, EventEmitter, ViewChild} from '@angular/core'; import {IdlService} from '@eg/core/idl.service'; import {EventService} from '@eg/core/event.service'; import {NetService} from '@eg/core/net.service'; @@ -6,6 +6,8 @@ import {AuthService} from '@eg/core/auth.service'; import {OrgService} from '@eg/core/org.service'; import {PcrudService} from '@eg/core/pcrud.service'; import {MarcRecord} from './marcrecord'; +import {ComboboxEntry, ComboboxComponent + } from '@eg/share/combobox/combobox.component'; /** * MARC Record editor main interface. @@ -20,6 +22,7 @@ export class MarcEditorComponent implements OnInit { record: MarcRecord; editorTab: 'rich' | 'flat'; + sources: ComboboxEntry[]; @Input() set recordId(id: number) { if (!id) { return; } @@ -41,6 +44,8 @@ export class MarcEditorComponent implements OnInit { // the record is successfully saved. @Output() recordSaved: EventEmitter; + @ViewChild('sourceSelector') sourceSelector: ComboboxComponent; + constructor( private evt: EventService, private idl: IdlService, @@ -49,13 +54,23 @@ export class MarcEditorComponent implements OnInit { private org: OrgService, private pcrud: PcrudService ) { + this.sources = []; this.recordSaved = new EventEmitter(); } - ngOnInit() { // Default to flat for now since it's all that's supported. this.editorTab = 'flat'; + + this.pcrud.retrieveAll('cbs').subscribe( + src => this.sources.push({id: +src.id(), label: src.source()}), + _ => {}, + () => { + this.sources = this.sources.sort((a, b) => + a.label.toLowerCase() < b.label.toLowerCase() ? -1 : 1 + ); + } + ); } saveRecord(): Promise { @@ -67,14 +82,15 @@ export class MarcEditorComponent implements OnInit { return Promise.resolve(); } + const source = this.sourceSelector.selected ? + this.sourceSelector.selected.label : null; // 'label' not a typo + if (this.record.id) { // Editing an existing record const method = 'open-ils.cat.biblio.record.marc.replace'; - return this.net.request( - 'open-ils.cat', method, - this.auth.token(), this.record.id, - xml, null /* TODO: record source */ + return this.net.request('open-ils.cat', method, + this.auth.token(), this.record.id, xml, source ).toPromise().then(response => { const evt = this.evt.parse(response); @@ -98,6 +114,9 @@ export class MarcEditorComponent implements OnInit { .toPromise().then(bib => { this.record = new MarcRecord(bib.marc()); this.record.id = id; + if (bib.source()) { + this.sourceSelector.applyEntryId(+bib.source()); + } }); } diff --git a/Open-ILS/src/eg2/src/app/staff/share/marc-edit/flat-editor.component.html b/Open-ILS/src/eg2/src/app/staff/share/marc-edit/flat-editor.component.html index 57f725b2ce..eaf54a92c1 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/marc-edit/flat-editor.component.html +++ b/Open-ILS/src/eg2/src/app/staff/share/marc-edit/flat-editor.component.html @@ -2,6 +2,6 @@
diff --git a/Open-ILS/src/eg2/src/app/staff/share/marc-edit/flat-editor.component.ts b/Open-ILS/src/eg2/src/app/staff/share/marc-edit/flat-editor.component.ts index f51214eee8..74b0729e92 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/marc-edit/flat-editor.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/share/marc-edit/flat-editor.component.ts @@ -30,6 +30,15 @@ export class MarcFlatEditorComponent implements OnInit { } ngOnInit() {} + + // When we have breaker text, limit the vertical expansion of the + // text area to the size of the data plus a little padding. + rowCount(): number { + if (this.record && this.record.breakerText) { + return this.record.breakerText.split(/\n/).length + 2; + } + return 40; + } } diff --git a/Open-ILS/src/eg2/src/app/staff/share/marc-edit/marc-edit.module.ts b/Open-ILS/src/eg2/src/app/staff/share/marc-edit/marc-edit.module.ts index 796fb96c6b..1992fcbfd0 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/marc-edit/marc-edit.module.ts +++ b/Open-ILS/src/eg2/src/app/staff/share/marc-edit/marc-edit.module.ts @@ -1,5 +1,5 @@ import {NgModule} from '@angular/core'; -import {EgCommonModule} from '@eg/common.module'; +import {StaffCommonModule} from '@eg/staff/common.module'; import {MarcEditorComponent} from './editor.component'; import {MarcRichEditorComponent} from './rich-editor.component'; import {MarcFlatEditorComponent} from './flat-editor.component'; @@ -11,7 +11,7 @@ import {MarcFlatEditorComponent} from './flat-editor.component'; MarcFlatEditorComponent ], imports: [ - EgCommonModule + StaffCommonModule ], exports: [ MarcEditorComponent -- 2.11.0