Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
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
Douglas
jio
Commits
0e46db8c
Commit
0e46db8c
authored
Mar 19, 2014
by
Tristan Cavelier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add some erp5.taskmanview features to erp5storage
parent
5fe97ed4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
131 deletions
+40
-131
src/jio.storage/erp5storage.js
src/jio.storage/erp5storage.js
+33
-40
src/jio.storage/erp5storage.taskmanagerview.js
src/jio.storage/erp5storage.taskmanagerview.js
+7
-91
No files found.
src/jio.storage/erp5storage.js
View file @
0e46db8c
...
...
@@ -223,26 +223,33 @@
}
ERP5Storage
.
getSiteDocument
=
getSiteDocument
;
ERP5Storage
.
onView
=
{};
ERP5Storage
.
onView
[
"
default
"
]
=
{};
// XXX docstring
function
onViewDefaultGet
(
param
,
options
)
{
return
getSiteDocument
(
this
.
_url
).
function
getDocumentAndHatoas
(
param
,
options
)
{
var
this_
=
this
;
return
ERP5Storage
.
getSiteDocument
(
this
.
_url
).
then
(
function
(
site_hal
)
{
// XXX need to get modified metadata
return
jIO
.
util
.
ajax
({
"
type
"
:
"
GET
"
,
"
url
"
:
UriTemplate
.
parse
(
site_hal
.
_links
.
traverse
.
href
)
.
expand
({
relative_url
:
param
.
_id
,
view
:
options
.
_view
||
"
view
"
view
:
options
.
_view
||
this_
.
_default_view
||
"
view
"
}),
"
xhrFields
"
:
{
withCredentials
:
true
}
});
})
.
then
(
function
(
response
)
{
});
}
ERP5Storage
.
onView
=
{};
ERP5Storage
.
onView
[
"
default
"
]
=
{};
// XXX docstring
ERP5Storage
.
onView
[
"
default
"
].
get
=
function
(
param
,
options
)
{
return
getDocumentAndHatoas
.
call
(
this
,
param
,
options
).
then
(
function
(
response
)
{
var
result
=
JSON
.
parse
(
response
.
target
.
responseText
);
result
.
_id
=
param
.
_id
;
result
.
portal_type
=
result
.
_links
.
type
.
name
;
...
...
@@ -252,24 +259,19 @@
new
jIO
.
Metadata
(
result
).
format
();
return
{
"
data
"
:
result
};
});
}
ERP5Storage
.
onView
[
"
default
"
].
get
=
onViewDefaultGet
;
};
// XXX docstring
ERP5Storage
.
onView
[
"
default
"
].
post
=
function
(
metadata
,
options
)
{
var
final_response
;
return
getSiteDocument
(
this
.
_url
)
.
then
(
function
(
site_hal
)
{
/*jslint forin: true */
var
post_action
=
site_hal
.
_actions
.
add
,
data
=
new
FormData
(),
key
;
data
=
new
FormData
();
data
.
append
(
"
portal_type
"
,
metadata
.
portal_type
);
for
(
key
in
metadata
)
{
if
(
hasOwnProperty
(
metadata
,
key
))
{
// XXX Not a form dialog in this case but distant script
data
.
append
(
key
,
metadata
[
key
]);
}
}
return
jIO
.
util
.
ajax
({
"
type
"
:
post_action
.
method
,
"
url
"
:
post_action
.
href
,
...
...
@@ -278,30 +280,23 @@
withCredentials
:
true
}
});
}).
then
(
function
(
doc
)
{
// XXX Really depend on server response...
var
uri
=
new
URI
(
doc
.
target
.
getResponseHeader
(
"
X-Location
"
));
return
{
"
id
"
:
uri
.
segment
(
2
)};
});
}).
then
(
function
(
event
)
{
final_response
=
{
"
status
"
:
event
.
target
.
status
};
if
(
!
metadata
.
_id
)
{
// XXX Really depend on server response...
var
uri
=
new
URI
(
event
.
target
.
getResponseHeader
(
"
X-Location
"
));
final_response
.
id
=
uri
.
segment
(
2
);
metadata
.
_id
=
final_response
.
id
;
}
}).
then
(
ERP5Storage
.
onView
[
"
default
"
].
put
.
bind
(
this
,
metadata
,
options
)).
then
(
function
()
{
return
final_response
;
});
};
// XXX docstring
ERP5Storage
.
onView
[
"
default
"
].
put
=
function
(
metadata
,
options
)
{
return
getSiteDocument
(
this
.
_url
).
then
(
function
(
site_hal
)
{
return
jIO
.
util
.
ajax
({
"
type
"
:
"
GET
"
,
"
url
"
:
UriTemplate
.
parse
(
site_hal
.
_links
.
traverse
.
href
)
.
expand
({
relative_url
:
metadata
.
_id
,
view
:
options
.
_view
||
"
view
"
}),
"
xhrFields
"
:
{
withCredentials
:
true
}
});
})
.
then
(
function
(
result
)
{
return
getDocumentAndHatoas
.
call
(
this
,
metadata
,
options
).
then
(
function
(
result
)
{
/*jslint forin: true */
result
=
JSON
.
parse
(
result
.
target
.
responseText
);
var
put_action
=
result
.
_embedded
.
_view
.
_actions
.
put
,
...
...
@@ -316,8 +311,6 @@
// Hardcoded my_ ERP5 behaviour
if
(
hasOwnProperty
(
renderer_form
,
"
my_
"
+
key
))
{
data
.
append
(
renderer_form
[
"
my_
"
+
key
].
key
,
metadata
[
key
]);
}
else
{
throw
new
Error
(
"
Can not save property
"
+
key
);
}
}
}
...
...
src/jio.storage/erp5storage.taskmanagerview.js
View file @
0e46db8c
...
...
@@ -5,7 +5,7 @@
*/
/*jslint indent: 2, maxlen: 80, nomen: true */
/*global jIO, UriTemplate, FormData, RSVP, URI, DOMParser, Blob,
console,
/*global jIO, UriTemplate, FormData, RSVP, URI, DOMParser, Blob,
ProgressEvent, define, ERP5Storage */
(
function
(
dependencies
,
module
)
{
...
...
@@ -173,24 +173,6 @@
return
result
;
}
function
getHatoas
(
param
)
{
return
ERP5Storage
.
getSiteDocument
(
this
.
_url
).
then
(
function
(
site_hal
)
{
// XXX need to get modified metadata
return
jIO
.
util
.
ajax
({
"
type
"
:
"
GET
"
,
"
url
"
:
UriTemplate
.
parse
(
site_hal
.
_links
.
traverse
.
href
)
.
expand
({
relative_url
:
param
.
_id
,
view
:
"
taskmanrecord
"
}),
"
xhrFields
"
:
{
withCredentials
:
true
}
});
});
}
ERP5Storage
.
onView
.
taskmanager
=
{};
ERP5Storage
.
onView
.
taskmanager
.
get
=
function
(
param
,
options
)
{
options
.
_view
=
"
taskmanrecord
"
;
...
...
@@ -202,81 +184,15 @@
};
ERP5Storage
.
onView
.
taskmanager
.
post
=
function
(
metadata
,
options
)
{
var
final_response
;
return
ERP5Storage
.
getSiteDocument
(
this
.
_url
).
then
(
function
(
site_hal
)
{
/*jslint forin: true */
var
post_action
=
site_hal
.
_actions
.
add
,
data
=
new
FormData
();
data
.
append
(
"
portal_type
"
,
metadata
.
type
);
// for (key in metadata) {
// if (hasOwnProperty(metadata, key)) {
// // XXX Not a form dialog in this case but distant script
// data.append(key, metadata[key]);
// }
// }
return
jIO
.
util
.
ajax
({
"
type
"
:
post_action
.
method
,
"
url
"
:
post_action
.
href
,
"
data
"
:
data
,
"
xhrFields
"
:
{
withCredentials
:
true
}
});
}).
then
(
function
(
event
)
{
final_response
=
{
"
status
"
:
event
.
target
.
status
};
if
(
!
metadata
.
_id
)
{
// XXX Really depend on server response...
var
uri
=
new
URI
(
event
.
target
.
getResponseHeader
(
"
X-Location
"
));
final_response
.
id
=
uri
.
segment
(
2
);
metadata
.
_id
=
final_response
.
id
;
}
console
.
log
(
metadata
);
}).
then
(
ERP5Storage
.
onView
.
taskmanager
.
put
.
bind
(
this
,
metadata
,
options
)).
then
(
function
()
{
return
final_response
;
});
metadata
=
toERP5Metadata
(
metadata
);
options
.
_view
=
"
taskmanrecord
"
;
return
ERP5Storage
.
onView
[
"
default
"
].
post
.
call
(
this
,
metadata
,
options
);
};
ERP5Storage
.
onView
.
taskmanager
.
put
=
function
(
metadata
,
options
)
{
return
getHatoas
.
call
(
this
,
metadata
,
options
).
then
(
function
(
event
)
{
var
key
,
result
=
JSON
.
parse
(
event
.
target
.
responseText
),
put_action
=
result
.
_embedded
.
_view
.
_actions
.
put
,
renderer_form
=
result
.
_embedded
.
_view
,
data
=
new
FormData
();
data
.
append
(
renderer_form
.
form_id
.
key
,
renderer_form
.
form_id
[
'
default
'
]);
metadata
=
toERP5Metadata
(
metadata
);
/*jslint forin: true */
for
(
key
in
metadata
)
{
if
(
hasOwnProperty
(
metadata
,
key
))
{
if
(
key
!==
"
_id
"
)
{
// Hardcoded my_ ERP5 behaviour
if
(
hasOwnProperty
(
renderer_form
,
"
my_
"
+
key
))
{
data
.
append
(
renderer_form
[
"
my_
"
+
key
].
key
,
metadata
[
key
]
);
}
// else {
// throw new Error("Can not save property " + key);
// }
}
}
}
return
jIO
.
util
.
ajax
({
"
type
"
:
put_action
.
method
,
"
url
"
:
put_action
.
href
,
"
data
"
:
data
,
"
xhrFields
"
:
{
withCredentials
:
true
}
});
});
metadata
=
toERP5Metadata
(
metadata
);
options
.
_view
=
"
taskmanrecord
"
;
return
ERP5Storage
.
onView
[
"
default
"
].
put
.
call
(
this
,
metadata
,
options
);
};
ERP5Storage
.
onView
.
taskmanager
.
allDocs
=
function
(
param
,
options
)
{
...
...
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