From 6034702a7cf5b9ec22d5d0fbb0cbf94c8ebc7ce0 Mon Sep 17 00:00:00 2001 From: nathan Date: Mon, 17 Oct 2022 14:47:34 -0600 Subject: [PATCH] Et2Link: Fix editable files were downloaded instead of opened in Collabora --- api/js/jsapi/egw_links.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/api/js/jsapi/egw_links.js b/api/js/jsapi/egw_links.js index b9415da63a..6026d7083b 100644 --- a/api/js/jsapi/egw_links.js +++ b/api/js/jsapi/egw_links.js @@ -169,6 +169,15 @@ egw.extend('links', egw.MODULE_GLOBAL, function() let data = {}; if (mime_info) { + if (this.isEditable(_type)) + { + data = { + 'menuaction': 'collabora.EGroupware\\collabora\\Ui.editor', + 'path': path, + 'cd': 'no' // needed to not reload framework in sharing + }; + return data; + } for(let attr in mime_info) { switch(attr) @@ -517,6 +526,25 @@ egw.extend('links', egw.MODULE_GLOBAL, function() select.dropdown.trigger.style.height = '0px'; }); }); + }, + + /** + * Check if a mimetype is editable + * + * Check mimetype & user preference + */ + isEditable: function (mime) + { + if (!mime) + { + return false; + } + let fe = egw_get_file_editor_prefered_mimes(mime); + if (!fe || !fe.mime || fe && fe.mime && !fe.mime[mime]) + { + return false; + } + return ['edit'].indexOf(fe.mime[mime].name) !== -1; } } }); \ No newline at end of file