webstaff serials: add context OU selector for subscription
authorGalen Charlton <gmc@equinoxinitiative.org>
Wed, 12 Jul 2017 21:01:52 +0000 (17:01 -0400)
committerGalen Charlton <gmc@equinoxinitiative.org>
Wed, 12 Jul 2017 21:41:24 +0000 (17:41 -0400)
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Open-ILS/src/templates/staff/serials/t_subscription_manager.tt2
Open-ILS/web/js/ui/default/staff/serials/directives/subscription_manager.js
Open-ILS/web/js/ui/default/staff/serials/services/core.js

index 8f61045..803f443 100644 (file)
@@ -1,4 +1,13 @@
-<form name="ssubform">
+<div>
+  <label>[% l('Subscriptions owned by or below') %]</label>
+  <eg-org-selector selected="owning_ou" onchange="owning_ou_changed"
+                   sticky-setting="serials.ssub_owning_lib_filter">
+  </eg-org-selector>
+  <span class="alert alert-warning" ng-show="subscriptions.length == 0">
+    [% l('No subscriptions are owned by this library') %]
+  </span>
+</div>
+<form name="ssubform" class="pad-vert">
   <div class="form-inline" ng-repeat="ssub in subscriptions">
     <div class="row form-inline">
       <div class="form-group col-sm-2">
index 9f0d049..9407b63 100644 (file)
@@ -14,8 +14,14 @@ angular.module('egSerialsAppDep')
 function($scope , $q , egSerialsCoreSvc , egCore , egGridDataProvider ,
          $uibModal , ngToast , egConfirmDialog ) {
 
+    $scope.selected_owning_ou = null;
+    $scope.owning_ou_changed = function(org) {
+        $scope.selected_owning_ou = org.id();
+        reload();
+    }
+
     function reload() {
-        egSerialsCoreSvc.fetch($scope.bibId).then(function() {
+        egSerialsCoreSvc.fetch($scope.bibId, $scope.selected_owning_ou).then(function() {
             $scope.subscriptions = egCore.idl.toTypedHash(egSerialsCoreSvc.subTree);
             // un-flesh receive unit template so that we can use
             // it as a model of a select
index faa411e..b2ea80b 100644 (file)
@@ -151,10 +151,9 @@ function(egCore , orderByFilter , $q , $filter , $uibModal , ngToast , egConfirm
     // fetch subscription, distributions, streams, captions,
     // and notes associated with the indicated bib
     service.fetch = function(bibId, contextOrg) {
-        // TODO filter by contextOrg
 
         var filter = { record_entry : bibId };
-        if (contextOrg) filter.owning_lib = contextOrg;
+        if (contextOrg) filter.owning_lib = egCore.org.descendants(contextOrg, true);
         return egCore.pcrud.search('ssub', filter,
             {
                 flesh : 5,