dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #38528
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19634: ER web message.
------------------------------------------------------------
revno: 19634
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2015-07-13 14:19:10 +0200
message:
ER web message.
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/scripts/core.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-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-05-19 13:21:58 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/scripts/app.js 2015-07-13 12:19:10 +0000
@@ -3069,8 +3069,7 @@
params: Ext.encode(favorite),
failure: function(r) {
ns.core.web.mask.show();
-
- ns.alert(r.status + '\n' + r.statusText + '\n' + r.responseText);
+ ns.alert(r);
},
success: function(r) {
var id = r.getAllResponseHeaders().location.split('/').pop();
@@ -3099,8 +3098,7 @@
method: 'GET',
failure: function(r) {
ns.core.web.mask.show();
-
- ns.alert(r.status + '\n' + r.statusText + '\n' + r.responseText);
+ ns.alert(r);
},
success: function(r) {
eventReport = Ext.decode(r.responseText);
@@ -3113,8 +3111,7 @@
params: Ext.encode(eventReport),
failure: function(r) {
ns.core.web.mask.show();
-
- ns.alert(r.status + '\n' + r.statusText + '\n' + r.responseText);
+ ns.alert(r);
},
success: function(r) {
if (ns.app.layout && ns.app.layout.id === id) {
@@ -3349,8 +3346,7 @@
method: 'GET',
failure: function(r) {
ns.app.viewport.mask.hide();
-
- ns.alert(r.status + '\n' + r.statusText + '\n' + r.responseText);
+ ns.alert(r);
},
success: function(r) {
var sharing = Ext.decode(r.responseText),
@@ -7174,12 +7170,13 @@
failure: function(r) {
web.mask.hide(ns.app.centerRegion);
- if (Ext.Array.contains([403], r.status)) {
- ns.alert(NS.i18n.you_do_not_have_access_to_all_items_in_this_favorite);
- }
- else {
- ns.alert(r.status + '\n' + r.statusText + '\n' + r.responseText);
- }
+ r = Ext.decode(r.responseText);
+
+ if (Ext.Array.contains([403], parseInt(r.httpStatusCode))) {
+ r.message = NS.i18n.you_do_not_have_access_to_all_items_in_this_favorite || r.message;
+ }
+
+ ns.alert(r);
},
success: function(r) {
var config = Ext.decode(r.responseText);
@@ -7240,7 +7237,7 @@
web.mask.hide(ns.app.centerRegion);
- ns.alert(r.status + '\n' + r.statusText + '\n' + r.responseText);
+ ns.alert(r);
},
success: function(r) {
ns.app.dateCreate = new Date();
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/scripts/core.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/scripts/core.js 2015-05-21 15:32:20 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-reports/scripts/core.js 2015-07-13 12:19:10 +0000
@@ -2291,24 +2291,42 @@
// message
web.message = {};
- web.message.alert = function(msg, type) {
+ web.message.alert = function(obj) {
var config = {},
+ type,
window;
- if (!msg) {
+ if (!obj || (Ext.isObject(obj) && !obj.message && !obj.responseText)) {
return;
}
- type = type || 'error';
-
- config.title = type === 'error' ? NS.i18n.error : (type === 'warning' ? NS.i18n.warning : NS.i18n.info);
+ // if response object
+ if (Ext.isObject(obj) && obj.responseText && !obj.message) {
+ obj = Ext.decode(obj.responseText);
+ }
+
+ // if string
+ if (Ext.isString(obj)) {
+ obj = {
+ status: 'ERROR',
+ message: obj
+ };
+ }
+
+ // web message
+ type = (obj.status || 'INFO').toLowerCase();
+
+ config.title = obj.status;
config.iconCls = 'ns-window-title-messagebox ' + type;
// html
- config.html = msg + (msg.substr(msg.length - 1) === '.' ? '' : '.');
+ config.html = '';
+ config.html += obj.httpStatusCode ? 'Code: ' + obj.httpStatusCode + '<br>' : '';
+ config.html += obj.httpStatus ? 'Status: ' + obj.httpStatus + '<br><br>' : '';
+ config.html += obj.message + (obj.message.substr(obj.message.length - 1) === '.' ? '' : '.');
// bodyStyle
- config.bodyStyle = 'padding: 10px; background: #fff; max-width: 350px; max-height: ' + ns.app.centerRegion.getHeight() / 2 + 'px';
+ config.bodyStyle = 'padding: 12px; background: #fff; max-width: 600px; max-height: ' + ns.app.centerRegion.getHeight() / 2 + 'px';
// destroy handler
config.modal = true;
@@ -2479,7 +2497,10 @@
msg += '\n\n' + 'Hint: A good way to reduce the number of items is to use relative periods and level/group organisation unit selection modes.';
- ns.alert(msg, 'warning');
+ ns.alert({
+ status: 'INFO',
+ message: msg
+ });
};
// report