mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-22 16:03:47 +01:00
Add Writable Share Link action into Share context menu
This commit is contained in:
parent
873a2a93d8
commit
6c093e0aac
@ -181,8 +181,16 @@ class filemanager_ui
|
|||||||
'icon' => 'filemanager/mail_post_to',
|
'icon' => 'filemanager/mail_post_to',
|
||||||
'group' => $group,
|
'group' => $group,
|
||||||
'children' => array(
|
'children' => array(
|
||||||
'sharelink' => array(
|
'shareReadonlyLink' => array(
|
||||||
'caption' => lang('Share link'),
|
'caption' => lang('Readonly Share link'),
|
||||||
|
'group' => 1,
|
||||||
|
'icon' => 'share',
|
||||||
|
'allowOnMultiple' => false,
|
||||||
|
'order' => 11,
|
||||||
|
'onExecute' => 'javaScript:app.filemanager.share_link'
|
||||||
|
),
|
||||||
|
'shareWritableLink' => array(
|
||||||
|
'caption' => lang('Writable Share link'),
|
||||||
'group' => 1,
|
'group' => 1,
|
||||||
'icon' => 'share',
|
'icon' => 'share',
|
||||||
'allowOnMultiple' => false,
|
'allowOnMultiple' => false,
|
||||||
@ -1542,9 +1550,27 @@ class filemanager_ui
|
|||||||
$arr['path'] = $dir;
|
$arr['path'] = $dir;
|
||||||
$arr['props'] = $props;
|
$arr['props'] = $props;
|
||||||
break;
|
break;
|
||||||
|
case 'shareWritableLink':
|
||||||
case 'sharelink':
|
case 'shareReadonlyLink':
|
||||||
$share = Vfs\Sharing::create($selected, Vfs\Sharing::READONLY, basename($selected), array() );
|
if ($action === 'shareWritableLink')
|
||||||
|
{
|
||||||
|
$share = Vfs\Sharing::create(
|
||||||
|
$selected,
|
||||||
|
Vfs\Sharing::WRITABLE,
|
||||||
|
basename($selected),
|
||||||
|
array(),
|
||||||
|
array('share_writable' => true)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$share = Vfs\Sharing::create(
|
||||||
|
$selected,
|
||||||
|
Vfs\Sharing::READONLY,
|
||||||
|
basename($selected),
|
||||||
|
array()
|
||||||
|
);
|
||||||
|
}
|
||||||
$arr["share_link"] = $link = Vfs\Sharing::share2link($share);
|
$arr["share_link"] = $link = Vfs\Sharing::share2link($share);
|
||||||
$arr["template"] = Api\Etemplate\Widget\Template::rel2url('/filemanager/templates/default/share_dialog.xet');
|
$arr["template"] = Api\Etemplate\Widget\Template::rel2url('/filemanager/templates/default/share_dialog.xet');
|
||||||
break;
|
break;
|
||||||
|
@ -1152,26 +1152,21 @@ app.classes.filemanager = AppJS.extend(
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* create a share-link for the given file or directory
|
* create a share-link for the given file or directory
|
||||||
* @param {object} _action egw actions
|
* @param {object} _action egw actions
|
||||||
* @param {object} _senders selected nm row
|
* @param {object} _senders selected nm row
|
||||||
* @returns {Boolean} returns false if not successful
|
* @returns {Boolean} returns false if not successful
|
||||||
*/
|
*/
|
||||||
|
|
||||||
share_link: function(_action, _senders){
|
share_link: function(_action, _senders){
|
||||||
var data = egw.dataGetUIDdata(_senders[0].id)
|
|
||||||
var path = this.id2path(_senders[0].id);
|
var path = this.id2path(_senders[0].id);
|
||||||
|
egw.json('filemanager_ui::ajax_action', [_action.id, path],
|
||||||
var request = egw.json('filemanager_ui::ajax_action', ['sharelink', path],
|
this._share_link_callback, this, true, this).sendRequest();
|
||||||
this._share_link_callback, this, true, this
|
|
||||||
).sendRequest();
|
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* share-link callback
|
* Share-link callback
|
||||||
|
* @param {object} _data
|
||||||
*/
|
*/
|
||||||
|
|
||||||
_share_link_callback: function(_data) {
|
_share_link_callback: function(_data) {
|
||||||
if (_data.msg || _data.share_link) window.egw_refresh(_data.msg, this.appname);
|
if (_data.msg || _data.share_link) window.egw_refresh(_data.msg, this.appname);
|
||||||
console.log("_data", _data);
|
console.log("_data", _data);
|
||||||
@ -1181,33 +1176,28 @@ app.classes.filemanager = AppJS.extend(
|
|||||||
var copy_link_to_clipboard = function(evt){
|
var copy_link_to_clipboard = function(evt){
|
||||||
var $target = jQuery(evt.target);
|
var $target = jQuery(evt.target);
|
||||||
$target.select();
|
$target.select();
|
||||||
|
|
||||||
console.log("share_link click");
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
successful = document.execCommand('copy');
|
var successful = document.execCommand('copy');
|
||||||
if (successful)
|
if (successful)
|
||||||
{
|
{
|
||||||
egw.message('Share link copied into clipboard');
|
egw.message('Share link copied into clipboard');
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (e) {}
|
catch (e) {}
|
||||||
egw.message('Failed to copy the link!');
|
egw.message('Failed to copy the link!');
|
||||||
|
|
||||||
};
|
};
|
||||||
jQuery("body").on("click", "[name=share_link]", copy_link_to_clipboard);
|
jQuery("body").on("click", "[name=share_link]", copy_link_to_clipboard);
|
||||||
|
et2_createWidget("dialog", {
|
||||||
var dialog = et2_createWidget("dialog",{
|
callback: function( button_id, value) {
|
||||||
callback: function( button_id, value){
|
jQuery("body").off("click", "[name=share_link]", copy_link_to_clipboard);
|
||||||
jQuery("body").off("click", "[name=share_link]", copy_link_to_clipboard);
|
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
title: "Share",
|
title: egw.lang("%1 Share Link", _data.action ==='shareWritableLink'? "Writable": "Readonly"),
|
||||||
template: _data.template,
|
template: _data.template,
|
||||||
value: { content:{ "share_link": _data.share_link } }
|
width: 450,
|
||||||
});
|
value: {content:{ "share_link": _data.share_link }}
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2,8 +2,7 @@
|
|||||||
<!DOCTYPE overlay PUBLIC "-//Stylite AG//eTemplate 2//EN" "http://www.egroupware.org/etemplate2.dtd">
|
<!DOCTYPE overlay PUBLIC "-//Stylite AG//eTemplate 2//EN" "http://www.egroupware.org/etemplate2.dtd">
|
||||||
<!-- $Id$ -->
|
<!-- $Id$ -->
|
||||||
<overlay>
|
<overlay>
|
||||||
<template id="filemanager.share_dialog" template="" lang="" group="0" version="1.9.003">
|
<template id="filemanager.share_dialog" template="" lang="" group="0" version="1.9.003">
|
||||||
<textbox id="share_link" no_lang="1" width="250px"/>
|
<textbox id="share_link" no_lang="1" class="et2_fullWidth"/>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
</overlay>
|
</overlay>
|
||||||
|
Loading…
Reference in New Issue
Block a user