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 @@
// }
/*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 */
(function (dependencies, module) {
......@@ -18,8 +18,13 @@
if (typeof define === 'function' && define.amd) {
return define(dependencies, module);
}
module(RSVP, jIO, complex_queries);
}(['rsvp', 'jio', 'complex_queries'], function (RSVP, jIO, complex_queries) {
module(RSVP, jIO, complex_queries, URI);
}([
'rsvp',
'jio',
'complex_queries',
'uri'
], function (RSVP, jIO, complex_queries, URI) {
"use strict";
function ERP5Storage(spec) {
......@@ -106,26 +111,9 @@
});
}).then(function (doc) {
// XXX Really depend on server response...
var new_document_url = doc.target.getResponseHeader("Location");
return jIO.util.ajax({
"type": "GET",
"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) {
var uri = new URI(doc.target.getResponseHeader("X-Location"));
command.success({"id": uri.segment(2)});
}).fail(function (event) {
console.error(event);
if (event instanceof ProgressEvent) {
return command.error(
......@@ -214,15 +202,16 @@
var data = catalog_json._embedded.contents,
count = data.length,
i,
uri,
item,
result = [],
promise_list = [result];
for (i = 0; i < count; i += 1) {
item = data[i];
item._id = item._relative_url;
uri = new URI(item._links.self.href);
result.push({
id: item._relative_url,
key: item._relative_url,
id: uri.segment(2),
key: uri.segment(2),
doc: {},
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