[open-ils-commits] [GIT] Evergreen ILS branch rel_3_0 updated. 937eb0c692a9cdcf3f0d3cc64b84d06ca659bb50

Evergreen Git git at git.evergreen-ils.org
Tue Nov 7 12:04:10 EST 2017


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Evergreen ILS".

The branch, rel_3_0 has been updated
       via  937eb0c692a9cdcf3f0d3cc64b84d06ca659bb50 (commit)
      from  f4c1c11c69f2409211a85082c02a470eb1c7c807 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 937eb0c692a9cdcf3f0d3cc64b84d06ca659bb50
Author: Bill Erickson <berickxx at gmail.com>
Date:   Mon Oct 30 11:36:29 2017 -0400

    LP#1728122 Webstaff survey display avoids deep fleshing
    
    Avoid collecting survey/question/answer data via deep pcrud fleshing.
    Opt instead to organize the data locally using the values fleshed
    directly on the response object.
    
    Additional fixes included:
    
    1. Avoid displaying survey responses for out-of-scope surveys.
    2. Format survey response dates using the configured date format instead
       of display a bare ISO date.
    
    Signed-off-by: Bill Erickson <berickxx at gmail.com>
    Signed-off-by: Chris Sharp <csharp at georgialibraries.org>
    Signed-off-by: Galen Charlton <gmc at equinoxinitiative.org>

diff --git a/Open-ILS/src/templates/staff/circ/patron/t_surveys.tt2 b/Open-ILS/src/templates/staff/circ/patron/t_surveys.tt2
index bd059b8..3f5e7d8 100644
--- a/Open-ILS/src/templates/staff/circ/patron/t_surveys.tt2
+++ b/Open-ILS/src/templates/staff/circ/patron/t_surveys.tt2
@@ -1,27 +1,34 @@
 <div class="strong-text-2">[% l('Surveys') %]</div>
-<div class="row pad-vert" ng-repeat="survey in surveys">
+<div class="row pad-vert" ng-repeat="collection in surveys">
   <div class="col-md-12">
     <div class="row">
-      <div class="col-md-2 strong-text">[% l('Survey') %] #{{survey.id()}}</div>
-      <div class="col-md-6 strong-text">{{survey.description()}}</div>
+      <div class="col-md-2 strong-text">
+        [% l('Survey') %] #{{collection.survey.id()}}
+      </div>
+      <div class="col-md-6 strong-text">{{collection.survey.description()}}</div>
       <div class="col-md-4">
         <div class="pull-right">
-          <span class="pad-horiz alert alert-warning strong-text" ng-if="survey.required() == 't'">[% l('Required') %]</span>
-          <span class="pad-horiz  alert alert-info strong-text " ng-if="survey.opac() == 't'">[% l('OPAC Visible') %]</span>
+          <span class="pad-horiz alert alert-warning strong-text" 
+            ng-if="collection.survey.required() == 't'">[% l('Required') %]</span>
+          <span class="pad-horiz  alert alert-info strong-text " 
+            ng-if="collection.survey.opac() == 't'">[% l('OPAC Visible') %]</span>
         </div>
       </div>
     </div>
     <div class="row">
       <div class="col-md-12 well" style="margin-left:12px">
         <ol>
-          <li ng-repeat="question in survey.questions()">{{question.question()}}
-            <div class="row" ng-repeat="response in question.responses() | limitTo:-1">
-              <span class="col-md-4">[% l('Last Answered on: ') %]{{response.answer_date() | date}}</span>
-              <span class="col-md-3">[% l('Answer: ') %] <span class="strong-text">{{response.answer().answer()}}</span></span>
-          </div>
+          <li ng-repeat="response in collection.responses">
+            <span class="col-md-3">{{response.question().question()}}</span>
+            <span class="col-md-3">[% l('Answer: ') %] <span class="strong-text">
+              {{response.answer().answer()}}</span>
+            </span>
+            <span class="col-md-3">[% l('Last Answered on: ') %]
+              {{response.answer_date() | date:$root.egDateFormat}}
+            </span>
           </li>
         </ol>
       </div>
     </div>
   </div>
-</div>
\ No newline at end of file
+</div>
diff --git a/Open-ILS/web/js/ui/default/staff/circ/patron/app.js b/Open-ILS/web/js/ui/default/staff/circ/patron/app.js
index 3c6c34d..8fbd807 100644
--- a/Open-ILS/web/js/ui/default/staff/circ/patron/app.js
+++ b/Open-ILS/web/js/ui/default/staff/circ/patron/app.js
@@ -1169,25 +1169,54 @@ function($scope,  $routeParams , $location , egCore , patronSvc) {
     $scope.initTab('other', $routeParams.id);
     var usr_id = $routeParams.id;
     var org_ids = egCore.org.fullPath(egCore.auth.user().ws_ou(), true);
+
     $scope.surveys = [];
-    // fetch the surveys
+    var svr_responses = {};
+
+    // fetch all survey responses for this user.
     egCore.pcrud.search('asvr',
         {usr : usr_id},
-        {flesh : 4, flesh_fields : {
-            asvr : ['question', 'survey', 'answer'],
-            asv : ['responses', 'questions'],
-            asvq : ['responses', 'question']
-    }},
-        {authoritative : true})
-    .then(null, null, function(survey) {
-        var sameSurveyId = false;
-        if (survey.survey().id() && $scope.surveys.length > 0) {
-            for (sid = 0; sid < $scope.surveys.length; sid++) {
-                if (survey.survey().id() == $scope.surveys[sid].id()) sameSurveyId = true; 
+        {flesh : 2, flesh_fields : {asvr : ['survey','question','answer']}}
+    ).then(
+        function() {
+            // All responses collected and deduplicated.
+            // Create one collection of responses per survey.
+
+            angular.forEach(svr_responses, function(questions, survey_id) {
+                var collection = {responses : []};
+                angular.forEach(questions, function(response) {
+                    collection.survey = response.survey(); // same for one.
+                    collection.responses.push(response);
+                });
+                $scope.surveys.push(collection);
+            });
+        },
+        null, 
+        function(response) {
+
+            // Discard responses for out-of-scope surveys.
+            if (org_ids.indexOf(response.survey().owner()) < 0) 
+                return;
+
+            // survey_id => question_id => response
+            var svr_id = response.survey().id();
+            var qst_id = response.question().id();
+
+            if (!svr_responses[svr_id]) 
+                svr_responses[svr_id] = [];
+
+            if (!svr_responses[svr_id][qst_id]) {
+                svr_responses[svr_id][qst_id] = response;
+
+            } else {
+                // We have multiple responses for the same question.
+                // For this UI we only care about the most recent response.
+                if (response.effective_date() > 
+                    svr_responses[svr_id][qst_id].effective_date())
+                    svr_responses[svr_id][qst_id] = response;
             }
         }
-        if (!sameSurveyId) $scope.surveys.push(survey.survey());
-    });
+    );
 }])
 
 .controller('PatronFetchLastCtrl',

-----------------------------------------------------------------------

Summary of changes:
 .../src/templates/staff/circ/patron/t_surveys.tt2  |   29 ++++++----
 .../web/js/ui/default/staff/circ/patron/app.js     |   57 +++++++++++++++-----
 2 files changed, 61 insertions(+), 25 deletions(-)


hooks/post-receive
-- 
Evergreen ILS


More information about the open-ils-commits mailing list