webstaff: dist/streams grid now handles partial subs
authorGalen Charlton <gmc@equinoxinitiative.org>
Wed, 19 Apr 2017 19:59:30 +0000 (15:59 -0400)
committerGalen Charlton <gmc@equinoxinitiative.org>
Tue, 30 May 2017 16:06:35 +0000 (12:06 -0400)
If a subscription has no distributions, or if a distribution
has no streams, a partially-filled-in row is now displayed
in the grid.

Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Open-ILS/web/js/ui/default/staff/serials/services/core.js

index f2ac3ad..f53c8e3 100644 (file)
@@ -42,6 +42,7 @@ function(egCore , orderByFilter) {
         var list = [];
         angular.forEach(service.subTree, function(ssub) {
             var ssubHash = egCore.idl.toHash(ssub);
+
             var _ssub = {
                 'id'                   : ssubHash.id,
                 'owning_lib.name'      : ssubHash.owning_lib.name,
@@ -49,6 +50,12 @@ function(egCore , orderByFilter) {
                 'end_date'             : ssubHash.end_date,
                 'expected_date_offset' : ssubHash.expected_date_offset
             };
+            // insert and escape if we have no distributions
+            if (ssubHash.distributions.length == 0) {
+                list.push(_ssub);
+                return;
+            }
+
             angular.forEach(ssubHash.distributions, function(sdist) {
                 var _sdist = {};
                 angular.forEach([
@@ -70,6 +77,14 @@ function(egCore , orderByFilter) {
                     sdist.bind_call_number ? sdist.bind_call_number.label : null;
                 _sdist['sdist.bind_unit_template.name'] =
                     sdist.bind_unit_template ? sdist.bind_unit_template.name : null;
+                // if we have no streams, add to the list and escape
+                if (sdist.streams.length == 0) {
+                    var row = {};
+                    angular.extend(row, _ssub, _sdist);
+                    list.push(row);
+                    return;
+                }
+
                 angular.forEach(sdist.streams, function(sstr) {
                     var _sstr = {
                         'sstr.id'                 : sstr.id,