webstaff: highlight currently active position in phys char wizard
authorGalen Charlton <gmc@esilibrary.com>
Mon, 12 Oct 2015 21:12:08 +0000 (21:12 +0000)
committerKathy Lussier <klussier@masslnc.org>
Tue, 2 Feb 2016 19:58:51 +0000 (14:58 -0500)
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Signed-off-by: Kathy Lussier <klussier@masslnc.org>
Open-ILS/src/templates/staff/cat/share/t_physchar_wizard.tt2
Open-ILS/src/templates/staff/css/cat.css.tt2
Open-ILS/web/js/ui/default/staff/cat/services/marcedit.js

index 2b86979..630e00a 100644 (file)
@@ -1,7 +1,7 @@
 <div>
   <div class="row">
     <div class="col-md-4">[% l('007 Value') %]</div>
-    <div class="col-md-4">{{field.data}}</div>
+    <div class="col-md-4"><pre ng-bind-html="highlightedFieldData()"></pre></div>
   </div>
   <div class="row"><div class="col-md-12 pad-vert"><hr/></div></div>
   <div class="row">
index a94f56e..3b87e42 100644 (file)
@@ -90,6 +90,11 @@ input.marcedit:focus {
     min-width: 1em;
 }
 
+.active-physchar {
+    font-weight: bold;
+    color: red;
+}
+
 .tooltip {
     /* width: 10em; */
 }
index 026767f..412c02e 100644 (file)
@@ -1625,7 +1625,7 @@ angular.module('egMarcMod', ['egCoreMod', 'ui.bootstrap'])
     }
 })
 
-.directive("egPhyscharWizard", function () {
+.directive("egPhyscharWizard", ['$sce', function ($sce) {
     return {
         restrict: 'E',
         replace: true,
@@ -1641,6 +1641,12 @@ angular.module('egMarcMod', ['egCoreMod', 'ui.bootstrap'])
                 // step==0 means we are currently selecting the type
                 $scope.step = 0;
 
+                // position and offset of the "subfields" we're
+                // currently editing; this is maintained as a convenience
+                // for the highlighting of the currently active position
+                $scope.offset = 0;
+                $scope.len = 1;
+
                 if (!$scope.field.data) 
                     $scope.field.data = '';
 
@@ -1661,6 +1667,8 @@ angular.module('egMarcMod', ['egCoreMod', 'ui.bootstrap'])
                     var promise;
 
                     if ($scope.step == 0) {
+                        $scope.offset = 0;
+                        $scope.len    = 1;
                         promise = egTagTable.getPhysCharTypeMap();
                     } else {
                         promise = current_subfield().then(
@@ -1697,6 +1705,8 @@ angular.module('egMarcMod', ['egCoreMod', 'ui.bootstrap'])
                         var after = value.substr(slot[0] + slot[1]);
                         $scope.field.data = 
                             before + new_val.substr(0, slot[1]) + after;
+                        $scope.offset = slot[0];
+                        $scope.len    = slot[1];
                     });
                 }
 
@@ -1745,6 +1755,8 @@ angular.module('egMarcMod', ['egCoreMod', 'ui.bootstrap'])
                             return (opt.ptype_key() == current_ptype())})[0];
                     } else {
                         get_step_slot().then(function(slot) {
+                            $scope.offset = slot[0];
+                            $scope.len    = slot[1];
                             var val = String.prototype.substr.apply(                      
                                 $scope.field.data, slot);
                             if (val) {
@@ -1757,11 +1769,30 @@ angular.module('egMarcMod', ['egCoreMod', 'ui.bootstrap'])
                         })
                     }
                 }
+
+                $scope.highlightedFieldData = function() {
+                    if (
+                            $scope.len && $scope.field.data &&
+                            $scope.field.data.length > 0 &&
+                            $scope.field.data.length >= $scope.offset
+                        ) {
+                        return $sce.trustAsHtml(
+                            $scope.field.data.substring(0, $scope.offset) + 
+                            '<span class="active-physchar">' +
+                            $scope.field.data.substr($scope.offset, $scope.len) +
+                            '</span>' +
+                            $scope.field.data.substr($scope.offset + $scope.len)
+                        );
+                    } else {
+                        return $scope.field.data;
+                    }
+                };
+
                 set_values_for_step();
             }
         ]
     }
-})
+}])
 
 
 .directive("egMarcEditAuthorityBrowser", function () {