From: Jane Sandberg Date: Tue, 1 Sep 2020 19:45:57 +0000 (-0700) Subject: LP1849212: try to add comboboxes to simplified editor X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=dbf223898077386dfacf092e83cf0e7346bd262b;p=working%2FEvergreen.git LP1849212: try to add comboboxes to simplified editor Signed-off-by: Jane Sandberg --- diff --git a/Open-ILS/src/eg2/src/app/staff/admin/local/course-reserves/course-associate-material.component.html b/Open-ILS/src/eg2/src/app/staff/admin/local/course-reserves/course-associate-material.component.html index da6036063a..2b3cdfa9df 100644 --- a/Open-ILS/src/eg2/src/app/staff/admin/local/course-reserves/course-associate-material.component.html +++ b/Open-ILS/src/eg2/src/app/staff/admin/local/course-reserves/course-associate-material.component.html @@ -162,7 +162,8 @@ placeholder="e.g. Required" class="flex-grow-1" /> - + diff --git a/Open-ILS/src/eg2/src/app/staff/share/marc-edit/simplified-editor/simplified-editor.component.html b/Open-ILS/src/eg2/src/app/staff/share/marc-edit/simplified-editor/simplified-editor.component.html index aeecb1c55e..df23cb98e4 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/marc-edit/simplified-editor/simplified-editor.component.html +++ b/Open-ILS/src/eg2/src/app/staff/share/marc-edit/simplified-editor/simplified-editor.component.html @@ -1,5 +1,17 @@ - +
+
+
Form
+
+ +
+
+
+
Type
+
+ +
+
diff --git a/Open-ILS/src/eg2/src/app/staff/share/marc-edit/simplified-editor/simplified-editor.component.ts b/Open-ILS/src/eg2/src/app/staff/share/marc-edit/simplified-editor/simplified-editor.component.ts index 2675f259cd..15db235eaf 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/marc-edit/simplified-editor/simplified-editor.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/share/marc-edit/simplified-editor/simplified-editor.component.ts @@ -1,7 +1,13 @@ import {AfterViewInit, Component, EventEmitter, Input, OnInit, Output} from '@angular/core'; -import {FormGroup, FormControl, ValidationErrors, ValidatorFn, FormArray} from '@angular/forms'; +import {FormGroup, FormControl} from '@angular/forms'; import {MarcField, MarcRecord} from '../marcrecord'; import {TagTableService} from '../tagtable.service'; +import {NetService} from '@eg/core/net.service'; +import { ComboboxEntry } from '@eg/share/combobox/combobox.component'; +import { Observable, of } from 'rxjs'; +import { switchMap } from 'rxjs/operators'; + +const DEFAULT_RECORD_TYPE = 'BKS'; /** * A simplified editor for basic MARC records, which @@ -16,9 +22,12 @@ export class MarcSimplifiedEditorComponent implements AfterViewInit, OnInit { @Input() buttonLabel: string; @Output() xmlRecordEvent = new EventEmitter(); + @Input() defaultMarcForm: string; fields: MarcField[] = []; editor: FormGroup; + marcForms: ComboboxEntry[]; + marcTypes: ComboboxEntry[]; // DOM id prefix to prevent id collisions. idPrefix: string; @@ -31,13 +40,17 @@ export class MarcSimplifiedEditorComponent implements AfterViewInit, OnInit { editorFieldIdentifier: (field: MarcField, subfield: Array) => string; constructor( + private net: NetService, private tagTable: TagTableService ) {} ngOnInit() { // Add some randomness to the generated DOM IDs to ensure against clobbering this.idPrefix = 'marc-simplified-editor-' + Math.floor(Math.random() * 100000); - this.editor = new FormGroup({}); + this.editor = new FormGroup({ + marcForm: new FormControl(), + marcType: new FormControl() + }); // Add a fieldId, and then add a new field to the array this.addField = (field: MarcField) => { @@ -53,6 +66,24 @@ export class MarcSimplifiedEditorComponent implements AfterViewInit, OnInit { return field.tag + subfield[0]; // e.g. 245a } + this.net.request('open-ils.cat', + 'open-ils.cat.biblio.fixed_field_values.by_rec_type', + DEFAULT_RECORD_TYPE, 'Form') + .subscribe((forms) => { + this.marcForms = forms['Form'].map((form) => { + return {id: form[0], label: form[1]} + }) + }); + + this.net.request('open-ils.cat', + 'open-ils.cat.biblio.fixed_field_values.by_rec_type', + DEFAULT_RECORD_TYPE, 'Type') + .subscribe((types) => { + this.marcTypes = types['Type'].map((type) => { + return {id: type[0], label: type[1]} + }) + }); + } ngAfterViewInit() { @@ -76,9 +107,23 @@ export class MarcSimplifiedEditorComponent implements AfterViewInit, OnInit { }) }); record.fields = this.fields; + record.setFixedField('Type', this.appropriateMarcType); + record.setFixedField('Form', this.appropriateMarcForm); this.xmlRecordEvent.emit(record.toXml()); } + get appropriateMarcType(): string { + return this.editor.get('marcType').value ? this.editor.get('marcType').value.id : 'a'; + } + + get appropriateMarcForm(): string { + if (this.editor.get('marcForm').value) { + return this.editor.get('marcForm').value.id; + } + return this.defaultMarcForm ? this.defaultMarcForm : ' '; + } + + }