Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
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
Boris Kocherov
erp5
Commits
b039bec7
Commit
b039bec7
authored
Oct 25, 2016
by
Boris Kocherov
Committed by
Boris Kocherov
Nov 21, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_officejs: change jio_getAttachment and jio_putAttachment for compatability with ooffice
parent
024db4fb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
79 additions
and
8 deletions
+79
-8
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_jio_js.js
...athTemplateItem/web_page_module/gadget_officejs_jio_js.js
+76
-5
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_jio_js.xml
...thTemplateItem/web_page_module/gadget_officejs_jio_js.xml
+3
-3
No files found.
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_jio_js.js
View file @
b039bec7
/*global window, rJS, jIO, FormData, UriTemplate */
/*global window, rJS, jIO, FormData, UriTemplate
, Rusha
*/
/*jslint indent: 2, maxerr: 3 */
(
function
(
window
,
rJS
,
jIO
)
{
"
use strict
"
;
var
rusha
=
new
Rusha
();
// jIO call wrapper for redirection to authentication page if needed
function
wrapJioCall
(
gadget
,
method_name
,
argument_list
)
{
var
storage
=
gadget
.
state_parameter_dict
.
jio_storage
;
...
...
@@ -86,11 +88,80 @@
.
declareMethod
(
'
remove
'
,
function
()
{
return
wrapJioCall
(
this
,
'
remove
'
,
arguments
);
})
.
declareMethod
(
'
getAttachment
'
,
function
()
{
return
wrapJioCall
(
this
,
'
gettAttachment
'
,
arguments
);
.
declareMethod
(
'
getAttachment
'
,
function
(
docId
,
atId
,
opt
)
{
return
wrapJioCall
(
this
,
'
getAttachment
'
,
[
docId
,
atId
])
.
push
(
function
(
blob
)
{
var
data
;
if
(
opt
===
"
asBlobURL
"
)
{
data
=
URL
.
createObjectURL
(
blob
);
}
else
if
(
opt
===
"
asDataURL
"
)
{
data
=
new
RSVP
.
Promise
(
function
(
resolve
,
reject
)
{
var
reader
=
new
FileReader
();
reader
.
addEventListener
(
'
load
'
,
function
()
{
resolve
(
reader
.
result
);
});
reader
.
readAsDataURL
(
blob
);
});
}
else
{
data
=
blob
;
}
return
data
;
});
})
.
declareMethod
(
'
putAttachment
'
,
function
()
{
return
wrapJioCall
(
this
,
'
putAttachment
'
,
arguments
);
.
declareMethod
(
'
putAttachment
'
,
function
(
docId
,
atId
,
data
)
{
var
start
=
data
.
slice
(
0
,
5
),
gadget
=
this
,
queue
=
new
RSVP
.
Queue
();
if
(
start
===
"
data:
"
)
{
queue
.
push
(
function
()
{
var
byteString
=
atob
(
data
.
split
(
'
,
'
)[
1
]);
// separate out the mime component
var
mimeString
=
data
.
split
(
'
,
'
)[
0
].
split
(
'
:
'
)[
1
].
split
(
'
;
'
)[
0
];
// write the bytes of the string to an ArrayBuffer
var
ab
=
new
ArrayBuffer
(
byteString
.
length
);
var
ia
=
new
Uint8Array
(
ab
);
for
(
var
i
=
0
;
i
<
byteString
.
length
;
i
++
)
{
ia
[
i
]
=
byteString
.
charCodeAt
(
i
);
}
return
[
ab
,
mimeString
];
});
}
else
if
(
start
===
"
blob:
"
)
{
queue
.
push
(
function
()
{
return
new
Promise
(
function
(
resolve
,
reject
)
{
var
xhr
=
new
XMLHttpRequest
();
xhr
.
open
(
'
GET
'
,
data
,
true
);
xhr
.
responseType
=
'
arraybuffer
'
;
xhr
.
onload
=
function
(
e
)
{
if
(
this
.
status
==
200
)
{
resolve
([
this
.
response
,
this
.
getResponseHeader
(
"
Content-Type
"
)]);
}
};
xhr
.
send
();
});
});
}
return
queue
.
push
(
function
(
result
)
{
var
ab
=
result
[
0
],
mimeString
=
result
[
1
];
if
(
!
atId
)
{
atId
=
mimeString
+
'
,
'
+
rusha
.
digestFromArrayBuffer
(
ab
);
}
return
wrapJioCall
(
gadget
,
'
allAttachments
'
,
[
docId
])
.
push
(
function
(
list
)
{
var
blob
;
if
(
list
.
hasOwnProperty
(
atId
))
{
return
{};
}
else
{
blob
=
new
Blob
([
ab
],
{
type
:
mimeString
});
return
wrapJioCall
(
gadget
,
'
putAttachment
'
,
[
docId
,
atId
,
blob
]);
}
});
})
.
push
(
function
()
{
return
atId
;
});
})
.
declareMethod
(
'
removeAttachment
'
,
function
()
{
return
wrapJioCall
(
this
,
'
removeAttachment
'
,
arguments
);
...
...
bt5/erp5_officejs/PathTemplateItem/web_page_module/gadget_officejs_jio_js.xml
View file @
b039bec7
...
...
@@ -216,7 +216,7 @@
</item>
<item>
<key>
<string>
actor
</string>
</key>
<value>
<string>
cedric.le.ninivin
</string>
</value>
<value>
<string>
zope
</string>
</value>
</item>
<item>
<key>
<string>
comment
</string>
</key>
...
...
@@ -230,7 +230,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
9
49.59977.1025.50722
</string>
</value>
<value>
<string>
9
54.52194.32966.50585
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -248,7 +248,7 @@
</tuple>
<state>
<tuple>
<float>
14
58319358.64
</float>
<float>
14
77254062.06
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
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