dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #28902
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14518: ER, reset layout when changing program/stage.
Merge authors:
Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 14518 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2014-03-28 14:08:42 +0100
message:
ER, reset layout when changing program/stage.
modified:
dhis-2/dhis-web/dhis-web-event-reports/src/main/webapp/dhis-web-event-reports/app/scripts/app.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-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-27 16:28:23 +0000
+++ dhis-2/dhis-web/dhis-web-event-reports/src/main/webapp/dhis-web-event-reports/app/scripts/app.js 2014-03-28 12:11:24 +0000
@@ -559,14 +559,13 @@
filterStore,
value,
- getData,
getStore,
getStoreKeys,
- getSetup,
addDimension,
removeDimension,
hasDimension,
saveState,
+ resetData,
dimensionStoreMap = {},
dimensionPanel,
@@ -578,19 +577,6 @@
defaultHeight = 220,
maxHeight = (ns.app.viewport.getHeight() - 100) / 2;
- getData = function(all) {
- var data = [];
-
- if (all) {
- data.push({id: dimConf.data.dimensionName, name: dimConf.data.name});
- data.push({id: dimConf.period.dimensionName, name: dimConf.relativePeriod.name});
- data.push({id: dimConf.organisationUnit.dimensionName, name: dimConf.organisationUnit.name});
- }
-
- //return data.concat(Ext.clone(ns.core.init.dimensions));
- return data;
- };
-
getStore = function(data) {
var config = {};
@@ -823,24 +809,39 @@
return false;
};
- saveState = function() {
+ saveState = function(map) {
+ map = map || dimensionStoreMap;
+
colStore.each(function(record) {
- dimensionStoreMap[record.data.id] = colStore;
+ map[record.data.id] = colStore;
});
rowStore.each(function(record) {
- dimensionStoreMap[record.data.id] = rowStore;
+ map[record.data.id] = rowStore;
});
filterStore.each(function(record) {
- dimensionStoreMap[record.data.id] = filterStore;
+ map[record.data.id] = filterStore;
});
fixedFilterStore.each(function(record) {
- dimensionStoreMap[record.data.id] = fixedFilterStore;
+ map[record.data.id] = fixedFilterStore;
});
+
+ return map;
};
+ resetData = function() {
+ var map = saveState({}),
+ keys = ['ou', 'pe', 'dates'];
+
+ for (var key in map) {
+ if (map.hasOwnProperty(key) && !Ext.Array.contains(keys, key)) {
+ removeDimension(key);
+ }
+ }
+ };
+
window = Ext.create('Ext.window.Window', {
title: NS.i18n.table_layout,
bodyStyle: 'background-color:#fff; padding:' + margin + 'px',
@@ -848,7 +849,6 @@
autoShow: true,
modal: true,
resizable: false,
- getSetup: getSetup,
colStore: colStore,
rowStore: rowStore,
fixedFilterStore: fixedFilterStore,
@@ -857,6 +857,7 @@
removeDimension: removeDimension,
hasDimension: hasDimension,
saveState: saveState,
+ resetData: resetData,
hideOnBlur: true,
items: selectPanel,
bbar: [
@@ -926,6 +927,8 @@
getSetup,
addDimension,
removeDimension,
+ saveState,
+ resetData,
dimensionStoreMap = {},
dimensionPanel,
@@ -1092,6 +1095,29 @@
}
};
+ saveState = function(map) {
+ dimensionStore.each(function(record) {
+ map[record.data.id] = dimensionStore;
+ });
+
+ colStore.each(function(record) {
+ map[record.data.id] = colStore;
+ });
+
+ return map;
+ };
+
+ resetData = function() {
+ var map = saveState({}),
+ keys = ['eventdate', 'latitude', 'longitude', 'ouname'];
+
+ for (var key in map) {
+ if (map.hasOwnProperty(key) && !Ext.Array.contains(keys, key)) {
+ removeDimension(key);
+ }
+ }
+ };
+
window = Ext.create('Ext.window.Window', {
title: NS.i18n.table_layout,
layout: 'column',
@@ -1105,6 +1131,7 @@
colStore: colStore,
addDimension: addDimension,
removeDimension: removeDimension,
+ resetData: resetData,
hideOnBlur: true,
items: [
dimension,
@@ -2598,6 +2625,9 @@
stagesByProgramStore.removeAll();
stagesByProgramStore.loadData(stages);
+ ns.app.aggregateLayoutWindow.resetData();
+ ns.app.queryLayoutWindow.resetData();
+
stageId = (favorite ? favorite.programStage.id : null) || (stages.length === 1 ? stages[0].id : null);
if (stageId) {
@@ -2673,6 +2703,8 @@
onStageSelect = function(stageId, favorite) {
dataElementSelected.removeAll();
+ ns.app.aggregateLayoutWindow.resetData();
+ ns.app.queryLayoutWindow.resetData();
loadDataElements(stageId, favorite);
};