dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #21552
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 10223: (PT) Favorite crud issues fixed.
Merge authors:
Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 10223 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2013-03-14 15:38:18 +0100
message:
(PT) Favorite crud issues fixed.
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
--
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 2013-03-14 12:56:36 +0000
+++ dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/app.js 2013-03-14 14:33:39 +0000
@@ -132,11 +132,11 @@
}
};
- util.pivot.getSettingsConfig = function() {
+ util.pivot.getLayoutConfig = function() {
var data = {},
- setup = pt.viewport.settingsWindow ? pt.viewport.settingsWindow.getSetup() : {},
+ setup = pt.viewport.layoutWindow ? pt.viewport.layoutWindow.getSetup() : {},
getData,
- extendSettings,
+ extendLayout,
config;
config = {
@@ -170,7 +170,7 @@
}
}();
- extendSettings = function() {
+ extendLayout = function() {
for (var i = 0, dimensionName; i < setup.col.length; i++) {
dimensionName = setup.col[i];
config.col.push({
@@ -408,7 +408,7 @@
return cmp;
};
- PT.app.SettingsWindow = function() {
+ PT.app.LayoutWindow = function() {
var dimension,
dimensionStore,
dimensionOrder,
@@ -532,8 +532,8 @@
style: 'margin-right:' + margin + 'px; margin-bottom:0px',
valueField: 'id',
displayField: 'name',
- dragGroup: 'settingsDD',
- dropGroup: 'settingsDD',
+ dragGroup: 'layoutDD',
+ dropGroup: 'layoutDD',
ddReorder: false,
store: dimensionStore,
tbar: {
@@ -562,8 +562,8 @@
style: 'margin-bottom:0px',
valueField: 'id',
displayField: 'name',
- dragGroup: 'settingsDD',
- dropGroup: 'settingsDD',
+ dragGroup: 'layoutDD',
+ dropGroup: 'layoutDD',
store: rowStore,
tbar: {
height: 25,
@@ -596,8 +596,8 @@
style: 'margin-bottom:' + margin + 'px',
valueField: 'id',
displayField: 'name',
- dragGroup: 'settingsDD',
- dropGroup: 'settingsDD',
+ dragGroup: 'layoutDD',
+ dropGroup: 'layoutDD',
store: colStore,
tbar: {
height: 25,
@@ -630,8 +630,8 @@
style: 'margin-right:' + margin + 'px; margin-bottom:' + margin + 'px',
valueField: 'id',
displayField: 'name',
- dragGroup: 'settingsDD',
- dropGroup: 'settingsDD',
+ dragGroup: 'layoutDD',
+ dropGroup: 'layoutDD',
store: filterStore,
tbar: {
height: 25,
@@ -975,16 +975,16 @@
getBody = function() {
var favorite;
- if (pt.xSettings) {
- favorite = Ext.clone(pt.xSettings.options);
+ if (pt.xLayout) {
+ favorite = Ext.clone(pt.xLayout.options);
// Server sync
favorite.totals = favorite.showTotals;
favorite.subtotals = favorite.showSubTotals;
// Dimensions
- for (var i = 0, obj, key, items; i < pt.xSettings.objects.length; i++) {
- obj = pt.xSettings.objects[i];
+ for (var i = 0, obj, key, items; i < pt.xLayout.objects.length; i++) {
+ obj = pt.xLayout.objects[i];
if (obj.objectName === pt.conf.finals.dimension.period.objectName) {
for (var j = 0, item; j < obj.items.length; j++) {
@@ -1044,32 +1044,37 @@
}
}
+ // Relative periods PUT workaround
+ if (!favorite.relativePeriods) {
+ favorite.relativePeriods = {};
+ }
+
// Setup
- if (pt.xSettings.col) {
+ if (pt.xLayout.col) {
var a = [];
- for (var i = 0; i < pt.xSettings.col.length; i++) {
- a.push(pt.xSettings.col[i].dimensionName);
+ for (var i = 0; i < pt.xLayout.col.length; i++) {
+ a.push(pt.xLayout.col[i].dimensionName);
}
favorite['columnDimensions'] = a;
}
- if (pt.xSettings.row) {
+ if (pt.xLayout.row) {
var a = [];
- for (var i = 0; i < pt.xSettings.row.length; i++) {
- a.push(pt.xSettings.row[i].dimensionName);
+ for (var i = 0; i < pt.xLayout.row.length; i++) {
+ a.push(pt.xLayout.row[i].dimensionName);
}
favorite['rowDimensions'] = a;
}
- if (pt.xSettings.filter) {
+ if (pt.xLayout.filter) {
var a = [];
- for (var i = 0; i < pt.xSettings.filter.length; i++) {
- a.push(pt.xSettings.filter[i].dimensionName);
+ for (var i = 0; i < pt.xLayout.filter.length; i++) {
+ a.push(pt.xLayout.filter[i].dimensionName);
}
favorite['filterDimensions'] = a;
@@ -1101,7 +1106,7 @@
text: 'Create', //i18n
handler: function() {
var favorite = getBody();
- favorite.name = nameTextfield.getValue();
+ favorite.name = nameTextfield.getValue ();
if (favorite && favorite.name) {
Ext.Ajax.request({
@@ -1212,7 +1217,7 @@
height: 26,
style: 'border-radius: 1px;',
menu: {},
- disabled: !Ext.isObject(pt.xSettings),
+ disabled: !Ext.isObject(pt.xLayout),
handler: function() {
nameWindow = new NameWindow(null, 'create');
nameWindow.show();
@@ -1755,7 +1760,7 @@
}
window = Ext.create('Ext.window.Window', {
- title: 'Sharing settings',
+ title: 'Sharing layout',
bodyStyle: 'padding:8px 8px 3px; background-color:#fff',
width: 434,
resizable: false,
@@ -3207,20 +3212,20 @@
return getPanels();
};
- validateSpecialCases = function(settings) {
+ validateSpecialCases = function(layout) {
var dimConf = pt.conf.finals.dimension,
dimensionNames = [],
- settingsObjects = [].concat(Ext.clone(settings.col || []), Ext.clone(settings.row || []), Ext.clone(settings.filter || []));
+ layoutObjects = [].concat(Ext.clone(layout.col || []), Ext.clone(layout.row || []), Ext.clone(layout.filter || []));
- // Settings names
- for (var i = 0; i < settingsObjects.length; i++) {
- dimensionNames.push(settingsObjects[i].dimensionName);
+ // Layout names
+ for (var i = 0; i < layoutObjects.length; i++) {
+ dimensionNames.push(layoutObjects[i].dimensionName);
}
// Indicator as filter
- if (settings.filter && pt.store.indicatorSelected.data.length) {
- for (var i = 0; i < settings.filter.length; i++) {
- if (settings.filter[i].dimensionName === dimConf.data.dimensionName) {
+ if (layout.filter && pt.store.indicatorSelected.data.length) {
+ for (var i = 0; i < layout.filter.length; i++) {
+ if (layout.filter[i].dimensionName === dimConf.data.dimensionName) {
alert('Indicators cannot be specified as filter'); //i18n
return;
}
@@ -3228,7 +3233,7 @@
}
// Categories as filter
- if (settings.filter && pt.viewport.settingsWindow.filterStore.getById(dimConf.category.dimensionName)) {
+ if (layout.filter && pt.viewport.layoutWindow.filterStore.getById(dimConf.category.dimensionName)) {
alert('Categories cannot be specified as filter');
return;
}
@@ -3247,18 +3252,18 @@
};
update = function() {
- var config = pt.util.pivot.getSettingsConfig(),
- settings = pt.api.Settings(config);
-
- if (!settings) {
- return;
- }
- if (!validateSpecialCases(settings)) {
- return;
- }
-
- if (settings) {
- pt.util.pivot.getTable(settings, pt);
+ var config = pt.util.pivot.getLayoutConfig(),
+ layout = pt.api.Layout(config);
+
+ if (!layout) {
+ return;
+ }
+ if (!validateSpecialCases(layout)) {
+ return;
+ }
+
+ if (layout) {
+ pt.util.pivot.getTable(layout, pt);
}
};
@@ -3323,11 +3328,11 @@
text: 'Layout',
menu: {},
handler: function() {
- if (!pt.viewport.settingsWindow) {
- pt.viewport.settingsWindow = PT.app.SettingsWindow(pt);
+ if (!pt.viewport.layoutWindow) {
+ pt.viewport.layoutWindow = PT.app.LayoutWindow(pt);
}
- pt.viewport.settingsWindow.show();
+ pt.viewport.layoutWindow.show();
}
});
@@ -3656,8 +3661,8 @@
pt.viewport = createViewport();
- pt.viewport.settingsWindow = PT.app.SettingsWindow();
- pt.viewport.settingsWindow.hide();
+ pt.viewport.layoutWindow = PT.app.LayoutWindow();
+ pt.viewport.layoutWindow.hide();
pt.viewport.optionsWindow = PT.app.OptionsWindow();
pt.viewport.optionsWindow.hide();
=== 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 2013-03-14 11:02:27 +0000
+++ dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/core.js 2013-03-14 14:33:39 +0000
@@ -522,8 +522,8 @@
util.pivot = {
getTable: function(settings, pt) {
var options = settings.options,
- extendSettings,
- getSyncronizedXSettings,
+ extendLayout,
+ getSyncronizedXLayout,
getParamString,
validateResponse,
extendResponse,
@@ -534,39 +534,39 @@
dimConf = pt.conf.finals.dimension;
- extendSettings = function(settings) {
- var xSettings = Ext.clone(settings),
+ extendLayout = function(settings) {
+ var xLayout = Ext.clone(settings),
addDimensions,
addDimensionNames,
addSortedDimensions,
addSortedFilterDimensions;
addDimensions = function() {
- xSettings.dimensions = [].concat(Ext.clone(xSettings.col) || [], Ext.clone(xSettings.row) || []);
+ xLayout.dimensions = [].concat(Ext.clone(xLayout.col) || [], Ext.clone(xLayout.row) || []);
}();
addDimensionNames = function() {
var a = [],
- dimensions = Ext.clone(xSettings.dimensions) || [];
+ dimensions = Ext.clone(xLayout.dimensions) || [];
for (var i = 0; i < dimensions.length; i++) {
a.push(dimensions[i].dimensionName);
}
- xSettings.dimensionNames = a;
+ xLayout.dimensionNames = a;
}();
addSortedDimensions = function() {
- xSettings.sortedDimensions = pt.util.array.sortDimensions(Ext.clone(xSettings.dimensions) || []);
+ xLayout.sortedDimensions = pt.util.array.sortDimensions(Ext.clone(xLayout.dimensions) || []);
}();
addSortedFilterDimensions = function() {
- xSettings.sortedFilterDimensions = pt.util.array.sortDimensions(Ext.clone(xSettings.filter) || []);
+ xLayout.sortedFilterDimensions = pt.util.array.sortDimensions(Ext.clone(xLayout.filter) || []);
}();
addNameItemsMap = function() {
var map = {},
- dimensions = Ext.clone(xSettings.dimensions) || [];
+ dimensions = Ext.clone(xLayout.dimensions) || [];
for (var i = 0, dim; i < dimensions.length; i++) {
dim = dimensions[i];
@@ -574,17 +574,17 @@
map[dim.dimensionName] = dim.items || [];
}
- xSettings.nameItemsMap = map;
+ xLayout.nameItemsMap = map;
}();
- return xSettings;
+ return xLayout;
};
- getSyncronizedXSettings = function(xSettings, response) {
+ getSyncronizedXLayout = function(xLayout, response) {
var getHeaderNames,
headerNames,
- newSettings;
+ newLayout;
getHeaderNames = function() {
var a = [];
@@ -596,7 +596,7 @@
return a;
};
- removeDimensionFromSettings = function(dimensionName) {
+ removeDimensionFromLayout = function(dimensionName) {
var getCleanAxis;
getAxis = function(axis) {
@@ -630,25 +630,25 @@
headerNames = getHeaderNames();
// remove co from settings if it does not exist in response
- if (Ext.Array.contains(xSettings.dimensionNames, dimConf.category.dimensionName) && !(Ext.Array.contains(headerNames, dimConf.category.dimensionName))) {
- removeDimensionFromSettings(dimConf.category.dimensionName);
-
- newSettings = pt.api.Settings(settings);
-
- if (!newSettings) {
+ if (Ext.Array.contains(xLayout.dimensionNames, dimConf.category.dimensionName) && !(Ext.Array.contains(headerNames, dimConf.category.dimensionName))) {
+ removeDimensionFromLayout(dimConf.category.dimensionName);
+
+ newLayout = pt.api.Layout(settings);
+
+ if (!newLayout) {
return;
}
- return extendSettings(newSettings);
+ return extendLayout(newLayout);
}
else {
- return xSettings;
+ return xLayout;
}
};
- getParamString = function(xSettings) {
- var sortedDimensions = xSettings.sortedDimensions,
- sortedFilterDimensions = xSettings.sortedFilterDimensions,
+ getParamString = function(xLayout) {
+ var sortedDimensions = xLayout.sortedDimensions,
+ sortedFilterDimensions = xLayout.sortedFilterDimensions,
paramString = '?';
for (var i = 0, sortedDim; i < sortedDimensions.length; i++) {
@@ -702,7 +702,7 @@
return true;
};
- extendResponse = function(response, xSettings) {
+ extendResponse = function(response, xLayout) {
var headers = response.headers,
metaData = response.metaData,
rows = response.rows;
@@ -715,7 +715,7 @@
// Extend headers: index, items (ordered), size
for (var i = 0, header, settingsItems, responseItems, orderedResponseItems; i < headers.length; i++) {
header = headers[i];
- settingsItems = xSettings.nameItemsMap[header.name],
+ settingsItems = xLayout.nameItemsMap[header.name],
responseItems = [];
orderedResponseItems = [];
@@ -767,7 +767,7 @@
var createValueIds = function() {
var valueHeaderIndex = response.nameHeaderMap[pt.conf.finals.dimension.value.value].index,
- dimensionNames = xSettings.dimensionNames,
+ dimensionNames = xLayout.dimensionNames,
idIndexOrder = [];
// idIndexOrder
@@ -1557,14 +1557,14 @@
initialize = function() {
var url,
- xSettings,
+ xLayout,
xResponse,
xColAxis,
xRowAxis;
- xSettings = extendSettings(settings);
+ xLayout = extendLayout(settings);
- pt.paramString = getParamString(xSettings);
+ pt.paramString = getParamString(xLayout);
url = pt.init.contextPath + '/api/analytics.json' + pt.paramString;
if (!validateUrl(url)) {
@@ -1596,17 +1596,17 @@
return;
}
- xSettings = getSyncronizedXSettings(xSettings, response);
+ xLayout = getSyncronizedXLayout(xLayout, response);
- if (!xSettings) {
+ if (!xLayout) {
pt.util.mask.hideMask();
return;
}
- xResponse = extendResponse(response, xSettings);
+ xResponse = extendResponse(response, xLayout);
- xColAxis = extendAxis('col', xSettings.col, xResponse);
- xRowAxis = extendAxis('row', xSettings.row, xResponse);
+ xColAxis = extendAxis('col', xLayout.col, xResponse);
+ xRowAxis = extendAxis('row', xLayout.row, xResponse);
html = getTableHtml(xColAxis, xRowAxis, xResponse);
@@ -1620,7 +1620,7 @@
pt.viewport.downloadButton.enable();
}
- pt.xSettings = xSettings;
+ pt.xLayout = xLayout;
pt.xResponse = xResponse;
}
});
@@ -1655,14 +1655,14 @@
PT.core.getAPI = function(pt) {
var api = {};
- api.Settings = function(config) {
+ api.Layout = function(config) {
var col,
row,
filter,
removeEmptyDimensions,
getValidatedAxis,
- validateSettings,
+ validateLayout,
defaultOptions = {
showTotals: true,
@@ -1738,7 +1738,7 @@
return options;
};
- validateSettings = function() {
+ validateLayout = function() {
var a = [].concat(Ext.clone(col), Ext.clone(row), Ext.clone(filter)),
dimensionNames = [],
dimConf = pt.conf.finals.dimension;
@@ -1767,7 +1767,7 @@
var obj = {};
if (!(config && Ext.isObject(config))) {
- alert('Settings config is not an object'); //i18n
+ alert('Layout config is not an object'); //i18n
return;
}
@@ -1775,7 +1775,7 @@
row = getValidatedAxis(config.row);
filter = getValidatedAxis(config.filter);
- if (!validateSettings()) {
+ if (!validateLayout()) {
return;
}
=== 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 2013-03-14 11:02:27 +0000
+++ dhis-2/dhis-web/dhis-web-pivot/src/main/webapp/dhis-web-pivot/app/scripts/plugin.js 2013-03-14 14:33:39 +0000
@@ -24,7 +24,7 @@
}
};
-xSettings = {
+xLayout = {
col: [
{name: 'dx', items: ['Uvn6LCg7dVU', 'OdiHJayrsKo', 'sB79w2hiLp8']},
{name: 'co'}