From ff19062265c4ebe3f5a84f7848c7f2a3493b6826 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Mon, 2 Jul 2012 23:03:27 +0000 Subject: [PATCH] Use filemanager popup to allow linking to already existing files --- .../inc/class.etemplate_widget_link.inc.php | 3 +++ etemplate/js/et2_widget_link.js | 24 +++++++++++++++++-- etemplate/templates/default/etemplate2.css | 1 + 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/etemplate/inc/class.etemplate_widget_link.inc.php b/etemplate/inc/class.etemplate_widget_link.inc.php index 9946bcb1a8..f87eaf6f45 100644 --- a/etemplate/inc/class.etemplate_widget_link.inc.php +++ b/etemplate/inc/class.etemplate_widget_link.inc.php @@ -230,6 +230,9 @@ class etemplate_widget_link extends etemplate_widget $link = egw_vfs::concat($app_path,egw_vfs::basename($target)); egw_vfs::symlink($target,$link); } + + // Return js to refresh opener and close popup + return 'window.close();'; } public function ajax_delete($value) { diff --git a/etemplate/js/et2_widget_link.js b/etemplate/js/et2_widget_link.js index 02ad704cba..64e995abb0 100644 --- a/etemplate/js/et2_widget_link.js +++ b/etemplate/js/et2_widget_link.js @@ -129,6 +129,7 @@ var et2_link_to = et2_inputWidget.extend({ et2_link_entry.prototype.set_blur(this.egw().lang("Comment..."),this.comment); // Filemanager link popup + var self = this; this.filemanager_button = $j(document.createElement("img")) .attr("src", this.egw().image("filemanager/navbar")) .addClass("et2_button et2_button_icon") @@ -136,11 +137,30 @@ var et2_link_to = et2_inputWidget.extend({ .click(this, function(e) { // Open the filemanager select in a popup var values = e.data.options.value; - e.data.egw().open_link( + var popup = e.data.egw().open_link( '/index.php?menuaction=filemanager.filemanager_select.select&mode=open-multiple&method=etemplate_widget_link::link_existing&label=link&id=' + values.to_app + ":" + values.to_id, - false, + 'link_existing', '640x580' ); + if(popup) + { + // Update on close doesn't always (ever, in chrome) work, so poll + var poll = self.egw().window.setInterval( + function() { + if(popup.closed) { + self.getRoot().iterateOver( + function(widget) { + if(widget.id == self.id) { + widget._get_links(); + } + }, + self, et2_link_list + ) + self.egw().window.clearInterval(poll); + } + },1000); + + } }); // Need a div for file upload widget diff --git a/etemplate/templates/default/etemplate2.css b/etemplate/templates/default/etemplate2.css index b849692f15..aadad418fe 100644 --- a/etemplate/templates/default/etemplate2.css +++ b/etemplate/templates/default/etemplate2.css @@ -540,6 +540,7 @@ ul.et2_link_string { */ ul.et2_vfs { padding-left: 0px; + margin: 1px; } .et2_vfs li.vfsFilename { display: inline;