Mercurial > lada > lada-client
comparison app/view/window/AuditTrail.js @ 1407:2195fd3946e4
Reduce code duplication.
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Wed, 22 Mar 2017 16:12:11 +0100 |
parents | d1f6aa80758f |
children | 86c6b6c01246 |
comparison
equal
deleted
inserted
replaced
1406:d1f6aa80758f | 1407:2195fd3946e4 |
---|---|
116 audit[i].identifier.messung + ' -> ' + | 116 audit[i].identifier.messung + ' -> ' + |
117 i18n.getMsg(audit[i].type) + ': ' + | 117 i18n.getMsg(audit[i].type) + ': ' + |
118 audit[i].identifier.identifier; | 118 audit[i].identifier.identifier; |
119 | 119 |
120 } | 120 } |
121 if (audit[i].action === 'I') { | 121 html += this.createHtmlChangedFields(audit[i]); |
122 html += '<br>angelegt<br><div style="margin-left:2em;">' | |
123 } | |
124 else { | |
125 html += '<br>geändert in<br><div style="margin-left:2em;">' | |
126 } | |
127 for (var key in audit[i].changedFields) { | |
128 var value = ''; | |
129 if (Ext.Array.contains(this.dateItems, key)) { | |
130 value = Ext.Date.format(new Date(audit[i].changedFields[key]), 'd.m.Y H:i'); | |
131 } | |
132 else { | |
133 value = audit[i].changedFields[key]; | |
134 } | |
135 html += '' + i18n.getMsg(key) + ': ' + | |
136 value + '<br>'; | |
137 } | |
138 html += '</div>'; | |
139 html += '</p>'; | |
140 } | 122 } |
141 } | 123 } |
142 return html; | 124 return html; |
143 }, | 125 }, |
144 | 126 |
155 (Ext.Date.format(new Date(audit[i].timestamp), 'd.m.Y H:i')) + '</b>'; | 137 (Ext.Date.format(new Date(audit[i].timestamp), 'd.m.Y H:i')) + '</b>'; |
156 if (audit[i].type !== 'messung') { | 138 if (audit[i].type !== 'messung') { |
157 html += '<br>' + i18n.getMsg(audit[i].type) + ': '; | 139 html += '<br>' + i18n.getMsg(audit[i].type) + ': '; |
158 html += audit[i].identifier; | 140 html += audit[i].identifier; |
159 } | 141 } |
160 if (audit[i].action === 'I') { | 142 html += this.createHtmlChangedFields(audit[i]); |
161 html += '<br>angelegt<br><div style="margin-left:2em;">' | |
162 } | |
163 else { | |
164 html += '<br>geändert in<br><div style="margin-left:2em;">' | |
165 } | |
166 for (var key in audit[i].changedFields) { | |
167 var value = ''; | |
168 if (Ext.Array.contains(this.dateItems, key)) { | |
169 value = Ext.Date.format(new Date(audit[i].changedFields[key]), 'd.m.Y H:i'); | |
170 } | |
171 else { | |
172 value = audit[i].changedFields[key]; | |
173 } | |
174 html += '' + i18n.getMsg(key) + ': ' + | |
175 value + '<br>'; | |
176 } | |
177 html += '</div>'; | |
178 html += '</p>'; | |
179 } | 143 } |
180 } | 144 } |
181 return html; | 145 return html; |
146 }, | |
147 | |
148 createHtmlChangedFields: function(audit) { | |
149 var i18n = Lada.getApplication().bundle; | |
150 html = '<br>' + i18n.getMsg(audit.action) | |
151 + '<br><div style="margin-left:2em;">'; | |
152 | |
153 for (var key in audit.changedFields) { | |
154 var value = ''; | |
155 if (Ext.Array.contains(this.dateItems, key)) { | |
156 value = Ext.Date.format(new Date(audit.changedFields[key]), | |
157 'd.m.Y H:i'); | |
158 } | |
159 else { | |
160 value = audit.changedFields[key]; | |
161 } | |
162 html += '' + i18n.getMsg(key) + ': ' + | |
163 value + '<br>'; | |
164 } | |
165 html += '</div>'; | |
166 html += '</p>'; | |
167 return html; | |
182 } | 168 } |
183 }); | 169 }); |