webstaff: provide MVR's for use with Print Labels
authorJason Etheridge <jason@esilibrary.com>
Fri, 14 Apr 2017 13:53:47 +0000 (09:53 -0400)
committerJason Etheridge <jason@esilibrary.com>
Fri, 14 Apr 2017 13:55:21 +0000 (09:55 -0400)
better than super simple record, but Display Fields will be better yet later on

Signed-off-by: Jason Etheridge <jason@esilibrary.com>
Open-ILS/src/templates/staff/share/print_templates/t_item_label.tt2
Open-ILS/web/js/ui/default/staff/cat/printlabels/app.js

index fed5e33..0480193 100644 (file)
@@ -10,6 +10,15 @@ with a variety of keys, including
   call_number.label 
   location.name
 
+There are also utility functions:
+
+  get_cn_for(copy)  -> returns the formatted call number from the
+                       Call Number Template and Call Numbers tab
+
+  get_bib_for(copy) -> returns an "MVR" with keys like title,
+                       author, publisher, pubdate, series,
+                       edition, and isbn
+
 Line-wrapping may be done with the | wrap filter.  The first
 parameter is the number of characters to target for the string
 width.  The second parameter is the wrapping algorithm to use.
@@ -67,8 +76,8 @@ Certain library settings are also available:
 <pre class="pocket" style="border:none" ng-show="true">
 {{copy.barcode}}
 {{copy['call_number.label']}}
-{{copy['call_number.record.simple_record.author']}}
-{{copy['call_number.record.simple_record.title'] | wrap:28:'once':' '}}
+{{get_bib_for(copy).author }}
+{{get_bib_for(copy).title | wrap:28:'once':' '}}
 </pre>
 </td>
 </tr>
index 15a6a74..1815652 100644 (file)
@@ -130,7 +130,11 @@ function($scope , $q , $window , $routeParams , $location , $timeout , egCore ,
                             return '...';
                         }
                     }
+                    ,'get_bib_for' : function(copy) {
+                        return $scope.record_details[copy['call_number.record.id']];
+                    }
                 };
+                $scope.record_details = {};
 
                 var promises = [];
 
@@ -157,20 +161,37 @@ function($scope , $q , $window , $routeParams , $location , $timeout , egCore ,
                 angular.forEach(data.copies, function(copy) {
                     promises.push(
                         itemSvc.fetch(null,copy).then(function(res) {
-                            $scope.preview_scope.copies.push(egCore.idl.toHash(res.copy, true));
+                            var flat_copy = egCore.idl.toHash(res.copy, true);
+                            $scope.preview_scope.copies.push(flat_copy);
+                            $scope.record_details[ flat_copy['call_number.record.id'] ] = 1;
                         })
                     )
                 });
 
                 $q.all(promises).then(function() {
 
-                    // today, staff, current_location, etc.
-                    egCore.print.fleshPrintScope($scope.preview_scope);
-
-                    $scope.template_changed(); // load the default
-                    $scope.rebuild_cn_set();
+                    var promises2 = [];
+                    angular.forEach($scope.record_details, function(el,k,obj) {
+                        promises2.push(
+                            egNet.request(
+                                'open-ils.search',
+                                'open-ils.search.biblio.record.mods_slim.retrieve.authoritative',
+                                k
+                            ).then(function (data) {
+                                obj[k] = egCore.idl.toHash(data, true);
+                            })
+                        );
+                    });
+
+                    $q.all(promises2).then(function() {
+                        // today, staff, current_location, etc.
+                        egCore.print.fleshPrintScope($scope.preview_scope);
+                        console.log($scope.record_details);
+                        $scope.template_changed(); // load the default
+                        $scope.rebuild_cn_set();
+                    });
 
-                })
+                });
             } else {
                 ngToast.danger(egCore.strings.KEY_EXPIRED);
             }