mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-27 09:09:04 +01:00
Add new preference to control default action of editing a document (open with:Collabora|CollabEditor|Download)
This commit is contained in:
parent
8d94fc699d
commit
a9a303a6ff
@ -1525,7 +1525,7 @@ var et2_link_string = (function(){ "use strict"; return expose(et2_valueWidget.e
|
|||||||
.appendTo(this.list)
|
.appendTo(this.list)
|
||||||
.addClass("et2_link loading")
|
.addClass("et2_link loading")
|
||||||
.click( function(e){
|
.click( function(e){
|
||||||
var fe = egw_get_file_editor_prefered_mimes();
|
var fe = egw_get_file_editor_prefered_mimes(_link_data.type);
|
||||||
if (self.options.expose_view && typeof _link_data.type !='undefined'
|
if (self.options.expose_view && typeof _link_data.type !='undefined'
|
||||||
&& _link_data.type.match(self.mime_regexp,'ig'))
|
&& _link_data.type.match(self.mime_regexp,'ig'))
|
||||||
{
|
{
|
||||||
@ -1916,7 +1916,7 @@ var et2_link_list = (function(){ "use strict"; return et2_link_string.extend(
|
|||||||
if (_link_data && (typeof _link_data.download_url != 'undefined' || _link_data.app !='egw-data'))
|
if (_link_data && (typeof _link_data.download_url != 'undefined' || _link_data.app !='egw-data'))
|
||||||
{
|
{
|
||||||
$td.click( function(){
|
$td.click( function(){
|
||||||
var fe_mime = egw_get_file_editor_prefered_mimes();
|
var fe_mime = egw_get_file_editor_prefered_mimes(_link_data.type);
|
||||||
// Check if the link entry is mime with media type, in order to open it in expose view
|
// Check if the link entry is mime with media type, in order to open it in expose view
|
||||||
if (typeof _link_data.type != 'undefined' &&
|
if (typeof _link_data.type != 'undefined' &&
|
||||||
(_link_data.type.match(self.mime_regexp,'ig') || (fe_mime && fe_mime.mime[_link_data.type])))
|
(_link_data.type.match(self.mime_regexp,'ig') || (fe_mime && fe_mime.mime[_link_data.type])))
|
||||||
|
@ -758,10 +758,20 @@ function addOption(id,label,value,do_onchange)
|
|||||||
if (selectBox.onchange && do_onchange) selectBox.onchange();
|
if (selectBox.onchange && do_onchange) selectBox.onchange();
|
||||||
}
|
}
|
||||||
|
|
||||||
function egw_get_file_editor_prefered_mimes(_data, _params)
|
/**
|
||||||
|
*
|
||||||
|
* @param {string} _mime current mime type
|
||||||
|
* @returns {object|null} returns object of filemanager editor hook
|
||||||
|
*/
|
||||||
|
function egw_get_file_editor_prefered_mimes(_mime)
|
||||||
{
|
{
|
||||||
var fe = jQuery.extend(true, {},egw.link_get_registry('filemanager-editor'));
|
var fe = jQuery.extend(true, {},egw.link_get_registry('filemanager-editor'));
|
||||||
var ex_mimes = egw.preference('collab_excluded_mimes', 'filemanager');
|
var ex_mimes = egw.preference('collab_excluded_mimes', 'filemanager');
|
||||||
|
var dblclick_action = egw.preference('document_doubleclick_action', 'filemanager');
|
||||||
|
if (dblclick_action == 'download' && typeof _mime === 'string')
|
||||||
|
{
|
||||||
|
ex_mimes = !ex_mimes ? _mime : ex_mimes+','+_mime;
|
||||||
|
}
|
||||||
if (fe && fe.mime && ex_mimes)
|
if (fe && fe.mime && ex_mimes)
|
||||||
{
|
{
|
||||||
ex_mimes = ex_mimes.split(',');
|
ex_mimes = ex_mimes.split(',');
|
||||||
@ -818,3 +828,6 @@ jQuery(function(){
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
jQuery(document).ready(function() {
|
||||||
|
jQuery('head').append('<link rel="manifest" href="/egroupware/pixelegg/manifest.json">');
|
||||||
|
})
|
@ -283,6 +283,18 @@ class filemanager_hooks
|
|||||||
'name' => 'merge_open_handler',
|
'name' => 'merge_open_handler',
|
||||||
'values' => array ('download' => lang('download'), 'collabora' => 'Collabora'),
|
'values' => array ('download' => lang('download'), 'collabora' => 'Collabora'),
|
||||||
'default' => 'collabora',
|
'default' => 'collabora',
|
||||||
|
),
|
||||||
|
'document_doubleclick_action' => array (
|
||||||
|
'type' => 'select',
|
||||||
|
'label' => lang('Default action on double-click'),
|
||||||
|
'help' => lang('Defines how to handle double click action on a document file.'),
|
||||||
|
'name' => 'document_doubleclick_action',
|
||||||
|
'values' => array (
|
||||||
|
'collabora' => lang('open documents with Collabora, if permissions are given'),
|
||||||
|
'download' => lang('download documents'),
|
||||||
|
'collabeditor' => lang('open odt documents with CollabEditor')
|
||||||
|
),
|
||||||
|
'default' => 'collabora',
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -333,11 +345,11 @@ class filemanager_hooks
|
|||||||
foreach ($implemented as $app)
|
foreach ($implemented as $app)
|
||||||
{
|
{
|
||||||
if (($access = \EGroupware\Api\Vfs\Links\StreamWrapper::check_app_rights($app)) &&
|
if (($access = \EGroupware\Api\Vfs\Links\StreamWrapper::check_app_rights($app)) &&
|
||||||
($l = Api\Hooks::process('filemanager-editor-link',$app, true)) && $l[$app])
|
($l = Api\Hooks::process('filemanager-editor-link',$app, true)) && $l[$app]
|
||||||
|
&& $GLOBALS['egw_info']['user']['preferences']['filemanager']['document_doubleclick_action'] == $app)
|
||||||
{
|
{
|
||||||
$link = $l[$app];
|
$link = $l[$app];
|
||||||
}
|
}
|
||||||
if ($app == 'collabora' && $access) break; // collabora is default
|
|
||||||
}
|
}
|
||||||
return $link;
|
return $link;
|
||||||
}
|
}
|
||||||
|
@ -785,6 +785,7 @@ app.classes.filemanager = AppJS.extend(
|
|||||||
{
|
{
|
||||||
var data = egw.dataGetUIDdata(_senders[0].id);
|
var data = egw.dataGetUIDdata(_senders[0].id);
|
||||||
var path = this.id2path(_senders[0].id);
|
var path = this.id2path(_senders[0].id);
|
||||||
|
this.et2 = this.et2 ? this.et2 : etemplate2.getById('filemanager-index').widgetContainer;
|
||||||
var mime = this.et2._inst.widgetContainer.getWidgetById('$row');
|
var mime = this.et2._inst.widgetContainer.getWidgetById('$row');
|
||||||
// try to get mime widget DOM node out of the row DOM
|
// try to get mime widget DOM node out of the row DOM
|
||||||
var mime_dom = jQuery(_senders[0].iface.getDOMNode()).find("span#filemanager-index_\\$row");
|
var mime_dom = jQuery(_senders[0].iface.getDOMNode()).find("span#filemanager-index_\\$row");
|
||||||
@ -809,8 +810,13 @@ app.classes.filemanager = AppJS.extend(
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
// Build ViewerJS url
|
// Build ViewerJS url
|
||||||
if (data.data.mime.match(/application\/vnd\.oasis\.opendocument/)) var url = '/ViewerJS/#..' + data.data.download_url;
|
if (data.data.mime.match(/application\/vnd\.oasis\.opendocument/) &&
|
||||||
|
egw.preference('document_doubleclick_action', 'filemanager') == 'collabeditor')
|
||||||
|
{
|
||||||
|
var url = '/ViewerJS/#..' + data.data.download_url;
|
||||||
|
}
|
||||||
|
|
||||||
egw.open({path: path, type: data.data.mime, download_url: url}, 'file','view',null,'_browser');
|
egw.open({path: path, type: data.data.mime, download_url: url}, 'file','view',null,'_browser');
|
||||||
}
|
}
|
||||||
@ -1293,7 +1299,7 @@ app.classes.filemanager = AppJS.extend(
|
|||||||
if (_senders.length>1) return false;
|
if (_senders.length>1) return false;
|
||||||
var data = egw.dataGetUIDdata(_senders[0].id),
|
var data = egw.dataGetUIDdata(_senders[0].id),
|
||||||
mime = this.et2._inst.widgetContainer.getWidgetById('$row');
|
mime = this.et2._inst.widgetContainer.getWidgetById('$row');
|
||||||
var fe = egw_get_file_editor_prefered_mimes();
|
var fe = egw_get_file_editor_prefered_mimes(data.data.mime);
|
||||||
if (fe && fe.mime && !fe.mime[data.data.mime]) return false;
|
if (fe && fe.mime && !fe.mime[data.data.mime]) return false;
|
||||||
return data.data.mime.match(mime.mime_odf_regex)?true:false;
|
return data.data.mime.match(mime.mime_odf_regex)?true:false;
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user