forked from extern/egroupware
Implement new feature for vfs-select widget to accept extra buttons action. Additionally, add extra "copy" and "move" actions to link-to vfs dialog.
This commit is contained in:
parent
5221ad68f9
commit
5c19bbfd2c
@ -185,6 +185,8 @@ var et2_link_to = (function(){ "use strict"; return et2_inputWidget.extend(
|
|||||||
button_caption: '',
|
button_caption: '',
|
||||||
readonly: this.options.readonly,
|
readonly: this.options.readonly,
|
||||||
dialog_title: egw.lang('Link'),
|
dialog_title: egw.lang('Link'),
|
||||||
|
extra_buttons:[{text: egw.lang("copy"), id:"copy", image: "copy"},
|
||||||
|
{text: egw.lang("move"), id:"move", image: "move"}],
|
||||||
onchange: function() {
|
onchange: function() {
|
||||||
var values = true;
|
var values = true;
|
||||||
// If entry not yet saved, store for linking on server
|
// If entry not yet saved, store for linking on server
|
||||||
|
@ -928,6 +928,11 @@ var et2_vfsSelect = (function(){ "use strict"; return et2_inputWidget.extend(
|
|||||||
default: "Save as",
|
default: "Save as",
|
||||||
description: "Title of dialog",
|
description: "Title of dialog",
|
||||||
translate:true
|
translate:true
|
||||||
|
},
|
||||||
|
"extra_buttons": {
|
||||||
|
name: "extra action buttons",
|
||||||
|
type: "any",
|
||||||
|
description: "Extra buttons passed to dialog. It's co-related to method.",
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -1007,9 +1012,19 @@ var et2_vfsSelect = (function(){ "use strict"; return et2_inputWidget.extend(
|
|||||||
text: egw.lang(_data.content.label),
|
text: egw.lang(_data.content.label),
|
||||||
id:"submit",
|
id:"submit",
|
||||||
image:_data.content.mode.match(/saveas|select-dir/) ? "save" : "check"
|
image:_data.content.mode.match(/saveas|select-dir/) ? "save" : "check"
|
||||||
},
|
}
|
||||||
{text: egw.lang("Close"), id:"close"}
|
|
||||||
];
|
];
|
||||||
|
if (this.options.extra_buttons && this.options.method)
|
||||||
|
{
|
||||||
|
var extra_buttons_action = [];
|
||||||
|
for (var i=0; i < this.options.extra_buttons.length; i++)
|
||||||
|
{
|
||||||
|
buttons.push(this.options.extra_buttons[i]);
|
||||||
|
extra_buttons_action[this.options.extra_buttons[i]['id']] = this.options.extra_buttons[i]['id'];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
buttons.push({text: egw.lang("Close"), id:"close"});
|
||||||
var data = jQuery.extend(_data, {'currentapp': egw(window).app_name()});
|
var data = jQuery.extend(_data, {'currentapp': egw(window).app_name()});
|
||||||
|
|
||||||
// define a mini app object for vfs select UI
|
// define a mini app object for vfs select UI
|
||||||
@ -1019,7 +1034,7 @@ var et2_vfsSelect = (function(){ "use strict"; return et2_inputWidget.extend(
|
|||||||
{
|
{
|
||||||
callback: function(_button_id, _value)
|
callback: function(_button_id, _value)
|
||||||
{
|
{
|
||||||
if (_button_id == 'submit' && _value)
|
if ((_button_id == 'submit' || extra_buttons_action[_button_id]) && _value)
|
||||||
{
|
{
|
||||||
var files = [];
|
var files = [];
|
||||||
switch(_data.content.mode)
|
switch(_data.content.mode)
|
||||||
@ -1049,7 +1064,7 @@ var et2_vfsSelect = (function(){ "use strict"; return et2_inputWidget.extend(
|
|||||||
{
|
{
|
||||||
egw(window).json(
|
egw(window).json(
|
||||||
self.options.method,
|
self.options.method,
|
||||||
[self.options.method_id, files],
|
[self.options.method_id, files, _button_id],
|
||||||
function(){
|
function(){
|
||||||
jQuery(self.node).change();
|
jQuery(self.node).change();
|
||||||
}
|
}
|
||||||
|
@ -243,11 +243,18 @@ class Link extends Etemplate\Widget
|
|||||||
$response = Api\Json\Response::get();
|
$response = Api\Json\Response::get();
|
||||||
$response->data($result !== false);
|
$response->data($result !== false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Symlink an existing file in filemanager
|
* Symlink/copy/move an existing file in filemanager
|
||||||
|
*
|
||||||
|
* @param string $app_id app's id, e.g. infolog:2
|
||||||
|
* @param array $files an array of paths
|
||||||
|
* @param string $action custom action, default is null which
|
||||||
|
* means link action (actions: copy, move)
|
||||||
|
*
|
||||||
|
* @return nothing
|
||||||
*/
|
*/
|
||||||
public static function ajax_link_existing($app_id, $files)
|
public static function ajax_link_existing($app_id, $files, $action = null)
|
||||||
{
|
{
|
||||||
list($app, $id, $dest_file) = explode(':', $app_id);
|
list($app, $id, $dest_file) = explode(':', $app_id);
|
||||||
|
|
||||||
@ -261,6 +268,16 @@ class Link extends Etemplate\Widget
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!is_array($files)) $files = array($files);
|
if(!is_array($files)) $files = array($files);
|
||||||
|
|
||||||
|
if ($action == "copy")
|
||||||
|
{
|
||||||
|
Api\Vfs::copy_files($files, Api\Link::vfs_path($app, $id, '', true));
|
||||||
|
}
|
||||||
|
if ($action == "move")
|
||||||
|
{
|
||||||
|
Api\Vfs::move_files($files, Api\Link::vfs_path($app, $id, '', true), $errs = array(), $moved = array());
|
||||||
|
}
|
||||||
|
|
||||||
foreach($files as $target)
|
foreach($files as $target)
|
||||||
{
|
{
|
||||||
Api\Link::link_file($app, $id, $target);
|
Api\Link::link_file($app, $id, $target);
|
||||||
|
Loading…
Reference in New Issue
Block a user