webstaff: Phys Char Wiz : initial dialog / wizard
authorBill Erickson <berickxx@gmail.com>
Mon, 7 Sep 2015 17:46:01 +0000 (13:46 -0400)
committerJason Stephenson <jstephenson@mvlc.org>
Mon, 14 Sep 2015 19:44:22 +0000 (15:44 -0400)
Signed-off-by: Bill Erickson <berickxx@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_physchar_dialog.tt2 [new file with mode: 0644]
Open-ILS/src/templates/staff/cat/share/t_physchar_wizard.tt2 [new file with mode: 0644]
Open-ILS/web/js/ui/default/staff/cat/services/marcedit.js
Open-ILS/web/js/ui/default/staff/cat/services/tagtable.js

diff --git a/Open-ILS/src/templates/staff/cat/share/t_physchar_dialog.tt2 b/Open-ILS/src/templates/staff/cat/share/t_physchar_dialog.tt2
new file mode 100644 (file)
index 0000000..0070889
--- /dev/null
@@ -0,0 +1,15 @@
+<div>
+  <div class="modal-header">
+    <button type="button" class="close"
+      ng-click="cancel()" aria-hidden="true">&times;</button>
+    <h4 class="modal-title">[% l('Physical Characteristics Wizard') %]</h4>
+  </div>
+  <div class="modal-body">
+    <eg-physchar-wizard changed="args.changed" field="args.field"/>
+  </div>
+  <div class="modal-footer">
+    <input type="submit" ng-click="ok(args)"
+        class="btn btn-primary" value="[% l('Save') %]"/>
+    <button class="btn btn-warning" ng-click="cancel()">[% l('Cancel') %]</button>
+  </div>
+</div>
diff --git a/Open-ILS/src/templates/staff/cat/share/t_physchar_wizard.tt2 b/Open-ILS/src/templates/staff/cat/share/t_physchar_wizard.tt2
new file mode 100644 (file)
index 0000000..953ffe9
--- /dev/null
@@ -0,0 +1,32 @@
+<div>
+  <div class="row">
+    <div class="col-md-4">[% l('007 Value') %]</div>
+    <div class="col-md-4">{{field.data}}</div>
+  </div>
+  <div class="row">
+    <div ng-if="step == 'a'">
+      <div class="col-md-4">[% l('Category of Material') %]</div>
+      <div class="col-md-4">
+        <select ng-model="value_for_step">
+          <option ng-repeat="option in values_for_step" 
+            value="{{option.ptype_key()}}">{{option.label()}}</option>
+        </select>
+      </div>
+    </div>
+    <div ng-if="step != 'a'">
+      <div class="col-md-4" ng-show="step != 'a'">{{get_label_for_step()}}</div>
+      <div class="col-md-4">
+        <select ng-model="value_for_step">
+          <option ng-repeat="option in values_for_step" 
+            value="{{option.value()}}">{{option.label()}}</option>
+        </select>
+      </div>
+    </div>
+    <div class="col-md-2">
+      <button class="btn btn-default">[% l('Previous') %]</button>
+    </div>
+    <div class="col-md-2">
+      <button class="btn btn-default">[% l('Next') %]</button>
+    </div>
+  </div>
+</div>
index 40235c9..4258173 100644 (file)
@@ -447,13 +447,30 @@ angular.module('egMarcMod', ['egCoreMod', 'ui.bootstrap'])
                   '</div>',
         scope: { field: "=", onKeydown: '=' },
         controller : ['$scope','$modal',
-            function ( $scope,  $modal ) {
+            function ( $scope,  $modal) {
                 $scope.showPhysCharLink = function () {
                     return ($scope.$parent.$parent.record_type == 'bre') 
                         && $scope.field.tag == '007';
                 }
                 $scope.spawnPhysCharWizard = function() {
-                    console.log('HERE');
+                    var args = {
+                        changed : false,
+                        field : $scope.field
+                    };
+                    $modal.open({
+                        templateUrl: './cat/share/t_physchar_dialog',
+                        controller: ['$scope','$modalInstance',
+                            function( $scope , $modalInstance) {
+                            $scope.focusMe = true;
+                            $scope.args = args;
+                            $scope.ok = function(args) { $modalInstance.close(args) };
+                            $scope.cancel = function () { $modalInstance.dismiss() };
+                        }],
+                    }).result.then(function (args) {
+                        if (!args.changed) return;
+                        // $scope.field.data = ...
+                    });
+
                 }
             }
         ]
@@ -1427,6 +1444,50 @@ angular.module('egMarcMod', ['egCoreMod', 'ui.bootstrap'])
     }
 })
 
+.directive("egPhyscharWizard", function () {
+    return {
+        restrict: 'E',
+        replace: true,
+        templateUrl: './cat/share/t_physchar_wizard',
+        scope : {
+            field : '='
+        },
+        controller: ['$scope','egTagTable',
+            function ($scope , egTagTable) {
+                $scope.step = 'a';
+                if ($scope.field.data) $scope.field.data = '';
+
+                $scope.value_for_step = '';
+                $scope.values_for_step = [];
+
+                egTagTable.getPhysCharTypeMap().then(function(list) {
+                    // we start with the types selector
+                    $scope.values_for_step = list;
+                });
+
+                $scope.current_ptype = function() {
+                    return $scope.field.data.substr(0, 1);   
+                }
+
+                $scope.get_label_for_step = function() {
+                    return 'TEST';
+                }
+
+                $scope.get_values_for_step = function() {
+                    if ($scope.step == 'a') {
+                        egTagTable.getPhysCharTypeMap().then(function(list) {
+                            $scope.values_for_step = list;
+                        });
+                    } else {
+                        //
+                    }
+                }
+            }
+        ]
+    }
+})
+
+
 .directive("egMarcEditAuthorityBrowser", function () {
     return {
         restrict: 'E',
index de64a13..dcc92be 100644 (file)
@@ -510,8 +510,8 @@ function($q,   egCore,   egAuth) {
             return $q.when(service.phys_char_type_map);
         }
 
-        return egCore.pcrud.retrieveAll('cmpctm')
-        .then(function(map) {service.phys_char_type_map = map});
+        return egCore.pcrud.retrieveAll('cmpctm', {}, {atomic : true})
+        .then(function(map) {return service.phys_char_type_map = map});
     }
 
     // Fetch+caches the config.marc21_physical_characteristic_subfield_map
@@ -525,9 +525,10 @@ function($q,   egCore,   egAuth) {
 
         return egCore.pcrud.search('cmpcsm', 
             {ptype_key : ptype_key},
-            {order_by : {cmpcsm : ['start_pos']}})
-        .then(function(maps) {
-            service.phys_char_sf_map[ptype_key] = maps;
+            {order_by : {cmpcsm : ['start_pos']}},
+            {atomic : true}
+        ).then(function(maps) {
+            return service.phys_char_sf_map[ptype_key] = maps;
         });
     }
 
@@ -541,9 +542,10 @@ function($q,   egCore,   egAuth) {
 
         return egCore.pcrud.search('cmpcvm', 
             {ptype_subfield : ptype_subfield},
-            {order_by : {cmpcsm : ['value']}})
-        .then(function(maps) {
-            service.phys_char_sf_map[ptype_subfield] = maps;
+            {order_by : {cmpcsm : ['value']}},
+            {atomic : true}
+        ).then(function(maps) {
+            return service.phys_char_sf_map[ptype_subfield] = maps;
         });
     }