← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14441: ER, fixed/dynamic filters.

 

Merge authors:
  Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 14441 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2014-03-26 16:35:57 +0100
message:
  ER, fixed/dynamic filters.
modified:
  dhis-2/dhis-web/dhis-web-event-reports/src/main/resources/org/hisp/dhis/eventreport/i18n_module.properties
  dhis-2/dhis-web/dhis-web-event-reports/src/main/webapp/dhis-web-event-reports/app/i18n.json
  dhis-2/dhis-web/dhis-web-event-reports/src/main/webapp/dhis-web-event-reports/app/scripts/app.js
  dhis-2/dhis-web/dhis-web-event-reports/src/main/webapp/dhis-web-event-reports/app/scripts/core.js
  dhis-2/dhis-web/dhis-web-event-reports/src/main/webapp/dhis-web-event-reports/app/styles/style.css


--
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-event-reports/src/main/resources/org/hisp/dhis/eventreport/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-event-reports/src/main/resources/org/hisp/dhis/eventreport/i18n_module.properties	2014-02-25 14:47:36 +0000
+++ dhis-2/dhis-web/dhis-web-event-reports/src/main/resources/org/hisp/dhis/eventreport/i18n_module.properties	2014-03-26 15:32:14 +0000
@@ -151,4 +151,5 @@
 count=Count
 sum=Sum
 by_data_element=By data element
-relative_periods=Relative periods
\ No newline at end of file
+relative_periods=Relative periods
+start_end_dates=Start-end dates
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-event-reports/src/main/webapp/dhis-web-event-reports/app/i18n.json'
--- dhis-2/dhis-web/dhis-web-event-reports/src/main/webapp/dhis-web-event-reports/app/i18n.json	2014-02-20 16:04:06 +0000
+++ dhis-2/dhis-web/dhis-web-event-reports/src/main/webapp/dhis-web-event-reports/app/i18n.json	2014-03-26 15:32:14 +0000
@@ -151,5 +151,6 @@
 "count",
 "sum",
 "by_data_element",
-"relative_periods"
+"relative_periods",
+"start_end_dates"
 ]

=== modified file 'dhis-2/dhis-web/dhis-web-event-reports/src/main/webapp/dhis-web-event-reports/app/scripts/app.js'
--- dhis-2/dhis-web/dhis-web-event-reports/src/main/webapp/dhis-web-event-reports/app/scripts/app.js	2014-03-25 16:56:37 +0000
+++ dhis-2/dhis-web/dhis-web-event-reports/src/main/webapp/dhis-web-event-reports/app/scripts/app.js	2014-03-26 15:32:14 +0000
@@ -549,12 +549,12 @@
 	// constructors
 
 	AggregateLayoutWindow = function() {
-		var dimension,
-			dimensionStore,
-			row,
+		var row,
 			rowStore,
 			col,
 			colStore,
+            fixedFilter,
+            fixedFilterStore,
 			filter,
 			filterStore,
 			value,
@@ -562,7 +562,6 @@
 			getData,
 			getStore,
 			getStoreKeys,
-			getCmpHeight,
 			getSetup,
             addDimension,
             removeDimension,
@@ -576,7 +575,7 @@
 
 			margin = 1,
 			defaultWidth = 160,
-			defaultHeight = 158,
+			defaultHeight = 220,
 			maxHeight = (ns.app.viewport.getHeight() - 100) / 2;
 
 		getData = function(all) {
@@ -627,71 +626,25 @@
 			return keys;
 		};
 
-		dimensionStore = getStore();
-		dimensionStore.reset = function(all) {
-			dimensionStore.removeAll();
-			dimensionStore.add(getData(all));
-		};
-		ns.app.stores.dimension = dimensionStore;
-
 		colStore = getStore();
 		colStore.add({id: dimConf.organisationUnit.dimensionName, name: dimConf.organisationUnit.name});
         colStore.add({id: dimConf.period.dimensionName, name: dimConf.period.name});
 
 		rowStore = getStore();
 
+        fixedFilterStore = getStore();
+        fixedFilterStore.setListHeight = function() {
+            var fixedFilterHeight = 26 + (this.getRange().length * 21) + 1;
+            fixedFilter.setHeight(fixedFilterHeight);
+            filter.setHeight(defaultHeight - fixedFilterHeight);
+        };
+
 		filterStore = getStore();
 
-		getCmpHeight = function() {
-			var size = dimensionStore.totalCount,
-				expansion = 10,
-				height = defaultHeight,
-				diff;
-
-			if (size > 10) {
-				diff = size - 10;
-				height += (diff * expansion);
-			}
-
-			height = height > maxHeight ? maxHeight : height;
-
-			return height;
-		};
-
-		dimension = Ext.create('Ext.ux.form.MultiSelect', {
-			cls: 'ns-toolbar-multiselect-leftright',
-			width: defaultWidth,
-			height: (getCmpHeight() * 2) + margin,
-			style: 'margin-right:' + margin + 'px; margin-bottom:0px',
-			valueField: 'id',
-			displayField: 'name',
-			dragGroup: 'layoutDD',
-			dropGroup: 'layoutDD',
-			ddReorder: false,
-			store: dimensionStore,
-			tbar: {
-				height: 25,
-				items: {
-					xtype: 'label',
-					text: NS.i18n.dimensions,
-					cls: 'ns-toolbar-multiselect-leftright-label'
-				}
-			},
-			listeners: {
-				afterrender: function(ms) {
-					ms.store.on('add', function() {
-						Ext.defer( function() {
-							ms.boundList.getSelectionModel().deselectAll();
-						}, 10);
-					});
-				}
-			}
-		});
-
 		col = Ext.create('Ext.ux.form.MultiSelect', {
 			cls: 'ns-toolbar-multiselect-leftright',
 			width: defaultWidth,
-			height: getCmpHeight(),
+			height: defaultHeight,
 			style: 'margin-bottom:' + margin + 'px',
 			valueField: 'id',
 			displayField: 'name',
@@ -710,7 +663,7 @@
 				afterrender: function(ms) {
 					ms.boundList.on('itemdblclick', function(view, record) {
 						ms.store.remove(record);
-						dimensionStore.add(record);
+						filterStore.add(record);
 					});
 
 					ms.store.on('add', function() {
@@ -718,21 +671,14 @@
 							ms.boundList.getSelectionModel().deselectAll();
 						}, 10);
 					});
-				},
-                added: function(n1, n2, n3, n4) {
-                    console.log(arguments);
-                    nissa1 = n1;
-                    nissa2 = n2;
-                    nissa3 = n3;
-                    nissa4 = n4;
-                }
+				}
 			}
 		});
 
 		row = Ext.create('Ext.ux.form.MultiSelect', {
 			cls: 'ns-toolbar-multiselect-leftright',
 			width: defaultWidth,
-			height: getCmpHeight(),
+			height: defaultHeight,
 			style: 'margin-bottom:0px',
 			valueField: 'id',
 			displayField: 'name',
@@ -751,7 +697,7 @@
 				afterrender: function(ms) {
 					ms.boundList.on('itemdblclick', function(view, record) {
 						ms.store.remove(record);
-						dimensionStore.add(record);
+						filterStore.add(record);
 					});
 
 					ms.store.on('add', function() {
@@ -763,30 +709,44 @@
 			}
 		});
 
+        fixedFilter = Ext.create('Ext.ux.form.MultiSelect', {
+			cls: 'ns-toolbar-multiselect-leftright ns-multiselect-fixed',
+			width: defaultWidth,
+			height: 26,
+			style: 'margin-right:' + margin + 'px; margin-bottom:0',
+			valueField: 'id',
+			displayField: 'name',
+			store: fixedFilterStore,
+			tbar: {
+				height: 25,
+				items: {
+					xtype: 'label',
+					text: NS.i18n.filter,
+					cls: 'ns-toolbar-multiselect-leftright-label'
+				}
+			},
+			listeners: {
+				afterrender: function(ms) {
+                    ms.on('change', function() {
+                        ms.boundList.getSelectionModel().deselectAll();
+                    });
+				}
+			}
+		});
+
 		filter = Ext.create('Ext.ux.form.MultiSelect', {
-			cls: 'ns-toolbar-multiselect-leftright',
+			cls: 'ns-toolbar-multiselect-leftright ns-multiselect-dynamic',
 			width: defaultWidth,
-			height: getCmpHeight(),
+			height: defaultHeight - 26,
 			style: 'margin-right:' + margin + 'px; margin-bottom:' + margin + 'px',
+            bodyStyle: 'border-top:0 none',
 			valueField: 'id',
 			displayField: 'name',
 			dragGroup: 'layoutDD',
 			dropGroup: 'layoutDD',
 			store: filterStore,
-			tbar: {
-				height: 25,
-				items: {
-					xtype: 'label',
-					text: NS.i18n.filter,
-					cls: 'ns-toolbar-multiselect-leftright-label'
-				}
-			},
 			listeners: {
 				afterrender: function(ms) {
-					ms.boundList.on('itemdblclick', function(view, record) {
-						ms.store.remove(record);
-						dimensionStore.add(record);
-					});
 
 					ms.store.on('add', function() {
 						Ext.defer( function() {
@@ -801,10 +761,18 @@
 			bodyStyle: 'border:0 none',
 			items: [
 				{
+                    xtype: 'container',
 					layout: 'column',
 					bodyStyle: 'border:0 none',
 					items: [
-						filter,
+                        {
+                            xtype: 'container',
+                            bodyStyle: 'border:0 none',
+                            items: [
+                                fixedFilter,
+                                filter
+                            ]
+                        },
 						col
 					]
 				},
@@ -818,16 +786,8 @@
 			]
 		});
 
-		getSetup = function() {
-			return {
-				col: getStoreKeys(colStore),
-				row: getStoreKeys(rowStore),
-				filter: getStoreKeys(filterStore)
-			};
-		};
-
         addDimension = function(record, store) {
-            var store = dimensionStoreMap[record.id] || store || dimensionStore;
+            var store = dimensionStoreMap[record.id] || store || filterStore;
 
             if (!hasDimension(record.id)) {
                 store.add(record);
@@ -835,7 +795,7 @@
         };
 
         removeDimension = function(dataElementId) {
-            var stores = [dimensionStore, colStore, rowStore, filterStore];
+            var stores = [colStore, rowStore, filterStore, fixedFilterStore];
 
             for (var i = 0, store, index; i < stores.length; i++) {
                 store = stores[i];
@@ -849,7 +809,7 @@
         };
 
         hasDimension = function(id) {
-            var stores = [dimensionStore, colStore, rowStore, filterStore];
+            var stores = [colStore, rowStore, filterStore, fixedFilterStore];
 
             for (var i = 0, store, index; i < stores.length; i++) {
                 store = stores[i];
@@ -876,8 +836,8 @@
                 dimensionStoreMap[record.data.id] = filterStore;
             });
 
-            dimensionStore.each(function(record) {
-                dimensionStoreMap[record.data.id] = dimensionStore;
+            fixedFilterStore.each(function(record) {
+                dimensionStoreMap[record.data.id] = fixedFilterStore;
             });
         };
 
@@ -889,23 +849,16 @@
 			modal: true,
 			resizable: false,
 			getSetup: getSetup,
-			dimensionStore: dimensionStore,
 			colStore: colStore,
 			rowStore: rowStore,
+            fixedFilterStore: fixedFilterStore,
 			filterStore: filterStore,
             addDimension: addDimension,
             removeDimension: removeDimension,
             hasDimension: hasDimension,
             saveState: saveState,
 			hideOnBlur: true,
-			items: {
-				layout: 'column',
-				bodyStyle: 'border:0 none',
-				items: [
-					dimension,
-					selectPanel
-				]
-			},
+			items: selectPanel,
 			bbar: [
 				'->',
 				{
@@ -946,7 +899,15 @@
 							ns.core.web.window.addHideOnBlurHandler(w);
 						}
 					}
-				}
+				},
+                render: function() {
+                    fixedFilterStore.on('add', function() {
+                        this.setListHeight();
+                    });
+                    fixedFilterStore.on('remove', function() {
+                        this.setListHeight();
+                    });
+                }
 			}
 		});
 
@@ -3032,7 +2993,9 @@
 		};
 
         selectDataElements = function(items) {
-            var dataElements = [];
+            var dataElements = [],
+                aggWindow = ns.app.aggregateLayoutWindow,
+                queryWindow = ns.app.queryLayoutWindow;
 
 			// data element objects
             for (var i = 0, item; i < items.length; i++) {
@@ -3052,13 +3015,15 @@
             }
 
 			// panel, store
-            for (var i = 0, element, ux; i < dataElements.length; i++) {
+            for (var i = 0, element, ux, store; i < dataElements.length; i++) {
 				element = dataElements[i];
 
 				addUxFromDataElement(element);
 
-                ns.app.aggregateLayoutWindow.addDimension(element, ns.app.aggregateLayoutWindow.rowStore);
-                ns.app.queryLayoutWindow.colStore.add(element);
+                store = (element.type === 'int' || element.type === 'boolean' || element.optionSet) ? aggWindow.rowStore : aggWindow.fixedFilterStore;
+
+                aggWindow.addDimension(element, store);
+                queryWindow.colStore.add(element);
 			}
         };
 
@@ -3115,6 +3080,7 @@
                 startEndDate.show();
                 periods.hide();
 
+                ns.app.aggregateLayoutWindow.addDimension({id: dimConf.startEndDate.value, name: dimConf.startEndDate.name}, ns.app.aggregateLayoutWindow.fixedFilterStore);
                 ns.app.aggregateLayoutWindow.removeDimension(dimConf.period.dimensionName);
             }
             else if (mode === 'periods') {
@@ -3122,6 +3088,7 @@
                 periods.show();
 
                 ns.app.aggregateLayoutWindow.addDimension({id: dimConf.period.dimensionName, name: dimConf.period.name}, ns.app.aggregateLayoutWindow.colStore);
+                ns.app.aggregateLayoutWindow.removeDimension(dimConf.startEndDate.value);
             }
         };
 

=== modified file 'dhis-2/dhis-web/dhis-web-event-reports/src/main/webapp/dhis-web-event-reports/app/scripts/core.js'
--- dhis-2/dhis-web/dhis-web-event-reports/src/main/webapp/dhis-web-event-reports/app/scripts/core.js	2014-03-19 18:06:54 +0000
+++ dhis-2/dhis-web/dhis-web-event-reports/src/main/webapp/dhis-web-event-reports/app/scripts/core.js	2014-03-26 15:32:14 +0000
@@ -75,6 +75,10 @@
 						value: 'relativePeriods',
 						name: NS.i18n.relative_periods
 					},
+                    startEndDate: {
+                        value: 'dates',
+                        name: NS.i18n.start_end_dates
+                    },
 					organisationUnit: {
 						value: 'organisationUnits',
 						name: NS.i18n.organisation_units,

=== modified file 'dhis-2/dhis-web/dhis-web-event-reports/src/main/webapp/dhis-web-event-reports/app/styles/style.css'
--- dhis-2/dhis-web/dhis-web-event-reports/src/main/webapp/dhis-web-event-reports/app/styles/style.css	2014-03-18 10:27:33 +0000
+++ dhis-2/dhis-web/dhis-web-event-reports/src/main/webapp/dhis-web-event-reports/app/styles/style.css	2014-03-26 12:34:11 +0000
@@ -509,6 +509,25 @@
 	border-right: 0 none;
 }
 
+    /* Multiselect dynamic/fixed */
+.ns-multiselect-fixed .x-panel-body {
+    border-bottom: 0 none;
+}
+.ns-multiselect-fixed .x-boundlist-item {
+    font-style: italic;
+    color: #666;
+    cursor: auto;
+}
+.ns-multiselect-fixed .x-boundlist-item-over {
+    background-color: transparent;
+    border-color: transparent;
+}
+
+.ns-multiselect-dynamic .x-panel-body {
+    border-top: 0 none;
+}
+
+
 
 /*----------------------------------------------------------------------------
  * Checkbox