Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
jio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Aurélien Vermylen
jio
Commits
d1895b24
Commit
d1895b24
authored
Nov 06, 2017
by
Aurélien Vermylen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make tests pass (except usual CryptStorage and stringify) and build.
parent
0e69426d
Changes
3
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
1286 additions
and
890 deletions
+1286
-890
dist/jio-v3.23.1.min.js
dist/jio-v3.23.1.min.js
+1
-1
dist/nodejs/jio.js
dist/nodejs/jio.js
+1251
-845
src/jio.storage/erp5storage.js
src/jio.storage/erp5storage.js
+34
-44
No files found.
dist/jio-v3.23.1.min.js
View file @
d1895b24
This diff is collapsed.
Click to expand it.
dist/nodejs/jio.js
View file @
d1895b24
This diff is collapsed.
Click to expand it.
src/jio.storage/erp5storage.js
View file @
d1895b24
...
...
@@ -11,7 +11,7 @@
/*jslint nomen: true, unparam: true */
/*global jIO, UriTemplate, FormData, RSVP, URI, Blob,
SimpleQuery, ComplexQuery
, btoa
*/
SimpleQuery, ComplexQuery*/
(
function
(
jIO
,
UriTemplate
,
FormData
,
RSVP
,
URI
,
Blob
,
SimpleQuery
,
ComplexQuery
)
{
...
...
@@ -24,9 +24,8 @@
"
type
"
:
"
GET
"
,
"
url
"
:
storage
.
_url
,
"
xhrFields
"
:
{
withCredentials
:
storage
.
_thisCredentials
},
"
headers
"
:
storage
.
_headers
withCredentials
:
true
}
});
})
.
push
(
function
(
event
)
{
...
...
@@ -51,9 +50,8 @@
view
:
options
.
_view
}),
"
xhrFields
"
:
{
withCredentials
:
storage
.
_thisCredentials
},
"
headers
"
:
storage
.
_headers
withCredentials
:
true
}
});
})
.
push
(
undefined
,
function
(
error
)
{
...
...
@@ -130,8 +128,8 @@
});
}
function
extractPropertyFromForm
(
storage
,
id
)
{
return
storage
.
getAttachment
(
id
,
"
view
"
)
function
extractPropertyFromForm
(
context
,
id
)
{
return
context
.
getAttachment
(
id
,
"
view
"
)
.
push
(
function
(
blob
)
{
return
jIO
.
util
.
readBlobAsText
(
blob
);
})
...
...
@@ -151,17 +149,20 @@
}
this
.
_url
=
spec
.
url
;
this
.
_default_view_reference
=
spec
.
default_view_reference
;
this
.
_headers
=
null
;
this
.
_thisCredentials
=
true
;
if
(
spec
.
login
!==
undefined
&&
spec
.
password
!==
undefined
)
{
this
.
_headers
=
{
"
Authorization
"
:
"
Basic
"
+
btoa
(
spec
.
login
+
"
:
"
+
spec
.
password
)};
this
.
_thisCredentials
=
false
;
}
}
function
convertJSONToGet
(
json
)
{
return
json
.
data
;
var
key
,
result
=
json
.
data
;
// Remove all ERP5 hateoas links / convert them into jIO ID
for
(
key
in
result
)
{
if
(
result
.
hasOwnProperty
(
key
))
{
if
(
!
result
[
key
])
{
delete
result
[
key
];
}
}
}
return
result
;
}
ERP5Storage
.
prototype
.
get
=
function
(
id
)
{
...
...
@@ -172,7 +173,7 @@
};
ERP5Storage
.
prototype
.
post
=
function
(
data
)
{
var
storage
=
this
,
var
context
=
this
,
new_id
;
return
getSiteDocument
(
this
)
...
...
@@ -185,16 +186,15 @@
url
:
site_hal
.
_actions
.
add
.
href
,
data
:
form_data
,
xhrFields
:
{
withCredentials
:
storage
.
_thisCredentials
},
"
headers
"
:
storage
.
_headers
withCredentials
:
true
}
});
})
.
push
(
function
(
evt
)
{
var
location
=
evt
.
target
.
getResponseHeader
(
"
X-Location
"
),
uri
=
new
URI
(
location
);
new_id
=
uri
.
segment
(
2
);
return
storage
.
put
(
new_id
,
data
);
return
context
.
put
(
new_id
,
data
);
})
.
push
(
function
()
{
return
new_id
;
...
...
@@ -202,9 +202,9 @@
};
ERP5Storage
.
prototype
.
put
=
function
(
id
,
data
)
{
var
storage
=
this
;
var
context
=
this
;
return
extractPropertyFromForm
(
storage
,
id
)
return
extractPropertyFromForm
(
context
,
id
)
.
push
(
function
(
result
)
{
var
key
,
json
=
result
.
form_data
,
...
...
@@ -237,7 +237,7 @@
403
);
}
return
storage
.
putAttachment
(
return
context
.
putAttachment
(
id
,
result
.
action_href
,
new
Blob
([
JSON
.
stringify
(
form_data
)],
{
type
:
"
application/json
"
})
...
...
@@ -246,10 +246,10 @@
};
ERP5Storage
.
prototype
.
allAttachments
=
function
(
id
)
{
var
storage
=
this
;
var
context
=
this
;
return
getDocumentAndHateoas
(
this
,
id
)
.
push
(
function
()
{
if
(
storage
.
_default_view_reference
===
undefined
)
{
if
(
context
.
_default_view_reference
===
undefined
)
{
return
{
links
:
{}
};
...
...
@@ -262,7 +262,6 @@
};
ERP5Storage
.
prototype
.
getAttachment
=
function
(
id
,
action
,
options
)
{
var
storage
=
this
;
if
(
options
===
undefined
)
{
options
=
{};
}
...
...
@@ -309,9 +308,8 @@
"
dataType
"
:
"
blob
"
,
"
url
"
:
action
,
"
xhrFields
"
:
{
withCredentials
:
storage
.
_thisCredentials
},
"
headers
"
:
storage
.
_headers
withCredentials
:
true
}
};
if
(
options
.
start
!==
undefined
||
options
.
end
!==
undefined
)
{
start
=
options
.
start
||
0
;
...
...
@@ -331,11 +329,7 @@
}
range
=
"
bytes=
"
+
start
+
"
-
"
+
end
;
}
if
(
storage
.
_headers
===
undefined
)
{
request_options
.
headers
=
{
Range
:
range
};
}
else
{
request_options
.
headers
.
Range
=
range
;
}
}
return
jIO
.
util
.
ajax
(
request_options
);
})
...
...
@@ -354,7 +348,6 @@
};
ERP5Storage
.
prototype
.
putAttachment
=
function
(
id
,
name
,
blob
)
{
var
storage
=
this
;
// Assert we use a callable on a document from the ERP5 site
if
(
name
.
indexOf
(
this
.
_url
)
!==
0
)
{
throw
new
jIO
.
util
.
jIOError
(
"
Can not store outside ERP5:
"
+
...
...
@@ -396,9 +389,8 @@
"
data
"
:
data
,
"
dataType
"
:
"
blob
"
,
"
xhrFields
"
:
{
withCredentials
:
storage
.
_thisCredentials
},
"
headers
"
:
storage
.
_headers
withCredentials
:
true
}
});
});
};
...
...
@@ -447,7 +439,6 @@
// jIO.Query.objectToSearchText(options.query) :
// undefined);
// }
var
storage
=
this
;
return
getSiteDocument
(
this
)
.
push
(
function
(
site_hal
)
{
var
query
=
options
.
query
,
...
...
@@ -516,9 +507,8 @@
local_roles
:
local_roles
}),
"
xhrFields
"
:
{
withCredentials
:
storage
.
_thisCredentials
},
"
headers
"
:
storage
.
_headers
withCredentials
:
true
}
});
})
.
push
(
function
(
response
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment