start work on egCopyAlertManagerDialog
authorGalen Charlton <gmc@esilibrary.com>
Thu, 3 Dec 2015 22:00:23 +0000 (17:00 -0500)
committerGalen Charlton <gmc@equinoxinitiative.org>
Fri, 3 Nov 2017 20:00:49 +0000 (16:00 -0400)
This dialog is currently capable of:

- displaying copy alerts during checkin and checkout
- allowing the operator to acknowledge temporary alerts

TODO:

- allow display of all current alerts
- allow alerts to be added

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Conflicts:
Open-ILS/web/js/ui/default/staff/circ/services/circ.js

Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Open-ILS/src/templates/staff/css/style.css.tt2
Open-ILS/src/templates/staff/share/t_copy_alert_manager_dialog.tt2 [new file with mode: 0644]
Open-ILS/web/js/ui/default/staff/circ/services/circ.js
Open-ILS/web/js/ui/default/staff/services/ui.js

index e5a661a..390e651 100644 (file)
@@ -179,6 +179,10 @@ table.list tr.selected td { /* deprecated? */
 /* barcode inputs are everywhere.  Let's have a consistent style. */
 .barcode { width: 16em !important; }
 
+/* use strike-through to mark something that has been acknowledged,
+   e.g., a copy alert */
+.acknowledged { text-decoration: line-through; }
+
 /* bootstrap alerts are heavily padded.  use this to reduce */
 .alert-less-pad {padding: 5px;}
 
diff --git a/Open-ILS/src/templates/staff/share/t_copy_alert_manager_dialog.tt2 b/Open-ILS/src/templates/staff/share/t_copy_alert_manager_dialog.tt2
new file mode 100644 (file)
index 0000000..6b2b3d6
--- /dev/null
@@ -0,0 +1,29 @@
+<!--
+  Copy alert manager dialog
+-->
+<div>
+  <div class="modal-header">
+    <button type="button" class="close" 
+      ng-click="cancel()" aria-hidden="true">&times;</button>
+    <h4 class="modal-title alert alert-info">[% l('Copy alerts') %]</h4> 
+  </div>
+  <div class="modal-body">
+    <div>
+      <div class="row" ng-repeat="alert in alerts">
+        <div class="col-md-8" ng-class="{ acknowledged: isAcknowledged(alert) }">{{alert.note()}}</div>
+        <div class="col-md-4">
+          <button ng-if="canBeAcknowledged(alert)"
+                  class="btn btn-xs btn-default"
+                  ng-click="alert.acked = !alert.acked" >[% l('Acknowledge') %]</button>
+        </div>
+      </div>
+    <div>
+  </div>
+  <div class="modal-footer">
+    [% dialog_footer %]
+    <input type="submit" class="btn btn-primary" 
+      ng-click="ok()" value="[% l('OK/Continue') %]"/>
+    <button class="btn btn-warning" 
+      ng-click="cancel()">[% l('Cancel') %]</button>
+  </div>
+</div>
index 1fb7627..e6c52cf 100644 (file)
@@ -5,9 +5,9 @@
 angular.module('egCoreMod')
 
 .factory('egCirc',
-       ['$uibModal','$q','egCore','egAlertDialog','egConfirmDialog',
+       ['$uibModal','$q','egCore','egAlertDialog','egConfirmDialog','egCopyAlertManagerDialog',
         'egWorkLog',
-function($uibModal , $q , egCore , egAlertDialog , egConfirmDialog,
+function($uibModal , $q , egCore , egAlertDialog , egConfirmDialog,  egCopyAlertManagerDialog,
          egWorkLog) {
 
     var service = {
@@ -1625,7 +1625,14 @@ function($uibModal , $q , egCore , egAlertDialog , egConfirmDialog,
                 return service[action](params, options);
             });
         } else { // we got a list of copy alert objects ...
-            // TODO: build a chain of alert ack (and maybe status selection) dialogs
+            return egCopyAlertManagerDialog.open({
+                alerts : evt.payload,
+                ok : function() {},
+                cancel : function() {}
+            }).result.then(function() {
+                options.override = true;
+                return service[action](params, options);
+            });
         }
     }
 
index b6198db..3fba8b8 100644 (file)
@@ -571,6 +571,56 @@ function($window , egStrings) {
     return service;
 }])
 
+/**
+ * egCopyAlertManagerDialog - manage copy alerts
+ */
+.factory('egCopyAlertManagerDialog', 
+       ['$modal','$interpolate','egCore',
+function($modal , $interpolate , egCore) {
+    var service = {};
+
+    service.open = function(args) {
+        return $modal.open({
+            templateUrl: './share/t_copy_alert_manager_dialog',
+            controller: ['$scope', '$modalInstance',
+                function($scope, $modalInstance) {
+                    $scope.alerts = args.alerts;
+                    $scope.mode = args.mode || 'checkin';
+
+                    $scope.isAcknowledged = function(copy_alert) {
+                        return (copy_alert.ack_time() || copy_alert.acked);
+                    };
+                    $scope.canBeAcknowledged = function(copy_alert) {
+                        return (!copy_alert.ack_time() && copy_alert.temp());
+                    };
+                    $scope.ok = function() {
+                        var acks = [];
+                        angular.forEach($scope.alerts, function (copy_alert) {
+                            if (copy_alert.acked) {
+                                copy_alert.ack_time('now');
+                                copy_alert.ack_staff(egCore.auth.user().id());
+                                copy_alert.ischanged(true);
+                                acks.push(copy_alert);
+                            }
+                        });
+                        if (acks.length > 0) {
+                            egCore.pcrud.apply(acks);
+                        }
+                        if (args.ok) args.ok();
+                        $modalInstance.close()
+                    }
+                    $scope.cancel = function() {
+                        if (args.cancel) args.cancel();
+                        $modalInstance.dismiss();
+                    }
+                }
+            ]
+        })
+    }
+
+    return service;
+}])
+
 .directive('aDisabled', function() {
     return {
         restrict : 'A',