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