annotate app/view/window/ImportResponse.js @ 1179:08bd9f1c791b

Implement allowBlank for custom ComboBox.
author Tom Gottfried <tom@intevation.de>
date Thu, 04 Aug 2016 16:59:37 +0200
parents def27cdd0dfa
children 746915a63a11
rev   line source
729
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
1 /**
890
def27cdd0dfa Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents: 729
diff changeset
2 * This Window is shown, when Proben could be imported from a LAF file
729
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
3 */
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
4 Ext.define('Lada.view.window.ImportResponse', {
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
5 extend: 'Ext.window.Window',
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
6 alias: 'widget.importresponse',
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
7
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
8 data: null,
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
9 message: null,
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
10 fileName: '',
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
11
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
12 layout: 'fit',
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
13 /**
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
14 * @private
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
15 * Initialize the view.
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
16 */
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
17 initComponent: function() {
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
18 var me = this;
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
19 var html;
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
20 if (me.data && me.message) {
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
21 html = me.parseResponse(me.message, me.data);
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
22 }
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
23 this.bodyStyle = {background: '#fff'};
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
24 me.items = [{
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
25 xtype: 'panel',
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
26 html: html,
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
27 margin: 10,
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
28 border: false
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
29 }];
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
30
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
31 this.callParent(arguments);
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
32 },
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
33
890
def27cdd0dfa Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents: 729
diff changeset
34 /**
def27cdd0dfa Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents: 729
diff changeset
35 * Parse the Response
def27cdd0dfa Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents: 729
diff changeset
36 * @param msg the Lada-Erro-Code
def27cdd0dfa Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents: 729
diff changeset
37 * @param data the payload of the response
def27cdd0dfa Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents: 729
diff changeset
38 */
729
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
39 parseResponse: function(msg, data) {
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
40 console.log(Ext.JSON.decode(data));
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
41 data = Ext.JSON.decode(data);
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
42 var errors = data.data.errors;
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
43 var warnings = data.data.warnings;
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
44 var out = [];
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
45 // There is a entry for each imported proben in the errors dict (might be
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
46 // empty)
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
47
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
48 var numErrors;
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
49 var numWarnings;
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
50 if (Ext.isEmpty(Object.keys(errors))) {
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
51 numErrors = 0;
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
52 }
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
53 else {
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
54 numErrors = Object.keys(errors).length;
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
55 }
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
56 if (Ext.isEmpty(Object.keys(warnings))) {
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
57 numWarnings = 0;
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
58 }
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
59 else {
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
60 numWarnings = Object.keys(warnings).length;
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
61 }
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
62 if (msg !== '200') {
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
63 out.push('Der Import der Datei ' + this.fileName +
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
64 ' war nicht erfolgreich. Der Importvorgang konnte ' +
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
65 'aufgrund eines Fehlers im Server nicht beendet werden.');
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
66 }
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
67 else {
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
68 if (numErrors > 0) {
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
69 out.push('Folgende Proben konnten nicht erfolgreich ' +
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
70 'importiert werden:');
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
71 out.push('<br/>');
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
72 out.push('<ol>');
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
73 var msgs;
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
74 for (var key in errors) {
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
75 out.push('<li>Probe: ' + key);
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
76 msgs = errors[key];
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
77 out.push('<ol>');
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
78 for (var i = msgs.length - 1; i >= 0; i--) {
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
79 if (msgs[i].key === 'validation') {
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
80 out.push('Validierungsfehler: ');
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
81 out.push('<ol>');
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
82 for (var vKey in msgs[i].value) {
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
83 out.push(Lada.getApplication().bundle.getMsg(vKey) + ': ');
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
84 for (var j = 0; j < msgs[i].value[vKey].length; j++) {
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
85 console.log(msgs[i].value[vKey][j]);
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
86 out.push(Lada.getApplication().bundle.getMsg(msgs[i].value[vKey][j].toString()));
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
87 }
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
88 }
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
89 out.push('</ol>');
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
90 }
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
91 else {
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
92 out.push(msgs[i].key +
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
93 ' (' + Lada.getApplication().bundle.getMsg(
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
94 msgs[i].code.toString()) +
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
95 '): ' + msgs[i].value);
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
96 }
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
97 }
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
98 out.push('</ol>');
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
99 out.push('</li>');
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
100 }
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
101 out.push('</ol>');
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
102 out.push('<br/>');
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
103 }
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
104 if (numWarnings > 0) {
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
105 out.push('<br/>');
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
106 out.push('Bei folgenden Proben traten Warnungen auf:');
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
107 out.push('<br/>');
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
108 out.push('<ol>');
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
109 for (key in warnings) {
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
110 out.push('<li>' + key);
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
111 msgs = warnings[key];
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
112 out.push('<ol>');
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
113 for (var i = msgs.length - 1; i >= 0; i--) {
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
114 if (msgs[i].key === 'validation') {
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
115 out.push('Validierungswarnungen: ');
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
116 out.push('<ol>');
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
117 for (var vKey in msgs[i].value) {
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
118 out.push(Lada.getApplication().bundle.getMsg(vKey) + ': ');
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
119 for (var j = 0; j < msgs[i].value[vKey].length; j++) {
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
120 console.log(msgs[i].value[vKey][j]);
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
121 out.push(Lada.getApplication().bundle.getMsg(msgs[i].value[vKey][j].toString()));
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
122 }
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
123 }
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
124 out.push('</ol>');
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
125 }
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
126 else {
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
127 out.push('<li>' + msgs[i].key + ' (' + Lada.getApplication().bundle.getMsg(msgs[i].code.toString())+'): '+msgs[i].value+'</li>')
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
128 }
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
129 }
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
130 out.push('</ol>');
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
131 out.push('</li>');
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
132 }
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
133 out.push('</ol>');
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
134 }
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
135 out.push('<br/>');
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
136 }
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
137 console.log(out.join(''));
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
138 return out.join('');
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
139 }
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
140 });

http://lada.wald.intevation.org