dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #35238
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18090: Dashboard, misc validation.
Merge authors:
Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 18090 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2015-01-21 19:34:45 +0100
message:
Dashboard, misc validation.
modified:
dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/javascript/dashboard.js
dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/plugin/chart.js
dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/plugin/eventchart.js
dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/plugin/eventreport.js
dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/plugin/map.js
dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/plugin/table.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-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/javascript/dashboard.js'
--- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/javascript/dashboard.js 2015-01-21 12:52:09 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/javascript/dashboard.js 2015-01-21 18:27:18 +0000
@@ -554,7 +554,7 @@
else if ( dhis2.db.shapeDoubleWidth == dashboardItem.shape ) {
width = dhis2.db.widthDouble;
}
-
+
dhis2.db.renderItems( $d, dashboardItem, width, false );
} );
@@ -583,16 +583,16 @@
{
width = width || dhis2.db.widthNormal;
prepend = prepend || false;
-
+
var style = "width:" + width + "px";
if ( "chart" == dashboardItem.type )
{
var content = $.tmpl( dhis2.db.tmpl.chartItem, { "itemId": dashboardItem.id, "id": dashboardItem.chart.id, "name": dashboardItem.chart.name, "style": style,
- "i18n_remove": i18n_remove, "i18n_get_as_image": i18n_get_as_image, "i18n_share": i18n_share_interpretation,
+ "i18n_remove": i18n_remove, "i18n_get_as_image": i18n_get_as_image, "i18n_share": i18n_share_interpretation,
"i18n_click_and_drag_to_new_position": i18n_click_and_drag_to_new_position } );
dhis2.db.preOrAppend( $d, content, prepend );
-
+
DHIS.getChart({
url: '..',
el: 'plugin-' + dashboardItem.id,
@@ -664,8 +664,8 @@
}
else if ( "map" == dashboardItem.type )
{
- var content = $.tmpl( dhis2.db.tmpl.mapItem, { "itemId": dashboardItem.id, "id": dashboardItem.map.id, "name": dashboardItem.map.name,
- "style": style, "height": dhis2.db.itemContentHeight, "i18n_remove": i18n_remove, "i18n_get_as_image": i18n_get_as_image,
+ var content = $.tmpl( dhis2.db.tmpl.mapItem, { "itemId": dashboardItem.id, "id": dashboardItem.map.id, "name": dashboardItem.map.name,
+ "style": style, "height": dhis2.db.itemContentHeight, "i18n_remove": i18n_remove, "i18n_get_as_image": i18n_get_as_image,
"i18n_share": i18n_share_interpretation, "i18n_click_and_drag_to_new_position": i18n_click_and_drag_to_new_position } );
dhis2.db.preOrAppend( $d, content, prepend );
@@ -818,9 +818,9 @@
id: id
},
success: function( data, textStatus, xhr ) {
-
+
var location = xhr.getResponseHeader( "Location" );
-
+
if ( location ) {
$.getJSON( "../api" + location, function( item ) {
if ( item && $.inArray( item.type, dhis2.db.visualItemTypes ) != -1 ) {
@@ -913,7 +913,7 @@
/**
* Prepends or appends the given content to the given jQuery element.
- *
+ *
* @param $el the jQuery element.
* @param content the content.
* @param prepend indicates whether to prepend or append.
=== modified file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/plugin/chart.js'
--- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/plugin/chart.js 2015-01-21 17:59:59 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/plugin/chart.js 2015-01-21 18:27:18 +0000
@@ -3954,7 +3954,8 @@
headers = {
'Content-Type': headerMap[type],
'Accepts': headerMap[type]
- };
+ },
+ el = Ext.get(init.el);
ns.plugin = init.plugin;
ns.dashboard = init.dashboard;
@@ -3964,8 +3965,8 @@
init.el = config.el;
- if (!ns.skipFade && init.el && Ext.get(init.el)) {
- Ext.get(init.el).setStyle('opacity', 0);
+ if (!ns.skipFade && el) {
+ el.setStyle('opacity', 0);
}
web.chart = web.chart || {};
@@ -4085,8 +4086,10 @@
if (!ns.skipFade) {
ns.app.chart.on('afterrender', function() {
Ext.defer( function() {
- if (ns.core.init.el && Ext.get(ns.core.init.el)) {
- Ext.get(ns.core.init.el).fadeIn({
+ var el = Ext.get(init.el);
+
+ if (el) {
+ el.fadeIn({
duration: 400
});
}
@@ -4149,7 +4152,7 @@
width,
height;
- if (!ns.skipFade && el && Ext.get(el)) {
+ if (!ns.skipFade && el) {
var elBorderW = parseInt(el.getStyle('border-left-width')) + parseInt(el.getStyle('border-right-width')),
elBorderH = parseInt(el.getStyle('border-top-width')) + parseInt(el.getStyle('border-bottom-width')),
elPaddingW = parseInt(el.getStyle('padding-left')) + parseInt(el.getStyle('padding-right')),
@@ -4173,6 +4176,8 @@
};
initialize = function() {
+ var el = Ext.get(config.el);
+
if (!validateConfig(config)) {
return;
}
@@ -4189,8 +4194,12 @@
// alert
init.alert = function(text) {
- Ext.get(config.el).setStyle('opacity', 1);
- Ext.get(config.el).update('<div class="ns-plugin-alert">' + text + '</div>');
+ var div = Ext.get(config.el);
+
+ if (div) {
+ div.setStyle('opacity', 1);
+ div.update('<div class="ns-plugin-alert">' + text + '</div>');
+ }
};
// init
@@ -4200,9 +4209,11 @@
ns.app.viewport = createViewport();
ns.app.centerRegion = ns.app.viewport.centerRegion;
- Ext.get(config.el).setViewportWidth = function(width) {
- ns.app.centerRegion.setWidth(width);
- };
+ if (el) {
+ el.setViewportWidth = function(width) {
+ ns.app.centerRegion.setWidth(width);
+ };
+ }
if (config && config.id) {
ns.core.web.chart.loadChart(config);
=== modified file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/plugin/eventchart.js'
--- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/plugin/eventchart.js 2015-01-21 17:59:59 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/plugin/eventchart.js 2015-01-21 18:30:44 +0000
@@ -4452,7 +4452,8 @@
headers = {
'Content-Type': headerMap[type],
'Accepts': headerMap[type]
- };
+ },
+ el = Ext.get(init.el);
ns.plugin = init.plugin;
ns.dashboard = init.dashboard;
@@ -4462,8 +4463,8 @@
init.el = config.el;
- if (!ns.skipFade) {
- Ext.get(init.el).setStyle('opacity', 0);
+ if (!ns.skipFade && el) {
+ el.setStyle('opacity', 0);
}
// report
@@ -4642,8 +4643,10 @@
if (!ns.skipFade) {
chart.on('afterrender', function() {
Ext.defer( function() {
- if (init.el && Ext.get(init.el)) {
- Ext.get(init.el).fadeIn({
+ var el = Ext.get(init.el);
+
+ if (el) {
+ el.fadeIn({
duration: 400
});
}
@@ -4698,8 +4701,13 @@
elBorderH = parseInt(el.getStyle('border-top-width')) + parseInt(el.getStyle('border-bottom-width')),
elPaddingW = parseInt(el.getStyle('padding-left')) + parseInt(el.getStyle('padding-right')),
elPaddingH = parseInt(el.getStyle('padding-top')) + parseInt(el.getStyle('padding-bottom')),
- width = el.getWidth() - elBorderW - elPaddingW,
- height = el.getHeight() - elBorderH - elPaddingH;
+ width,
+ height;
+
+ if (el) {
+ width = el.getWidth() - elBorderW - elPaddingW;
+ height = el.getHeight() - elBorderH - elPaddingH;
+ }
centerRegion = Ext.create('Ext.panel.Panel', {
renderTo: el,
@@ -4715,6 +4723,8 @@
};
initialize = function() {
+ var el = Ext.get(config.el);
+
if (!validateConfig(config)) {
return;
}
@@ -4731,8 +4741,12 @@
// alert
init.alert = function(text) {
- Ext.get(config.el).setStyle('opacity', 1);
- Ext.get(config.el).update('<div class="ns-plugin-alert">' + text + '</div>');
+ var div = Ext.get(config.el);
+
+ if (div) {
+ div.setStyle('opacity', 1);
+ div.update('<div class="ns-plugin-alert">' + text + '</div>');
+ }
};
// init
@@ -4742,9 +4756,11 @@
ns.app.viewport = createViewport();
ns.app.centerRegion = ns.app.viewport.centerRegion;
- Ext.get(config.el).setViewportWidth = function(width) {
- ns.app.centerRegion.setWidth(width);
- };
+ if (el) {
+ el.setViewportWidth = function(width) {
+ ns.app.centerRegion.setWidth(width);
+ };
+ }
if (config && config.id) {
ns.core.web.report.loadReport(config);
=== modified file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/plugin/eventreport.js'
--- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/plugin/eventreport.js 2015-01-21 17:59:59 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/plugin/eventreport.js 2015-01-21 18:27:18 +0000
@@ -3425,7 +3425,8 @@
headers = {
'Content-Type': headerMap[type],
'Accepts': headerMap[type]
- };
+ },
+ el = Ext.get(init.el);
ns.plugin = init.plugin;
ns.dashboard = init.dashboard;
@@ -3435,10 +3436,8 @@
init.el = config.el;
- if (!ns.skipFade) {
- if (init.el && Ext.get(init.el)) {
- Ext.get(init.el).setStyle('opacity', 0);
- }
+ if (!ns.skipFade && el) {
+ el.setStyle('opacity', 0);
}
// mouse events
@@ -3450,7 +3449,7 @@
obj = xResponse.sortableIdObjects[i];
el = Ext.get(obj.uuid);
- if (el.dom) {
+ if (el && el.dom) {
el.dom.layout = layout;
el.dom.response = response;
el.dom.xResponse = xResponse;
@@ -3464,7 +3463,7 @@
el.dom.setAttribute('onmouseout', 'this.onColumnHeaderMouseOut(this)');
}
else {
- console.log('No element.dom, setColumnHeaderMouseHandlers, ' + init.el);
+ console.log('No column header element, setColumnHeaderMouseHandlers, ' + init.el);
}
}
}
@@ -3490,11 +3489,19 @@
};
web.events.onColumnHeaderMouseOver = function(el) {
- Ext.get(el).addCls('pointer highlighted');
+ var div = Ext.get(el);
+
+ if (div) {
+ div.addCls('pointer highlighted');
+ }
};
web.events.onColumnHeaderMouseOut = function(el) {
- Ext.get(el).removeCls('pointer highlighted');
+ var div = Ext.get(el);
+
+ if (div) {
+ div.removeCls('pointer highlighted');
+ }
};
// report
@@ -3699,8 +3706,10 @@
// fade
if (!ns.skipFade) {
Ext.defer( function() {
- if (init.el && Ext.get(init.el)) {
- Ext.get(init.el).fadeIn({
+ var el = Ext.get(init.el);
+
+ if (el) {
+ el.fadeIn({
duration: 400
});
}
@@ -3776,8 +3785,10 @@
ns.app.centerRegion.update(getTitleHtml(layout.name) + table.html);
Ext.defer( function() {
- if (init.el && Ext.get(init.el)) {
- Ext.get(init.el).fadeIn({
+ var el = Ext.get(init.el);
+
+ if (el) {
+ el.fadeIn({
duration: 400
});
}
@@ -3848,6 +3859,8 @@
};
initialize = function() {
+ var el = Ext.get(config.el);
+
if (!validateConfig(config)) {
return;
}
@@ -3864,8 +3877,12 @@
// alert
init.alert = function(text) {
- Ext.get(config.el).setStyle('opacity', 1);
- Ext.get(config.el).update('<div class="ns-plugin-alert">' + text + '</div>');
+ var div = Ext.get(config.el);
+
+ if (div) {
+ div.setStyle('opacity', 1);
+ div.update('<div class="ns-plugin-alert">' + text + '</div>');
+ }
};
// init
@@ -3875,9 +3892,11 @@
ns.app.viewport = createViewport();
ns.app.centerRegion = ns.app.viewport.centerRegion;
- Ext.get(config.el).setViewportWidth = function(width) {
- ns.app.centerRegion.setWidth(width);
- };
+ if (el) {
+ el.setViewportWidth = function(width) {
+ ns.app.centerRegion.setWidth(width);
+ };
+ }
if (config && config.id) {
ns.core.web.report.loadReport(config);
=== modified file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/plugin/map.js'
--- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/plugin/map.js 2015-01-21 15:21:09 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/plugin/map.js 2015-01-21 18:27:18 +0000
@@ -7172,6 +7172,8 @@
};
initialize = function () {
+ var el = Ext.get(config.el);
+
if (!validateConfig()) {
return;
}
@@ -7260,14 +7262,16 @@
gis.viewport = createViewport();
// dashboard element
- Ext.get(config.el).setViewportWidth = function(width) {
- gis.viewport.setWidth(width);
- gis.viewport.centerRegion.setWidth(width);
+ if (el) {
+ el.setViewportWidth = function(width) {
+ gis.viewport.setWidth(width);
+ gis.viewport.centerRegion.setWidth(width);
- if (gis.viewport.northRegion) {
- gis.viewport.northRegion.setWidth(width);
- }
- };
+ if (gis.viewport.northRegion) {
+ gis.viewport.northRegion.setWidth(width);
+ }
+ };
+ }
gis.olmap.mask = Ext.create('Ext.LoadMask', gis.viewport.centerRegion.getEl(), {
msg: 'Loading'
=== modified file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/plugin/table.js'
--- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/plugin/table.js 2015-01-21 18:03:50 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/plugin/table.js 2015-01-21 18:31:10 +0000
@@ -3132,7 +3132,11 @@
init.el = config.el;
if (!ns.skipFade) {
- Ext.get(init.el).setStyle('opacity', 0);
+ var el = Ext.get(init.el);
+
+ if (el) {
+ el.setStyle('opacity', 0);
+ }
}
// mouse events
@@ -3144,7 +3148,7 @@
obj = xResponse.sortableIdObjects[i];
el = Ext.get(obj.uuid);
- if (el.dom) {
+ if (el && el.dom) {
el.dom.layout = layout;
el.dom.xLayout = xLayout;
el.dom.response = response;
@@ -3181,11 +3185,19 @@
};
web.events.onColumnHeaderMouseOver = function(el) {
- Ext.get(el).addCls('pointer highlighted');
+ var div = Ext.get(el);
+
+ if (div) {
+ div.addCls('pointer highlighted');
+ }
};
web.events.onColumnHeaderMouseOut = function(el) {
- Ext.get(el).removeCls('pointer highlighted');
+ var div = Ext.get(el);
+
+ if (div) {
+ div.removeCls('pointer highlighted');
+ }
};
// pivot
@@ -3337,8 +3349,10 @@
// fade
if (!ns.skipFade) {
Ext.defer(function() {
- if (ns.core.init.el && Ext.get(ns.core.init.el)) {
- Ext.get(ns.core.init.el).fadeIn({
+ var el = Ext.get(init.el);
+
+ if (el) {
+ el.fadeIn({
duration: 400
});
}
@@ -3410,6 +3424,8 @@
};
initialize = function() {
+ var el = Ext.get(config.el);
+
if (!validateConfig(config)) {
return;
}
@@ -3426,8 +3442,12 @@
// alert
init.alert = function(text) {
- Ext.get(config.el).setStyle('opacity', 1);
- Ext.get(config.el).update('<div class="ns-plugin-alert">' + text + '</div>');
+ var div = Ext.get(config.el);
+
+ if (div) {
+ div.setStyle('opacity', 1);
+ div.update('<div class="ns-plugin-alert">' + text + '</div>');
+ }
};
// init
@@ -3437,9 +3457,11 @@
ns.app.viewport = createViewport();
ns.app.centerRegion = ns.app.viewport.centerRegion;
- Ext.get(config.el).setViewportWidth = function(width) {
- ns.app.centerRegion.setWidth(width);
- };
+ if (el) {
+ el.setViewportWidth = function(width) {
+ ns.app.centerRegion.setWidth(width);
+ };
+ }
if (config && config.id) {
ns.core.web.pivot.loadTable(config);