diff --git a/api/js/etemplate/Et2Link/Et2LinkList.ts b/api/js/etemplate/Et2Link/Et2LinkList.ts index f53e87acbb..0d16d1a76a 100644 --- a/api/js/etemplate/Et2Link/Et2LinkList.ts +++ b/api/js/etemplate/Et2Link/Et2LinkList.ts @@ -207,14 +207,58 @@ export class Et2LinkList extends Et2LinkString protected _rowTemplate(link) : TemplateResult { return html` -
`; } + /** + * Handle dragstart event for dragging out a file + * + * @param _data + * @param _ev + * @protected + */ + protected _handleDragStart (_data, _ev) + { + // // Unfortunately, dragging files is currently only supported by Chrome + if(navigator && navigator.userAgent.indexOf('Chrome') >= 0) { + + if (_ev.dataTransfer == null) { + return; + } + if (_data && _data.type && _data.download_url) { + _ev.dataTransfer.dropEffect = "copy"; + _ev.dataTransfer.effectAllowed = "copy"; + + let url = _data.download_url; + + // NEED an absolute URL + if (url[0] == '/') url = egw.link(url); + // egw.link adds the webserver, but that might not be an absolute URL - try again + if (url[0] == '/') url = window.location.origin + url; + + // Unfortunately, dragging files is currently only supported by Chrome + if (navigator && navigator.userAgent.indexOf('Chrome')) { + _ev.dataTransfer.setData("DownloadURL", _data.type + ':' + _data.title + ':' + url); + } + + // Include URL as a fallback + _ev.dataTransfer.setData("text/uri-list", url); + } + + if (_ev.dataTransfer.types.length == 0) { + // No file data? Abort: drag does nothing + _ev.preventDefault(); + return; + } + } + } + /** * Handle show/hide delete button * @param _ev