← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20614: ER program indicators (wip).

 

------------------------------------------------------------
revno: 20614
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2015-10-11 15:56:59 +0300
message:
  ER program indicators (wip).
modified:
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/scripts/app.js
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/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-apps/src/main/webapp/dhis-web-event-reports/scripts/app.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/scripts/app.js	2015-10-08 13:37:41 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/scripts/app.js	2015-10-11 12:56:59 +0000
@@ -129,6 +129,7 @@
         Ext.define('Ext.ux.panel.DataElementIntegerContainer', {
 			extend: 'Ext.container.Container',
 			alias: 'widget.dataelementintegerpanel',
+            cls: 'ns-dxselector',
 			layout: 'column',
             bodyStyle: 'border:0 none',
             style: 'margin: ' + margin,
@@ -412,7 +413,7 @@
                         fields: [idProperty, nameProperty]
                     }),
                     listeners: {
-                        added: function(cb) {                            
+                        added: function(cb) {
                             cb.store.add({
                                 id: defaultRangeSetId,
                                 name: 'No range set'
@@ -420,7 +421,7 @@
 
                             if (container.dataElement.legendSet) {
                                 var legendSet = ns.core.init.idLegendSetMap[container.dataElement.legendSet.id];
-                                
+
                                 if (Ext.isObject(legendSet)) {
                                     cb.store.add(legendSet);
 
@@ -463,6 +464,7 @@
         Ext.define('Ext.ux.panel.DataElementStringContainer', {
 			extend: 'Ext.container.Container',
 			alias: 'widget.dataelementstringpanel',
+            cls: 'ns-dxselector',
 			layout: 'column',
             bodyStyle: 'border:0 none',
             style: 'margin: ' + margin,
@@ -556,6 +558,7 @@
         Ext.define('Ext.ux.panel.DataElementDateContainer', {
 			extend: 'Ext.container.Container',
 			alias: 'widget.dataelementdatepanel',
+            cls: 'ns-dxselector',
 			layout: 'column',
             bodyStyle: 'border:0 none',
             style: 'margin: ' + margin,
@@ -657,6 +660,7 @@
 		Ext.define('Ext.ux.panel.DataElementBooleanContainer', {
 			extend: 'Ext.container.Container',
 			alias: 'widget.dataelementbooleanpanel',
+            cls: 'ns-dxselector',
 			layout: 'column',
             bodyStyle: 'border:0 none',
             style: 'margin: ' + margin,
@@ -893,6 +897,7 @@
 		Ext.define('Ext.ux.panel.OrganisationUnitGroupSetContainer', {
 			extend: 'Ext.container.Container',
 			alias: 'widget.organisationunitgroupsetpanel',
+            cls: 'ns-dxselector',
 			layout: 'column',
             bodyStyle: 'border:0 none',
             style: 'margin: ' + margin,
@@ -1800,6 +1805,10 @@
 		});
 
         addDimension = function(record, store, excludedStores, force) {
+            if (record.isProgramIndicator) {
+                return;
+            }
+
             store = store && force ? store : dimensionStoreMap[record.id] || store || filterStore;
 
             if (hasDimension(record.id, excludedStores)) {
@@ -3971,9 +3980,11 @@
         // cache
             stageStorage = {},
             attributeStorage = {},
+            programIndicatorStorage = {},
             dataElementStorage = {},
 
 		// gui
+            onTypeClick,
             setLayout,
 			program,
             onProgramSelect,
@@ -4095,7 +4106,7 @@
 		});
 
 		dataElementsByStageStore = Ext.create('Ext.data.Store', {
-			fields: ['id', 'name', 'isAttribute'],
+			fields: ['id', 'name', 'isAttribute', 'isProgramIndicator'],
 			data: [],
 			sorters: [
                 {
@@ -4108,6 +4119,8 @@
                 }
             ],
             onLoadData: function() {
+
+                // layout window
                 var layoutWindow = ns.app.aggregateLayoutWindow;
 
                 this.each( function(record) {
@@ -4115,6 +4128,19 @@
                         layoutWindow.valueStore.add(record.data);
                     }
                 });
+
+                this.toggleProgramIndicators();
+            },
+            toggleProgramIndicators: function(type) {
+                type = type || ns.app.typeToolbar.getType();
+
+                this.clearFilter();
+
+                if (type === finalsDataTypeConf.aggregated_values) {
+                    this.filterBy(function(record) {
+                        return !record.data.isProgramIndicator;
+                    });
+                }
             }
 		});
 
@@ -4156,6 +4182,15 @@
         // components
 
             // data element
+        onTypeClick = function(type) {
+
+            // available
+            dataElementsByStageStore.toggleProgramIndicators(type);
+
+            // selected
+            dataElementSelected.toggleProgramIndicators(type);
+        };
+
         setLayout = function(layout) {
 			var dimensions = Ext.Array.clean([].concat(layout.columns || [], layout.rows || [], layout.filters || [])),
 				recMap = ns.core.service.layout.getObjectNameDimensionItemsMapFromDimensionArray(dimensions),
@@ -4350,11 +4385,12 @@
             }
             else {
                 Ext.Ajax.request({
-                    url: ns.core.init.contextPath + '/api/programs.json?filter=id:eq:' + programId + '&fields=programStages[id,name],programTrackedEntityAttributes[trackedEntityAttribute[id,' + ns.core.init.namePropertyUrl + ',valueType,optionSet[id,name],legendSet[id,name]]]&paging=false',
+                    url: ns.core.init.contextPath + '/api/programs.json?filter=id:eq:' + programId + '&fields=programIndicators[id,name],programStages[id,name],programTrackedEntityAttributes[trackedEntityAttribute[id,' + ns.core.init.namePropertyUrl + ',valueType,optionSet[id,name],legendSet[id,name]]]&paging=false',
                     success: function(r) {
                         var program = Ext.decode(r.responseText).programs[0],
                             stages,
                             attributes,
+                            programIndicators,
                             stageId;
 
                         if (!program) {
@@ -4363,6 +4399,7 @@
 
                         stages = program.programStages;
                         attributes = Ext.Array.pluck(program.programTrackedEntityAttributes, 'trackedEntityAttribute');
+                        programIndicators = program.programIndicators;
 
                         // mark as attribute
                         for (var i = 0; i < attributes.length; i++) {
@@ -4374,6 +4411,16 @@
                             attributeStorage[programId] = attributes;
                         }
 
+                        // mark as program indicator
+                        for (var i = 0; i < programIndicators.length; i++) {
+                            programIndicators[i].isProgramIndicator = true;
+                        }
+
+                        // program indicator cache
+                        if (Ext.isArray(programIndicators) && programIndicators.length) {
+                            programIndicatorStorage[programId] = programIndicators;
+                        }
+
                         if (Ext.isArray(stages) && stages.length) {
 
                             // stages cache
@@ -4435,7 +4482,8 @@
 
 			load = function(dataElements) {
                 var attributes = attributeStorage[programId],
-                    data = Ext.Array.clean([].concat(attributes || [], dataElements || []));
+                    programIndicators = programIndicatorStorage[programId],
+                    data = Ext.Array.clean([].concat(attributes || [], programIndicators || [], dataElements || []));
 
 				dataElementsByStageStore.loadData(data);
                 dataElementsByStageStore.onLoadData();
@@ -4672,7 +4720,22 @@
 				for (var i = 0; i < len; i++) {
 					items[0].removeDataElement(reset);
 				}
-			}
+			},
+            toggleProgramIndicators: function(type) {
+				var items = this.items.items,
+					len = items.length;
+
+				for (var i = 0, item; i < len; i++) {
+					item = items[i];
+
+                    if (type === finalsDataTypeConf.aggregated_values && item.isProgramIndicator) {
+                        item.disable();
+                    }
+                    else {
+                        item.enable();
+                    }
+				}
+            }
         });
 
         addUxFromDataElement = function(element, index) {
@@ -4703,7 +4766,7 @@
 					return 'Ext.ux.panel.DataElementBooleanContainer';
 				}
 
-				return 'Ext.ux.panel.DataElementStringContainer';
+				return 'Ext.ux.panel.DataElementIntegerContainer';
 			};
 
 			// add
@@ -4711,6 +4774,9 @@
 				dataElement: element
 			}));
 
+            ux.isAttribute = element.isAttribute;
+            ux.isProgramIndicator = element.isProgramIndicator;
+
 			ux.removeDataElement = function(reset) {
 				dataElementSelected.remove(ux);
 
@@ -6455,8 +6521,6 @@
 		};
 
         setGui = function(layout, response, updateGui) {
-			var dimensions = Ext.Array.clean([].concat(layout.columns || [], layout.rows || [], layout.filters || [])),
-				recMap = ns.core.service.layout.getObjectNameDimensionItemsMapFromDimensionArray(dimensions);
 
 			// state
 			ns.app.downloadButton.enable();
@@ -6468,11 +6532,9 @@
             ns.app.statusBar.setStatus(layout, response);
 
 			// set gui
-			if (!updateGui) {
-				return;
+			if (updateGui) {
+				setLayout(layout);
 			}
-
-            setLayout(layout);
 		};
 
 		getView = function(config) {
@@ -6691,6 +6753,8 @@
 			setGui: setGui,
 			getView: getView,
 
+            onTypeClick: onTypeClick,
+
             getUxArray: function(id) {
                 return dataElementSelected.getUxArrayById(id);
             },
@@ -7430,7 +7494,7 @@
 
                 // success
                 ns.app.layout = layout;
-                ns.app.response = response;                
+                ns.app.response = response;
 
                 ns.app.accordion.setGui(layout, response, isUpdateGui);
 
@@ -7595,6 +7659,8 @@
 				button.toggle();
 			}
 
+            ns.app.accordion.onTypeClick(typeToolbar.getType());
+
 			update();
 		};
 
@@ -8307,7 +8373,7 @@
                 finalsStyleConf = ns.core.conf.finals.style;
                 styleConf = ns.core.conf.style;
                 finalsDataTypeConf = ns.core.conf.finals.dataType;
-                
+
 				ns.app.viewport = createViewport();
 
                 ns.core.app.getViewportWidth = function() { return ns.app.viewport.getWidth(); };

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/styles/style.css'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/styles/style.css	2015-10-10 08:05:19 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/styles/style.css	2015-10-11 12:56:59 +0000
@@ -434,6 +434,19 @@
 
 
 /*----------------------------------------------------------------------------
+ * PT Data Selector
+ *--------------------------------------------------------------------------*/
+
+.ns-dxselector .x-mask {
+    background: transparent;
+}
+
+.ns-dxselector.x-item-disabled {
+    opacity: 0.6;
+}
+
+
+/*----------------------------------------------------------------------------
  * NS form
  *--------------------------------------------------------------------------*/