← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 15398: drop down menus for program selection and advanced search - wip

 

------------------------------------------------------------
revno: 15398
committer: Abyot Asalefew Gizaw abyota@xxxxxxxxx
branch nick: dhis2
timestamp: Mon 2014-05-26 10:08:05 +0200
message:
  drop down menus for program selection and advanced search - wip
modified:
  dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/i18n/en.json
  dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/index.html
  dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/scripts/controllers.js
  dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/scripts/tracker-capture.js
  dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/styles/style.css
  dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/home.html
  dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/pagination.html
  dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/registration.html
  dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/search.html


--
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-tracker-capture/src/main/webapp/dhis-web-tracker-capture/i18n/en.json'
--- dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/i18n/en.json	2014-05-21 15:55:51 +0000
+++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/i18n/en.json	2014-05-26 08:08:05 +0000
@@ -63,6 +63,7 @@
     "show_hide_widgets": "Show/Hide widgets",
     "select_widgets_to_show": "Select widgets to show",
     "close": "Close",
+    "list_programs": "List programs",
     "program_stage": "Program stage",
     "scheduled_date": "Scheduled date",
     "scheduling": "Scheduling",

=== modified file 'dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/index.html'
--- dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/index.html	2014-05-16 11:32:21 +0000
+++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/index.html	2014-05-26 08:08:05 +0000
@@ -63,7 +63,7 @@
         <script type="text/javascript" src="scripts/filters.js"></script>
         <script type="text/javascript" src="scripts/directives.js"></script>
         <script type="text/javascript" src="scripts/controllers.js"></script> 
-        
+          
         <!-- Menu scripts -->
         <script type="text/javascript" src="../dhis-web-commons/javascripts/dhis2/dhis2.translate.js"></script>
         <script type="text/javascript" src="../dhis-web-commons/javascripts/dhis2/dhis2.menu.js"></script>

=== modified file 'dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/scripts/controllers.js'
--- dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/scripts/controllers.js	2014-05-21 16:21:54 +0000
+++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/scripts/controllers.js	2014-05-26 08:08:05 +0000
@@ -37,8 +37,8 @@
     $scope.showSearchDiv = false;
     $scope.searchText = null;
     $scope.emptySearchText = false;
-    $scope.searchFilterExists = false;
-    $scope.attributes = AttributesFactory.getWithoutProgram();    
+    $scope.searchFilterExists = false;    
+    
     $scope.searchMode = { 
                             listAll: 'LIST_ALL', 
                             freeText: 'FREE_TEXT', 
@@ -51,6 +51,8 @@
     //watch for selection of org unit from tree
     $scope.$watch('selectedOrgUnit', function() {
         
+        $scope.attributes = AttributesFactory.getWithoutProgram();    
+        
         if( angular.isObject($scope.selectedOrgUnit)){   
             
             storage.set('SELECTED_OU', $scope.selectedOrgUnit);
@@ -60,8 +62,9 @@
             
             //apply translation - by now user's profile is fetched from server.
             TranslationService.translate();
-            $scope.loadPrograms($scope.selectedOrgUnit);
+            $scope.loadPrograms($scope.selectedOrgUnit);            
             $scope.search($scope.searchMode.listAll);
+            
         }
     });
     
@@ -91,7 +94,8 @@
                 if( !angular.isUndefined($scope.programs)){                    
                     if($scope.programs.length === 1){
                         $scope.selectedProgram = $scope.programs[0];
-                        $scope.pr = $scope.selectedProgram;                        
+                        $scope.pr = $scope.selectedProgram;    
+                        $scope.attributes = AttributesFactory.getByProgram($scope.selectedProgram);
                     }                    
                 }
             }
@@ -101,16 +105,19 @@
     $scope.getProgramAttributes = function(program){ 
         $scope.trackedEntityList = null; 
         $scope.selectedProgram = program;
+        
         if($scope.selectedProgram){
             $scope.attributes = AttributesFactory.getByProgram($scope.selectedProgram);
         }
         else{
             $scope.attributes = AttributesFactory.getWithoutProgram();
         }
+
+        $scope.search($scope.searchMode);
     };
     
     $scope.search = function(mode){ 
-
+        
         $scope.emptySearchText = false;
         $scope.emptySearchAttribute = false;
         $scope.showSearchDiv = false;
@@ -148,6 +155,8 @@
         else if( mode === $scope.searchMode.listAll ){   
             $scope.showTrackedEntityDiv = true;    
         }      
+        
+        $scope.gridColumns = $scope.generateGridColumns($scope.attributes);
 
         //get events for the specified parameters
         TEIService.search($scope.selectedOrgUnit.id, 
@@ -155,12 +164,7 @@
                                             queryUrl,
                                             programUrl,
                                             attributeUrl.url).then(function(data){
-            $scope.trackedEntityList = data;
-            
-            if($scope.trackedEntityList){
-                $scope.gridColumns = $scope.generateGridColumns($scope.attributes); 
-            }                      
-            
+            $scope.trackedEntityList = data;            
         });
     };
     

=== modified file 'dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/scripts/tracker-capture.js'
--- dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/scripts/tracker-capture.js	2014-05-21 16:13:41 +0000
+++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/scripts/tracker-capture.js	2014-05-26 08:08:05 +0000
@@ -124,6 +124,23 @@
    
     //dhis2.availability.startAvailabilityCheck();
     
+    //drop down menus for program selection and advanced search
+    $( "#searchDropDown" ).width($( "#searchDropDownParent" ).width());   
+    $( "#selectDropDown" ).width($( "#selectDropDownParent" ).width());
+    
+    $(".select-drop-down-button").on('click', function(e){
+       e.stopPropagation();
+       $("#selectDropDown").dropdown('toggle');
+    });
+    
+});
+
+$(window).resize(function() {
+    $( "#selectDropDown" ).width($( "#selectDropDownParent" ).width());  
+    $( "#searchDropDown" ).width($( "#searchDropDownParent" ).width());  
+    
+    console.log('select parent width is-r:  ', $( "#selectDropDownParent" ).width());
+    console.log('select width is-r:  ', $( "#selectDropDown" ).width());
 });
 
 function ajax_login()

=== modified file 'dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/styles/style.css'
--- dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/styles/style.css	2014-05-22 13:19:01 +0000
+++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/styles/style.css	2014-05-26 08:08:05 +0000
@@ -849,4 +849,14 @@
 
 .underline{
     text-decoration: underline;
+}
+
+.select-drop-down-button{
+    text-align: left;
+    padding: 6px 12px;
+    color: #999;
+}
+
+.dropdown-menu {
+    margin-top: -5px;
 }
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/home.html'
--- dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/home.html	2014-05-22 13:19:01 +0000
+++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/home.html	2014-05-26 08:08:05 +0000
@@ -21,11 +21,15 @@
 
     <input type="text" selected-org-unit ng-model="selectedOrgUnit.name" ng-hide=true>
     <div class="row">        
-        <div class="input-group col-md-4">
+        <div id="searchDropDownParent" class="input-group col-md-6">
             <input type="text" placeholder="{{'your_search_input_here'| translate}}" ng-model="searchText" class="form-control" ng-class="{true: 'invalid - input'} [!searchText && emptySearchText]" ng-focus="hideSearch()" ng-disabled="showRegistrationDiv">
-            <span class="input-group-btn">
-                <button class="btn btn-default trim" type="button" title="{{'advanced_search'| translate}}" ng-click="showSearch()" ng-disabled="showRegistrationDiv"><i class="fa fa-caret-down"></i></button>
-            </span>                
+            <div class="input-group-btn">
+                <button class="btn btn-default trim" type="button" title="{{'advanced_search'| translate}}" data-toggle="dropdown" ng-disabled="showRegistrationDiv"><i class="fa fa-caret-down"></i></button>
+                <div id="searchDropDown" class="dropdown-menu pull-right">
+                    <form ng-include="'views/search.html'">                       
+                    </form>
+                </div>
+            </div>                
         </div>        
         <div class="col-md-3 trim">            
             <button type="button" 
@@ -44,11 +48,21 @@
     </div>
 
     <div class="row vertical-spacing">
-        <div class="col-md-4">
-            <select class="form-control" ng-model="pr" ng-change="getProgramAttributes(pr)" ng-options="program as program.name for program in programs | orderBy: 'name'">
-                <option value="">{{'please_select_a_program'| translate}}</option>
-            </select>
+        <div id="selectDropDownParent" class="input-group col-md-6">            
+            <button type="button" class="select-drop-down-button form-control" >{{selectedProgram ? selectedProgram.name : 'please_select_a_program'| translate}}</button>
+            <div class="input-group-btn">
+                <button class="btn btn-default trim" type="button" title="{{'list_programs'| translate}}" data-toggle="dropdown"><i class="fa fa-caret-down"></i></button>
+                <ul id="selectDropDown" class="dropdown-menu pull-right">
+                    <li>
+                        <a href ng-click="getProgramAttributes(null)">{{'please_select_a_program'| translate}}</a>
+                    </li>
+                    <li ng-repeat="program in programs | orderBy: 'name'">
+                        <a href ng-click="getProgramAttributes(program)">{{program.name}}</a>
+                    </li>
+                </ul>
+            </div>                
         </div>
+
         <div class="col-md-3 trim"> 
             <button type="button" 
                     class="btn btn-default" 
@@ -59,17 +73,17 @@
     </div>
 
     <div class="row vertical-spacing" ng-if="!searchText && emptySearchText">
-        <div class="col-md-4">
+        <div class="col-md-6">
             <div class="alert alert-danger">{{'search_input_required'| translate}}</div>         
         </div>
     </div>
 
     <!-- search begins -->
-    <div class="row" ng-show="showSearchDiv">
+    <!--<div class="row" ng-show="showSearchDiv">
         <div class="col-md-6">
             <div ng-include="'views/search.html'"></div>             
         </div>
-    </div>
+    </div>-->
     <!-- search ends -->
 
     <!--registration begins -->

=== modified file 'dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/pagination.html'
--- dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/pagination.html	2014-05-22 13:19:01 +0000
+++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/pagination.html	2014-05-26 08:08:05 +0000
@@ -1,5 +1,5 @@
 <div class="paging-container">
-    <table style="background-color: #f5f5f5;" width='100%'>
+    <table style="background-color: #ebf0f6;" width='100%'>
         <tr>
             <td>
                 {{'total_number_of_pages'| translate}}: {{paginator.pageCount()}}

=== modified file 'dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/registration.html'
--- dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/registration.html	2014-05-21 14:59:16 +0000
+++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/registration.html	2014-05-26 08:08:05 +0000
@@ -81,10 +81,10 @@
                 </table>
             </div>
             
-            <div class="btn-group vertical-spacing">                
+            <div class="vertical-spacing">                
                 <button type="button" class="btn btn-default" ng-click="registerEntity(true)">{{'save_and_continue'| translate}}</button>
-                <button type="button" class="btn btn-default" ng-click="registerEntity(false)">{{'save_and_add_new'| translate}}</button>
-                <button type="button" class="btn btn-default" ng-click="showRegistration()">{{'cancel'| translate}}</button>
+                <button type="button" class="btn btn-default small-horizonal-spacing" ng-click="registerEntity(false)">{{'save_and_add_new'| translate}}</button>
+                <button type="button" class="btn btn-default small-horizonal-spacing" ng-click="showRegistration()">{{'cancel'| translate}}</button>
             </div>
         </form>
     </div>

=== modified file 'dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/search.html'
--- dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/search.html	2014-05-22 13:19:01 +0000
+++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/views/search.html	2014-05-26 08:08:05 +0000
@@ -1,53 +1,49 @@
-<div class="bordered-div">    
-
-    <div class="search-container">
-        <table class="table-borderless table-striped">
-            <tr>
-                <td>{{'org_unit_mode'| translate}}</td>
-                <td>
-                    <input type="radio" ng-model="ouMode.name" value="SELECTED">{{'use_selected'| translate}}<br/>
-                    <input type="radio" ng-model="ouMode.name" value="CHILDREN">{{'use_immediate_children'| translate}}<br/>
-                    <input type="radio" ng-model="ouMode.name" value="DESCENDANTS">{{'use_all_children'| translate}}
-                </td>
-            </tr>
-            <tr ng-repeat="attribute in attributes">
-                <td>
-                    {{attribute.name}} - {{attribute.valueType}}
-                </td>
-                <td>
-                    <div ng-switch="attribute.valueType">
-                        <div ng-switch-when="date">
-                            <input type="text" class="form-control" ng-date ng-model="attribute.value" />
-                        </div>
-                        <div ng-switch-when="trueOnly">
-                            <input type="checkbox" class="form-control" ng-model="attribute.value" />
-                        </div>
-                        <div ng-switch-when="bool">
-                            <select multiple ui-select2 ng-model="attribute.value" data-placeholder="{{'please_select'| translate}}" style="width:100%;">
-                                <option value="0">{{'no'| translate}}</option>
-                                <option value="1">{{'yes'| translate}}</option>
-                            </select>
-                        </div>
-                        <div ng-switch-when="combo">
-                            <select multiple ui-select2  ng-model="attribute.value" data-placeholder="{{'please_select'| translate}}" style="width:100%;">
-                                <option ng-repeat="option in attribute.optionSet.options" value="{{option}}">{{option}}</option>
-                            </select>
-                        </div>
-                        <div ng-switch-when="number">
-                            <input type="number" class="form-control" ng-model="attribute.value"/>
-                        </div>
-                        <div ng-switch-default>
-                            <input type="text" class="form-control" ng-model="attribute.value" />                                        
-                        </div>
-                    </div>                                                                                                    
-                </td>
-            </tr>         
-        </table>
-    </div>   
-
+
+    <table class="table-borderless table-striped">
+        <tr>
+            <td>{{'org_unit_mode'| translate}}</td>
+            <td>
+                <input type="radio" ng-model="ouMode.name" value="SELECTED">{{'use_selected'| translate}}<br/>
+                <input type="radio" ng-model="ouMode.name" value="CHILDREN">{{'use_immediate_children'| translate}}<br/>
+                <input type="radio" ng-model="ouMode.name" value="DESCENDANTS">{{'use_all_children'| translate}}
+            </td>
+        </tr>
+        <tr ng-repeat="attribute in attributes">
+            <td>
+                {{attribute.name}} - {{attribute.valueType}}
+            </td>
+            <td>
+                <div ng-switch="attribute.valueType">
+                    <div ng-switch-when="date">
+                        <input type="text" class="form-control" ng-date ng-model="attribute.value" />
+                    </div>
+                    <div ng-switch-when="trueOnly">
+                        <input type="checkbox" class="form-control" ng-model="attribute.value" />
+                    </div>
+                    <div ng-switch-when="bool">
+                        <select multiple ui-select2 ng-model="attribute.value" data-placeholder="{{'please_select'| translate}}" style="width:100%;">
+                            <option value="0">{{'no'| translate}}</option>
+                            <option value="1">{{'yes'| translate}}</option>
+                        </select>
+                    </div>
+                    <div ng-switch-when="combo">
+                        <select multiple ui-select2  ng-model="attribute.value" data-placeholder="{{'please_select'| translate}}" style="width:100%;">
+                            <option ng-repeat="option in attribute.optionSet.options" value="{{option}}">{{option}}</option>
+                        </select>
+                    </div>
+                    <div ng-switch-when="number">
+                        <input type="number" class="form-control" ng-model="attribute.value"/>
+                    </div>
+                    <div ng-switch-default>
+                        <input type="text" class="form-control" ng-model="attribute.value" />                                        
+                    </div>
+                </div>                                                                                                    
+            </td>
+        </tr>         
+    </table>
 
     <button type="button" 
-            class="btn btn-default small-horizonal-spacing"
+            class="btn btn-default"
             ng-click="search(searchMode.attributeBased)">
         {{'search'| translate}}
     </button>
@@ -68,4 +64,4 @@
         </div>
     </div>
 
-</div>
\ No newline at end of file
+