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 @@ ...@@ -24,30 +24,22 @@
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// declared methods // 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) { .declareMethod('getDocumentUrl', function (raw_url) {
var gadget = this; var gadget = this;
return gadget.jio_getAttachment(raw_url, "links") return gadget.jio_getAttachment(raw_url, "links")
.push(function (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({ return gadget.getUrlFor({
command: 'display', command: 'display_erp5_action_with_history',
options: { options: {
jio_key: "document_module", jio_key: raw_url,
view: full_size_url page: page
} }
}); });
}); });
...@@ -175,14 +167,6 @@ ...@@ -175,14 +167,6 @@
if (post.attachment_link === null) { if (post.attachment_link === null) {
return post; 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( return gadget.getDocumentUrl(post.attachment_link).push(
function (attachment_link) { function (attachment_link) {
post.attachment_link = attachment_link; post.attachment_link = attachment_link;
...@@ -275,4 +259,4 @@ ...@@ -275,4 +259,4 @@
.onEvent('submit', function () { .onEvent('submit', function () {
return this.submitPostComment(); return this.submitPostComment();
}); });
}(window, rJS, RSVP, calculatePageTitle, moment, Handlebars)); }(window, rJS, RSVP, calculatePageTitle, moment, Handlebars));
\ No newline at end of file
...@@ -224,7 +224,7 @@ ...@@ -224,7 +224,7 @@
</item> </item>
<item> <item>
<key> <string>actor</string> </key> <key> <string>actor</string> </key>
<value> <string>zope</string> </value> <value> <string>ERP5TypeTestCase</string> </value>
</item> </item>
<item> <item>
<key> <string>comment</string> </key> <key> <string>comment</string> </key>
...@@ -238,7 +238,7 @@ ...@@ -238,7 +238,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>962.47417.29437.25668</string> </value> <value> <string>985.17756.63769.9284</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -256,8 +256,8 @@ ...@@ -256,8 +256,8 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1542273914.05</float> <float>1594840751.27</float>
<string>GMT+9</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
</object> </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