← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 11642: Data entry, code style

 

------------------------------------------------------------
revno: 11642
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2013-08-12 21:34:06 +0200
message:
  Data entry, code style
modified:
  dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/entry.js
  dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.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-dataentry/src/main/webapp/dhis-web-dataentry/javascript/entry.js'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/entry.js	2013-07-20 12:35:56 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/entry.js	2013-08-12 19:34:06 +0000
@@ -230,7 +230,7 @@
 {
     fieldId = '#' + fieldId;
 
-    var value = $( fieldId ).attr('checked');
+    var value = $( fieldId ).attr( 'checked' );
 
     $( fieldId ).css( 'background-color', COLOR_YELLOW );
 

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js	2013-08-07 14:18:03 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js	2013-08-12 19:34:06 +0000
@@ -414,7 +414,7 @@
         $( this ).css( 'margin-right', '2px' );
     } );
 
-    $( 'entrytrueonly' ).each( function( i )
+    $( '.entrytrueonly' ).each( function( i )
     {
         var id = $( this ).attr( 'id' );
         var split = splitFieldId( id );
@@ -967,7 +967,7 @@
             showLoader();
             $( '#selectedPeriodId' ).val( periodId );
 
-            var isMultiOrganisationUnitForm = !!$('#selectedDataSetId :selected').data('multiorg');
+            var isMultiOrganisationUnitForm = !!$( '#selectedDataSetId :selected' ).data( 'multiorg' );
             loadForm( dataSetId, isMultiOrganisationUnitForm );
         }
         else
@@ -1048,8 +1048,6 @@
 
     $( '.entryfield' ).filter( ':disabled' ).css( 'background-color', COLOR_GREY );
     
-    // Disable and grey dynamic fields to start with and enable later
-
     $.ajax( {
     	url: 'getDataValues.action',
     	data:
@@ -1070,17 +1068,17 @@
 	    {
 	    	if ( json.locked )
 	    	{
-	            $('#contentDiv input').attr('disabled', 'disabled');
-	            $('.entryoptionset').autocomplete('disable');
-                $('.sectionFilter').removeAttr('disabled');
+	            $( '#contentDiv input').attr( 'disabled', 'disabled' );
+	            $( '.entryoptionset').autocomplete( 'disable' );
+                $( '.sectionFilter').removeAttr( 'disabled' );
                 $( '#completenessDiv' ).hide();
 	    		setHeaderDelayMessage( i18n_dataset_is_locked );
 	    	}
 	    	else
 	    	{
-                $('.entryoptionset').autocomplete('enable');
-                $('#contentDiv input').removeAttr('disabled');
-                $('#contentDiv input').css('backgroundColor', '#fff');
+                $( '.entryoptionset' ).autocomplete( 'enable' );
+                $( '#contentDiv input' ).removeAttr( 'disabled' );
+                $( '#contentDiv input' ).css( 'backgroundColor', '#fff' );
 	    		$( '#completenessDiv' ).show();
 	    	}
 	    	
@@ -1092,9 +1090,12 @@
 
 	            if ( $( fieldId ).length > 0 )
 	            {
-                    if ( $( fieldId ).attr( 'name' ) == 'entrytrueonly' ) {
-                        $( fieldId ).attr('checked', true);
-                    } else {
+                    if ( $( fieldId ).attr( 'name' ) == 'entrytrueonly' ) 
+                    {
+                        $( fieldId ).attr( 'checked', true);
+                    } 
+                    else 
+                    {
                         $( fieldId ).val( value.val );
                     }
                 }
@@ -1104,7 +1105,8 @@
 
 	        // Set min-max values and colorize violation fields
 
-            if(!json.locked) {
+            if( !json.locked ) 
+            {
                 $.safeEach( json.minMaxDataElements, function( i, value )
                 {
                     var minId = value.id + '-min';
@@ -1153,9 +1155,10 @@
 	            $( '#infoDiv' ).hide();
 	        }
 
-            if(json.locked) {
-                $('#contentDiv input').css('backgroundColor', '#eee');
-                $('.sectionFilter').css('backgroundColor', '#fff');
+            if ( json.locked ) 
+            {
+                $( '#contentDiv input' ).css( 'backgroundColor', '#eee' );
+                $( '.sectionFilter' ).css( 'backgroundColor', '#fff' );
             }
         }
 	} );
@@ -1168,19 +1171,6 @@
     $( '#validationButton' ).removeAttr( 'disabled' );
     $( '#validateButton' ).removeAttr( 'disabled' );
 
-    /*
-    if ( !multiOrganisationUnit )
-    {
-        $( '#validationButton' ).removeAttr( 'disabled' );
-        $( '#validateButton' ).removeAttr( 'disabled' );
-    }
-    else
-    {
-        $( '#validationButton' ).attr( 'disabled', true );
-        $( '#validateButton' ).attr( 'disabled', true );
-    }
-    */
-
     dataEntryFormIsLoaded = true;
     hideLoader();
     
@@ -1325,8 +1315,8 @@
 {
     var confirmed = confirm( i18n_confirm_undo );
     var params = storageManager.getCurrentCompleteDataSetParams();
-    params['organisationUnitId'] = selection.getSelected();
-    params['multiOrganisationUnit'] = multiOrganisationUnit;
+    params[ 'organisationUnitId' ] = selection.getSelected();
+    params[ 'multiOrganisationUnit' ] = multiOrganisationUnit;
 
     if ( confirmed )
     {
@@ -1374,7 +1364,8 @@
 	{
 		var url = '../dhis-web-commons-ajax-json/getUser.action';
 
-		$.getJSON( url, { username:currentCompletedByUser }, function( json ) {
+		$.getJSON( url, { username:currentCompletedByUser }, function( json ) 
+		{
 			$( '#userFullName' ).html( json.user.firstName + ' ' + json.user.surname );
 			$( '#userUsername' ).html( json.user.username );
 			$( '#userEmail' ).html( json.user.email );
@@ -2134,14 +2125,15 @@
 // Option set
 // -----------------------------------------------------------------------------
 
-function searchOptionSet( uid, query, success ) {
-    if(window.DAO !== undefined && window.DAO.store !== undefined ) {
+function searchOptionSet( uid, query, success ) 
+{
+    if ( window.DAO !== undefined && window.DAO.store !== undefined ) {
         DAO.store.get( 'optionSets', uid ).done( function ( obj ) {
-            if(obj) {
+            if ( obj ) {
                 var options = [];
 
-                if(query == null || query == "") {
-                    options = obj.optionSet.options.slice(0, MAX_DROPDOWN_DISPLAYED-1);
+                if ( query == null || query == '' ) {
+                    options = obj.optionSet.options.slice( 0, MAX_DROPDOWN_DISPLAYED - 1 );
                 } else {
                     query = query.toLowerCase();
 
@@ -2198,9 +2190,9 @@
     var promise = deferred.promise();
 
     _.each( options, function ( item, idx ) {
-        if(uids.indexOf(item.uid) == -1) {
-            DAO.store.get('optionSets', item.uid).done(function(obj) {
-                if(!obj || obj.optionSet.version !== item.v) {
+        if( uids.indexOf( item.uid ) == -1 ) {
+            DAO.store.get('optionSets', item.uid).done( function( obj ) {
+                if( !obj || obj.optionSet.version !== item.v ) {
                     promise = promise.then( function () {
                         return $.ajax( {
                             url: '../api/optionSets/' + item.uid + '.json?links=false',
@@ -2246,13 +2238,13 @@
 }
 
 function autocompleteOptionSetField( idField, optionSetUid ) {
-    var input = jQuery( "#" + idField );
+    var input = jQuery( '#' + idField );
 
     if ( !input ) {
         return;
     }
 
-    input.css( "width", "85%" );
+    input.css( 'width', '85%' );
     input.autocomplete( {
         delay: 0,
         minLength: 0,
@@ -2261,40 +2253,40 @@
         },
         select: function ( event, ui ) {
             input.val( ui.item.value );
-            input.autocomplete( "close" );
+            input.autocomplete( 'close' );
             input.change();
         }
-    } ).addClass( "ui-widget" );
+    } ).addClass( 'ui-widget' );
 
-    input.data( "autocomplete" )._renderItem = function ( ul, item ) {
-        return $( "<li></li>" )
-            .data( "item.autocomplete", item )
-            .append( "<a>" + item.label + "</a>" )
+    input.data( 'autocomplete' )._renderItem = function ( ul, item ) {
+        return $( '<li></li>' )
+            .data( 'item.autocomplete', item )
+            .append( '<a>' + item.label + '</a>' )
             .appendTo( ul );
     };
 
-    var wrapper = this.wrapper = $( "<span style='width:200px'>" )
-        .addClass( "ui-combobox" )
+    var wrapper = this.wrapper = $( '<span style="width:200px">' )
+        .addClass( 'ui-combobox' )
         .insertAfter( input );
 
-    var button = $( "<a style='width:20px; margin-bottom:-5px;height:20px;'>" )
-        .attr( "tabIndex", -1 )
-        .attr( "title", i18n_show_all_items )
+    var button = $( '<a style="width:20px; margin-bottom:-5px;height:20px;">' )
+        .attr( 'tabIndex', -1 )
+        .attr( 'title', i18n_show_all_items )
         .appendTo( wrapper )
         .button( {
             icons: {
-                primary: "ui-icon-triangle-1-s"
+                primary: 'ui-icon-triangle-1-s'
             },
             text: false
         } )
         .addClass( 'small-button' )
         .click( function () {
-            if ( input.autocomplete( "widget" ).is( ":visible" ) ) {
-                input.autocomplete( "close" );
+            if ( input.autocomplete( 'widget' ).is( ':visible' ) ) {
+                input.autocomplete( 'close' );
                 return;
             }
             $( this ).blur();
-            input.autocomplete( "search", "" );
+            input.autocomplete( 'search', '' );
             input.focus();
         } );
 }