},
popupErrorDialog: function(responseText) {
- $("#xos-error-dialog").html(templateFromId("#xos-error-response")($.parseJSON(responseText)));
+ try {
+ parsed_error=$.parseJSON(responseText);
+ width=300;
+ }
+ catch(err) {
+ parsed_error=undefined;
+ width=640; // django stacktraces like wide width
+ }
+ if (parsed_error) {
+ $("#xos-error-dialog").html(templateFromId("#xos-error-response")(json));
+ } else {
+ $("#xos-error-dialog").html(templateFromId("#xos-error-rawresponse")({responseText: responseText}))
+ }
+
$("#xos-error-dialog").dialog({
modal: true,
+ width: width,
buttons: {
Ok: function() { $(this).dialog("close"); }
}
this.app.showError(result);\r
},\r
\r
- saveSuccess: function(model, result, xhr, infoMsgId) {\r
+ saveSuccess: function(model, result, xhr, infoMsgId, isNew) {\r
+ console.log("saveSuccess");\r
+ if (isNew) {\r
+ this.collection.add(model);\r
+ this.collection.sort();\r
+ }\r
result = {status: xhr.xhr.status, statusText: xhr.xhr.statusText};\r
result["what"] = "save " + model.modelName + " " + model.attributes.humanReadableName;\r
result["infoMsgId"] = infoMsgId;\r
model.save, we call it ourselves, so we can throw up our\r
validation error before creating the infoMsg in the log\r
*/\r
- errors = this.model.validate(data);\r
+ errors = this.model.xosValidate(data);\r
if (errors) {\r
this.onFormDataInvalid(errors);\r
return;\r
}\r
\r
+ if (isNew) {\r
+ this.model.attributes.humanReadableName = "new " + model.modelName;\r
+ }\r
+\r
var infoMsgId = this.app.showInformational( {what: "save " + model.modelName + " " + model.attributes.humanReadableName, status: "", statusText: "in progress..."} );\r
\r
this.model.save(data, {error: function(model, result, xhr) { that.saveError(model,result,xhr,infoMsgId);},\r
- success: function(model, result, xhr) { that.saveSuccess(model,result,xhr,infoMsgId);}});\r
- if (isNew) {\r
- console.log(this.model);\r
+ invalid: function(model, result, xhr) { console.log("invalid!"); that.saveError(model,result,xhr,infoMsgId);},\r
+ success: function(model, result, xhr) { that.saveSuccess(model,result,xhr,infoMsgId, isNew);}});\r
+ /*if (isNew) {\r
this.collection.add(this.model);\r
this.collection.sort();\r
- }\r
+ }*/\r
this.dirty = false;\r
},