← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2342: (GIS) Improved code: Lazy rendering and lazy instantiation + Improved GUI: Favorites window.

 

Merge authors:
  Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 2342 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2010-12-11 21:10:33 +0100
message:
  (GIS) Improved code: Lazy rendering and lazy instantiation + Improved GUI: Favorites window.
modified:
  dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/impl/DefaultReportTableService.java
  dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/css/style.css
  dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/index.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-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/impl/DefaultReportTableService.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/impl/DefaultReportTableService.java	2010-12-10 22:00:25 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/impl/DefaultReportTableService.java	2010-12-11 19:53:11 +0000
@@ -75,6 +75,7 @@
 {
     private static final Log log = LogFactory.getLog( DefaultReportTableService.class );
     
+    private static final String NULL_REPLACEMENT = "0.0";
     private static final String MODE_REPORT = "report";
     private static final String MODE_REPORT_TABLE = "table";
 
@@ -498,7 +499,7 @@
                         
                         for ( String identifier : reportTable.getCrossTabIdentifiers() )
                         {
-                            grid.addValue( valueOf( map.get( identifier ) ) );
+                            grid.addValue( parseAndReplaceNull( map.get( identifier ) ) );
                         }
                         
                         // -----------------------------------------------------
@@ -509,11 +510,11 @@
                         {
                             for ( DimensionOption dimensionOption : reportTable.getDimensionOptions() )
                             {
-                                grid.addValue( valueOf( aggregatedDataValueService.
+                                grid.addValue( String.valueOf( aggregatedDataValueService.
                                     getAggregatedValue( (DataElement) metaObject, dimensionOption, period, unit ) ) );
                             }
                             
-                            grid.addValue( valueOf( aggregatedDataValueService.getAggregatedValue( (DataElement) metaObject, period, unit ) ) );
+                            grid.addValue( String.valueOf( aggregatedDataValueService.getAggregatedValue( (DataElement) metaObject, period, unit ) ) );
                         }
                     }
                 }
@@ -524,14 +525,14 @@
     }
     
     /**
-     * Converts the given Double to String.
+     * Converts the given Double to String or replaces with default value if null.
      * 
      * @param value the Double.
      * @return the String.
      */
-    private String valueOf( Double value )
+    private String parseAndReplaceNull( Double value )
     {
-        return value != null ? String.valueOf( value ) : null;
+        return value != null ? String.valueOf( value ) : NULL_REPLACEMENT;
     }
     
     /**

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/css/style.css'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/css/style.css	2010-12-10 18:26:13 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/css/style.css	2010-12-11 19:53:11 +0000
@@ -213,15 +213,11 @@
 }
 .x-btn .icon-add {
 	background-image:url(../../../images/add.png);
-    padding-left:
 }
 .x-btn .icon-remove {
 	background-image:url(../../../images/remove.png);
 }
 .x-btn .icon-assign {
-	background-image:url(../../../images/assign2.png);
-}
-.x-btn .icon-assign {
 	background-image:url(../../../images/accept.png);
 }
 .x-btn .icon-export {

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/index.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/index.js	2010-12-11 16:47:49 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/index.js	2010-12-11 19:53:11 +0000
@@ -447,133 +447,61 @@
 	}
 	addOverlaysToMap(true);
 			
-	/* Section: mapview */
-    var newViewPanel = new Ext.form.FormPanel({
-        id: 'newview_p',
-		bodyStyle: 'border:0px solid #fff',
-        items: [
-            new Ext.form.TextField({
-                id: 'viewname_tf',
-                emptytext: GLOBAL.conf.emptytext,
-                labelSeparator: GLOBAL.conf.labelseparator,
-                fieldLabel: i18n_display_name,
-                width: GLOBAL.conf.combo_width_fieldset,
-                autoCreate: {tag: 'input', type: 'text', size: '20', autocomplete: 'off', maxlength: '35'}
-            })
-        ]
-    });
-    
-    var deleteViewPanel = new Ext.form.FormPanel({   
-        id: 'deleteview_p',
-		bodyStyle: 'border:0px solid #fff',
-        items: [
-            new Ext.form.ComboBox({
-                id: 'view_cb',
-                editable: false,
-                valueField: 'id',
-                displayField: 'name',
-                mode: 'remote',
-                forceSelection: true,
-                triggerAction: 'all',
-                emptyText: GLOBAL.conf.emptytext,
-                labelSeparator: GLOBAL.conf.labelseparator,
-                fieldLabel: i18n_favorite,
-                selectOnFocus: true,
-                width: GLOBAL.conf.combo_width_fieldset,
-                minListWidth: GLOBAL.conf.combo_width_fieldset,
-                store:GLOBAL.stores.mapView
-            })
-        ]
-    });
-    
-    var dashboardViewPanel = new Ext.form.FormPanel({   
-        id: 'dashboardview_p',
-		bodyStyle: 'border:0px solid #fff',
-        items: [
-            new Ext.form.ComboBox({
-                id: 'view2_cb',
-                editable: false,
-                valueField: 'id',
-                displayField: 'name',
-                mode: 'remote',
-                forceSelection: true,
-                triggerAction: 'all',
-                emptyText: GLOBAL.conf.emptytext,
-                labelSeparator: GLOBAL.conf.labelseparator,
-                fieldLabel: i18n_favorite,
-                selectOnFocus: true,
-                width: GLOBAL.conf.combo_width_fieldset,
-                minListWidth: GLOBAL.conf.combo_width_fieldset,
-                store: GLOBAL.stores.mapView
-            })
-        ]
-    });
-    
-	var viewWindow = new Ext.Window({
-        id: 'view_w',
+	/* Section: mapview */    
+	var favoriteWindow = new Ext.Window({
+        id: 'favorite_w',
         title: '<span id="window-favorites-title">' + i18n_favorites + '</span>',
 		layout: 'fit',
         closeAction: 'hide',
 		width: GLOBAL.conf.window_width,
-        height: 125,
-        items:
-        [
+        height: 180,
+        items: [
             {
-                xtype: 'tabpanel',
-                activeTab: 0,
-				layoutOnTabChange: true,
-                deferredRender: false,
-                plain: true,
-                defaults: {
-                    bodyStyle: 'padding:8px; border:0px'
-                },
-                listeners: {
-                    tabchange: function(panel, tab)
-                    {
-                        if (tab.id == 'view0') {
-                            Ext.getCmp('newview_b').show();
-                            Ext.getCmp('deleteview_b').hide();
-                            Ext.getCmp('dashboardview_b').hide();
-                        }
-                        else if (tab.id == 'view1') {
-                            Ext.getCmp('newview_b').hide();
-                            Ext.getCmp('deleteview_b').show();
-                            Ext.getCmp('dashboardview_b').hide();
-                        }
-                        else if (tab.id == 'view2') {
-                            Ext.getCmp('newview_b').hide();
-                            Ext.getCmp('deleteview_b').hide();
-                            Ext.getCmp('dashboardview_b').show();
-                        }
-                    }
-                },
+                xtype: 'form',
+                bodyStyle: 'padding:8px',
                 items: [
-                    {
-                        title: '<span class="panel-tab-title">' + i18n_new + '</span>',
-                        id: 'view0',
-                        items: [newViewPanel]
-                    },
-                    {
-                        title: '<span class="panel-tab-title">' + i18n_delete + '</span>',
-                        id: 'view1',
-                        items: [deleteViewPanel]
-                    },
-                    {
-                        title: '<span class="panel-tab-title">' + i18n_dhis_dashboard + '</span>',
-                        id: 'view2',
-                        items: [dashboardViewPanel]
+                    {html: '<div class="window-info">Register current map as a favorite</div>'},
+                    {
+                        xtype: 'textfield',
+                        id: 'favoritename_tf',
+                        emptytext: GLOBAL.conf.emptytext,
+                        labelSeparator: GLOBAL.conf.labelseparator,
+                        fieldLabel: i18n_display_name,
+                        width: GLOBAL.conf.combo_width_fieldset,
+                        autoCreate: {tag: 'input', type: 'text', size: '20', autocomplete: 'off', maxlength: '35'}
+                    },
+                    {html: '<div class="window-p"></div>'},
+                    {html: '<div class="window-info">Delete / Add favorite to dashboard</div>'},
+                    {
+                        xtype: 'combo',
+                        id: 'favorite_cb',
+                        editable: false,
+                        valueField: 'id',
+                        displayField: 'name',
+                        mode: 'remote',
+                        forceSelection: true,
+                        triggerAction: 'all',
+                        emptyText: GLOBAL.conf.emptytext,
+                        labelSeparator: GLOBAL.conf.labelseparator,
+                        fieldLabel: i18n_favorite,
+                        selectOnFocus: true,
+                        width: GLOBAL.conf.combo_width_fieldset,
+                        minListWidth: GLOBAL.conf.combo_width_fieldset,
+                        store:GLOBAL.stores.mapView
                     }
                 ]
             }
         ],
         bbar: [
-            '->',            
-            new Ext.Button({
+            '->',
+            {
+                xtype: 'button',
                 id: 'newview_b',
+                iconCls: 'icon-add',
 				hideLabel: true,
 				text: i18n_register,
 				handler: function() {
-					var vn = Ext.getCmp('viewname_tf').getValue();
+					var vn = Ext.getCmp('favoritename_tf').getValue();
                     
                     if (!vn) {
 						Ext.message.msg(false, i18n_form_is_not_complete);
@@ -639,17 +567,45 @@
 							else if (formValues.featureType == GLOBAL.conf.map_feature_type_multipolygon) {
 								GLOBAL.stores.pointMapView.load();
 							}
-                            Ext.getCmp('viewname_tf').reset();
+                            Ext.getCmp('favoritename_tf').reset();
                         }
                     });
 				}
-			}),
-            new Ext.Button({
+			},
+            {
+                xtype: 'button',
+                id: 'dashboardview_b',
+                iconCls: 'icon-assign',
+				hideLabel: true,
+				text: i18n_add,
+				handler: function() {
+					var v = Ext.getCmp('favorite_cb').getValue();
+					var rv = Ext.getCmp('favorite_cb').getRawValue();
+					
+					if (!v) {
+						Ext.message.msg(false, i18n_please_select_a_map_view);
+						return;
+					}
+					
+					Ext.Ajax.request({
+						url: GLOBAL.conf.path_mapping + 'addMapViewToDashboard' + GLOBAL.conf.type,
+						method: 'POST',
+						params: {id:v},
+						success: function(r) {
+							Ext.message.msg(true, i18n_favorite + ' <span class="x-msg-hl">' + rv + '</span> ' + i18n_added_to_dashboard);
+                            Ext.getCmp('favorite_cb').clearValue();
+						}
+					});
+				}
+            },
+            {
+                xtype: 'button',
                 id: 'deleteview_b',
+                iconCls: 'icon-remove',
 				hideLabel: true,
 				text: i18n_delete,
 				handler: function() {
-					var v = Ext.getCmp('view_cb').getValue();
+					var v = Ext.getCmp('favorite_cb').getValue();
 					
                     if (!v) {
 						Ext.message.msg(false, i18n_please_select_a_map_view);
@@ -665,8 +621,7 @@
 						success: function(r) {
 							Ext.message.msg(true, i18n_favorite + ' <span class="x-msg-hl">' + name + '</span> ' + i18n_deleted);
                             GLOBAL.stores.mapView.load();
-                            Ext.getCmp('view_cb').clearValue();
-                            Ext.getCmp('view2_cb').clearValue();
+                            Ext.getCmp('favorite_cb').clearValue();
                             if (v == choropleth.form.findField('mapview').getValue()) {
                                 choropleth.form.findField('mapview').clearValue();
                             }
@@ -676,31 +631,7 @@
 						}
 					});
 				}
-			}),
-            new Ext.Button({
-                id: 'dashboardview_b',
-				isFormField: true,
-				hideLabel: true,
-				text: i18n_add,
-				handler: function() {
-					var v = Ext.getCmp('view2_cb').getValue();
-					var rv = Ext.getCmp('view2_cb').getRawValue();
-					
-					if (!v) {
-						Ext.message.msg(false, i18n_please_select_a_map_view);
-						return;
-					}
-					
-					Ext.Ajax.request({
-						url: GLOBAL.conf.path_mapping + 'addMapViewToDashboard' + GLOBAL.conf.type,
-						method: 'POST',
-						params: {id:v},
-						success: function(r) {
-							Ext.message.msg(true, i18n_favorite + ' <span class="x-msg-hl">' + rv + '</span> ' + i18n_added_to_dashboard);
-						}
-					});
-				}
-            })
+			}
         ]
     });
 	
@@ -2637,13 +2568,13 @@
 		handler: function() {
 			var x = Ext.getCmp('center').x + 15;
 			var y = Ext.getCmp('center').y + 41;    
-			viewWindow.setPosition(x,y);
+			favoriteWindow.setPosition(x,y);
 
-			if (viewWindow.visible) {
-				viewWindow.hide();
+			if (favoriteWindow.visible) {
+				favoriteWindow.hide();
 			}
 			else {
-				viewWindow.show();
+				favoriteWindow.show();
 			}
 		}
 	});