Commit 27a3b950 authored by Romain Courteaud's avatar Romain Courteaud

ERP5Storage: require default view reference.

Allow to choose which action_reference will be used as default view.
parent 8221432f
...@@ -59,6 +59,7 @@ ...@@ -59,6 +59,7 @@
"which contains more than one character."); "which contains more than one character.");
} }
this._url = spec.url; this._url = spec.url;
this._default_view_reference = spec.default_view_reference;
} }
ERP5Storage.prototype.get = function (param) { ERP5Storage.prototype.get = function (param) {
...@@ -93,7 +94,8 @@ ...@@ -93,7 +94,8 @@
var action = param._attachment; var action = param._attachment;
if (action === "view") { if (action === "view") {
return getDocumentAndHateoas(this, param, {"_view": param._attachment}) return getDocumentAndHateoas(this, param,
{"_view": this._default_view_reference})
.push(function (response) { .push(function (response) {
var result = JSON.parse(response.target.responseText); var result = JSON.parse(response.target.responseText);
result._id = param._id; result._id = param._id;
......
...@@ -34,11 +34,13 @@ ...@@ -34,11 +34,13 @@
test("Storage store URL", function () { test("Storage store URL", function () {
var jio = jIO.createJIO({ var jio = jIO.createJIO({
type: "erp5", type: "erp5",
url: domain url: domain,
default_view_reference: "bar_view"
}); });
equal(jio.__type, "erp5"); equal(jio.__type, "erp5");
deepEqual(jio.__storage._url, domain); deepEqual(jio.__storage._url, domain);
deepEqual(jio.__storage._default_view_reference, "bar_view");
}); });
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
...@@ -225,7 +227,8 @@ ...@@ -225,7 +227,8 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "erp5", type: "erp5",
url: domain url: domain,
default_view_reference: "foo_view"
}); });
}, },
teardown: function () { teardown: function () {
...@@ -258,7 +261,7 @@ ...@@ -258,7 +261,7 @@
test("getAttachment: view uses default form", function () { test("getAttachment: view uses default form", function () {
var id = "person_module/1", var id = "person_module/1",
traverse_url = domain + "?mode=traverse&relative_url=" + traverse_url = domain + "?mode=traverse&relative_url=" +
encodeURIComponent(id) + "&view=view", encodeURIComponent(id) + "&view=foo_view",
document_hateoas = JSON.stringify({ document_hateoas = JSON.stringify({
"title": "foo", "title": "foo",
"_bar": "john doo", "_bar": "john doo",
......
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