add a copy alert editor dialog
authorGalen Charlton <gmc@esilibrary.com>
Fri, 2 Sep 2016 21:36:25 +0000 (17:36 -0400)
committerGalen Charlton <gmc@equinoxinitiative.org>
Mon, 27 Mar 2017 20:30:50 +0000 (16:30 -0400)
This replaces, in certain contexts, the copy alert manager,
which is now used only during checkin/checkout.

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

Open-ILS/src/templates/staff/share/t_copy_alert_editor_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

diff --git a/Open-ILS/src/templates/staff/share/t_copy_alert_editor_dialog.tt2 b/Open-ILS/src/templates/staff/share/t_copy_alert_editor_dialog.tt2
new file mode 100644 (file)
index 0000000..aad1a6b
--- /dev/null
@@ -0,0 +1,55 @@
+<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('Manage Copy Alerts') %]</h4>
+    </div>
+    <div class="modal-body">
+      <div class="row" ng-repeat="a in copy_alert_list" ng-init="temp = (a.temp() == 't'); note = a.note(); acked = (a.ack_time() !== null); alert_type = a.alert_type().id()">
+        <div class="col-md-12">
+          <div class="row">
+            <div class="col-md-6 form-inline">
+              <label for="copy-alert-type-select-{{a.id()}}">[% l('Type') %]</label>
+              <select id="copy-alert-type-select-{{a.id()}}" class="form-control"
+                      ng-model="alert_type"
+                      ng-change="a.alert_type(alert_type) && a.ischanged(1)"
+                      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="temp" ng-change="a.temp(temp ? 't' : 'f') && a.ischanged(1)" ng-disabled="acked"/>
+                [% l('Temporary') %]
+              </label>
+            </div>
+            <div class="col-md-3">
+              <label>
+                <input type="checkbox" ng-model="acked" ng-change="(acked ? a.ack_time('now') : a.ack_time(null)) && a.ischanged(1)"/>
+                [% l('Clear?') %]
+              </label>
+            </div>
+          </div>
+          <div class="row pad-vert">
+            <div class="col-md-12">
+              <textarea class="form-control" ng-change="a.note(note) && a.ischanged(1)"
+                ng-model="note" placeholder="[% l('Alert...') %]" ng-disabled="acked">
+              </textarea>
+            </div>
+          </div>
+          <div class="row">
+            <div class="col-md-12">
+              <hr/>
+            </div>
+          </div>
+        </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 1fc5ca5..0172e55 100644 (file)
@@ -6,9 +6,9 @@ angular.module('egCoreMod')
 
 .factory('egCirc',
 
-       ['$uibModal','$q','egCore','egAlertDialog','egConfirmDialog','egAddCopyAlertDialog','egCopyAlertManagerDialog',
+       ['$uibModal','$q','egCore','egAlertDialog','egConfirmDialog','egAddCopyAlertDialog','egCopyAlertManagerDialog','egCopyAlertEditorDialog',
         'egWorkLog',
-function($uibModal , $q , egCore , egAlertDialog , egConfirmDialog,  egAddCopyAlertDialog , egCopyAlertManagerDialog,
+function($uibModal , $q , egCore , egAlertDialog , egConfirmDialog,  egAddCopyAlertDialog , egCopyAlertManagerDialog,  egCopyAlertEditorDialog ,
          egWorkLog) {
 
     var service = {
@@ -1233,9 +1233,8 @@ function($uibModal , $q , egCore , egAlertDialog , egConfirmDialog,  egAddCopyAl
     }
 
     service.manage_copy_alerts = function(item_ids) {
-        return egCopyAlertManagerDialog.open({
+        return egCopyAlertEditorDialog.open({
             copy_id : item_ids[0],
-            mode : 'manage',
             ok : function() { },
             cancel : function() {}
         }).result.then(function() { });
index 8888191..b9a7d95 100644 (file)
@@ -595,6 +595,69 @@ function($uibModal , $interpolate , egCore) {
     return service;
 }])
 
+/**
+ * egCopyAlertEditorDialog - manage copy alerts
+ */
+.factory('egCopyAlertEditorDialog', 
+       ['$uibModal','$interpolate','egCore',
+function($uibModal , $interpolate , egCore) {
+    var service = {};
+
+    service.get_user_copy_alerts = function(copy_id) {
+        return egCore.pcrud.search('aca', { copy : copy_id, ack_time : null },
+            { flesh : 1, flesh_fields : { aca : ['alert_type'] } },
+            { atomic : true }
+        );
+    }
+
+    service.get_copy_alert_types = function() {
+        return egCore.pcrud.search('ccat',
+            { active : 't' },
+            {},
+            { atomic : true }
+        );
+    };
+
+    service.open = function(args) {
+        return $uibModal.open({
+            templateUrl: './share/t_copy_alert_editor_dialog',
+            controller: ['$scope','$q','$uibModalInstance',
+                function( $scope , $q , $uibModalInstance) {
+
+                    function init(args) {
+                        var defer = $q.defer();
+                        if (args.copy_id) {
+                            service.get_user_copy_alerts(args.copy_id).then(function(aca) {
+                                defer.resolve(aca);
+                            });
+                        } else {
+                            defer.resolve(args.alerts);
+                        }
+                        return defer.promise;
+                    }
+
+                    init(args).then(function(copy_alerts) {
+                        $scope.copy_alert_list = copy_alerts;
+                    });
+                    service.get_copy_alert_types().then(function(ccat) {
+                        $scope.alert_types = ccat;
+                    });
+
+                    $scope.ok = function() {
+                        egCore.pcrud.apply($scope.copy_alert_list);
+                        $uibModalInstance.close()
+                    }
+                    $scope.cancel = function() {
+                        if (args.cancel) args.cancel();
+                        $uibModalInstance.dismiss();
+                    }
+                }
+            ]
+        })
+    }
+
+    return service;
+}])
 .directive('aDisabled', function() {
     return {
         restrict : 'A',