[Lada-commits] [PATCH] Show error and warnings in new forms
Wald Commits
scm-commit at wald.intevation.org
Thu Feb 2 11:04:06 CET 2017
# HG changeset patch
# User Maximilian Krambach <mkrambach at intevation.de>
# Date 1486029841 -3600
# Node ID 171eacf989d81b179f395644a552c5b5aa030ebe
# Parent c1b7db04b39ca2b30aa7de1f1df41843d651fc4e
Show error and warnings in new forms
diff -r c1b7db04b39c -r 171eacf989d8 app/controller/form/Ortszuordnung.js
--- a/app/controller/form/Ortszuordnung.js Thu Feb 02 10:34:53 2017 +0100
+++ b/app/controller/form/Ortszuordnung.js Thu Feb 02 11:04:01 2017 +0100
@@ -91,10 +91,8 @@
if (json) {
if(Object.keys(json.errors).length > 0 ||
Object.keys(json.warnings).length > 0) {
-
formPanel.setMessages(json.errors, json.warnings);
}
-
if(json.message){
Ext.Msg.alert(i18n.getMsg('err.msg.save.title')
+' #'+json.message,
diff -r c1b7db04b39c -r 171eacf989d8 app/view/form/Ortserstellung.js
--- a/app/view/form/Ortserstellung.js Thu Feb 02 10:34:53 2017 +0100
+++ b/app/view/form/Ortserstellung.js Thu Feb 02 11:04:01 2017 +0100
@@ -271,6 +271,11 @@
success: function(record, response) {
var newOrtId;
var ozw = this_panel.up().parentWindow;
+ var json = Ext.decode(response.response.responseText);
+ if (json) {
+ this_panel.clearMessages();
+ this_panel.setMessages(json.errors, json.warnings);
+ }
ozw.ortstore.load({
callback: function(records, operation, success) {
ozw.down('map').addLocations(ozw.ortstore);
@@ -286,7 +291,6 @@
msg: 'Ort erfolgreich angelegt!',
buttons: Ext.Msg.OK
});
- this_panel.close();
},
scope: this
});
@@ -312,5 +316,45 @@
}
}
});
- }
+ },
+
+ setMessages: function(errors, warnings) {
+ var key;
+ var element;
+ var content;
+ var i18n = Lada.getApplication().bundle;
+ if (warnings) {
+ for (key in warnings) {
+ element = this.down('component[name=' + key + ']');
+ if (!element) {
+ continue;
+ }
+ content = warnings[key];
+ var warnText = '';
+ for (var i = 0; i < content.length; i++) {
+ warnText += i18n.getMsg(content[i].toString()) + '\n';
+ }
+ element.showWarnings(warnText);
+ }
+ }
+ if (errors) {
+ for (key in errors) {
+ element = this.down('component[name=' + key + ']');
+ if (!element) {
+ continue;
+ }
+ content = errors[key];
+ var errorText = '';
+ for (var i = 0; i < content.length; i++) {
+ errorText += i18n.getMsg(content[i].toString()) + '\n';
+ }
+ element.showErrors(errorText);
+ }
+ }
+ },
+
+ clearMessages: function() {
+ // TODO: this is a stub
+ }
+
});
diff -r c1b7db04b39c -r 171eacf989d8 app/view/form/Ortszuordnung.js
--- a/app/view/form/Ortszuordnung.js Thu Feb 02 10:34:53 2017 +0100
+++ b/app/view/form/Ortszuordnung.js Thu Feb 02 11:04:01 2017 +0100
@@ -208,7 +208,7 @@
for (var i = 0; i < content.length; i++) {
errorText += i18n.getMsg(content[i].toString()) + '\n';
}
- element.markInvalid(errorText);
+ element.showErrors(errorText);
}
}
},
More information about the Lada-commits
mailing list