Revision c72a830d ui/static/snf/js/ui/web/ui_model_views.js
b/ui/static/snf/js/ui/web/ui_model_views.js | ||
---|---|---|
148 | 148 |
reset_form_errors: function() { |
149 | 149 |
this.form.find(".form-field").removeClass("error"); |
150 | 150 |
this.form.find(".form-field .errors").empty(); |
151 |
this.form.find(".form-messages").empty(); |
|
151 | 152 |
}, |
152 | 153 |
|
153 | 154 |
show_form_errors: function(errors) { |
... | ... | |
163 | 164 |
field.find(".errors").append(error_el); |
164 | 165 |
}); |
165 | 166 |
}, this)); |
166 |
//var el = $('<div class="error">{1}</div>'.format(type, msg)); |
|
167 |
//this.list_messages.append(el); |
|
167 |
|
|
168 |
var msg = errors['']; |
|
169 |
if (msg) { |
|
170 |
var el = $('<div class="error">{0}</div>'.format(msg)); |
|
171 |
this.$(".form-messages").append(el); |
|
172 |
} |
|
168 | 173 |
}, |
169 | 174 |
|
170 | 175 |
clean_form_errors: function() { |
176 |
|
|
171 | 177 |
}, |
172 | 178 |
|
173 | 179 |
submit_form: function() { |
... | ... | |
272 | 278 |
this.show_list_msg("success", this.create_success_msg || "Entry created"); |
273 | 279 |
}, this), |
274 | 280 |
|
275 |
error: _.bind(function(){ |
|
276 |
this.show_form_errors({'': this.create_failed_msg || 'Entry submition failed'}) |
|
281 |
error: _.bind(function(data, xhr){ |
|
282 |
var resp_error = ""; |
|
283 |
// try to parse response |
|
284 |
try { |
|
285 |
json_resp = JSON.parse(xhr.responseText); |
|
286 |
resp_error = json_resp.errors[json_resp.non_field_key].join("<br />"); |
|
287 |
} catch (err) {} |
|
288 |
|
|
289 |
var form_error = resp_error != "" ? |
|
290 |
this.create_failed_msg + " ({0})".format(resp_error) : |
|
291 |
this.create_failed_msg; |
|
292 |
|
|
293 |
this.show_form_errors({'': form_error || 'Entry submition failed'}) |
|
277 | 294 |
}, this), |
278 | 295 |
|
279 | 296 |
complete: _.bind(function(){ |
280 | 297 |
this.submiting = false; |
281 | 298 |
this.form.find("form-action.submit").addClass("in-progress"); |
282 |
}, this) |
|
299 |
}, this), |
|
300 |
|
|
301 |
skip_api_error: true |
|
283 | 302 |
} |
284 | 303 |
|
285 | 304 |
if (this.editing_id && this.collection.get(this.editing_id)) { |
Also available in: Unified diff