webstaff: implement Create New MARC Record
authorGalen Charlton <gmc@esilibrary.com>
Thu, 3 Sep 2015 15:47:21 +0000 (15:47 +0000)
committerJason Stephenson <jstephenson@mvlc.org>
Mon, 14 Sep 2015 19:44:19 +0000 (15:44 -0400)
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Signed-off-by: Jason Stephenson <jstephenson@mvlc.org>
Open-ILS/src/templates/staff/cat/catalog/t_new_bib.tt2 [new file with mode: 0644]
Open-ILS/src/templates/staff/navbar.tt2
Open-ILS/web/js/ui/default/staff/cat/catalog/app.js
Open-ILS/web/js/ui/default/staff/cat/services/marcedit.js

diff --git a/Open-ILS/src/templates/staff/cat/catalog/t_new_bib.tt2 b/Open-ILS/src/templates/staff/cat/catalog/t_new_bib.tt2
new file mode 100644 (file)
index 0000000..fdc9757
--- /dev/null
@@ -0,0 +1,13 @@
+<div class="form-inline row" ng-show="!have_template">
+    <div class="col-xs-6">
+        <div class="form-group">
+            <label for="select-marc-template" class="control-label">[% l('Select MARC template') %]</label>
+            <select id="select-marc-template" class="form-control" ng-model="template_name" ng-options="name as name for name in template_list"></select>
+        </div>
+        <button class="btn btn-primary" ng-click="loadTemplate()">[% l('Load') %]</button>
+        <button class="btn btn-default" ng-click="setDefaultTemplate()">[% l('Set Workstation Default') %]</button>
+    </div>
+</div>
+<div ng-show="have_template" class="row col-md-12">
+  <eg-marc-edit-record dirty-flag="stop_unload" record_id="new_bib_id" marc-xml="marc_template" record-type="bre" />
+</div>
index 52b4448..0c8748b 100644 (file)
           </li>
           <li class="divider"></li>
           <li>
+            <a href="./cat/catalog/new_bib" target="_self">
+              <span class="glyphicon glyphicon-plus"></span>
+              [% l('Create New MARC Record') %]
+            </a>
+          </li>
+          <li>
             <a href="./cat/z3950/index" target="_self">
               <span class="glyphicon glyphicon-cloud-download"></span>
               [% l('Import Record from Z39.50') %]
index 3dcea57..2608418 100644 (file)
@@ -45,6 +45,12 @@ angular.module('egCatalogApp', ['ui.bootstrap','ngRoute','egCoreMod','egGridMod'
         resolve : resolver
     });
 
+    $routeProvider.when('/cat/catalog/new_bib', {
+        templateUrl: './cat/catalog/t_new_bib',
+        controller: 'NewBibCtrl',
+        resolve : resolver
+    });
+
     // create some catalog page-specific mappings
     $routeProvider.when('/cat/catalog/record/:record_id', {
         templateUrl: './cat/catalog/t_catalog',
@@ -163,6 +169,62 @@ function($scope , $routeParams , $location , $q , egCore ) {
 
 }])
 
+.controller('NewBibCtrl',
+       ['$scope','$routeParams','$location','$window','$q','egCore',
+        'egGridDataProvider','egHoldGridActions','$timeout','holdingsSvc',
+function($scope , $routeParams , $location , $window , $q , egCore) {
+
+    $scope.have_template = false;
+    $scope.marc_template = '';
+    $scope.stop_unload = false;
+    $scope.template_list = [];
+    $scope.template_name = '';
+    $scope.new_bib_id = 0;
+
+    egCore.net.request(
+        'open-ils.cat',
+        'open-ils.cat.marc_template.types.retrieve'
+    ).then(function(resp) {
+        angular.forEach(resp, function(name) {
+            $scope.template_list.push(name);
+        });
+        $scope.template_list.sort();
+    });
+    egCore.hatch.getItem('cat.default_bib_marc_template').then(function(template) {
+        $scope.template_name = template;
+    });
+
+    $scope.loadTemplate = function() {
+        if ($scope.template_name) {
+            egCore.net.request(
+                'open-ils.cat',
+                'open-ils.cat.biblio.marc_template.retrieve',
+                $scope.template_name
+            ).then(function(template) {
+                $scope.marc_template = template;
+                $scope.have_template = true;
+            });
+        }
+    }
+
+    $scope.setDefaultTemplate = function() {
+        var hatch_key = "cat.default_bib_marc_template";
+        if ($scope.template_name) {
+            egCore.hatch.setItem(hatch_key, $scope.template_name);
+        } else {
+            egCore.hatch.removeItem(hatch_key);
+        }
+    }
+
+    $scope.$watch('new_bib_id', function(newVal, oldVal) {
+        if (newVal) {
+            $location.path('/cat/catalog/record/' + $scope.new_bib_id);
+        }
+    });
+    
+
+}])
+
 .controller('CatalogCtrl',
        ['$scope','$routeParams','$location','$window','$q','egCore','egHolds','egCirc',
         'egGridDataProvider','egHoldGridActions','$timeout','holdingsSvc',
index f45376a..b420749 100644 (file)
@@ -1026,6 +1026,13 @@ angular.module('egMarcMod', ['egCoreMod', 'ui.bootstrap'])
                         }
                     }
                 );
+                $scope.$watch('marcXml',
+                    function(newVal, oldVal) {
+                        if (newVal && newVal !== oldVal) {
+                            loadRecord();
+                        }
+                    }
+                );
 
                 var unregister = $scope.$watch(function() {
                     return egTagTable.initialized();