Commit 816000e1 authored by Romain Courteaud's avatar Romain Courteaud

[linshare] jslint

parent 903ed2df
......@@ -23,10 +23,10 @@
* http://download.linshare.org/components/linshare-core/2.2.2/
* Can't set up id, implied can't put new document
*/
/*global Blob, jIO, RSVP, UriTemplate*/
/*global Blob, jIO, RSVP, UriTemplate, FormData*/
/*jslint nomen: true*/
(function (jIO, RSVP, Blob, UriTemplate) {
(function (jIO, RSVP, Blob, UriTemplate, FormData) {
"use strict";
var default_url = "https://softinst89769.host.vifib.net/erp5/portal_skins/" +
"erp5_http_proxy/ERP5Site_getHTTPResource?url=https://demo.linshare.org/" +
......@@ -67,20 +67,20 @@
});
}
function checkAttachmentMap(storage, id, name) {
checkDocumentMap(storage, id);
if (!storage._id_map[id].attachment.hasOwnProperty(name)) {
function checkDocumentMap(storage, id) {
if (!storage._id_map.hasOwnProperty(id)) {
throw new jIO.util.jIOError(
"Can't find attachment with name :" + name,
"Can't find document with id : " + id,
404
);
}
}
function checkDocumentMap(storage, id) {
if (!storage._id_map.hasOwnProperty(id)) {
function checkAttachmentMap(storage, id, name) {
checkDocumentMap(storage, id);
if (!storage._id_map[id].attachment.hasOwnProperty(name)) {
throw new jIO.util.jIOError(
"Can't find document with id : " + id,
"Can't find attachment with name :" + name,
404
);
}
......@@ -171,7 +171,7 @@
var rows = [],
len = result.length,
i;
for (i = 0 ; i < len ; i += 1) {
for (i = 0; i < len; i += 1) {
if (result[i].hasOwnProperty('type')) {
if (result[i].description === 'jio/document') {
rows.push({id: JSON.parse(result[i].metaData).id, value: {}});
......@@ -183,14 +183,9 @@
};
// Attachments link by field "description" - Dict
LinshareStorage.prototype.allAttachments = function (id) {
};
LinshareStorage.prototype.putAttachment = function (id, name, blob) {
var storage = this,
data = new FormData(),
uuid;
data = new FormData();
if (!storage._id_map.hasOwnProperty(id)) {
throw new jIO.util.JIOError(
"Can't find document with id :" + id,
......@@ -248,13 +243,12 @@
type: "GET"
})
.push(function (result) {
var rows = [],
len = result.length,
var len = result.length,
i,
metadata,
row,
id;
for (i = 0 ; i < len ; i += 1) {
for (i = 0; i < len; i += 1) {
row = result[i];
if (row.hasOwnProperty('description')) {
if (row.description === 'jio/document') {
......@@ -279,4 +273,4 @@
jIO.addStorage('linshare', LinshareStorage);
}(jIO, RSVP, Blob, UriTemplate));
\ No newline at end of file
}(jIO, RSVP, Blob, UriTemplate, FormData));
\ No newline at end of file
......@@ -27,6 +27,7 @@
ok = QUnit.ok,
expect = QUnit.expect,
equal = QUnit.equal,
deepEqual = QUnit.deepEqual,
module = QUnit.module;
/////////////////////////////////////////////////////////////////
......@@ -82,7 +83,6 @@
jio.allDocs({include_docs: true})
.then(function (result) {
deepEqual(result, {}, 'check result');
console.warn(res);
})
.fail(function (error) {
ok(false, error);
......
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