webstaff: Flat Text MARC editor support
authorMike Rylander <mrylander@gmail.com>
Mon, 6 Apr 2015 16:55:47 +0000 (12:55 -0400)
committerJason Stephenson <jstephenson@mvlc.org>
Wed, 19 Aug 2015 17:39:15 +0000 (13:39 -0400)
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Signed-off-by: Jason Stephenson <jstephenson@mvlc.org>
Open-ILS/src/templates/staff/cat/share/t_marcedit.tt2
Open-ILS/web/js/ui/default/staff/cat/services/marcedit.js

index 7dadafd..1e1374e 100644 (file)
 <div>
   <div ng-if="bre" class="row col-md-12 pad-vert marcfastitemadd">
-    <input id="mfiacn" type="text" placeholder="[% l('Call Number:') %]" ng-model="fast_item_callnumber"/>
+    <input id="mfiacn" type="text" placeholder="[% l('Call Number') %]" ng-model="fast_item_callnumber"/>
     <input id="mfiabc" type="text" placeholder="[% l('Barcode') %]" ng-model="fast_item_barcode"/>
     <button class="btn btn-default" ng-click="saveFastItem()">Add Item</button>
   </div>
   <div class="pad-vert row col-md-12 marctypesource">
+    <div class="col-md-2"><label>Flat Text Editor:</label> <input type="checkbox" ng-model="flatEditor" ng-change="refreshVisual()"/></div>
     <div class="col-md-2"><label>Record Type:</label> {{calculated_record_type}}</div>
     <div ng-if="bre" class="col-md-2"><eg-marc-edit-bibsource/></div>
   </div>
-  <div class="row pad-vert">
-  <div class="marcffeditor">
-    <div class="row col-md-12">
-        <eg-marc-edit-fixed-field fixed-field="Type" record="record"></eg-marc-edit-fixed-field>
-        <eg-marc-edit-fixed-field fixed-field="ELvl" record="record"></eg-marc-edit-fixed-field>
-        <eg-marc-edit-fixed-field fixed-field="Srce" record="record"></eg-marc-edit-fixed-field>
-        <eg-marc-edit-fixed-field fixed-field="Audn" record="record"></eg-marc-edit-fixed-field>
-        <eg-marc-edit-fixed-field fixed-field="Ctrl" record="record"></eg-marc-edit-fixed-field>
-        <eg-marc-edit-fixed-field fixed-field="Lang" record="record"></eg-marc-edit-fixed-field>
-    </div>
-    <div class="row col-md-12">
-        <eg-marc-edit-fixed-field fixed-field="BLvl" record="record"></eg-marc-edit-fixed-field>
-        <eg-marc-edit-fixed-field fixed-field="Form" record="record"></eg-marc-edit-fixed-field>
-        <eg-marc-edit-fixed-field fixed-field="Conf" record="record"></eg-marc-edit-fixed-field>
-        <eg-marc-edit-fixed-field fixed-field="Biog" record="record"></eg-marc-edit-fixed-field>
-        <eg-marc-edit-fixed-field fixed-field="MRec" record="record"></eg-marc-edit-fixed-field>
-        <eg-marc-edit-fixed-field fixed-field="Ctry" record="record"></eg-marc-edit-fixed-field>
-    </div>
-    <div class="row col-md-12">
-        <eg-marc-edit-fixed-field fixed-field="s_l" record="record"></eg-marc-edit-fixed-field>
-        <eg-marc-edit-fixed-field fixed-field="Cont" record="record"></eg-marc-edit-fixed-field>
-        <eg-marc-edit-fixed-field fixed-field="GPub" record="record"></eg-marc-edit-fixed-field>
-        <eg-marc-edit-fixed-field fixed-field="LitF" record="record"></eg-marc-edit-fixed-field>
-        <eg-marc-edit-fixed-field fixed-field="Indx" record="record"></eg-marc-edit-fixed-field>
-        <eg-marc-edit-fixed-field fixed-field="Alph" record="record"></eg-marc-edit-fixed-field>
-    </div>
-    <div class="row col-md-12">
-        <eg-marc-edit-fixed-field fixed-field="Desc" record="record"></eg-marc-edit-fixed-field>
-        <eg-marc-edit-fixed-field fixed-field="Ills" record="record"></eg-marc-edit-fixed-field>
-        <eg-marc-edit-fixed-field fixed-field="Fest" record="record"></eg-marc-edit-fixed-field>
-        <eg-marc-edit-fixed-field fixed-field="DtSt" record="record"></eg-marc-edit-fixed-field>
-        <eg-marc-edit-fixed-field fixed-field="Date1" record="record"></eg-marc-edit-fixed-field>
-        <eg-marc-edit-fixed-field fixed-field="Date2" record="record"></eg-marc-edit-fixed-field>
-    </div>
-    <div class="row col-md-12">
-        <eg-marc-edit-fixed-field fixed-field="SrTp" record="record"></eg-marc-edit-fixed-field>
-        <eg-marc-edit-fixed-field fixed-field="Regl" record="record"></eg-marc-edit-fixed-field>
-        <eg-marc-edit-fixed-field fixed-field="Orig" record="record"></eg-marc-edit-fixed-field>
-        <eg-marc-edit-fixed-field fixed-field="Freq" record="record"></eg-marc-edit-fixed-field>
-        <eg-marc-edit-fixed-field fixed-field="EntW" record="record"></eg-marc-edit-fixed-field>
-    </div>
-    <div class="row col-md-12">
-        <eg-marc-edit-fixed-field fixed-field="TrAr" record="record"></eg-marc-edit-fixed-field>
-        <eg-marc-edit-fixed-field fixed-field="Part" record="record"></eg-marc-edit-fixed-field>
-        <eg-marc-edit-fixed-field fixed-field="LTxt" record="record"></eg-marc-edit-fixed-field>
-        <eg-marc-edit-fixed-field fixed-field="FMus" record="record"></eg-marc-edit-fixed-field>
-        <eg-marc-edit-fixed-field fixed-field="AccM" record="record"></eg-marc-edit-fixed-field>
-        <eg-marc-edit-fixed-field fixed-field="Comp" record="record"></eg-marc-edit-fixed-field>
-    </div>
-    <div class="row col-md-12">
-        <eg-marc-edit-fixed-field fixed-field="SpFm" record="record"></eg-marc-edit-fixed-field>
-        <eg-marc-edit-fixed-field fixed-field="Relf" record="record"></eg-marc-edit-fixed-field>
-        <eg-marc-edit-fixed-field fixed-field="Proj" record="record"></eg-marc-edit-fixed-field>
-        <eg-marc-edit-fixed-field fixed-field="CrTp" record="record"></eg-marc-edit-fixed-field>
-    </div>
-    <div class="row col-md-12">
-        <eg-marc-edit-fixed-field fixed-field="TMat" record="record"></eg-marc-edit-fixed-field>
-        <eg-marc-edit-fixed-field fixed-field="Time" record="record"></eg-marc-edit-fixed-field>
-        <eg-marc-edit-fixed-field fixed-field="Tech" record="record"></eg-marc-edit-fixed-field>
-        <eg-marc-edit-fixed-field fixed-field="File" record="record"></eg-marc-edit-fixed-field>
-    </div>
-    <div class="row col-md-12">
-        <eg-marc-edit-fixed-field fixed-field="Type_tbmfhd" record="record"></eg-marc-edit-fixed-field>
-        <eg-marc-edit-fixed-field fixed-field="ELvl_tbmfhd" record="record"></eg-marc-edit-fixed-field>
-        <eg-marc-edit-fixed-field fixed-field="Item_tbmfhd" record="record"></eg-marc-edit-fixed-field>
-        <eg-marc-edit-fixed-field fixed-field="GeoDiv" record="record"></eg-marc-edit-fixed-field>
-        <eg-marc-edit-fixed-field fixed-field="Roman" record="record"></eg-marc-edit-fixed-field>
-        <eg-marc-edit-fixed-field fixed-field="CatLang" record="record"></eg-marc-edit-fixed-field>
-    </div>
-    <div class="row col-md-12">
-        <eg-marc-edit-fixed-field fixed-field="Kind" record="record"></eg-marc-edit-fixed-field>
-        <eg-marc-edit-fixed-field fixed-field="Rules" record="record"></eg-marc-edit-fixed-field>
-        <eg-marc-edit-fixed-field fixed-field="Subj" record="record"></eg-marc-edit-fixed-field>
-        <eg-marc-edit-fixed-field fixed-field="Series" record="record"></eg-marc-edit-fixed-field>
-        <eg-marc-edit-fixed-field fixed-field="SerNum" record="record"></eg-marc-edit-fixed-field>
-        <eg-marc-edit-fixed-field fixed-field="NameUse" record="record"></eg-marc-edit-fixed-field>
-    </div>
-    <div class="row col-md-12">
-        <eg-marc-edit-fixed-field fixed-field="SubjUse" record="record"></eg-marc-edit-fixed-field>
-        <eg-marc-edit-fixed-field fixed-field="SerUse" record="record"></eg-marc-edit-fixed-field>
-        <eg-marc-edit-fixed-field fixed-field="TypeSubd" record="record"></eg-marc-edit-fixed-field>
-        <eg-marc-edit-fixed-field fixed-field="GovAgn" record="record"></eg-marc-edit-fixed-field>
-        <eg-marc-edit-fixed-field fixed-field="RefStatus" record="record"></eg-marc-edit-fixed-field>
-        <eg-marc-edit-fixed-field fixed-field="UpdStatus" record="record"></eg-marc-edit-fixed-field>
-    </div>
-    <div class="row col-md-12">
-        <eg-marc-edit-fixed-field fixed-field="Name" record="record"></eg-marc-edit-fixed-field>
-        <eg-marc-edit-fixed-field fixed-field="Status" record="record"></eg-marc-edit-fixed-field>
-        <eg-marc-edit-fixed-field fixed-field="ModRec" record="record"></eg-marc-edit-fixed-field>
-        <eg-marc-edit-fixed-field fixed-field="Source" record="record"></eg-marc-edit-fixed-field>
-    </div>
-  </div>
+  <div ng-show="flatEditor">
+    <textarea cols="120" rows="40" ng-model="flat_text_marc" ng-change="saveFlatTextMARC()"></textarea>
   </div>
-  <div class="marcrecord pad-vert">
-    <div>
-      <eg-marc-edit-leader record="record" on-keydown="onKeydown"/>
-    </div>
-    <div>
-      <eg-marc-edit-controlfield 
-        ng-repeat="field in controlfields" 
-        field="field" on-keydown="onKeydown"
-        id="r{{field.record.subfield('901','c')[1]}}f{{field.position}}"
-      />
+  <div ng-show="!flatEditor">
+    <div class="row pad-vert">
+      <div class="marcffeditor">
+        <div class="row col-md-12">
+            <eg-marc-edit-fixed-field fixed-field="Type" record="record"></eg-marc-edit-fixed-field>
+            <eg-marc-edit-fixed-field fixed-field="ELvl" record="record"></eg-marc-edit-fixed-field>
+            <eg-marc-edit-fixed-field fixed-field="Srce" record="record"></eg-marc-edit-fixed-field>
+            <eg-marc-edit-fixed-field fixed-field="Audn" record="record"></eg-marc-edit-fixed-field>
+            <eg-marc-edit-fixed-field fixed-field="Ctrl" record="record"></eg-marc-edit-fixed-field>
+            <eg-marc-edit-fixed-field fixed-field="Lang" record="record"></eg-marc-edit-fixed-field>
+        </div>
+        <div class="row col-md-12">
+            <eg-marc-edit-fixed-field fixed-field="BLvl" record="record"></eg-marc-edit-fixed-field>
+            <eg-marc-edit-fixed-field fixed-field="Form" record="record"></eg-marc-edit-fixed-field>
+            <eg-marc-edit-fixed-field fixed-field="Conf" record="record"></eg-marc-edit-fixed-field>
+            <eg-marc-edit-fixed-field fixed-field="Biog" record="record"></eg-marc-edit-fixed-field>
+            <eg-marc-edit-fixed-field fixed-field="MRec" record="record"></eg-marc-edit-fixed-field>
+            <eg-marc-edit-fixed-field fixed-field="Ctry" record="record"></eg-marc-edit-fixed-field>
+        </div>
+        <div class="row col-md-12">
+            <eg-marc-edit-fixed-field fixed-field="s_l" record="record"></eg-marc-edit-fixed-field>
+            <eg-marc-edit-fixed-field fixed-field="Cont" record="record"></eg-marc-edit-fixed-field>
+            <eg-marc-edit-fixed-field fixed-field="GPub" record="record"></eg-marc-edit-fixed-field>
+            <eg-marc-edit-fixed-field fixed-field="LitF" record="record"></eg-marc-edit-fixed-field>
+            <eg-marc-edit-fixed-field fixed-field="Indx" record="record"></eg-marc-edit-fixed-field>
+            <eg-marc-edit-fixed-field fixed-field="Alph" record="record"></eg-marc-edit-fixed-field>
+        </div>
+        <div class="row col-md-12">
+            <eg-marc-edit-fixed-field fixed-field="Desc" record="record"></eg-marc-edit-fixed-field>
+            <eg-marc-edit-fixed-field fixed-field="Ills" record="record"></eg-marc-edit-fixed-field>
+            <eg-marc-edit-fixed-field fixed-field="Fest" record="record"></eg-marc-edit-fixed-field>
+            <eg-marc-edit-fixed-field fixed-field="DtSt" record="record"></eg-marc-edit-fixed-field>
+            <eg-marc-edit-fixed-field fixed-field="Date1" record="record"></eg-marc-edit-fixed-field>
+            <eg-marc-edit-fixed-field fixed-field="Date2" record="record"></eg-marc-edit-fixed-field>
+        </div>
+        <div class="row col-md-12">
+            <eg-marc-edit-fixed-field fixed-field="SrTp" record="record"></eg-marc-edit-fixed-field>
+            <eg-marc-edit-fixed-field fixed-field="Regl" record="record"></eg-marc-edit-fixed-field>
+            <eg-marc-edit-fixed-field fixed-field="Orig" record="record"></eg-marc-edit-fixed-field>
+            <eg-marc-edit-fixed-field fixed-field="Freq" record="record"></eg-marc-edit-fixed-field>
+            <eg-marc-edit-fixed-field fixed-field="EntW" record="record"></eg-marc-edit-fixed-field>
+        </div>
+        <div class="row col-md-12">
+            <eg-marc-edit-fixed-field fixed-field="TrAr" record="record"></eg-marc-edit-fixed-field>
+            <eg-marc-edit-fixed-field fixed-field="Part" record="record"></eg-marc-edit-fixed-field>
+            <eg-marc-edit-fixed-field fixed-field="LTxt" record="record"></eg-marc-edit-fixed-field>
+            <eg-marc-edit-fixed-field fixed-field="FMus" record="record"></eg-marc-edit-fixed-field>
+            <eg-marc-edit-fixed-field fixed-field="AccM" record="record"></eg-marc-edit-fixed-field>
+            <eg-marc-edit-fixed-field fixed-field="Comp" record="record"></eg-marc-edit-fixed-field>
+        </div>
+        <div class="row col-md-12">
+            <eg-marc-edit-fixed-field fixed-field="SpFm" record="record"></eg-marc-edit-fixed-field>
+            <eg-marc-edit-fixed-field fixed-field="Relf" record="record"></eg-marc-edit-fixed-field>
+            <eg-marc-edit-fixed-field fixed-field="Proj" record="record"></eg-marc-edit-fixed-field>
+            <eg-marc-edit-fixed-field fixed-field="CrTp" record="record"></eg-marc-edit-fixed-field>
+        </div>
+        <div class="row col-md-12">
+            <eg-marc-edit-fixed-field fixed-field="TMat" record="record"></eg-marc-edit-fixed-field>
+            <eg-marc-edit-fixed-field fixed-field="Time" record="record"></eg-marc-edit-fixed-field>
+            <eg-marc-edit-fixed-field fixed-field="Tech" record="record"></eg-marc-edit-fixed-field>
+            <eg-marc-edit-fixed-field fixed-field="File" record="record"></eg-marc-edit-fixed-field>
+        </div>
+        <div class="row col-md-12">
+            <eg-marc-edit-fixed-field fixed-field="Type_tbmfhd" record="record"></eg-marc-edit-fixed-field>
+            <eg-marc-edit-fixed-field fixed-field="ELvl_tbmfhd" record="record"></eg-marc-edit-fixed-field>
+            <eg-marc-edit-fixed-field fixed-field="Item_tbmfhd" record="record"></eg-marc-edit-fixed-field>
+            <eg-marc-edit-fixed-field fixed-field="GeoDiv" record="record"></eg-marc-edit-fixed-field>
+            <eg-marc-edit-fixed-field fixed-field="Roman" record="record"></eg-marc-edit-fixed-field>
+            <eg-marc-edit-fixed-field fixed-field="CatLang" record="record"></eg-marc-edit-fixed-field>
+        </div>
+        <div class="row col-md-12">
+            <eg-marc-edit-fixed-field fixed-field="Kind" record="record"></eg-marc-edit-fixed-field>
+            <eg-marc-edit-fixed-field fixed-field="Rules" record="record"></eg-marc-edit-fixed-field>
+            <eg-marc-edit-fixed-field fixed-field="Subj" record="record"></eg-marc-edit-fixed-field>
+            <eg-marc-edit-fixed-field fixed-field="Series" record="record"></eg-marc-edit-fixed-field>
+            <eg-marc-edit-fixed-field fixed-field="SerNum" record="record"></eg-marc-edit-fixed-field>
+            <eg-marc-edit-fixed-field fixed-field="NameUse" record="record"></eg-marc-edit-fixed-field>
+        </div>
+        <div class="row col-md-12">
+            <eg-marc-edit-fixed-field fixed-field="SubjUse" record="record"></eg-marc-edit-fixed-field>
+            <eg-marc-edit-fixed-field fixed-field="SerUse" record="record"></eg-marc-edit-fixed-field>
+            <eg-marc-edit-fixed-field fixed-field="TypeSubd" record="record"></eg-marc-edit-fixed-field>
+            <eg-marc-edit-fixed-field fixed-field="GovAgn" record="record"></eg-marc-edit-fixed-field>
+            <eg-marc-edit-fixed-field fixed-field="RefStatus" record="record"></eg-marc-edit-fixed-field>
+            <eg-marc-edit-fixed-field fixed-field="UpdStatus" record="record"></eg-marc-edit-fixed-field>
+        </div>
+        <div class="row col-md-12">
+            <eg-marc-edit-fixed-field fixed-field="Name" record="record"></eg-marc-edit-fixed-field>
+            <eg-marc-edit-fixed-field fixed-field="Status" record="record"></eg-marc-edit-fixed-field>
+            <eg-marc-edit-fixed-field fixed-field="ModRec" record="record"></eg-marc-edit-fixed-field>
+            <eg-marc-edit-fixed-field fixed-field="Source" record="record"></eg-marc-edit-fixed-field>
+        </div>
+      </div>
     </div>
-    <div>
-      <eg-marc-edit-datafield 
-        ng-repeat="field in datafields" 
-        field="field" on-keydown="onKeydown" 
-        id="r{{field.record.subfield('901','c')[1]}}f{{field.position}}"
-      />
+    <div class="marcrecord pad-vert">
+      <div>
+        <eg-marc-edit-leader record="record" on-keydown="onKeydown"/>
+      </div>
+      <div>
+        <eg-marc-edit-controlfield 
+          ng-repeat="field in controlfields" 
+          field="field" on-keydown="onKeydown"
+          id="r{{field.record.subfield('901','c')[1]}}f{{field.position}}"
+        />
+      </div>
+      <div>
+        <eg-marc-edit-datafield 
+          ng-repeat="field in datafields" 
+          field="field" on-keydown="onKeydown" 
+          id="r{{field.record.subfield('901','c')[1]}}f{{field.position}}"
+        />
+      </div>
     </div>
   </div>
   <button class="btn btn-default" ng-click="saveRecord()">Save</button>
index c114dd8..9a364ea 100644 (file)
@@ -447,6 +447,9 @@ angular.module('egMarcMod', ['egCoreMod', 'ui.bootstrap'])
         controller : ['$timeout','$scope','egCore', 'egTagTable',
             function ( $timeout , $scope , egCore ,  egTagTable ) {
 
+                MARC21.Record.delimiter = '$';
+
+                $scope.flatEditor = false;
                 $scope.bib_source = null;
                 $scope.record_type = $scope.recordType || 'bre';
                 $scope.max_undo = $scope.maxUndo || 100;
@@ -461,6 +464,17 @@ angular.module('egMarcMod', ['egCoreMod', 'ui.bootstrap'])
 
                 egTagTable.loadTagTable();
 
+                $scope.saveFlatTextMARC = function () {
+                    $scope.record = new MARC21.Record({ marcbreaker : $scope.flat_text_marc });
+                };
+
+                $scope.refreshVisual = function () {
+                    if (!$scope.flatEditor) {
+                        $scope.controlfields = $scope.record.fields.filter(function(f){ return f.isControlfield() });
+                        $scope.datafields = $scope.record.fields.filter(function(f){ return !f.isControlfield() });
+                    }
+                };
+
                 $scope.onKeydown = function (event) {
                     var event_return = true;
 
@@ -798,6 +812,7 @@ angular.module('egMarcMod', ['egCoreMod', 'ui.bootstrap'])
                         $scope.controlfields = $scope.record.fields.filter(function(f){ return f.isControlfield() });
                         $scope.datafields = $scope.record.fields.filter(function(f){ return !f.isControlfield() });
                         $scope.save_stack_depth = $scope.record_undo_stack.length;
+                        $scope.flat_text_marc = $scope.record.toBreaker();
 
                         if ($scope.record_type == 'bre') {
                             $scope.bib_source = $scope[$scope.record_type].source();
@@ -824,6 +839,7 @@ angular.module('egMarcMod', ['egCoreMod', 'ui.bootstrap'])
                             $scope.force_render = false;
                         }
 
+                        $scope.flat_text_marc = newVal;
                     }
 
                     if ($scope.record_undo_stack.length != $scope.save_stack_depth) {