From: Bill Erickson Date: Fri, 28 Jun 2019 15:22:17 +0000 (-0400) Subject: angular flat marc edit X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=e51f990a267173a5cf2b60a15ea97b781e9c4990;p=working%2FEvergreen.git angular flat marc edit Signed-off-by: Bill Erickson --- 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 5b8de510cf..fdaf7e50cd 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 @@ -1,4 +1,18 @@ + + + + + + + +
@@ -9,8 +23,16 @@ i18n-placeholder>
- + + + + + + +
@@ -44,8 +66,8 @@
- +
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 b0addaca51..88d5a3052a 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 @@ -8,6 +8,8 @@ import {PcrudService} from '@eg/core/pcrud.service'; import {MarcRecord} from './marcrecord'; import {ComboboxEntry, ComboboxComponent } from '@eg/share/combobox/combobox.component'; +import {ConfirmDialogComponent} from '@eg/share/dialog/confirm.component'; + /** * MARC Record editor main interface. @@ -45,6 +47,9 @@ export class MarcEditorComponent implements OnInit { @Output() recordSaved: EventEmitter; @ViewChild('sourceSelector') sourceSelector: ComboboxComponent; + @ViewChild('confirmDelete') confirmDelete: ConfirmDialogComponent; + @ViewChild('confirmUndelete') confirmUndelete: ConfirmDialogComponent; + @ViewChild('cannotDelete') cannotDelete: ConfirmDialogComponent; constructor( private evt: EventService, @@ -114,6 +119,7 @@ export class MarcEditorComponent implements OnInit { .toPromise().then(bib => { this.record = new MarcRecord(bib.marc()); this.record.id = id; + this.record.deleted = bib.deleted() === 't'; if (bib.source()) { this.sourceSelector.applyEntryId(+bib.source()); } @@ -124,7 +130,53 @@ export class MarcEditorComponent implements OnInit { this.record = new MarcRecord(xml); this.record.id = null; } -} + deleteRecord(): Promise { + + return this.confirmDelete.open().toPromise() + .then(yes => { + if (!yes) { return; } + + return this.net.request('open-ils.cat', + 'open-ils.cat.biblio.record_entry.delete', + this.auth.token(), this.record.id).toPromise() + + .then(resp => { + + const evt = this.evt.parse(resp); + if (evt) { + if (evt.textcode === 'RECORD_NOT_EMPTY') { + return this.cannotDelete.open().toPromise(); + } else { + console.error(evt); + return alert(evt); + } + } + return this.fromId(this.record.id) + .then(_ => this.recordSaved.emit(this.record.toXml())); + }); + }); + } + undeleteRecord(): Promise { + + return this.confirmUndelete.open().toPromise() + .then(yes => { + if (!yes) { return; } + + return this.net.request('open-ils.cat', + 'open-ils.cat.biblio.record_entry.undelete', + this.auth.token(), this.record.id).toPromise() + + .then(resp => { + + const evt = this.evt.parse(resp); + if (evt) { console.error(evt); return alert(evt); } + + return this.fromId(this.record.id) + .then(_ => this.recordSaved.emit(this.record.toXml())); + }); + }); + } +} diff --git a/Open-ILS/src/eg2/src/app/staff/share/marc-edit/marcrecord.ts b/Open-ILS/src/eg2/src/app/staff/share/marc-edit/marcrecord.ts index bb815f7a98..1b0c488e46 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/marc-edit/marcrecord.ts +++ b/Open-ILS/src/eg2/src/app/staff/share/marc-edit/marcrecord.ts @@ -7,6 +7,7 @@ declare var MARC21; export class MarcRecord { id: number; // Database ID when known. + deleted: boolean; record: any; // MARC21.Record object breakerText: string;