X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=planetstack%2Fcore%2Fxoslib%2Fstatic%2Fjs%2Fxoslib%2FxosHelper.js;h=9f5eadf7f7cef15b18e1734e586316b22e6df6cd;hb=8dbddcbf922454fc061318df12c6381e812fff55;hp=6b6419c884d8a503653569ed8d03cc875e246d4a;hpb=fe290f49559b1e19b9251b83877862f70679bf86;p=plstackapi.git diff --git a/planetstack/core/xoslib/static/js/xoslib/xosHelper.js b/planetstack/core/xoslib/static/js/xoslib/xosHelper.js index 6b6419c..9f5eadf 100644 --- a/planetstack/core/xoslib/static/js/xoslib/xosHelper.js +++ b/planetstack/core/xoslib/static/js/xoslib/xosHelper.js @@ -4,6 +4,21 @@ HTMLView = Marionette.ItemView.extend({ }, }); +FilteredCompositeView = Marionette.CompositeView.extend( { + showCollection: function() { + var ChildView; + this.collection.each(function(child, index) { + filterFunc = this.options.filter || this.filter; + if (filterFunc && !filterFunc(child)) { + return; + } + ChildView = this.getChildView(child); + this.addChild(child, ChildView, index); + }, this); + + }, +}); + SliceSelectorOption = Marionette.ItemView.extend({ template: "#xos-sliceselector-option", tagName: "option", @@ -16,7 +31,7 @@ SliceSelectorOption = Marionette.ItemView.extend({ }, }); -SliceSelectorView = Marionette.CompositeView.extend({ +SliceSelectorView = FilteredCompositeView.extend({ template: "#xos-sliceselector-select", childViewContainer: "select", childView: SliceSelectorOption, @@ -39,20 +54,6 @@ SliceSelectorView = Marionette.CompositeView.extend({ templateHelpers: function() { return {caption: this.options.caption || this.caption }; }, }); -FilteredCompositeView = Marionette.CompositeView.extend( { - showCollection: function() { - var ChildView; - this.collection.each(function(child, index) { - if (this.filter && !this.filter(child)) { - return; - } - ChildView = this.getChildView(child); - this.addChild(child, ChildView, index); - }, this); - - }, -}); - XOSRouter = Marionette.AppRouter.extend({ initialize: function() { this.routeStack=[]; @@ -146,10 +147,18 @@ XOSApplication = Marionette.Application.extend({ } console.log(responseText); console.log(parsed_error); - if (parsed_error) { + + if (parsed_error && ("error" in parsed_error)) { + // this error comes from genapi views + $("#xos-error-dialog").html(templateFromId("#xos-error-response")(parsed_error)); + } else if (parsed_error && ("detail" in parsed_error)) { + // this error response comes from rest_framework APIException + parsed_error["error"] = "API Error"; + parsed_error["specific_error"] = parsed_error["detail"]; + parsed_error["reasons"] = []; $("#xos-error-dialog").html(templateFromId("#xos-error-response")(parsed_error)); } else { - $("#xos-error-dialog").html(templateFromId("#xos-error-rawresponse")({responseText: responseText})) + $("#xos-error-dialog").html(templateFromId("#xos-error-rawresponse")({responseText: strip_scripts(responseText)})) } $("#xos-error-dialog").dialog({ @@ -672,6 +681,7 @@ XOSDetailView = Marionette.ItemView.extend({ model: this.model, detailView: this, choices: this.options.choices || this.choices || this.model.choices || {}, + helpText: this.options.helpText || this.helpText || this.model.helpText || {}, }}, });