- Add props parameter for upload

- If user cancels rename/overwrite, remove file from file widget
This commit is contained in:
Nathan Gray 2013-11-07 23:30:50 +00:00
parent ba9782138c
commit 6209c42dc4
2 changed files with 34 additions and 4 deletions

View File

@ -1227,7 +1227,7 @@ class filemanager_ui
* @param string $dir=null current directory
* @see self::action()
*/
public static function ajax_action($action, $selected, $dir=null)
public static function ajax_action($action, $selected, $dir=null, $props=null)
{
$response = egw_json_response::get();
@ -1277,7 +1277,7 @@ class filemanager_ui
$tmp_path = ini_get('upload_tmp_dir').'/'.basename($tmp_name);
}
if (egw_vfs::copy_uploaded($tmp_path, $path, null, false))
if (egw_vfs::copy_uploaded($tmp_path, $path, $props, false))
{
++$arr['files'];
$uploaded[] = $data['name'];
@ -1298,6 +1298,7 @@ class filemanager_ui
}
$arr['uploaded'] = $selected;
$arr['path'] = $dir;
$arr['props'] = $props;
break;
default:

View File

@ -199,6 +199,29 @@ app.classes.filemanager = AppJS.extend(
}
},
/**
* Finish callback for file a file dialog, to get the overwrite / rename prompt
*/
file_a_file_upload: function(_event, _file_count)
{
var widget = _event.data;
var value = widget.getValue();
var path = widget.getRoot().getWidgetById("path").getValue();
var action = widget.getRoot().getWidgetById("action").getValue();
var link = widget.getRoot().getWidgetById("entry").getValue();
if(action == 'save_as' && link.app && link.id)
{
path = "/apps/"+link.app+"/"+link.id;
}
var props = widget.getInstanceManager().getValues(widget.getRoot());
egw.json('filemanager_ui::ajax_action', ['upload', widget.getValue(), path, props],
app.filemanager._upload_callback, app.filemanager, true, this
).sendRequest(true);
return true;
},
/**
* Callback for server response to upload request:
* - display message and refresh list
@ -234,10 +257,15 @@ app.classes.filemanager = AppJS.extend(
uploaded[this.my_data.file].name = _value;
delete uploaded[this.my_data.file].confirm;
// send overwrite-confirmation and/or rename request to server
egw.json('filemanager_ui::ajax_action', ['upload', uploaded, this.my_data.path],
egw.json('filemanager_ui::ajax_action', ['upload', uploaded, this.my_data.path, this.my_data.props],
that._upload_callback, that, true, that
).sendRequest();
return;
case "cancel":
// Remove that file from every file widget...
that.et2.iterateOver(function(_widget) {
_widget.remove_file(this.my_data.data.name);
}, this, et2_file);
}
},
_data.uploaded[file].confirm === "is_dir" ?
@ -249,7 +277,8 @@ app.classes.filemanager = AppJS.extend(
dialog.my_data = {
file: file,
path: _data.path,
data: _data.uploaded[file]
data: _data.uploaded[file],
props: _data.props
};
}
}