* added share-link feature to filemanager context menu

This commit is contained in:
W.A. Mozart
2017-08-01 15:25:33 +02:00
parent 1159df66cf
commit 91ecb5defc
3 changed files with 91 additions and 2 deletions

View File

@@ -299,6 +299,10 @@ app.classes.filemanager = AppJS.extend(
}
},
/**
* Finish callback for file a file dialog, to get the overwrite / rename prompt
*
@@ -1139,6 +1143,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
*