From: Bill Erickson Date: Fri, 6 Dec 2019 16:54:26 +0000 (-0500) Subject: LPXXX help and more X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=a188f17e43290a50e5f1038a885853585127aa22;p=working%2FEvergreen.git LPXXX help and more Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/src/eg2/src/app/staff/share/marc-edit/editable-content.component.ts b/Open-ILS/src/eg2/src/app/staff/share/marc-edit/editable-content.component.ts index 96d71acf86..c26578b727 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/marc-edit/editable-content.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/share/marc-edit/editable-content.component.ts @@ -4,7 +4,7 @@ import {Subscription} from 'rxjs'; import {filter} from 'rxjs/operators'; import {MarcRecord, MarcField, MarcSubfield} from './marcrecord'; import {MarcEditContext, FieldFocusRequest, MARC_EDITABLE_FIELD_TYPE, - UndoRedoAction} from './editor-context'; + TextUndoRedoAction} from './editor-context'; import {ContextMenuEntry} from '@eg/share/context-menu/context-menu.service'; import {TagTableService} from './tagtable.service'; @@ -68,9 +68,9 @@ export class EditableContentComponent } watchForUndoRedoRequests() { - this.undoRedoSub = this.context.undoRedoRequest.pipe( - filter((action: UndoRedoAction) => this.focusRequestIsMe(action.position))) - .subscribe((action: UndoRedoAction) => this.processUndoRedo(action)); + this.undoRedoSub = this.context.textUndoRedoRequest.pipe( + filter((action: TextUndoRedoAction) => this.focusRequestIsMe(action.position))) + .subscribe((action: TextUndoRedoAction) => this.processUndoRedo(action)); } focusRequestIsMe(req: FieldFocusRequest): boolean { @@ -219,7 +219,7 @@ export class EditableContentComponent const lastUndo = this.context.undoStack[0]; if (lastUndo - && lastUndo.textContent !== undefined + && lastUndo instanceof TextUndoRedoAction && lastUndo.textContent === this.undoBackToText && this.focusRequestIsMe(lastUndo.position)) { // Most recent undo entry was a text change event within the @@ -228,17 +228,16 @@ export class EditableContentComponent return; } - const undo = { - textContent: this.undoBackToText, - position: this.context.lastFocused - }; + const undo = new TextUndoRedoAction(); + undo.position = this.context.lastFocused; + undo.textContent = this.undoBackToText; this.context.undoStack.unshift(undo); } // Apply the undo or redo action and track its opposite // action on the necessary stack - processUndoRedo(action: UndoRedoAction) { + processUndoRedo(action: TextUndoRedoAction) { // Undoing a text change const recoverContent = this.getContent(); diff --git a/Open-ILS/src/eg2/src/app/staff/share/marc-edit/editor-context.ts b/Open-ILS/src/eg2/src/app/staff/share/marc-edit/editor-context.ts index 0e48cb7baa..9e097af8ce 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/marc-edit/editor-context.ts +++ b/Open-ILS/src/eg2/src/app/staff/share/marc-edit/editor-context.ts @@ -15,39 +15,41 @@ export interface FieldFocusRequest { sfOffset?: number; // focus a specific subfield by its offset } -export interface UndoRedoAction { - +export class UndoRedoAction { // Which point in the record was modified. position: FieldFocusRequest; - isRedo?: boolean; - - // Track text changes. - textContent?: string; + // Which stack do we toss this on once it's been applied? + isRedo: boolean; +} - // Retain a copy of the affected field so deletion - // recovery can extract what's needed. - field?: MarcField; +export class TextUndoRedoAction extends UndoRedoAction { + textContent: string; +} - // If this is a subfield modification. - subfield?: MarcSubfield; +export class StructUndoRedoAction extends UndoRedoAction { + /* Add or remove a part of the record (field, subfield, etc.) */ // Does this action track an addition or deletion. - wasAddition?: boolean; + wasAddition: boolean; + + // Field to add/delete or field to modify for subfield adds/deletes + field: MarcField; + + // If this is a subfield modification. + subfield: MarcSubfield; // Position preceding the modified position to mark the position // of deletion recovery. - prevPosition?: FieldFocusRequest; - - // Where should focus be returned once the undo is processed? - prevFocus?: FieldFocusRequest; + prevPosition: FieldFocusRequest; } + export class MarcEditContext { recordChange: EventEmitter; fieldFocusRequest: EventEmitter; - undoRedoRequest: EventEmitter; + textUndoRedoRequest: EventEmitter; recordType: 'biblio' | 'authority' = 'biblio'; lastFocused: FieldFocusRequest = null; @@ -71,7 +73,7 @@ export class MarcEditContext { constructor() { this.recordChange = new EventEmitter(); this.fieldFocusRequest = new EventEmitter(); - this.undoRedoRequest = new EventEmitter(); + this.textUndoRedoRequest = new EventEmitter(); } requestFieldFocus(req: FieldFocusRequest) { @@ -100,19 +102,19 @@ export class MarcEditContext { } distributeUndoRedo(action: UndoRedoAction) { - if (action.textContent !== undefined) { + if (action instanceof TextUndoRedoAction) { // Let the editable content component handle it. - this.undoRedoRequest.emit(action); + this.textUndoRedoRequest.emit(action); } else { // Manage structural changes within - this.handleStructuralUndoRedo(action); + this.handleStructuralUndoRedo(action as StructUndoRedoAction); } } - handleStructuralUndoRedo(action: UndoRedoAction) { + handleStructuralUndoRedo(action: StructUndoRedoAction) { if (action.wasAddition) { - // Remove the added field and focus the field before it. + // Remove the added field if (action.subfield) { @@ -122,11 +124,17 @@ export class MarcEditContext { } else { this.record.deleteFields(action.field); - this.requestFieldFocus(action.prevPosition); + + if (this.lastFocused.fieldId === action.field.fieldId) { + // If the field we are deleting is currently focused, + // move focus to the previous field. Otherwse, leave + // the focus where it is. + this.requestFieldFocus(action.prevPosition); + } } } else { - // Re-insert the removed field and focus it + // Re-insert the removed field and focus it. if (action.subfield) { @@ -176,14 +184,12 @@ export class MarcEditContext { } } - const action = { - field: field, - subfield: subfield, - wasAddition: isAddition, - position: position, - prevPosition: prevPos, - prevFocus: this.lastFocused - }; + const action = new StructUndoRedoAction(); + action.field = field; + action.subfield = subfield; + action.wasAddition = isAddition; + action.position = position; + action.prevPosition = prevPos; this.undoStack.unshift(action); } 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 bd7c559457..dea85817e1 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 @@ -19,6 +19,13 @@
+ +

+ + Record Type {{record ? record.recordType() : ''}} + +

+
+
+
+
+
+
+ + +
+
+
+
+ +
+
+
    +
  • Undo: CTRL-z
  • +
  • Redo: CTRL-y
  • +
  • Add Row: CTRL+Enter
  • +
  • Insert Row: CTRL+Shift+Enter
  • +
+
+
+
    +
  • Copy Current Row Above: CTRL+Up
  • +
  • Copy Current Row Below: CTRL+Down
  • +
  • Add Subfield: CTRL+D or CTRL+I
  • +
  • Remove Row: CTRL+Del
  • +
+
+
+
    +
  • Remove Subfield: Shift+Del
  • +
  • Create/Replace 006: Shift+F6
  • +
  • Create/Replace 007: Shift+F7
  • +
  • Create/Replace 008: Shift+F8
  • +
+
diff --git a/Open-ILS/src/eg2/src/app/staff/share/marc-edit/rich-editor.component.ts b/Open-ILS/src/eg2/src/app/staff/share/marc-edit/rich-editor.component.ts index d7fc2a1a70..aa03c20c53 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/marc-edit/rich-editor.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/share/marc-edit/rich-editor.component.ts @@ -23,6 +23,9 @@ export class MarcRichEditorComponent implements OnInit { get record(): MarcRecord { return this.context.record; } dataLoaded: boolean; + showHelp: boolean; + randId = Math.floor(Math.random() * 100000); + stackSubfields: boolean; constructor( private idl: IdlService,