W.I.P. VFS Select Widget:

- Add name and dialog_title as new attributes
- Fix SaveToVfs, SaveAttachmentToVfs, SaveAllToVfs in mail
- Fix button tile
This commit is contained in:
Hadi Nategh 2017-10-12 13:19:42 +02:00
parent 4e9ad744cc
commit 2c721c95b2
5 changed files with 53 additions and 56 deletions

View File

@ -895,8 +895,8 @@ var et2_vfsSelect = (function(){ "use strict"; return et2_inputWidget.extend(
default: "open"
},
"value": {
"type": "any", // Object
"description": "Array of paths (strings)"
type: "any", // Object
description: "Array of paths (strings)"
},
"button_caption":{
name: "button caption",
@ -904,6 +904,19 @@ var et2_vfsSelect = (function(){ "use strict"; return et2_inputWidget.extend(
default: "Select files from Filemanager ...",
description: "Caption for vfs-select button.",
translate:true
},
"name": {
name:"File name",
type: "any", // Object
description: "file name",
default: ""
},
"dialog_title":{
name: "dialog title",
type: "string",
default: "Save as",
description: "Title of dialog",
translate:true
}
},
@ -951,7 +964,8 @@ var et2_vfsSelect = (function(){ "use strict"; return et2_inputWidget.extend(
mode: this.options.mode,
label: this.options.button_label,
path: this.options.path || null,
mime: this.options.mime || null
mime: this.options.mime || null,
name: this.options.name
};
var callback = _callback || this._buildDialog;
egw(window).json(
@ -1031,7 +1045,7 @@ var et2_vfsSelect = (function(){ "use strict"; return et2_inputWidget.extend(
delete app.vfsSelectUI;
}
},
title: egw.lang('Save File'),
title: this.options.dialog_title,
buttons: buttons,
minWidth: 500,
minHeight: 400,

View File

@ -377,12 +377,12 @@ class Vfs extends File
*
* There are the following ($params) parameters:
*
* - mode=(open|open-multiple|saveas|select-dir) (required)
* - method=app.class.method (optional callback, gets called with id and selected file(s))
* - id=... (optional parameter passed to callback)
* - path=... (optional start path in VFS)
* - mime=... (optional mime-type to limit display to given type)
* - label=... (optional label for submit button, default "Open")
* - mode=(open|open-multiple|saveas|select-dir)(required)
* - method=app.class.method (optional callback, gets called with id and selected file(s))
* - method_id= array()|string (optional parameter passed to callback)
* - path=string (optional path in VFS)
* - mime=string (optional mime-type to limit display to given type)
* - name=array|string (optional name value to preset name field)
*
* @param array $content
* @param array $params
@ -395,7 +395,6 @@ class Vfs extends File
if (!is_array($content))
{
$content = array_merge($params, array(
'label' => isset($params['label']) ? $params['label'] : lang('Open'),
'name' => (string)$params['name'],
'path' => empty($params['path']) ?
Api\Cache::getSession('filemanger', 'select_path'): $params['path'],

View File

@ -641,7 +641,7 @@ class filemanager_ui
if (strpos($path, 'mail::') === 0 && $path = substr($path, 6))
{
// Support for dropping mail in filemanager - Pass mail back to mail app
if(ExecMethod2('mail.mail_ui.vfsSaveMessage', $path, $dir, false))
if(ExecMethod2('mail.mail_ui.vfsSaveMessage', $path, $dir))
{
++$files;
}

View File

@ -2480,39 +2480,6 @@ $filter['before']= date("d-M-Y", $cutoffdate2);
'smime_type' => $value['smime_type']
);
$attachmentHTML[$key]['link_save'] ="<a href='".Egw::link('/index.php',$linkData)."' title='".$attachmentHTML[$key]['filename']."'>".Api\Html::image('mail','fileexport')."</a>";
if ($GLOBALS['egw_info']['user']['apps']['filemanager'])
{
$link_vfs_save = Egw::link('/index.php',array(
'menuaction' => 'filemanager.filemanager_select.select',
'mode' => 'saveas',
'name' => $value['name'],
'mime' => strtolower($value['mimeType']),
'method' => 'mail.mail_ui.vfsSaveAttachment',
'id' => $rowID.'::'.$value['partID'].'::'.$value['is_winmail'],
'label' => lang('Save'),
));
$vfs_save = "<a href='#' onclick=\"egw_openWindowCentered('$link_vfs_save','vfs_save_attachment','640','570',window.outerWidth/2,window.outerHeight/2); return false;\">$url_img_vfs</a>";
// add save-all icon for first attachment
if (!$key && count($attachments) > 1)
{
$attachmentHTML[$key]['classSaveAllPossiblyDisabled'] = "";
foreach ($attachments as $ikey => $value)
{
//$rowID
$ids["id[$ikey]"] = $rowID.'::'.$value['partID'].'::'.$value['is_winmail'].'::'.$value['name'];
}
$link_vfs_save = Egw::link('/index.php',array(
'menuaction' => 'filemanager.filemanager_select.select',
'mode' => 'select-dir',
'method' => 'mail.mail_ui.vfsSaveAttachment',
'label' => lang('Save all'),
)+$ids);
$vfs_save .= "<a href='#' onclick=\"egw_openWindowCentered('$link_vfs_save','vfs_save_attachment','640','530',window.outerWidth/2,window.outerHeight/2); return false;\">$url_img_vfs_save_all</a>";
}
$attachmentHTML[$key]['link_save'] .= $vfs_save;
//error_log(__METHOD__.__LINE__.$attachmentHTML[$key]['link_save']);
}
}
$attachmentHTMLBlock="<table width='100%'>";
foreach ((array)$attachmentHTML as $row)
@ -2802,15 +2769,27 @@ $filter['before']= date("d-M-Y", $cutoffdate2);
}
}
/**
* Ajax function to save message(s) in the vfs
*
* @param array $ids array of mail ids
* @param string $path path to save the emails
*/
function ajax_vfsSaveMessage ($ids,$path)
{
$result = $this->vfsSaveMessage($ids, $path);
$response = Api\Json\Response::get();
$response->data($result);
}
/**
* Save an Message in the vfs
*
* @param string|array $ids use splitRowID, to separate values
* @param string $path path in vfs (no Vfs::PREFIX!), only directory for multiple id's ($ids is an array)
* @param boolean $close Return javascript to close the window
* @return string|boolean javascript eg. to close the selector window if $close is true, or success/fail if $close is false
*/
function vfsSaveMessage($ids,$path, $close = true)
function vfsSaveMessage($ids,$path)
{
//error_log(__METHOD__.' IDs:'.array2string($ids).' SaveToPath:'.$path);
@ -2867,14 +2846,19 @@ $filter['before']= date("d-M-Y", $cutoffdate2);
$this->changeProfile($rememberServerID);
}
if($close)
{
Framework::window_close(($err?$err:null));
}
else
{
return $succeeded;
}
return $succeeded;
}
/**
* Ajax function to store attachments in the vfs
* @param string|array $ids '::' delimited mailbox::uid::part-id::is_winmail::name (::name for multiple id's)
* @param string $path path in vfs (no Vfs::PREFIX!), only directory for multiple id's ($ids is an array)
*/
function ajax_vfsSaveAttachment($ids,$path)
{
$result = $this->vfsSaveAttachment($ids, $path);
$response = Api\Json\Response::get();
$response->data($result);
}
/**

View File

@ -6,7 +6,7 @@
<vbox class="mailCompose mailComposeHeaderSection" width="100%">
<toolbar id="composeToolbar" width="et2_fullWidth" view_range="7" flat_list="false"/>
<hbox class="mail-compose_toolbar_assist" width="100%">
<vfs-select class="$cont[vfsNotAvailable] compose_egw_icons" id="selectFromVFSForCompose" onchange="app.mail.vfsUploadForCompose" button_caption=""/>
<vfs-select class="$cont[vfsNotAvailable] compose_egw_icons" dialog_title="Attach files" button_label="attach" id="selectFromVFSForCompose" onchange="app.mail.vfsUploadForCompose" button_caption=""/>
<file class="mail-compose_fileselector" statustext="Select file to attach to message" multiple='true' progress='attachments' onFinish="app.mail.uploadForCompose" onStart="app.mail.composeUploadStart" id="uploadForCompose" drop_target ="mail-compose"/>
<checkbox statustext="check to save as infolog on send" id="to_infolog" options="on,off"/>
<checkbox statustext="check to save as tracker entry on send" id="to_tracker" options="on,off"/>