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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Junming
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 @@
...
@@ -223,26 +223,33 @@
}
}
ERP5Storage
.
getSiteDocument
=
getSiteDocument
;
ERP5Storage
.
getSiteDocument
=
getSiteDocument
;
ERP5Storage
.
onView
=
{};
ERP5Storage
.
onView
[
"
default
"
]
=
{};
// XXX docstring
// XXX docstring
function
onViewDefaultGet
(
param
,
options
)
{
function
getDocumentAndHatoas
(
param
,
options
)
{
return
getSiteDocument
(
this
.
_url
).
var
this_
=
this
;
return
ERP5Storage
.
getSiteDocument
(
this
.
_url
).
then
(
function
(
site_hal
)
{
then
(
function
(
site_hal
)
{
// XXX need to get modified metadata
return
jIO
.
util
.
ajax
({
return
jIO
.
util
.
ajax
({
"
type
"
:
"
GET
"
,
"
type
"
:
"
GET
"
,
"
url
"
:
UriTemplate
.
parse
(
site_hal
.
_links
.
traverse
.
href
)
"
url
"
:
UriTemplate
.
parse
(
site_hal
.
_links
.
traverse
.
href
)
.
expand
({
.
expand
({
relative_url
:
param
.
_id
,
relative_url
:
param
.
_id
,
view
:
options
.
_view
||
"
view
"
view
:
options
.
_view
||
this_
.
_default_view
||
"
view
"
}),
}),
"
xhrFields
"
:
{
"
xhrFields
"
:
{
withCredentials
:
true
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
);
var
result
=
JSON
.
parse
(
response
.
target
.
responseText
);
result
.
_id
=
param
.
_id
;
result
.
_id
=
param
.
_id
;
result
.
portal_type
=
result
.
_links
.
type
.
name
;
result
.
portal_type
=
result
.
_links
.
type
.
name
;
...
@@ -252,24 +259,19 @@
...
@@ -252,24 +259,19 @@
new
jIO
.
Metadata
(
result
).
format
();
new
jIO
.
Metadata
(
result
).
format
();
return
{
"
data
"
:
result
};
return
{
"
data
"
:
result
};
});
});
}
};
ERP5Storage
.
onView
[
"
default
"
].
get
=
onViewDefaultGet
;
// XXX docstring
// XXX docstring
ERP5Storage
.
onView
[
"
default
"
].
post
=
function
(
metadata
,
options
)
{
ERP5Storage
.
onView
[
"
default
"
].
post
=
function
(
metadata
,
options
)
{
var
final_response
;
return
getSiteDocument
(
this
.
_url
)
return
getSiteDocument
(
this
.
_url
)
.
then
(
function
(
site_hal
)
{
.
then
(
function
(
site_hal
)
{
/*jslint forin: true */
/*jslint forin: true */
var
post_action
=
site_hal
.
_actions
.
add
,
var
post_action
=
site_hal
.
_actions
.
add
,
data
=
new
FormData
(),
data
=
new
FormData
();
key
;
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
({
return
jIO
.
util
.
ajax
({
"
type
"
:
post_action
.
method
,
"
type
"
:
post_action
.
method
,
"
url
"
:
post_action
.
href
,
"
url
"
:
post_action
.
href
,
...
@@ -278,30 +280,23 @@
...
@@ -278,30 +280,23 @@
withCredentials
:
true
withCredentials
:
true
}
}
});
});
}).
then
(
function
(
doc
)
{
}).
then
(
function
(
event
)
{
// XXX Really depend on server response...
final_response
=
{
"
status
"
:
event
.
target
.
status
};
var
uri
=
new
URI
(
doc
.
target
.
getResponseHeader
(
"
X-Location
"
));
if
(
!
metadata
.
_id
)
{
return
{
"
id
"
:
uri
.
segment
(
2
)};
// 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
// XXX docstring
ERP5Storage
.
onView
[
"
default
"
].
put
=
function
(
metadata
,
options
)
{
ERP5Storage
.
onView
[
"
default
"
].
put
=
function
(
metadata
,
options
)
{
return
getSiteDocument
(
this
.
_url
).
return
getDocumentAndHatoas
.
call
(
this
,
metadata
,
options
).
then
(
function
(
site_hal
)
{
then
(
function
(
result
)
{
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
)
{
/*jslint forin: true */
/*jslint forin: true */
result
=
JSON
.
parse
(
result
.
target
.
responseText
);
result
=
JSON
.
parse
(
result
.
target
.
responseText
);
var
put_action
=
result
.
_embedded
.
_view
.
_actions
.
put
,
var
put_action
=
result
.
_embedded
.
_view
.
_actions
.
put
,
...
@@ -316,8 +311,6 @@
...
@@ -316,8 +311,6 @@
// Hardcoded my_ ERP5 behaviour
// Hardcoded my_ ERP5 behaviour
if
(
hasOwnProperty
(
renderer_form
,
"
my_
"
+
key
))
{
if
(
hasOwnProperty
(
renderer_form
,
"
my_
"
+
key
))
{
data
.
append
(
renderer_form
[
"
my_
"
+
key
].
key
,
metadata
[
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 @@
...
@@ -5,7 +5,7 @@
*/
*/
/*jslint indent: 2, maxlen: 80, nomen: true */
/*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 */
ProgressEvent, define, ERP5Storage */
(
function
(
dependencies
,
module
)
{
(
function
(
dependencies
,
module
)
{
...
@@ -173,24 +173,6 @@
...
@@ -173,24 +173,6 @@
return
result
;
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
=
{};
ERP5Storage
.
onView
.
taskmanager
.
get
=
function
(
param
,
options
)
{
ERP5Storage
.
onView
.
taskmanager
.
get
=
function
(
param
,
options
)
{
options
.
_view
=
"
taskmanrecord
"
;
options
.
_view
=
"
taskmanrecord
"
;
...
@@ -202,81 +184,15 @@
...
@@ -202,81 +184,15 @@
};
};
ERP5Storage
.
onView
.
taskmanager
.
post
=
function
(
metadata
,
options
)
{
ERP5Storage
.
onView
.
taskmanager
.
post
=
function
(
metadata
,
options
)
{
var
final_response
;
metadata
=
toERP5Metadata
(
metadata
);
return
ERP5Storage
.
getSiteDocument
(
this
.
_url
).
options
.
_view
=
"
taskmanrecord
"
;
then
(
function
(
site_hal
)
{
return
ERP5Storage
.
onView
[
"
default
"
].
post
.
call
(
this
,
metadata
,
options
);
/*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
;
});
};
};
ERP5Storage
.
onView
.
taskmanager
.
put
=
function
(
metadata
,
options
)
{
ERP5Storage
.
onView
.
taskmanager
.
put
=
function
(
metadata
,
options
)
{
return
getHatoas
.
call
(
this
,
metadata
,
options
).
metadata
=
toERP5Metadata
(
metadata
);
then
(
function
(
event
)
{
options
.
_view
=
"
taskmanrecord
"
;
var
key
,
result
=
JSON
.
parse
(
event
.
target
.
responseText
),
return
ERP5Storage
.
onView
[
"
default
"
].
put
.
call
(
this
,
metadata
,
options
);
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
}
});
});
};
};
ERP5Storage
.
onView
.
taskmanager
.
allDocs
=
function
(
param
,
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