Commit c636da2f authored by Tristan Cavelier's avatar Tristan Cavelier

Add default view to erp5storage

parent 4130b7af
...@@ -169,6 +169,7 @@ ...@@ -169,6 +169,7 @@
"which contains more than one character."); "which contains more than one character.");
} }
this._url = spec.url; this._url = spec.url;
this._default_view = spec.default_view;
} }
// XXX docstring // XXX docstring
...@@ -176,7 +177,7 @@ ...@@ -176,7 +177,7 @@
return function (command, param, options) { return function (command, param, options) {
RSVP.resolve(). RSVP.resolve().
then(function () { then(function () {
var view = ERP5Storage.onView[options._view] || var view = ERP5Storage.onView[options._view || this._default_view] ||
ERP5Storage.onView.default; ERP5Storage.onView.default;
if (typeof view[method] !== "function") { if (typeof view[method] !== "function") {
view = ERP5Storage.onView.default; view = ERP5Storage.onView.default;
...@@ -227,7 +228,7 @@ ...@@ -227,7 +228,7 @@
ERP5Storage.onView.default = {}; ERP5Storage.onView.default = {};
// XXX docstring // XXX docstring
function onViewDefaultGet(param) { function onViewDefaultGet(param, options) {
return getSiteDocument(this._url). return getSiteDocument(this._url).
then(function (site_hal) { then(function (site_hal) {
return jIO.util.ajax({ return jIO.util.ajax({
...@@ -235,7 +236,7 @@ ...@@ -235,7 +236,7 @@
"url": UriTemplate.parse(site_hal._links.traverse.href) "url": UriTemplate.parse(site_hal._links.traverse.href)
.expand({ .expand({
relative_url: param._id, relative_url: param._id,
view: "metadata" view: options._view || "view"
}), }),
"xhrFields": { "xhrFields": {
withCredentials: true withCredentials: true
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment