Commit 61d20125 authored by Tristan Cavelier's avatar Tristan Cavelier

Merge branch 'master' of https://git.erp5.org/repos/jio

Conflicts:
	src/jio.storage/erp5storage.js
parents 36b4a5d2 4763d057
This diff is collapsed.
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
// } // }
/*jslint indent: 2, nomen: true, unparam: true */ /*jslint indent: 2, nomen: true, unparam: true */
/*global jIO, complex_queries, console, UriTemplate, FormData, RSVP, /*global jIO, complex_queries, console, UriTemplate, FormData, RSVP, URI,
ProgressEvent, define */ ProgressEvent, define */
(function (dependencies, module) { (function (dependencies, module) {
...@@ -18,8 +18,13 @@ ...@@ -18,8 +18,13 @@
if (typeof define === 'function' && define.amd) { if (typeof define === 'function' && define.amd) {
return define(dependencies, module); return define(dependencies, module);
} }
module(RSVP, jIO, complex_queries); module(RSVP, jIO, complex_queries, URI);
}(['rsvp', 'jio', 'complex_queries'], function (RSVP, jIO, complex_queries) { }([
'rsvp',
'jio',
'complex_queries',
'uri'
], function (RSVP, jIO, complex_queries, URI) {
"use strict"; "use strict";
function ERP5Storage(spec) { function ERP5Storage(spec) {
...@@ -106,26 +111,9 @@ ...@@ -106,26 +111,9 @@
}); });
}).then(function (doc) { }).then(function (doc) {
// XXX Really depend on server response... // XXX Really depend on server response...
var new_document_url = doc.target.getResponseHeader("Location"); var uri = new URI(doc.target.getResponseHeader("X-Location"));
return jIO.util.ajax({ command.success({"id": uri.segment(2)});
"type": "GET", }).fail(function (event) {
"url": new_document_url,
"xhrFields": {
withCredentials: true
}
});
}).then(function (response) {
var doc_hal = JSON.parse(response.target.responseText);
if (doc_hal !== null) {
command.success({"id": doc_hal._relative_url});
} else {
command.error(
"not_found",
"missing",
"Cannot find document"
);
}
}, function (event) {
console.error(event); console.error(event);
if (event instanceof ProgressEvent) { if (event instanceof ProgressEvent) {
return command.error( return command.error(
...@@ -214,15 +202,16 @@ ...@@ -214,15 +202,16 @@
var data = catalog_json._embedded.contents, var data = catalog_json._embedded.contents,
count = data.length, count = data.length,
i, i,
uri,
item, item,
result = [], result = [],
promise_list = [result]; promise_list = [result];
for (i = 0; i < count; i += 1) { for (i = 0; i < count; i += 1) {
item = data[i]; item = data[i];
item._id = item._relative_url; uri = new URI(item._links.self.href);
result.push({ result.push({
id: item._relative_url, id: uri.segment(2),
key: item._relative_url, key: uri.segment(2),
doc: {}, doc: {},
value: item value: item
}); });
......
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