add 'add copy alert' action
authorGalen Charlton <gmc@esilibrary.com>
Fri, 18 Dec 2015 18:18:46 +0000 (13:18 -0500)
committerGalen Charlton <gmc@equinoxinitiative.org>
Fri, 3 Nov 2017 20:02:42 +0000 (16:02 -0400)
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/cat/item/t_summary_pane.tt2
Open-ILS/src/templates/staff/circ/checkin/t_checkin_table.tt2
Open-ILS/src/templates/staff/circ/patron/t_checkout.tt2
Open-ILS/src/templates/staff/circ/renew/t_renew.tt2
Open-ILS/src/templates/staff/share/t_add_copy_alert_dialog.tt2 [new file with mode: 0644]
Open-ILS/web/js/ui/default/staff/cat/item/app.js
Open-ILS/web/js/ui/default/staff/circ/checkin/app.js
Open-ILS/web/js/ui/default/staff/circ/patron/checkout.js
Open-ILS/web/js/ui/default/staff/circ/renew/app.js
Open-ILS/web/js/ui/default/staff/circ/services/circ.js
Open-ILS/web/js/ui/default/staff/services/ui.js

index dad33c7..9e37939 100644 (file)
   <div class="flex-row">
     <div class="flex-cell">[% l('Copy Alerts') %]</div>
     <div id="item-status-alert-msg">
+      <button class="btn btn-default" ng-click="addCopyAlerts(copy.id())" >[% l('Add') %]</button>
       <button class="btn btn-default" ng-click="manageCopyAlerts(copy.id())" >[% l('Manage') %]</button>
     </div>
   </div>
index b85db1f..c0ade10 100644 (file)
     label="[% l('Cancel Transits') %]">
   </eg-grid-action>
   <eg-grid-action 
+    handler="addCopyAlerts"
+    label="[% l('Add Copy Alerts') %]">
+  </eg-grid-action>
+  <eg-grid-action 
     handler="manageCopyAlerts"
     label="[% l('Acknowledge Alerts') %]">
   </eg-grid-action>
index 75256d6..8980a33 100644 (file)
   dateformat="{{$root.egDateAndTimeFormat}}">
 
   <eg-grid-action
+    handler="addCopyAlerts"
+    label="[% l('Add Copy Alerts') %]">
+  </eg-grid-action>
+  <eg-grid-action
     handler="manageCopyAlerts"
     label="[% l('Acknowledge Alerts') %]">
   </eg-grid-action>
index 7233765..7f006ce 100644 (file)
     label="[% l('Cancel Transits') %]">
   </eg-grid-action>
   <eg-grid-action divider="true"></eg-grid-action>
-  <eg-grid-action wq
+  <eg-grid-action
+    handler="addCopyAlerts"
+    label="[% l('Add Copy Alerts') %]">
+  </eg-grid-action>
+  <eg-grid-action
     handler="manageCopyAlerts"
     label="[% l('Acknowledge Alerts') %]">
   </eg-grid-action>
diff --git a/Open-ILS/src/templates/staff/share/t_add_copy_alert_dialog.tt2 b/Open-ILS/src/templates/staff/share/t_add_copy_alert_dialog.tt2
new file mode 100644 (file)
index 0000000..0b97a3f
--- /dev/null
@@ -0,0 +1,40 @@
+<form ng-submit="ok(copy_alert)" role="form">
+    <div class="modal-header">
+      <button type="button" class="close" ng-click="cancel()" 
+        aria-hidden="true">&times;</button>
+      <h4 class="modal-title">[% l('Add Copy Alert') %]</h4>
+    </div>
+    <div class="modal-body">
+      <div class="row">
+        <div class="col-md-6 form-inline">
+          <label for="copy-alert-type-selector"> [% l('Type') %]</label>
+          <select id="copy-alert-type-selector" class="form-control"
+            ng-model="copy_alert.alert_type"
+            ng-options="at.id() as at.name() for at in alert_types">
+          </select>
+        </div>
+        <div class="col-md-3">
+          <label>
+            <input type="checkbox" ng-model="copy_alert.temp"/>
+            [% l('Temporary') %]
+          </label>
+        </div>
+      </div>
+      <div class="row pad-vert">
+        <div class="col-md-12">
+          <textarea class="form-control" 
+            ng-model="copy_alert.note" placeholder="[% l('Alert...') %]">
+          </textarea>
+        </div>
+      </div>
+    </div>
+    <div class="modal-footer">
+      <div class="row">
+        <div class="col-md-10 pull-right">
+          <input type="submit" class="btn btn-primary" value="[% l('OK') %]"/>
+          <button class="btn btn-warning" ng-click="cancel($event)">[% l('Cancel') %]</button>
+        </div>
+      </div>
+
+    </div>
+</form>
index c2c79f1..58a2b7a 100644 (file)
@@ -897,6 +897,11 @@ function($scope , $q , $location , $routeParams , $timeout , $window , egCore ,
         return;
     }
 
+    $scope.addCopyAlerts = function(copy_id) {
+        egCirc.add_copy_alerts([copy_id]).then(function() {
+            // update grid items?
+        });
+    }
     $scope.manageCopyAlerts = function(copy_id) {
         egCirc.manage_copy_alerts([copy_id]).then(function() {
             // update grid items?
index d5eb598..91a3288 100644 (file)
@@ -388,6 +388,16 @@ function($scope , $q , $window , $location , $timeout , egCore , checkinSvc , eg
         itemSvc.print_spine_labels(copy_ids);
     }
 
+    $scope.addCopyAlerts = function(items) {
+        var copy_ids = [];
+        angular.forEach(items, function(item) {
+            if (item.acp) copy_ids.push(item.acp.id());
+        });
+        egCirc.add_copy_alerts(copy_ids).then(function() {
+            // update grid items?
+        });
+    }
+
     $scope.manageCopyAlerts = function(items) {
         var copy_ids = [];
         angular.forEach(items, function(item) {
index 8acad73..1a72654 100644 (file)
@@ -255,6 +255,16 @@ function($scope , $q , $routeParams , egCore , egUser , patronSvc ,
         }
     }
 
+    $scope.addCopyAlerts = function(items) {
+        var copy_ids = [];
+        angular.forEach(items, function(item) {
+            if (item.acp) copy_ids.push(item.acp.id());
+        });
+        egCirc.add_copy_alerts(copy_ids).then(function() {
+            // update grid items?
+        });
+    }
+
     $scope.manageCopyAlerts = function(items) {
         var copy_ids = [];
         angular.forEach(items, function(item) {
index 91d589f..1f95cac 100644 (file)
@@ -200,6 +200,16 @@ function($scope , $window , $location , egCore , egGridDataProvider , egCirc) {
         });
     }
 
+    $scope.addCopyAlerts = function(items) {
+        var copy_ids = [];
+        angular.forEach(items, function(item) {
+            if (item.acp) copy_ids.push(item.acp.id());
+        });
+        egCirc.add_copy_alerts(copy_ids).then(function() {
+            // update grid items?
+        });
+    }
+
     $scope.manageCopyAlerts = function(items) {
         var copy_ids = [];
         angular.forEach(items, function(item) {
index dd3c51f..9d4767f 100644 (file)
@@ -5,9 +5,9 @@
 angular.module('egCoreMod')
 
 .factory('egCirc',
-       ['$uibModal','$q','egCore','egAlertDialog','egConfirmDialog','egCopyAlertManagerDialog',
+       ['$uibModal','$q','egCore','egAlertDialog','egConfirmDialog','egAddCopyAlertDialog','egCopyAlertManagerDialog',
         'egWorkLog',
-function($uibModal , $q , egCore , egAlertDialog , egConfirmDialog,  egCopyAlertManagerDialog,
+function($uibModal , $q , egCore , egAlertDialog , egConfirmDialog,  egAddCopyAlertDialog , egCopyAlertManagerDialog,
          egWorkLog) {
 
     var service = {
@@ -1339,6 +1339,14 @@ function($uibModal , $q , egCore , egAlertDialog , egConfirmDialog,  egCopyAlert
         });
     }
 
+    service.add_copy_alerts = function(item_ids) {
+        return egAddCopyAlertDialog.open({
+            copy_ids : item_ids,
+            ok : function() { },
+            cancel : function() {}
+        }).result.then(function() { });
+    }
+
     service.manage_copy_alerts = function(item_ids) {
         return egCopyAlertManagerDialog.open({
             copy_id : item_ids[0],
index b8dec81..e5985b7 100644 (file)
@@ -572,6 +572,73 @@ function($window , egStrings) {
 }])
 
 /**
+ * egAddCopyAlertDialog - manage copy alerts
+ */
+.factory('egAddCopyAlertDialog', 
+       ['$modal','$interpolate','egCore',
+function($modal , $interpolate , egCore) {
+    var service = {};
+
+    service.open = function(args) {
+        return $modal.open({
+            templateUrl: './share/t_add_copy_alert_dialog',
+            controller: ['$scope','$q','$modalInstance',
+                function( $scope , $q , $modalInstance) {
+
+                    $scope.copy_ids = args.copy_ids;
+                    egCore.pcrud.search('ccat',
+                        { active : 't' },
+                        {},
+                        { atomic : true }
+                    ).then(function (ccat) {
+                        $scope.alert_types = ccat;
+                    }); 
+
+                    $scope.copy_alert = {
+                        create_staff : egCore.auth.user().id(),
+                        note         : '',
+                        temp         : false
+                    };
+
+                    $scope.ok = function(copy_alert) {
+                        if (typeof(copy_alert.note) != 'undefined' &&
+                            copy_alert.note != '') {
+                            copy_alerts = [];
+                            angular.forEach($scope.copy_ids, function (cp_id) {
+                                var a = new egCore.idl.aca();
+                                a.isnew(1);
+                                a.create_staff(copy_alert.create_staff);
+                                a.note(copy_alert.note);
+                                a.temp(copy_alert.temp ? 't' : 'f');
+                                a.copy(cp_id);
+                                a.ack_time(null);
+                                a.alert_type(
+                                    $scope.alert_types.filter(function(at) {
+                                        return at.id() == copy_alert.alert_type;
+                                    })[0]
+                                );
+                                copy_alerts.push( a );
+                            });
+                            if (copy_alerts.length > 0) {
+                                egCore.pcrud.apply(copy_alerts);
+                            }
+                        }
+                        if (args.ok) args.ok();
+                        $modalInstance.close()
+                    }
+                    $scope.cancel = function() {
+                        if (args.cancel) args.cancel();
+                        $modalInstance.dismiss();
+                    }
+                }
+            ]
+        })
+    }
+
+    return service;
+}])
+
+/**
  * egCopyAlertManagerDialog - manage copy alerts
  */
 .factory('egCopyAlertManagerDialog',