← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18636: some performance improvement for tracker and event capture apps

 

------------------------------------------------------------
revno: 18636
committer: Abyot Asalefew Gizaw <abyota@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2015-03-19 15:30:09 +0100
message:
  some performance improvement for tracker and event capture apps
modified:
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/event-capture.js
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/eventList.html
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/tracker-capture.js


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/event-capture.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/event-capture.js	2015-03-19 10:50:45 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/event-capture.js	2015-03-19 14:30:09 +0000
@@ -18,6 +18,7 @@
 var PROGRAMS_METADATA = 'EVENT_PROGRAMS';
 
 var EVENT_VALUES = 'EVENT_VALUES';
+var optionSetsInPromise = [];
 
 dhis2.ec.store = null;
 dhis2.ec.memoryOnly = $('html').hasClass('ie7') || $('html').hasClass('ie8');
@@ -394,9 +395,10 @@
                     build = build.then(function() {
                         var d = $.Deferred();
                         var p = d.promise();
-                        dhis2.ec.store.get('optionSets', prStDe.dataElement.optionSet.id).done(function(obj) {                    
-                            if(!obj || obj.version !== prStDe.dataElement.optionSet.version) {
-                                promise = promise.then( getOptionSet( prStDe.dataElement.optionSet.id ) );
+                        dhis2.ec.store.get('optionSets', prStDe.dataElement.optionSet.id).done(function(obj) {
+                            if( (!obj || obj.version !== prStDe.dataElement.optionSet.version) && optionSetsInPromise.indexOf(prStDe.dataElement.optionSet.id) === -1) {
+                                optionSetsInPromise.push( prStDe.dataElement.optionSet.id );
+                                promise = promise.then( getOptionSet( prStDe.dataElement.optionSet.id ) );                                
                             }
                             d.resolve();
                         });

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/eventList.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/eventList.html	2015-03-06 10:08:41 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/eventList.html	2015-03-19 14:30:09 +0000
@@ -96,169 +96,182 @@
                     <tbody id="list">
                         <tr title="{{'click_for_action' | translate}}" ng-repeat="dhis2Event in dhis2Events | orderBy:d2Sort:reverse | gridFilter:filterText:filterTypes">
                            
-                            <!-- Visible when event is not under editing -->
-                            <td d2-context-menu 
-                                selected-item={{dhis2Event}}
-                                ng-click="showEventList()"
-                                ng-hide="(currentEvent.event == dhis2Event.event) || !eventGridColumn.show || eventGridColumn.id === 'comment'" 
-                                ng-repeat="eventGridColumn in eventGridColumns">
-                                <span ng-switch="eventGridColumn.type">
-                                    <span ng-switch-when="bool">
-                                        <span ng-if="dhis2Event[eventGridColumn.id] == 'false'">{{'no'| translate}}</span>
-                                        <span ng-if="dhis2Event[eventGridColumn.id] == 'true'">{{'yes'| translate}}</span>
-                                    </span>
-                                    <span ng-switch-default>
-                                        {{dhis2Event[eventGridColumn.id]}}
-                                    </span>
-                                </span>                                
-                            </td>
-
-                            <!-- Visible when event is under editing - in grid -->
-                            <td style="cursor:default;"
-                                ng-if="(currentEvent.event == dhis2Event.event) && eventGridColumn.show && eventGridColumn.id !== 'comment'" 
-                                ng-repeat="eventGridColumn in eventGridColumns">
-                                <ng-form name="innerFormGrid">
-                                    <div ng-switch="eventGridColumn.type">
-                                        <div ng-switch-when="int">
-                                            <input type="text" 
-                                                   program-stage-data-element={{prStDes[eventGridColumn.id]}}
-                                                   d2-validation 
-                                                   d2-number-validation
-                                                   number-type={{prStDes[eventGridColumn.id].dataElement.numberType}}
-                                                   ng-model="currentEvent[eventGridColumn.id]" 
-                                                   ng-blur="updateEventDataValue(dhis2Event, eventGridColumn.id)" 
-                                                   ng-required={{eventGridColumn.compulsory}}
-                                                   input-field-id={{eventGridColumn.id}} 
-                                                   name="foo" 
-                                                   style="width:98%;"
-                                                   ng-class="{true: 'update-success'} [currentElement.updated == true && currentElement.id == eventGridColumn.id]"
-                                                   ng-class="{true: 'update-error'} [!currentElement.updated == true && currentElement.id == eventGridColumn.id]"/>
-                                        </div>
-                                        <div ng-switch-when="string">                                        
-                                            <div ng-if="eventGridColumn.id == 'uid'">
-                                                <input type="text"
+                            <td ng-repeat="eventGridColumn in eventGridColumns" ng-if="eventGridColumn.show">
+                                
+                                <!-- Visible when event is not under editing -->
+                                <div d2-context-menu 
+                                    selected-item={{dhis2Event}}
+                                    ng-click="showEventList()"
+                                    ng-show="currentEvent.event !== dhis2Event.event && eventGridColumn.id !== 'comment'">
+                                    <span ng-switch="eventGridColumn.type">
+                                        <span ng-switch-when="bool">
+                                            <span ng-if="dhis2Event[eventGridColumn.id] == 'false'">{{'no'| translate}}</span>
+                                            <span ng-if="dhis2Event[eventGridColumn.id] == 'true'">{{'yes'| translate}}</span>
+                                        </span>
+                                        <span ng-switch-default>
+                                            <span ng-if="dhis2Event[eventGridColumn.id]">
+                                                {{dhis2Event[eventGridColumn.id]}}
+                                            </span>
+                                            <span ng-if="!dhis2Event[eventGridColumn.id]">
+                                                &nbsp;
+                                            </span>
+                                        </span>
+                                    </span>                                
+                                </div>
+                                <!-- Visible when event is not under editing -->
+                                
+                                
+                                <!-- Visible when event is under editing in grid -->
+                                <div style="cursor:default;"
+                                    ng-if="(currentEvent.event == dhis2Event.event) && eventGridColumn.show && eventGridColumn.id !== 'comment'">
+                                    <ng-form name="innerFormGrid">
+                                        <div ng-switch="eventGridColumn.type">
+                                            <div ng-switch-when="int">
+                                                <input type="text" 
+                                                       program-stage-data-element={{prStDes[eventGridColumn.id]}}
                                                        d2-validation 
-                                                       ng-model="currentEvent[eventGridColumn.id]"                                                                    
-                                                       ng-disabled=true 
+                                                       d2-number-validation
+                                                       number-type={{prStDes[eventGridColumn.id].dataElement.numberType}}
+                                                       ng-model="currentEvent[eventGridColumn.id]" 
+                                                       ng-blur="updateEventDataValue(dhis2Event, eventGridColumn.id)" 
+                                                       ng-required={{eventGridColumn.compulsory}}
+                                                       input-field-id={{eventGridColumn.id}} 
                                                        name="foo" 
-                                                       style="width:99%;"/>                                                    
+                                                       style="width:98%;"
+                                                       ng-class="{true: 'update-success'} [currentElement.updated == true && currentElement.id == eventGridColumn.id]"
+                                                       ng-class="{true: 'update-error'} [!currentElement.updated == true && currentElement.id == eventGridColumn.id]"/>
                                             </div>
-                                            <div ng-if="eventGridColumn.id !== 'uid'">
-                                                <div class="container-fluid" ng-if="optionSets[prStDes[eventGridColumn.id].dataElement.optionSet.id]">                                                
-                                                    <span ng-if="!selectedProgram.dataEntryMethod || optionSets[prStDes[eventGridColumn.id].dataElement.optionSet.id].options.length > 7">
+                                            <div ng-switch-when="string">                                        
+                                                <div ng-if="eventGridColumn.id == 'uid'">
+                                                    <input type="text"
+                                                           d2-validation 
+                                                           ng-model="currentEvent[eventGridColumn.id]"                                                                    
+                                                           ng-disabled=true 
+                                                           name="foo" 
+                                                           style="width:99%;"/>                                                    
+                                                </div>
+                                                <div ng-if="eventGridColumn.id !== 'uid'">
+                                                    <div class="container-fluid" ng-if="optionSets[prStDes[eventGridColumn.id].dataElement.optionSet.id]">                                                
+                                                        <span ng-if="!selectedProgram.dataEntryMethod || optionSets[prStDes[eventGridColumn.id].dataElement.optionSet.id].options.length > 7">
+                                                            <input type="text" 
+                                                               class="typeahead"
+                                                               placeholder="&#xf0d7;&nbsp;&nbsp;"                                                 
+                                                               ng-model="currentEvent[eventGridColumn.id]" 
+                                                               ng-blur="updateEventDataValue(dhis2Event, eventGridColumn.id)" 
+                                                               typeahead="option.name as option.name for option in optionSets[prStDes[eventGridColumn.id].dataElement.optionSet.id].options | filter:$viewValue | limitTo:20" 
+                                                               typeahead-open-on-focus
+                                                               typeahead-editable="false" 
+                                                               d2-typeahead-validation 
+                                                               ng-required={{eventGridColumn.compulsory}}
+                                                               ng-disabled="eventGridColumn.id == 'uid'"
+                                                               input-field-id={{eventGridColumn.id}} 
+                                                               name="foo" 
+                                                               style="width:98%;"
+                                                               ng-class="{true: 'update-success'} [currentElement.updated == true && currentElement.id == eventGridColumn.id]"
+                                                               ng-class="{true: 'update-error'} [!currentElement.updated == true && currentElement.id == eventGridColumn.id]"
+                                                               />
+                                                        </span>
+                                                        <span ng-if="selectedProgram.dataEntryMethod && optionSets[prStDes[eventGridColumn.id].dataElement.optionSet.id].options.length < 7">                                    
+                                                            <label>
+                                                                <input type="radio" 
+                                                                       input-field-id={{eventGridColumn.id}} 
+                                                                       name="foo"
+                                                                       d2-validation 
+                                                                       ng-required={{eventGridColumn.compulsory}}
+                                                                       ng-model="currentEvent[eventGridColumn.id]" 
+                                                                       ng-change="updateEventDataValue(dhis2Event, eventGridColumn.id)" 
+                                                                       value=""> {{'no_value' | translate}}<br>                                     
+                                                            </label>                                    
+                                                            <label ng-repeat="option in  optionSets[prStDes[eventGridColumn.id].dataElement.optionSet.id].options">
+                                                                <input type="radio" 
+                                                                       input-field-id={{eventGridColumn.id}} 
+                                                                       name={{eventGridColumn.id}}   
+                                                                       d2-validation 
+                                                                       ng-required={{eventGridColumn.compulsory}}
+                                                                       ng-model="currentEvent[eventGridColumn.id]" 
+                                                                       ng-change="updateEventDataValue(dhis2Event, eventGridColumn.id)"
+                                                                       ng-class="{true: 'update-success'} [currentElement.updated == true && currentElement.id == eventGridColumn.id]"
+                                                                       ng-class="{true: 'update-error'} [!currentElement.updated == true && currentElement.id == eventGridColumn.id]"
+                                                                       value={{option.name}}> {{option.name}}<br>                                    
+                                                            </label>
+                                                        </span>                                                
+                                                    </div>
+                                                    <div ng-if="!optionSets[prStDes[eventGridColumn.id].dataElement.optionSet.id]">
                                                         <input type="text" 
-                                                           class="typeahead"
-                                                           placeholder="&#xf0d7;&nbsp;&nbsp;"                                                 
-                                                           ng-model="currentEvent[eventGridColumn.id]" 
-                                                           ng-blur="updateEventDataValue(dhis2Event, eventGridColumn.id)" 
-                                                           typeahead="option.name as option.name for option in optionSets[prStDes[eventGridColumn.id].dataElement.optionSet.id].options | filter:$viewValue | limitTo:20" 
-                                                           typeahead-open-on-focus
-                                                           typeahead-editable="false" 
-                                                           d2-typeahead-validation 
-                                                           ng-required={{eventGridColumn.compulsory}}
-                                                           ng-disabled="eventGridColumn.id == 'uid'"
-                                                           input-field-id={{eventGridColumn.id}} 
-                                                           name="foo" 
-                                                           style="width:98%;"
-                                                           ng-class="{true: 'update-success'} [currentElement.updated == true && currentElement.id == eventGridColumn.id]"
-                                                           ng-class="{true: 'update-error'} [!currentElement.updated == true && currentElement.id == eventGridColumn.id]"
-                                                           />
-                                                    </span>
-                                                    <span ng-if="selectedProgram.dataEntryMethod && optionSets[prStDes[eventGridColumn.id].dataElement.optionSet.id].options.length < 7">                                    
-                                                        <label>
-                                                            <input type="radio" 
-                                                                   input-field-id={{eventGridColumn.id}} 
-                                                                   name="foo"
-                                                                   d2-validation 
-                                                                   ng-required={{eventGridColumn.compulsory}}
-                                                                   ng-model="currentEvent[eventGridColumn.id]" 
-                                                                   ng-change="updateEventDataValue(dhis2Event, eventGridColumn.id)" 
-                                                                   value=""> {{'no_value' | translate}}<br>                                     
-                                                        </label>                                    
-                                                        <label ng-repeat="option in  optionSets[prStDes[eventGridColumn.id].dataElement.optionSet.id].options">
-                                                            <input type="radio" 
-                                                                   input-field-id={{eventGridColumn.id}} 
-                                                                   name={{eventGridColumn.id}}   
-                                                                   d2-validation 
-                                                                   ng-required={{eventGridColumn.compulsory}}
-                                                                   ng-model="currentEvent[eventGridColumn.id]" 
-                                                                   ng-change="updateEventDataValue(dhis2Event, eventGridColumn.id)"
-                                                                   ng-class="{true: 'update-success'} [currentElement.updated == true && currentElement.id == eventGridColumn.id]"
-                                                                   ng-class="{true: 'update-error'} [!currentElement.updated == true && currentElement.id == eventGridColumn.id]"
-                                                                   value={{option.name}}> {{option.name}}<br>                                    
-                                                        </label>
-                                                    </span>                                                
+                                                            d2-validation    
+                                                            ng-model="currentEvent[eventGridColumn.id]" 
+                                                            ng-blur="updateEventDataValue(dhis2Event, eventGridColumn.id)" 
+                                                            ng-required={{eventGridColumn.compulsory}}
+                                                            ng-disabled="eventGridColumn.id == 'uid'"
+                                                            input-field-id={{eventGridColumn.id}} 
+                                                            name="foo" 
+                                                            style="width:98%;"
+                                                            ng-class="{true: 'update-success'} [currentElement.updated == true && currentElement.id == eventGridColumn.id]"
+                                                            ng-class="{true: 'update-error'} [!currentElement.updated == true && currentElement.id == eventGridColumn.id]"
+                                                            />
+                                                    </div>
                                                 </div>
-                                                <div ng-if="!optionSets[prStDes[eventGridColumn.id].dataElement.optionSet.id]">
-                                                    <input type="text" 
-                                                        d2-validation    
+                                            </div>                                        
+                                            <div ng-switch-when="bool">
+                                                <select d2-validation 
                                                         ng-model="currentEvent[eventGridColumn.id]" 
-                                                        ng-blur="updateEventDataValue(dhis2Event, eventGridColumn.id)" 
+                                                        ng-change="updateEventDataValue(dhis2Event, eventGridColumn.id)" 
                                                         ng-required={{eventGridColumn.compulsory}}
-                                                        ng-disabled="eventGridColumn.id == 'uid'"
                                                         input-field-id={{eventGridColumn.id}} 
                                                         name="foo" 
                                                         style="width:98%;"
                                                         ng-class="{true: 'update-success'} [currentElement.updated == true && currentElement.id == eventGridColumn.id]"
-                                                        ng-class="{true: 'update-error'} [!currentElement.updated == true && currentElement.id == eventGridColumn.id]"
-                                                        />
-                                                </div>
-                                            </div>
-                                        </div>                                        
-                                        <div ng-switch-when="bool">
-                                            <select d2-validation 
-                                                    ng-model="currentEvent[eventGridColumn.id]" 
-                                                    ng-change="updateEventDataValue(dhis2Event, eventGridColumn.id)" 
-                                                    ng-required={{eventGridColumn.compulsory}}
-                                                    input-field-id={{eventGridColumn.id}} 
-                                                    name="foo" 
-                                                    style="width:98%;"
-                                                    ng-class="{true: 'update-success'} [currentElement.updated == true && currentElement.id == eventGridColumn.id]"
-                                                    ng-class="{true: 'update-error'} [!currentElement.updated == true && currentElement.id == eventGridColumn.id]">
-                                                <option value="">{{'please_select'| translate}}</option>                        
-                                                <option value="false">{{'no'| translate}}</option>
-                                                <option value="true">{{'yes'| translate}}</option>
-                                            </select>
-                                        </div>
-                                        <div ng-switch-when="date">
-                                            <input type="text" 
-                                                   placeholder="{{dhis2CalendarFormat.keyDateFormat}}"
-                                                   d2-date
-                                                   max-date="prStDes[eventGridColumn.id].allowFutureDate ? '' : 0" 
-                                                   d2-validation 
-                                                   ng-model="currentEvent[eventGridColumn.id]"
-                                                   blur-or-change="updateEventDataValue(dhis2Event, eventGridColumn.id)" 
-                                                   ng-required={{eventGridColumn.compulsory}}
-                                                   ng-disabled="eventGridColumn.id == 'event_date'"
-                                                   input-field-id={{eventGridColumn.id}} 
-                                                   name="foo" 
-                                                   style="width:98%;"
-                                                   ng-class="{true: 'update-success'} [currentElement.updated == true && currentElement.id == eventGridColumn.id]"
-                                                   ng-class="{true: 'update-error'} [!currentElement.updated == true && currentElement.id == eventGridColumn.id]"
-                                                   />
-                                        </div>
-                                        <div ng-switch-when="trueOnly">
-                                            <input type="checkbox"
-                                                   d2-validation 
-                                                   ng-model="currentEvent[eventGridColumn.id]"
-                                                   ng-change="updateEventDataValue(dhis2Event, eventGridColumn.id)" 
-                                                   ng-required={{eventGridColumn.compulsory}} 
-                                                   input-field-id={{eventGridColumn.id}} 
-                                                   name="foo" 
-                                                   ng-class="{true: 'update-success'} [currentElement.updated == true && currentElement.id == eventGridColumn.id]"
-                                                   ng-class="{true: 'update-error'} [!currentElement.updated == true && currentElement.id == eventGridColumn.id]"
-                                                   />
-                                        </div>
-                                    </div>
-                                    <span ng-show="currentEvent[eventGridColumn.id] && innerFormGrid.foo.$invalid || outerForm.submitted && innerFormGrid.foo.$invalid" class="required">{{getErrorMessage(eventGridColumn.id)}}</span>
-                                </ng-form>
-                            </td>
-                            <td ng-repeat="eventGridColumn in eventGridColumns" ng-if="eventGridColumn.id === 'comment' && eventGridColumn.show">                                
-                                <a href ng-click="showNotes(dhis2Event)" title="{{'show_comments'| translate}}" ng-if="dhis2Event.notes"><i class="fa fa-info-circle"></i></a>
+                                                        ng-class="{true: 'update-error'} [!currentElement.updated == true && currentElement.id == eventGridColumn.id]">
+                                                    <option value="">{{'please_select'| translate}}</option>                        
+                                                    <option value="false">{{'no'| translate}}</option>
+                                                    <option value="true">{{'yes'| translate}}</option>
+                                                </select>
+                                            </div>
+                                            <div ng-switch-when="date">
+                                                <input type="text" 
+                                                       placeholder="{{dhis2CalendarFormat.keyDateFormat}}"
+                                                       d2-date
+                                                       max-date="prStDes[eventGridColumn.id].allowFutureDate ? '' : 0" 
+                                                       d2-validation 
+                                                       ng-model="currentEvent[eventGridColumn.id]"
+                                                       blur-or-change="updateEventDataValue(dhis2Event, eventGridColumn.id)" 
+                                                       ng-required={{eventGridColumn.compulsory}}
+                                                       ng-disabled="eventGridColumn.id == 'event_date'"
+                                                       input-field-id={{eventGridColumn.id}} 
+                                                       name="foo" 
+                                                       style="width:98%;"
+                                                       ng-class="{true: 'update-success'} [currentElement.updated == true && currentElement.id == eventGridColumn.id]"
+                                                       ng-class="{true: 'update-error'} [!currentElement.updated == true && currentElement.id == eventGridColumn.id]"
+                                                       />
+                                            </div>
+                                            <div ng-switch-when="trueOnly">
+                                                <input type="checkbox"
+                                                       d2-validation 
+                                                       ng-model="currentEvent[eventGridColumn.id]"
+                                                       ng-change="updateEventDataValue(dhis2Event, eventGridColumn.id)" 
+                                                       ng-required={{eventGridColumn.compulsory}} 
+                                                       input-field-id={{eventGridColumn.id}} 
+                                                       name="foo" 
+                                                       ng-class="{true: 'update-success'} [currentElement.updated == true && currentElement.id == eventGridColumn.id]"
+                                                       ng-class="{true: 'update-error'} [!currentElement.updated == true && currentElement.id == eventGridColumn.id]"
+                                                       />
+                                            </div>
+                                        </div>
+                                        <span ng-show="currentEvent[eventGridColumn.id] && innerFormGrid.foo.$invalid || outerForm.submitted && innerFormGrid.foo.$invalid" class="required">{{getErrorMessage(eventGridColumn.id)}}</span>
+                                    </ng-form>
+                                </div>
+                                <!-- Visible when event is under editing in grid -->
+                                
+                                <!-- visible when comment exisits -->
+                                <span ng-if="eventGridColumn.id === 'comment'" >                                
+                                    <a href ng-click="showNotes(dhis2Event)" title="{{'show_comments'| translate}}" ng-if="dhis2Event.notes"><i class="fa fa-info-circle"></i></a>
+                                </span>    
+                                <!-- visible when comment exisits -->                                
                             </td>
                         </tr>
                     </tbody>        
                 </table>
+                
                 <serverside-paginator></serverside-paginator>
             </form>
             <!-- grid ends -->

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/tracker-capture.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/tracker-capture.js	2015-03-19 10:50:45 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/tracker-capture.js	2015-03-19 14:30:09 +0000
@@ -1,3 +1,5 @@
+/* global dhis2 */
+
 dhis2.util.namespace('dhis2.tc');
 
 // whether current user has any organisation units
@@ -13,6 +15,7 @@
 var i18n_uploading_data_notification = 'Uploading locally stored data to the server';
 
 var optionSetsInPromise = [];
+var attributesInPromise = [];
 
 dhis2.tc.store = null;
 dhis2.tc.memoryOnly = $('html').hasClass('ie7') || $('html').hasClass('ie8');
@@ -415,9 +418,9 @@
                             build = build.then(function() {
                                 var d = $.Deferred();
                                 var p = d.promise();
-                                dhis2.tc.store.get('optionSets', prStDe.dataElement.optionSet.id).done(function(obj) {                            
-                                    if((!obj || obj.version !== prStDe.dataElement.optionSet.version) && !optionSetsInPromise[prStDe.dataElement.optionSet.id]) {                                
-                                        optionSetsInPromise[prStDe.dataElement.optionSet.id] = prStDe.dataElement.optionSet.id;                                
+                                dhis2.tc.store.get('optionSets', prStDe.dataElement.optionSet.id).done(function(obj) {                                    
+                                    if( (!obj || obj.version !== prStDe.dataElement.optionSet.version) && optionSetsInPromise.indexOf(prStDe.dataElement.optionSet.id) === -1) {                                
+                                        optionSetsInPromise.push( prStDe.dataElement.optionSet.id );
                                         promise = promise.then( getOptionSet( prStDe.dataElement.optionSet.id ) );
                                     }
                                     d.resolve();
@@ -624,7 +627,8 @@
             var d = $.Deferred();
             var p = d.promise();
             dhis2.tc.store.get('attributes', teAttribute.id).done(function(obj) {
-                if(!obj || obj.version !== teAttribute.version) {
+                if((!obj || obj.version !== teAttribute.version) && attributesInPromise.indexOf(teAttribute.id) === -1) {
+                    attributesInPromise.push( teAttribute.id );
                     promise = promise.then( getAttribute( teAttribute.id ) );
                 }
                 d.resolve();
@@ -654,7 +658,7 @@
         return $.ajax( {
             url: '../api/trackedEntityAttributes.json',
             type: 'GET',
-            data: 'filter=id:eq:' + id +'&fields=id,name,code,version,description,valueType,confidential,inherit,sortOrderInVisitSchedule,sortOrderInListNoProgram,displayOnVisitSchedule,displayInListNoProgram,unique,optionSet[id,version]'
+            data: 'filter=id:eq:' + id +'&paging=false&fields=id,name,code,version,description,valueType,confidential,inherit,sortOrderInVisitSchedule,sortOrderInListNoProgram,displayOnVisitSchedule,displayInListNoProgram,unique,optionSet[id,version]'
         }).done( function( response ){            
             _.each( _.values( response.trackedEntityAttributes ), function( teAttribute ) {
                 dhis2.tc.store.set( 'attributes', teAttribute );
@@ -685,8 +689,8 @@
                 var d = $.Deferred();
                 var p = d.promise();
                 dhis2.tc.store.get('optionSets', teAttribute.optionSet.id).done(function(obj) {                            
-                    if((!obj || obj.version !== teAttribute.optionSet.version) && !optionSetsInPromise[teAttribute.optionSet.id]) {                                
-                        optionSetsInPromise[teAttribute.optionSet.id] = teAttribute.optionSet.id;                                
+                    if((!obj || obj.version !== teAttribute.optionSet.version) && optionSetsInPromise.indexOf(teAttribute.optionSet.id) === -1) {                                
+                        optionSetsInPromise.push(teAttribute.optionSet.id);
                         promise = promise.then( getOptionSet( teAttribute.optionSet.id ) );
                     }
                     d.resolve();