← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 15747: DV api sync, dataset paging/filtering, gui fixes + PT cleanup.

 

Merge authors:
  Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 15747 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2014-06-18 14:09:43 +0200
message:
  DV api sync, dataset paging/filtering, gui fixes + PT cleanup.
modified:
  dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/app.js
  dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/core.js
  dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/plugin.js
  dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/scripts/app.js
  dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/scripts/core.js
  dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/scripts/plugin.js
  dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/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-pivot/src/main/webapp/dhis-web-pivot/app/scripts/app.js'
--- dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/app.js	2014-06-18 08:53:12 +0000
+++ dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/app.js	2014-06-18 11:16:24 +0000
@@ -2828,7 +2828,7 @@
                     url: ns.core.init.contextPath + '/api' + path,
                     params: {
                         page: store.nextPage,
-                        pageSize: 15
+                        pageSize: 50
                     },
                     failure: function() {
                         store.isPending = false;

=== modified file 'dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/core.js'
--- dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/core.js	2014-06-18 07:58:40 +0000
+++ dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/core.js	2014-06-18 11:06:05 +0000
@@ -223,11 +223,6 @@
                     '!periods',
                     '!organisationUnitLevels',
                     '!organisationUnits'
-                ],
-                sharingFields: [
-                    'id',
-                    'name',
-                    'access'
                 ]
             };
 		}());

=== modified file 'dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/plugin.js'
--- dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/plugin.js	2014-06-18 07:58:40 +0000
+++ dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/plugin.js	2014-06-18 11:06:05 +0000
@@ -2774,14 +2774,6 @@
 			}
 		});
 
-		//requests.push({
-			//url: url + '/api/mapLegendSets.jsonp?viewClass=detailed&links=false&paging=false',
-			//success: function(r) {
-				//init.legendSets = r.mapLegendSets;
-				//fn();
-			//}
-		//});
-
         init.legendSets = [];
 
 		requests.push({

=== modified file 'dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/scripts/app.js'
--- dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/scripts/app.js	2014-06-12 11:37:11 +0000
+++ dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/scripts/app.js	2014-06-18 11:16:24 +0000
@@ -623,8 +623,6 @@
 
 								ns.app.stores.chart.loadStore();
 
-								ns.app.shareButton.enable();
-
 								window.destroy();
 							}
 						});
@@ -640,7 +638,7 @@
 
 					if (id && name) {
 						Ext.Ajax.request({
-							url: ns.core.init.contextPath + '/api/charts/' + id + '.json?viewClass=dimensional&links=false',
+							url: ns.core.init.contextPath + '/api/charts/' + id + '.json?fields=' + ns.core.conf.url.analysisFields.join(','),
 							method: 'GET',
 							failure: function(r) {
 								ns.core.web.mask.show();
@@ -742,7 +740,7 @@
 							this.currentValue = this.getValue();
 
 							var value = this.getValue(),
-								url = value ? ns.core.init.contextPath + '/api/charts.json?viewClass=sharing&fields=id,name,access' + (value ? '&filter=name:like:' + value : '') : null;
+								url = value ? ns.core.init.contextPath + '/api/charts.json?fields=id,name,access' + (value ? '&filter=name:like:' + value : '') : null;
 								store = ns.app.stores.chart;
 
 							store.page = 1;
@@ -758,7 +756,7 @@
 			text: NS.i18n.prev,
 			handler: function() {
 				var value = searchTextfield.getValue(),
-					url = value ? ns.core.init.contextPath + '/api/charts.json?viewClass=sharing&fields=id,name,access' + (value ? '&filter=name:like:' + value : '') : null;
+					url = value ? ns.core.init.contextPath + '/api/charts.json?fields=id,name,access' + (value ? '&filter=name:like:' + value : '') : null;
 					store = ns.app.stores.chart;
 
 				store.page = store.page <= 1 ? 1 : store.page - 1;
@@ -770,7 +768,7 @@
 			text: NS.i18n.next,
 			handler: function() {
 				var value = searchTextfield.getValue(),
-					url = value ? ns.core.init.contextPath + '/api/charts.json?viewClass=sharing&fields=id,name,access' + (value ? '&filter=name:like:' + value : '') : null;
+					url = value ? ns.core.init.contextPath + '/api/charts.json?fields=id,name,access' + (value ? '&filter=name:like:' + value : '') : null;
 					store = ns.app.stores.chart;
 
 				store.page = store.page + 1;
@@ -863,8 +861,6 @@
 													ns.app.xLayout.name = true;
 
 													ns.app.stores.chart.loadStore();
-
-													ns.app.shareButton.enable();
 												}
 											});
 										}
@@ -1783,7 +1779,7 @@
 				}
 
 				Ext.Ajax.request({
-					url: init.contextPath + '/api/charts/' + id + '.json?viewClass=dimensional&links=false',
+					url: init.contextPath + '/api/charts/' + id + '.json?fields=' + ns.core.conf.url.analysisFields.join(','),
 					failure: function(r) {
 						web.mask.hide(ns.app.centerRegion);
 						alert(r.responseText);
@@ -1956,6 +1952,9 @@
             dataElementGroup,
             dataElementDetailLevel,
             dataElement,
+            dataSetLabel,
+            dataSetSearch,
+            dataSetFilter,
             dataSetAvailable,
             dataSetSelected,
             dataSet,
@@ -2614,29 +2613,67 @@
 
 		dataSetAvailableStore = Ext.create('Ext.data.Store', {
 			fields: ['id', 'name'],
-			proxy: {
-				type: 'ajax',
-				url: ns.core.init.contextPath + '/api/dataSets.json?fields=id,name',
-				reader: {
-					type: 'json',
-					root: 'dataSets'
-				},
-				pageParam: false,
-				startParam: false,
-				limitParam: false
-			},
+            lastPage: null,
+            nextPage: 1,
+            isPending: false,
+            reset: function() {
+                this.removeAll();
+                this.lastPage = null;
+                this.nextPage = 1;
+                this.isPending = false;
+                dataSetSearch.hideFilter();
+            },
+            loadPage: function(filter, append) {
+                var store = this,
+                    path = '/dataSets.json?fields=id,name' + (filter ? '&filter=name:like:' + filter : '');
+
+                filter = filter || dataSetFilter.getValue() || null;
+
+                if (!append) {
+                    this.lastPage = null;
+                    this.nextPage = 1;
+                }
+
+                if (store.nextPage === store.lastPage) {
+                    return;
+                }
+
+                store.isPending = true;
+
+                Ext.Ajax.request({
+                    url: ns.core.init.contextPath + '/api' + path,
+                    params: {
+                        page: store.nextPage,
+                        pageSize: 50
+                    },
+                    failure: function() {
+                        store.isPending = false;
+                    },
+                    success: function(r) {
+                        var response = Ext.decode(r.responseText),
+                            data = response.dataSets || [],
+                            pager = response.pager;
+
+                        store.loadStore(data, pager, append);
+                    }
+                });
+            },
+            loadStore: function(data, pager, append) {
+                this.loadData(data, append);
+                this.lastPage = this.nextPage;
+
+                if (pager.pageCount > this.nextPage) {
+                    this.nextPage++;
+                }
+
+                this.isPending = false;
+                ns.core.web.multiSelect.filterAvailable({store: dataSetAvailableStore}, {store: dataSetSelectedStore});
+            },
 			storage: {},
+			parent: null,
+            isLoaded: false,
 			sortStore: function() {
 				this.sort('name', 'ASC');
-			},
-			isLoaded: false,
-			listeners: {
-				load: function(s) {
-					this.isLoaded = true;
-
-					ns.core.web.storage.internal.add(s);
-					ns.core.web.multiSelect.filterAvailable({store: s}, {store: dataSetSelectedStore});
-				}
 			}
 		});
 		ns.app.stores.dataSetAvailable = dataSetAvailableStore;
@@ -2687,7 +2724,7 @@
 			isLoaded: false,
 			pageSize: 10,
 			page: 1,
-			defaultUrl: ns.core.init.contextPath + '/api/charts.json?viewClass=sharing&fields=id,name,access',
+			defaultUrl: ns.core.init.contextPath + '/api/charts.json?fields=id,name,access',
 			loadStore: function(url) {
 				this.proxy.url = url || this.defaultUrl;
 
@@ -3255,6 +3292,71 @@
 			}
 		};
 
+        dataSetLabel = Ext.create('Ext.form.Label', {
+            text: NS.i18n.available,
+            cls: 'ns-toolbar-multiselect-left-label',
+            style: 'margin-right:5px'
+        });
+
+        dataSetSearch = Ext.create('Ext.button.Button', {
+            width: 22,
+            height: 22,
+            cls: 'ns-button-icon',
+            style: 'background: url(images/search_14.png) 3px 3px no-repeat',
+            showFilter: function() {
+                dataSetLabel.hide();
+                this.hide();
+                dataSetFilter.show();
+                dataSetFilter.reset();
+            },
+            hideFilter: function() {
+                dataSetLabel.show();
+                this.show();
+                dataSetFilter.hide();
+                dataSetFilter.reset();
+            },
+            handler: function() {
+                this.showFilter();
+            }
+        });
+
+        dataSetFilter = Ext.create('Ext.form.field.Trigger', {
+            cls: 'ns-trigger-filter',
+            emptyText: 'Filter available..',
+            height: 22,
+            hidden: true,
+            enableKeyEvents: true,
+            fieldStyle: 'height:22px; border-right:0 none',
+            style: 'height:22px',
+            onTriggerClick: function() {
+				if (this.getValue()) {
+					this.reset();
+					this.onKeyUp();
+				}
+            },
+            onKeyUp: function() {
+                var store = dataSetAvailableStore;
+                store.loadPage(this.getValue(), false);
+            },
+            listeners: {
+                keyup: {
+                    fn: function(cmp) {
+                        cmp.onKeyUp();
+                    },
+                    buffer: 100
+                },
+                show: function(cmp) {
+                    cmp.focus(false, 50);
+                },
+                focus: function(cmp) {
+                    cmp.addCls('ns-trigger-filter-focused');
+                },
+                blur: function(cmp) {
+                    cmp.removeCls('ns-trigger-filter-focused');
+                }
+            }
+        });
+
 		dataSetAvailable = Ext.create('Ext.ux.form.MultiSelect', {
 			cls: 'ns-toolbar-multiselect-left',
 			width: (ns.core.conf.layout.west_fieldset_width - ns.core.conf.layout.west_width_padding) / 2,
@@ -3262,11 +3364,9 @@
 			displayField: 'name',
 			store: dataSetAvailableStore,
 			tbar: [
-				{
-					xtype: 'label',
-					text: NS.i18n.available,
-					cls: 'ns-toolbar-multiselect-left-label'
-				},
+				dataSetLabel,
+                dataSetSearch,
+                dataSetFilter,
 				'->',
 				{
 					xtype: 'button',
@@ -3286,7 +3386,15 @@
 				}
 			],
 			listeners: {
-				afterrender: function() {
+				render: function(ms) {
+                    var el = Ext.get(ms.boundList.getEl().id + '-listEl').dom;
+
+                    el.addEventListener('scroll', function(e) {
+                        if (isScrolled(e) && !dataSetAvailableStore.isPending) {
+                            dataSetAvailableStore.loadPage(null, true);
+                        }
+                    });
+
 					this.boundList.on('itemdblclick', function() {
 						ns.core.web.multiSelect.select(this, dataSetSelected);
 					}, this);
@@ -3364,8 +3472,9 @@
 				);
 
 				if (!dataSetAvailableStore.isLoaded) {
-					dataSetAvailableStore.load();
-				}
+                    dataSetAvailableStore.isLoaded = true;
+					dataSetAvailableStore.loadPage(null, false);
+                }
 			},
 			items: [
 				{
@@ -4976,6 +5085,7 @@
 
 		shareButton = Ext.create('Ext.button.Button', {
 			text: NS.i18n.share,
+            disabled: true,
 			xableItems: function() {
 				interpretationItem.xable();
 				pluginItem.xable();
@@ -5208,10 +5318,7 @@
 
 			// State
 			downloadButton.enable();
-
-			if (layout.id) {
-				shareButton.enable();
-			}
+            shareButton.enable();
 
 			// Set gui
 			if (!updateGui) {
@@ -5553,15 +5660,6 @@
 									}
 								});
 
-								// legend sets
-								//requests.push({
-									//url: init.contextPath + '/api/mapLegendSets.json?viewClass=detailed&links=false&paging=false',
-									//success: function(r) {
-										//init.legendSets = Ext.decode(r.responseText).mapLegendSets || [];
-										//fn();
-									//}
-								//});
-
 								// dimensions
 								requests.push({
 									url: init.contextPath + '/api/dimensions.json?links=false&paging=false',

=== modified file 'dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/scripts/core.js'
--- dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/scripts/core.js	2014-06-17 14:48:42 +0000
+++ dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/scripts/core.js	2014-06-18 11:23:18 +0000
@@ -218,7 +218,43 @@
                     ok: 'ok.png'
                 }
             };
-
+            
+            conf.url = {
+                analysisFields: [
+                    '*',
+                    'program[id,name]',
+                    'programStage[id,name]',
+                    'columns[dimension,filter,items[id,name]]',
+                    'rows[dimension,filter,items[id,name]]',
+                    'filters[dimension,filter,items[id,name]]',
+                    '!lastUpdated',
+                    '!href',
+                    '!created',
+                    '!publicAccess',
+                    '!rewindRelativePeriods',
+                    '!userOrganisationUnit',
+                    '!userOrganisationUnitChildren',
+                    '!userOrganisationUnitGrandChildren',
+                    '!externalAccess',
+                    '!access',
+                    '!relativePeriods',
+                    '!columnDimensions',
+                    '!rowDimensions',
+                    '!filterDimensions',
+                    '!user',
+                    '!organisationUnitGroups',
+                    '!itemOrganisationUnitGroups',
+                    '!userGroupAccesses',
+                    '!indicators',
+                    '!dataElements',
+                    '!dataElementOperands',
+                    '!dataElementGroups',
+                    '!dataSets',
+                    '!periods',
+                    '!organisationUnitLevels',
+                    '!organisationUnits'
+                ]
+            };
         }());
 
         // api
@@ -1262,6 +1298,10 @@
 					}
 				}
 
+				if (!layout.hideEmptyRows) {
+					delete layout.hideEmptyRows;
+				}
+
 				if (!layout.showTrendLine) {
 					delete layout.showTrendLine;
 				}
@@ -1282,10 +1322,6 @@
 					delete layout.baseLineTitle;
 				}
 
-				if (layout.showValues) {
-					delete layout.showValues;
-				}
-
 				if (!layout.hideLegend) {
 					delete layout.hideLegend;
 				}
@@ -1306,10 +1342,36 @@
 					delete layout.rangeAxisTitle;
 				}
 
+				if (!layout.rangeAxisMaxValue) {
+					delete layout.rangeAxisMaxValue;
+				}
+
+				if (!layout.rangeAxisMinValue) {
+					delete layout.rangeAxisMinValue;
+				}
+
+				if (!layout.rangeAxisSteps) {
+					delete layout.rangeAxisSteps;
+				}
+
+				if (!layout.rangeAxisDecimals) {
+					delete layout.rangeAxisDecimals;
+				}
+
 				if (!layout.sorting) {
 					delete layout.sorting;
 				}
 
+				if (!layout.legend) {
+					delete layout.legend;
+				}
+
+                // default true
+
+				if (layout.showValues) {
+					delete layout.showValues;
+				}
+
 				delete layout.parentGraphMap;
 				delete layout.reportingPeriod;
 				delete layout.organisationUnit;

=== modified file 'dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/scripts/plugin.js'
--- dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/scripts/plugin.js	2014-06-17 14:58:39 +0000
+++ dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/scripts/plugin.js	2014-06-18 11:06:05 +0000
@@ -2817,7 +2817,7 @@
 		});
 
 		requests.push({
-			url: url + '/api/organisationUnits.jsonp?userOnly=true&viewClass=detailed&paging=false&links=false',
+			url: url + '/api/organisationUnits.jsonp?userOnly=true&fields=id,name,children[id,name]&paging=false',
 			success: function(r) {
 				var organisationUnits = r.organisationUnits || [],
                     ou = [],
@@ -2847,14 +2847,6 @@
 			}
 		});
 
-		//requests.push({
-			//url: url + '/api/mapLegendSets.jsonp?viewClass=detailed&links=false&paging=false',
-			//success: function(r) {
-				//init.legendSets = r.mapLegendSets;
-				//fn();
-			//}
-		//});
-
 		requests.push({
 			url: url + '/api/dimensions.jsonp?links=false&paging=false',
 			success: function(r) {
@@ -2913,9 +2905,9 @@
 				}
 
 				Ext.data.JsonP.request({
-					url: init.contextPath + '/api/charts/' + id + '.jsonp?viewClass=dimensional&links=false',
+					url: init.contextPath + '/api/charts/' + id + '.jsonp?fields=' + conf.url.analysisFields.join(','),
 					failure: function(r) {
-						window.open(init.contextPath + '/api/charts/' + id + '.json?viewClass=dimensional&links=false', '_blank');
+						window.open(init.contextPath + '/api/charts/' + id + '.json?fields=' + conf.url.analysisFields.join(',')', '_blank');
 					},
 					success: function(r) {
                         Ext.apply(r, config);

=== modified file 'dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/styles/style.css'
--- dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/styles/style.css	2014-03-20 09:06:16 +0000
+++ dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/styles/style.css	2014-06-18 12:02:36 +0000
@@ -399,7 +399,6 @@
     border-color: #bbb;
     border-radius: 2px;
 }
-
 .x-menu-item-active .x-menu-item-link {
 	border-radius: 0;
 	border-color: #e1e1e1;
@@ -409,8 +408,15 @@
 .x-menu-body {
 	padding: 0;
 }
+.x-menu-body .x-box-inner {
+	background-color: #fafafa;
+}
 
 	/* Menu item */
+.x-menu-item {
+	background-color: #fafafa;
+}
+
 .x-menu-item-link {
     padding: 4px 5px 4px 26px;
 }