Commit cfc93a86 authored by Gabriel Monnerat's avatar Gabriel Monnerat

erp5_officejs_support_request_ui: Simplify code to render the expected action...

erp5_officejs_support_request_ui: Simplify code to render the expected action to preview any attachement document
parent bb695c0b
......@@ -24,30 +24,22 @@
/////////////////////////////////////////////////////////////////
// declared methods
/////////////////////////////////////////////////////////////////
.declareMethod('getImageUrl', function (raw_url) {
var gadget = this;
return gadget.jio_getAttachment(raw_url, "links")
.push(function (links) {
var full_size_url = links._links.view[1].href;
return gadget.getUrlFor({
command: 'display',
options: {
jio_key: "image_module",
view: full_size_url
}
});
});
})
.declareMethod('getDocumentUrl', function (raw_url) {
var gadget = this;
return gadget.jio_getAttachment(raw_url, "links")
.push(function (links) {
var full_size_url = links._links.view[4].href;
var page = "preview",
has_preview = links._links.view.filter(function (i) {
return i.name === "preview";
}).length > 0;
if (!has_preview) {
page = "html_view";
}
return gadget.getUrlFor({
command: 'display',
command: 'display_erp5_action_with_history',
options: {
jio_key: "document_module",
view: full_size_url
jio_key: raw_url,
page: page
}
});
});
......@@ -175,14 +167,6 @@
if (post.attachment_link === null) {
return post;
}
if (post.attachment_link.indexOf("image_module") !== -1) {
return gadget.getImageUrl(post.attachment_link).push(
function (attachment_link) {
post.attachment_link = attachment_link;
return post;
}
);
}
return gadget.getDocumentUrl(post.attachment_link).push(
function (attachment_link) {
post.attachment_link = attachment_link;
......
......@@ -224,7 +224,7 @@
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
<value> <string>ERP5TypeTestCase</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
......@@ -238,7 +238,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>962.47417.29437.25668</string> </value>
<value> <string>985.17756.63769.9284</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -256,8 +256,8 @@
</tuple>
<state>
<tuple>
<float>1542273914.05</float>
<string>GMT+9</string>
<float>1594840751.27</float>
<string>UTC</string>
</tuple>
</state>
</object>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment