copy alert type editor can now create and update copy alert types
authorGalen Charlton <gmc@esilibrary.com>
Fri, 11 Dec 2015 04:15:34 +0000 (23:15 -0500)
committerGalen Charlton <gmc@equinoxinitiative.org>
Fri, 3 Nov 2017 20:02:04 +0000 (16:02 -0400)
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Open-ILS/src/templates/staff/admin/local/autoGridEditor/ccat.tt2 [new file with mode: 0644]
Open-ILS/web/js/ui/default/staff/admin/local/app.js

diff --git a/Open-ILS/src/templates/staff/admin/local/autoGridEditor/ccat.tt2 b/Open-ILS/src/templates/staff/admin/local/autoGridEditor/ccat.tt2
new file mode 100644 (file)
index 0000000..e3011e9
--- /dev/null
@@ -0,0 +1,89 @@
+<!-- use <form> so we get submit-on-enter for free -->
+<form class="form-validated" novalidate name="form" ng-submit="ok(record)">
+  <div>
+    <div class="modal-header">
+      <button type="button" class="close" 
+        ng-click="cancel()" aria-hidden="true">&times;</button>
+      <h4 ng-if="creating"  class="modal-title">[% l('Create copy alert type') %]</h4>
+      <h4 ng-if="!creating" class="modal-title">[% l('Update copy alert type') %]</h4>
+    </div>
+    <div class="modal-body">
+      <div class="form-group">
+        <label for="edit-alert-name">[% l('Name') %]</label>
+        <input type="text" class="form-control" focus-me='focusMe' required
+          id="edit-alert-name" ng-model="record.name" placeholder="[% l('Name...') %]"/>
+      </div>
+      <div class="form-group">
+        <label for="active-selector">[% l('Active') %]</label>
+        <select id="active-selector" class="form-control" ng-model="record.active">
+            <option value="t">[% l('Yes') %]</option>
+            <option value="f">[% l('No') %]</option>
+        </select>
+      </div>
+      <div class="form-group">
+        <label for="state-selector">[% l('State') %]</label>
+        <select id="state-selector" class="form-control" ng-model="record.state">
+            <option value="NORMAL">[% l('Normal') %]</option>
+            <option value="LOST">[% l('Lost') %]</option>
+            <option value="LOST_AND_PAID">[% l('Lost and paid for') %]</option>
+            <option value="MISSING">[% l('Missing') %]</option>
+            <option value="DAMAGED">[% l('Damaged') %]</option>
+            <option value="CLAIMSRETURNED">[% l('Claims returned') %]</option>
+            <option value="CLAIMSNEVERCHECKEDOUT">[% l('Claims never checked out') %]</option>
+        </select>
+      </div>
+      <div class="form-group">
+        <label for="event-selector">[% l('Event') %]</label>
+        <select id="event-selector" class="form-control" ng-model="record.event">
+            <option value="CHECKIN">[% l('Checkin') %]</option>
+            <option value="CHECKOUT">[% l('Checkout') %]</option>
+        </select>
+      </div>
+      <div class="form-group">
+        <label for="select-org-unit">[% l('Scope Org Unit') %]</label>
+        <eg-org-selector selected="record.scope_org"></eg-org-selector>
+      </div>
+      <div class="form-group">
+        <label for="edit-alert-next-statuses">[% l('Next Status') %]</label>
+        <input type="text" class="form-control" focus-me='focusMe' 
+          id="edit-alert-next-statuses" ng-model="record.next_status" />
+      </div>
+      <div class="form-group">
+        <label for="inrenew-selector">[% l('Renewing?') %]</label>
+        <select id="inrenew-selector" class="form-control" ng-model="record.in_renew">
+            <option value="">[% l('Any') %]</option>
+            <option value="t">[% l('Yes') %]</option>
+            <option value="f">[% l('No') %]</option>
+        </select>
+      </div>
+      <div class="form-group">
+        <label for="invert-location-selector">[% l('Invert location?') %]</label>
+        <select id="invert-location-selector" class="form-control" ng-model="record.invert_location">
+            <option value="t">[% l('Yes') %]</option>
+            <option value="f">[% l('No') %]</option>
+        </select>
+      </div>
+      <div class="form-group">
+        <label for="at-circ-selector">[% l('At Circulating Library?') %]</label>
+        <select id="at-circ-selector" class="form-control" ng-model="record.at_circ">
+            <option value="">[% l('Do not care') %]</option>
+            <option value="t">[% l('Yes') %]</option>
+            <option value="f">[% l('No') %]</option>
+        </select>
+      </div>
+      <div class="form-group">
+        <label for="at-owning-selector">[% l('At Owning Library?') %]</label>
+        <select id="at-owning-selector" class="form-control" ng-model="record.at_owning">
+            <option value="">[% l('Do not care') %]</option>
+            <option value="t">[% l('Yes') %]</option>
+            <option value="f">[% l('No') %]</option>
+        </select>
+      </div>
+    </div>
+    <div class="modal-footer">
+      <input type="submit" ng-disabled="form.$invalid" 
+          class="btn btn-primary" value="[% l('Save') %]"/>
+      <button class="btn btn-warning" ng-click="cancel()">[% l('Cancel') %]</button>
+    </div>
+  </div> <!-- modal-content -->
+</form>
index 9d0e802..160fe80 100644 (file)
@@ -54,7 +54,12 @@ angular.module('egLocalAdmin',
     $routeProvider.when('/admin/local/config/copy_alert_types', {
         templateUrl: './admin/local/t_grid_editor',
         controller: 'AutoGridEditorCtl',
-        fmBase: 'ccat'
+        fmBase: 'ccat',
+        createEditPrefetch: {
+            ccs : { id : {'!=' : null} }
+        },
+        createEditOrgExpand: ['scope_org'],
+        createEditNullableBool : ['in_renew', 'at_circ', 'at_owning']
     });
 
     $routeProvider.when('/admin/local/actor/copy_alert_suppress', {
@@ -130,6 +135,7 @@ function($scope , $route , $location , egCore , $timeout , egConfirmDialog , $mo
     $scope.baseFmClass = $route.current.$$route.fmBase;
     $scope.createEditPrefetch = $route.current.$$route.createEditPrefetch || {};
     $scope.createEditOrgExpand = $route.current.$$route.createEditOrgExpand || [];
+    $scope.createEditNullableBool = $route.current.$$route.createEditNullableBool || [];
     $scope.gridControls = {
         setQuery : function(q) {
             if (q) query = q;
@@ -179,6 +185,10 @@ function($scope , $route , $location , egCore , $timeout , egConfirmDialog , $mo
                     newRec[key](val);
                 }
             });
+            angular.forEach($scope.createEditNullableBool, function(nb_field) {
+                if (!(record[nb_field] == null) && record[nb_field] == "")
+                    newRec[nb_field](null);
+            });
             return egCore.pcrud.create(newRec);
         }).then(function(){
             $scope.gridControls.refresh();
@@ -188,12 +198,16 @@ function($scope , $route , $location , egCore , $timeout , egConfirmDialog , $mo
         openCreateEditDialog(items[0].id).result.then(function(record) {
             var editedRec = new egCore.idl[$scope.baseFmClass]();
             angular.forEach(record, function(val, key) {
-                if (typeof(val) === 'object') {
+                if (angular.isObject(val)) {
                     editedRec[key](val.id());
                 } else {
                     editedRec[key](val);
                 }
             });
+            angular.forEach($scope.createEditNullableBool, function(nb_field) {
+                if (!(record[nb_field] == null) && record[nb_field] == "")
+                    editedRec[nb_field](null);
+            });
             return egCore.pcrud.update(editedRec);
         }).then(function(){
             $scope.gridControls.refresh();