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
52db405e47
commit
eb1eed5b8d
@ -185,6 +185,8 @@ var et2_link_to = (function(){ "use strict"; return et2_inputWidget.extend(
|
||||
button_caption: '',
|
||||
readonly: this.options.readonly,
|
||||
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() {
|
||||
var values = true;
|
||||
// If entry not yet saved, store for linking on server
|
||||
|
@ -940,6 +940,11 @@ var et2_vfsSelect = (function(){ "use strict"; return et2_inputWidget.extend(
|
||||
default: "Save as",
|
||||
description: "Title of dialog",
|
||||
translate:true
|
||||
},
|
||||
"extra_buttons": {
|
||||
name: "extra action buttons",
|
||||
type: "any",
|
||||
description: "Extra buttons passed to dialog. It's co-related to method.",
|
||||
}
|
||||
},
|
||||
|
||||
@ -1019,9 +1024,19 @@ var et2_vfsSelect = (function(){ "use strict"; return et2_inputWidget.extend(
|
||||
text: egw.lang(_data.content.label),
|
||||
id:"submit",
|
||||
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()});
|
||||
|
||||
// define a mini app object for vfs select UI
|
||||
@ -1031,7 +1046,7 @@ var et2_vfsSelect = (function(){ "use strict"; return et2_inputWidget.extend(
|
||||
{
|
||||
callback: function(_button_id, _value)
|
||||
{
|
||||
if (_button_id == 'submit' && _value)
|
||||
if ((_button_id == 'submit' || extra_buttons_action[_button_id]) && _value)
|
||||
{
|
||||
var files = [];
|
||||
switch(_data.content.mode)
|
||||
@ -1061,7 +1076,7 @@ var et2_vfsSelect = (function(){ "use strict"; return et2_inputWidget.extend(
|
||||
{
|
||||
egw(window).json(
|
||||
self.options.method,
|
||||
[self.options.method_id, files],
|
||||
[self.options.method_id, files, _button_id],
|
||||
function(){
|
||||
jQuery(self.node).change();
|
||||
}
|
||||
|
@ -243,11 +243,18 @@ class Link extends Etemplate\Widget
|
||||
$response = Api\Json\Response::get();
|
||||
$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);
|
||||
|
||||
@ -261,6 +268,16 @@ class Link extends Etemplate\Widget
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
Api\Link::link_file($app, $id, $target);
|
||||
|
Loading…
Reference in New Issue
Block a user