LP1373690 egPcrud auto(), promises, authoritative repair
authorBill Erickson <berickxx@gmail.com>
Wed, 8 Mar 2017 17:47:55 +0000 (12:47 -0500)
committerBill Erickson <berickxx@gmail.com>
Wed, 8 Mar 2017 22:10:41 +0000 (17:10 -0500)
1. Fix the broken egPcrud.apply() function, which was named 'auto'
internally, by syncronizing on egPcrud.auto().  I chose .auto() over
apply, since Prototype.apply() is already a JS function -- best not
clobber it.

2. Propagate failed request promise rejections for CUD/auto calls all
the way back to the caller, so rejected promises can be properly handled
in the UI.

3. Finish implementing the paritally implemented 'authoritative' egPcrud
request option, which forces retrieve/search queries to run inside a
transaction.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/templates/staff/admin/acq/t_edi_attr_set.tt2 [new file with mode: 0644]
Open-ILS/web/js/ui/default/staff/services/pcrud.js

diff --git a/Open-ILS/src/templates/staff/admin/acq/t_edi_attr_set.tt2 b/Open-ILS/src/templates/staff/admin/acq/t_edi_attr_set.tt2
new file mode 100644 (file)
index 0000000..8e533ad
--- /dev/null
@@ -0,0 +1,49 @@
+<div class="container-fluid" style="text-align:center">
+  <div class="alert alert-info alert-less-pad strong-text-2">
+    <span>[% l('EDI Attribute Sets') %]</span>
+  </div>
+</div>
+
+<div class="row">
+  <div class="col-md-4">
+    <div class="input-group">
+      <div class="input-group-btn" uib-dropdown>
+        <button type="button" class="btn btn-default" uib-dropdown-toggle>
+          [% l('Attribute Set') %]
+          <span class="caret"></span>
+        </button>
+        <ul uib-dropdown-menu>
+          <li ng-repeat="set in attr_sets">
+            <a href='' ng-click="select_set(set)">{{set.label()}}</a>
+          </li>
+        </ul>
+      </div><!-- /btn-group -->
+      <input type="text" ng-if="!cur_attr_set"
+        class="form-control" disabled="disabled"
+        value="[% l('No Attribute Set Selected') %]"/>
+      <input type="text" ng-if="cur_attr_set"
+        class="form-control" disabled="disabled"
+        value="{{cur_attr_set.label()}}"/>
+    </div>
+  </div>
+  <div class="col-md-4">
+    <button class="btn btn-success" 
+      ng-click="apply()">[% l('Apply Changes') %]</button>
+  </div>
+</div>
+
+<div class="pad-vert">
+  <div class="row" ng-repeat="attr in attrs | orderBy:'key()'"
+    ng-class="cur_attr_set._local_map[attr.key()] ? 'selected-row' : ''">
+    <div class="col-md-3">
+      <span class="pad-right-min">
+        <input type="checkbox" 
+          ng-model="cur_attr_set._local_map[attr.key()]"/>
+      </span>
+      <span>{{attr.key()}}</span>
+    </div>
+    <div class="col-md-9">{{attr.label()}}</div>
+  </div>
+</div>
+
+
index 1f78b17..4fa405a 100644 (file)
@@ -46,7 +46,7 @@ angular.module('egCoreMod')
     // create service-level pass through functions 
     // for one-off PCRUDContext actions.
     angular.forEach(['connect', 'retrieve', 'retrieveAll', 
-        'search', 'create', 'update', 'remove', 'apply'],
+        'search', 'create', 'update', 'remove', 'auto'],
         function(action) {
             service[action] = function() {
                 var ctx = new PCRUDContext();
@@ -91,7 +91,9 @@ angular.module('egCoreMod')
             this.session.disconnect();
         };
 
-        this.retrieve = function(fm_class, pkey, pcrud_ops) {
+        this.retrieve = function(fm_class, pkey, pcrud_ops, req_ops) {
+            req_ops = req_ops || {};
+            this.authoritative = req_ops.authoritative;
             return this._dispatch(
                 'open-ils.pcrud.retrieve.' + fm_class,
                 [egAuth.token(), pkey, pcrud_ops]
@@ -106,6 +108,7 @@ angular.module('egCoreMod')
 
         this.search = function (fm_class, search, pcrud_ops, req_ops) {
             req_ops = req_ops || {};
+            this.authoritative = req_ops.authoritative;
 
             var return_type = req_ops.idlist ? 'id_list' : 'search';
             var method = 'open-ils.pcrud.' + return_type + '.' + fm_class;
@@ -119,7 +122,7 @@ angular.module('egCoreMod')
         this.create = function(list) {return this.CUD('create', list)};
         this.update = function(list) {return this.CUD('update', list)};
         this.remove = function(list) {return this.CUD('delete', list)};
-        this.apply  = function(list) {return this.CUD('apply',  list)};
+        this.auto  = function(list)  {return this.CUD('auto',  list)};
 
         this.xactClose = function() {
             return this._send_request(
@@ -179,7 +182,7 @@ angular.module('egCoreMod')
                 },
 
                 // main body error handler
-                function() {}, 
+                function() {deferred.reject()}, 
 
                 // main body notify() handler
                 function(data) {deferred.notify(data)}
@@ -287,7 +290,8 @@ angular.module('egCoreMod')
                     self.cud_last = data;
                     self.cud_deferred.notify(data);
                     self._CUD_next_request();
-                }
+                },
+                self.cud_deferred.reject
             );
            
         };