implement setting next status upon checkin
authorGalen Charlton <gmc@esilibrary.com>
Tue, 8 Dec 2015 14:22:27 +0000 (09:22 -0500)
committerMike Rylander <mrylander@gmail.com>
Thu, 31 Aug 2017 17:08:26 +0000 (13:08 -0400)
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Open-ILS/src/templates/staff/share/t_copy_alert_manager_dialog.tt2
Open-ILS/web/js/ui/default/staff/circ/services/circ.js
Open-ILS/web/js/ui/default/staff/services/ui.js

index 75c2df0..2b615e8 100644 (file)
                   ng-click="alert.acked = !alert.acked" >[% l('Acknowledge') %]</button>
         </div>
       </div>
-    <div>
+    </div>
+    <div ng-if="mode == 'checkin' && next_statuses.length > 0">
+        <div ng-if="next_statuses.length == 1">
+            [% l('Will set copy status to [_1]', '{{next_statuses[0].name()}}') %]
+        </div>
+        <div ng-if="next_statuses.length > 1">
+          <div class="col-md-4">
+            <label for="select-next-status">[% l('Next copy status') %]</label>
+          </div>
+          <div class="col-md-4">
+            <select id="select-next-status" class="form-control"
+                    ng-model="params.the_next_status"
+                    ng-options="st.id() as st.name() for st in next_statuses">
+            </select>
+          </select>
+        </div>
+    </div>
   </div>
   <div class="modal-footer">
     [% dialog_footer %]
index 77a9e1c..78fa40a 100644 (file)
@@ -1552,7 +1552,11 @@ function($uibModal , $q , egCore , egAlertDialog , egConfirmDialog,  egCopyAlert
             return egCopyAlertManagerDialog.open({
                 alerts : evt.payload,
                 mode : action,
-                ok : function() {},
+                ok : function(the_next_status) {
+                        if (the_next_status !== null) {
+                            params.next_copy_status = [ the_next_status ];
+                        }
+                     },
                 cancel : function() {}
             }).result.then(function() {
                 options.override = true;
index 5149afd..7d022eb 100644 (file)
@@ -563,19 +563,57 @@ function($modal , $interpolate , egCore) {
                     $scope.alerts = args.alerts;
                     $scope.mode = args.mode || 'checkin';
 
+                    var next_statuses = [];
+                    var seen_statuses = {};
                     angular.forEach($scope.alerts, function(copy_alert) {
                         var state = copy_alert.alert_type().state();
                         var evt   = copy_alert.alert_type().event();
+
                         copy_alert.message = copy_alert.note() ||
                             egCore.strings.ON_DEMAND_COPY_ALERT[evt][state];
+
+                        if (copy_alert.temp() == 't') {
+                            angular.forEach(copy_alert.alert_type().next_status(), function (st) {
+                                if (!seen_statuses[st]) {
+                                    seen_statuses[st] = true;
+                                    next_statuses.push(st);
+                                }
+                            });
+                        }
                     });
 
+                    // returns a promise resolved with the list of circ mods
+                    $scope.get_copy_statuses = function() {
+                        if (egCore.env.ccm)
+                            return $q.when(egCore.env.ccs.list);
+
+                        return egCore.pcrud.retrieveAll('ccs', null, {atomic : true})
+                        .then(function(list) {
+                            egCore.env.absorbList(list, 'ccs');
+                            return list;
+                        });
+                    };
+
+                    $scope.next_statuses = [];
+                    $scope.params = {
+                        'the_next_status' : null
+                    }
+                    if ($scope.mode == 'checkin' && next_statuses.length > 0) {
+                        $scope.get_copy_statuses().then(function() {
+                            angular.forEach(next_statuses, function(st) {
+                                $scope.next_statuses.push(egCore.env.ccs.list[st]);
+                            });
+                            $scope.params.the_next_status = $scope.next_statuses[0].id();
+                        });
+                    }
+
                     $scope.isAcknowledged = function(copy_alert) {
                         return (copy_alert.acked);
                     };
                     $scope.canBeAcknowledged = function(copy_alert) {
-                        return (!copy_alert.ack_time() && copy_alert.temp());
+                        return (!copy_alert.ack_time() && copy_alert.temp() == 't');
                     };
+
                     $scope.ok = function() {
                         var acks = [];
                         angular.forEach($scope.alerts, function (copy_alert) {
@@ -589,7 +627,7 @@ function($modal , $interpolate , egCore) {
                         if (acks.length > 0) {
                             egCore.pcrud.apply(acks);
                         }
-                        if (args.ok) args.ok();
+                        if (args.ok) args.ok($scope.params.the_next_status);
                         $modalInstance.close()
                     }
                     $scope.cancel = function() {