+++ /dev/null
-import {Component, Host, Input, OnInit, Output, ViewChildren, QueryList, AfterViewInit} from '@angular/core';
-import {MarcSimplifiedEditorComponent} from './simplified-editor.component';
-import {MarcField, MarcSubfield} from '../marcrecord';
-import { MarcSimplifiedEditorSubfieldComponent } from './simplified-editor-subfield.component';
-
-/**
- * A field that a user can edit, which will later be
- * compiled into MARC
- */
-
-@Component({
- selector: 'eg-marc-simplified-editor-field',
- template: '<ng-template></ng-template>'
-})
-export class MarcSimplifiedEditorFieldComponent implements OnInit, AfterViewInit {
-
- @Input() tag = 'a';
- @Input() ind1 = ' ';
- @Input() ind2 = ' ';
-
- @ViewChildren(MarcSimplifiedEditorSubfieldComponent)
- subfields: QueryList<MarcSimplifiedEditorSubfieldComponent>;
-
- marcVersion: MarcField;
-
- addSubfield: (subfield: MarcSubfield) => void;
-
- constructor(@Host() private editor: MarcSimplifiedEditorComponent) {}
-
- ngOnInit() {
- this.marcVersion = {
- tag: this.tag,
- authValid: false,
- authChecked: false,
- isCtrlField: false,
- isControlfield: () => false,
- indicator: (ind: number) => (ind === 1) ? this.ind1 : this.ind2,
- deleteExactSubfields: (...subfield: MarcSubfield[]) => 0, // not used by the simplified editor
- };
- }
-
- ngAfterViewInit() {
- this.subfields.forEach((subfield: MarcSimplifiedEditorSubfieldComponent, index: number) => {
- this.marcVersion.subfields.push(
- [
- subfield.code,
- subfield.defaultValue ? subfield.defaultValue : '',
- index
- ]
- );
- });
- this.editor.addField(this.marcVersion);
- }
-
-}
-
-
-
--- /dev/null
+import {Directive, Host, Input, OnInit, ViewChildren, QueryList, AfterViewInit} from '@angular/core';
+import {MarcSimplifiedEditorComponent} from './simplified-editor.component';
+import {MarcField, MarcSubfield} from '../marcrecord';
+import {MarcSimplifiedEditorSubfieldDirective} from './simplified-editor-subfield.directive';
+
+/**
+ * A field that a user can edit, which will later be
+ * compiled into MARC
+ */
+
+@Directive({
+ selector: 'eg-marc-simplified-editor-field',
+})
+export class MarcSimplifiedEditorFieldDirective implements OnInit, AfterViewInit {
+
+ @Input() tag = 'a';
+ @Input() ind1 = ' ';
+ @Input() ind2 = ' ';
+
+ @ViewChildren(MarcSimplifiedEditorSubfieldDirective)
+ subfields: QueryList<MarcSimplifiedEditorSubfieldDirective>;
+
+ marcVersion: MarcField;
+
+ constructor(@Host() private editor: MarcSimplifiedEditorComponent) {}
+
+ ngOnInit() {
+ this.marcVersion = {
+ tag: this.tag,
+ subfields: [],
+ authValid: false,
+ authChecked: false,
+ isCtrlField: false,
+ isControlfield: () => false,
+ indicator: (ind: number) => (ind === 1) ? this.ind1 : this.ind2,
+ deleteExactSubfields: (...subfield: MarcSubfield[]) => 0, // not used by the simplified editor
+ };
+ }
+
+ ngAfterViewInit() {
+ this.subfields.forEach((subfield: MarcSimplifiedEditorSubfieldDirective, index: number) => {
+ this.marcVersion.subfields.push(
+ [
+ subfield.code,
+ subfield.defaultValue ? subfield.defaultValue : '',
+ index
+ ]
+ );
+ });
+ this.editor.addField(this.marcVersion);
+ }
+
+}
+
+
+
+++ /dev/null
-import {Component, Input} from '@angular/core';
-
-/**
- * A subfield that a user can edit, which will later be
- * compiled into MARC
- */
-
-@Component({
- selector: 'eg-marc-simplified-editor-subfield',
- template: '<ng-template></ng-template>'
-})
-export class MarcSimplifiedEditorSubfieldComponent {
-
- @Input() code: string;
- @Input() defaultValue: string;
-
-}
--- /dev/null
+import {Directive, Input} from '@angular/core';
+
+/**
+ * A subfield that a user can edit, which will later be
+ * compiled into MARC
+ */
+
+@Directive({
+ selector: 'eg-marc-simplified-editor-subfield',
+})
+export class MarcSimplifiedEditorSubfieldDirective {
+
+ @Input() code: string;
+ @Input() defaultValue: string;
+
+}
const record = new MarcRecord('<record xmlns="http://www.loc.gov/MARC21/slim"></record>');
// need to add the value to field.subfields[0][1]
this.fields.forEach((field) => {
- if (field.subfields[0][1] === '') { // Default value has not been applied
- field.subfields[0][1] = this.editor.get(String(field.fieldId)).value;
- }
+ field.subfields.forEach((subfield) => {
+ if (subfield[1] === '') { // Default value has not been applied
+ subfield[1] = this.editor.get(String(field.fieldId)).value;
+ }
+ })
});
record.fields = this.fields;
this.xmlRecordEvent.emit(record.toXml());
import {StaffCommonModule} from '@eg/staff/common.module';
import {CommonWidgetsModule} from '@eg/share/common-widgets.module';
import {MarcSimplifiedEditorComponent} from './simplified-editor.component';
-import {MarcSimplifiedEditorFieldComponent} from './simplified-editor-field.component';
-import {MarcSimplifiedEditorSubfieldComponent} from './simplified-editor-subfield.component';
+import {MarcSimplifiedEditorFieldDirective} from './simplified-editor-field.directive';
+import {MarcSimplifiedEditorSubfieldDirective} from './simplified-editor-subfield.directive';
import {TagTableService} from '../tagtable.service';
@NgModule({
declarations: [
MarcSimplifiedEditorComponent,
- MarcSimplifiedEditorFieldComponent,
- MarcSimplifiedEditorSubfieldComponent,
+ MarcSimplifiedEditorFieldDirective,
+ MarcSimplifiedEditorSubfieldDirective,
],
imports: [
StaffCommonModule,
],
exports: [
MarcSimplifiedEditorComponent,
- MarcSimplifiedEditorFieldComponent,
- MarcSimplifiedEditorSubfieldComponent
+ MarcSimplifiedEditorFieldDirective,
+ MarcSimplifiedEditorSubfieldDirective
],
providers: [
TagTableService