Fix missing parts of commit 91ecb5defc backport

This commit is contained in:
Hadi Nategh 2017-09-22 12:33:12 +02:00
parent 295c381037
commit d69fa7a5a7
3 changed files with 76 additions and 1 deletions

View File

@ -161,7 +161,7 @@ class filemanager_ui
'onExecute' => 'javaScript:app.filemanager.createdir'
),
'mail' => array(
'caption' => lang('Mail files'),
'caption' => lang('Share files'),
'icon' => 'filemanager/mail_post_to',
'group' => $group,
'children' => array(
@ -1462,6 +1462,12 @@ class filemanager_ui
$arr['props'] = $props;
break;
case 'sharelink':
$share = Vfs\Sharing::create($selected, Vfs\Sharing::READONLY, basename($selected), array() );
$arr["share_link"] = $link = Vfs\Sharing::share2link($share);
$arr["template"] = Api\Etemplate\Widget\Template::rel2url('/filemanager/templates/default/share_dialog.xet');
break;
// Upload, then link
case 'link':
// First upload

View File

@ -1128,6 +1128,66 @@ app.classes.filemanager = AppJS.extend(
}
},
/**
* create a share-link for the given file or directory
* @param {object} _action egw actions
* @param {object} _senders selected nm row
* @returns {Boolean} returns false if not successful
*/
share_link: function(_action, _senders){
var data = egw.dataGetUIDdata(_senders[0].id)
var path = this.id2path(_senders[0].id);
var request = egw.json('filemanager_ui::ajax_action', ['sharelink', path],
this._share_link_callback, this, true, this
).sendRequest();
return true;
},
/**
* share-link callback
*/
_share_link_callback: function(_data) {
if (_data.msg || _data.share_link) window.egw_refresh(_data.msg, this.appname);
console.log("_data", _data);
var copy_link_to_clipboard = null;
var copy_link_to_clipboard = function(evt){
var $target = jQuery(evt.target);
$target.select();
console.log("share_link click");
try {
successful = document.execCommand('copy');
if (successful)
{
egw.message('Share link copied into clipboard');
return true;
}
}
catch (e) {}
egw.message('Failed to copy the link!');
};
jQuery("body").on("click", "[name=share_link]", copy_link_to_clipboard);
var dialog = et2_createWidget("dialog",{
callback: function( button_id, value){
jQuery("body").off("click", "[name=share_link]", copy_link_to_clipboard);
return true;
},
title: "Share",
template: _data.template,
value: { content:{ "share_link": _data.share_link } }
});
},
/**
* This function copies the selected file/folder entry as webdav link into clipboard
*

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE overlay PUBLIC "-//Stylite AG//eTemplate 2//EN" "http://www.egroupware.org/etemplate2.dtd">
<!-- $Id$ -->
<overlay>
<template id="filemanager.share_dialog" template="" lang="" group="0" version="1.9.003">
<textbox id="share_link" no_lang="1" width="250px"/>
</template>
</overlay>