Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
ecommerce-ui
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
ecommerce-ui
Commits
d0ac9f8f
Commit
d0ac9f8f
authored
Feb 21, 2014
by
Sven Franck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
first pass at running requests through POST with all hacks in storage
parent
093bd8cb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
6 deletions
+20
-6
js/libs/jio/hateoasstorage.js
js/libs/jio/hateoasstorage.js
+20
-6
No files found.
js/libs/jio/hateoasstorage.js
View file @
d0ac9f8f
...
...
@@ -75,10 +75,22 @@
HateoasStorage
.
prototype
.
post
=
function
(
command
,
metadata
,
options
)
{
return
this
.
_getSiteDocument
()
// HACK: get me... default _add, otherwise passed through options!
.
then
(
function
(
site_hal
)
{
var
post_action
=
site_hal
.
_actions
.
add
,
data
=
new
FormData
(),
key
;
return
jIO
.
util
.
ajax
({
"
url
"
:
site_hal
.
_links
.
me
.
href
,
"
xhrFields
"
:
{
"
withCredentials
"
:
true
}
})
})
.
then
(
function
(
opts
)
{
var
doc_hal
,
custom_action
,
post_action
,
data
,
key
;
doc_hal
=
JSON
.
parse
(
opts
.
target
.
responseText
);
custom_action
=
doc_hal
.
_actions
[
options
.
call
];
post_action
=
custom_action
||
site_hal
.
_actions
.
add
;
data
=
new
FormData
();
for
(
key
in
metadata
)
{
if
(
metadata
.
hasOwnProperty
(
key
))
{
...
...
@@ -86,22 +98,24 @@
data
.
append
(
key
,
metadata
[
key
]);
}
}
return
jIO
.
util
.
ajax
({
"
type
"
:
post_action
.
method
,
"
url
"
:
post_action
.
href
,
"
data
"
:
data
,
"
xhrFields
"
:
{
withCredentials
:
true
"
withCredentials
"
:
true
}
});
}).
then
(
function
(
doc
)
{
})
.
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
"
withCredentials
"
:
true
}
});
}).
then
(
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