Try to warn user when switching between filemodes in compose dialog, also indicate each filemode with an icon.

This commit is contained in:
Hadi Nategh 2018-07-12 15:42:07 +02:00
parent cc3e00f9f1
commit 50d02bff81
4 changed files with 65 additions and 2 deletions

View File

@ -266,6 +266,7 @@ app.classes.filemanager = AppJS.extend(
params['preset[file]['+i+']'] = 'vfs://default'+attachments[i]; params['preset[file]['+i+']'] = 'vfs://default'+attachments[i];
content.data.files.file.push('vfs://default'+attachments[i]); content.data.files.file.push('vfs://default'+attachments[i]);
} }
content.data.files.filemode = params['preset[filemode]'];
// always open compose in html mode, as attachment links look a lot nicer in html // always open compose in html mode, as attachment links look a lot nicer in html
params.mimeType = 'html'; params.mimeType = 'html';
return egw.openWithinWindow("mail", "setCompose", content, params, /mail.mail_compose.compose/); return egw.openWithinWindow("mail", "setCompose", content, params, /mail.mail_compose.compose/);

View File

@ -317,6 +317,7 @@ class mail_compose
if ($_content['appendix_data']) if ($_content['appendix_data'])
{ {
$appendix_data = json_decode($_content['appendix_data'], true); $appendix_data = json_decode($_content['appendix_data'], true);
$_content['appendix_data'] = '';
} }
if ($appendix_data['emails']) if ($appendix_data['emails'])
@ -332,7 +333,6 @@ class mail_compose
} }
$suppressSigOnTop = true; $suppressSigOnTop = true;
unset($appendix_data); unset($appendix_data);
$_content['appendix_data'] = '';
} }
if (isset($_GET['reply_id'])) $replyID = $_GET['reply_id']; if (isset($_GET['reply_id'])) $replyID = $_GET['reply_id'];
@ -811,6 +811,9 @@ class mail_compose
{ {
$_REQUEST['preset']['file'] = $appendix_data['files']['file']; $_REQUEST['preset']['file'] = $appendix_data['files']['file'];
$_REQUEST['preset']['type'] = $appendix_data['files']['type']; $_REQUEST['preset']['type'] = $appendix_data['files']['type'];
$_content['filemode'] = !empty($appendix_data['files']['filemode']) &&
isset(Vfs\Sharing::$modes[$appendix_data['files']['filemode']]) ?
$appendix_data['files']['filemode'] : Vfs\Sharing::ATTACH;
$suppressSigOnTop = true; $suppressSigOnTop = true;
unset($_content['attachments']); unset($_content['attachments']);
$this->addPresetFiles($content, $insertSigOnTop, true); $this->addPresetFiles($content, $insertSigOnTop, true);
@ -1370,6 +1373,15 @@ class mail_compose
if (is_array($content[$f])) $content[$f]= self::resolveEmailAddressList ($content[$f]); if (is_array($content[$f])) $content[$f]= self::resolveEmailAddressList ($content[$f]);
} }
// set filemode icons for all attachments
foreach($content['attachments'] as &$attach)
{
$attach['is_dir'] = is_dir($attach['file']);
$attach['filemode_icon'] = !is_dir($attach['file']) &&
($content['filemode'] == Vfs\Sharing::READONLY || $content['filemode'] == Vfs\Sharing::WRITABLE)
? Vfs\Sharing::LINK : $content['filemode'];
}
$content['to'] = self::resolveEmailAddressList($content['to']); $content['to'] = self::resolveEmailAddressList($content['to']);
//error_log(__METHOD__.__LINE__.array2string($content)); //error_log(__METHOD__.__LINE__.array2string($content));
$etpl->exec('mail.mail_compose.compose',$content,$sel_options,array(),$preserv,2); $etpl->exec('mail.mail_compose.compose',$content,$sel_options,array(),$preserv,2);

View File

@ -694,7 +694,28 @@ app.classes.mail = AppJS.extend(
{ {
var w = compose_et2[0].widgetContainer.getWidgetById('appendix_data'); var w = compose_et2[0].widgetContainer.getWidgetById('appendix_data');
w.set_value(JSON.stringify(content[field])); w.set_value(JSON.stringify(content[field]));
return compose_et2[0].widgetContainer._inst.submit(); var filemode = compose_et2[0].widgetContainer.getWidgetById('filemode');
if (content[field]['files'] && content[field]['files']['filemode']
&& filemode && filemode.get_value() != content[field]['files']['filemode'])
{
var filemode_label = filemode.options.select_options[content[field]['files']['filemode']]['label'];
var files = content[field]['files']['file'].join('\n\r');
et2_dialog.show_dialog(function(_button){
if (_button == 2)
{
compose_et2[0].widgetContainer._inst.submit();
}
},
this.egw.lang(
'Be aware by adding all selected files as %1 mode, it will also change all existing attachments in the list to %2 mode as well. \n\r \n\r\ Would you like to proceed?',
filemode_label, filemode_label, files),
this.egw.lang('Add files as %1', filemode_label), '', et2_dialog.BUTTONS_YES_NO, et2_dialog.WARNING_MESSAGE);
return;
}
else
{
return compose_et2[0].widgetContainer._inst.submit();
}
} }
var widget = compose_et2[0].widgetContainer.getWidgetById(field); var widget = compose_et2[0].widgetContainer.getWidgetById(field);
@ -4970,6 +4991,33 @@ app.classes.mail = AppJS.extend(
this.egw.message(this.egw.lang('Writable sharing requires EPL version!'), 'info'); this.egw.message(this.egw.lang('Writable sharing requires EPL version!'), 'info');
_widget.set_value('share_ro'); _widget.set_value('share_ro');
} }
if (typeof _node != 'undefined')
{
et2_dialog.alert(this.egw.lang(
'Be aware that all attachments will be sent as %1!',
_widget.options.select_options[_widget.get_value()]['label']
),
this.egw.lang(
'Filemode has been switched to %1',
_widget.options.select_options[_widget.get_value()]['label']
),
et2_dialog.WARNING_MESSAGE);
var content = this.et2.getArrayMgr('content');
var attachments = this.et2.getWidgetById('attachments');
for (var i in content.data.attachments)
{
if (content.data.attachments[i] == null)
{
content.data.attachments.splice(i,1);
continue;
}
content.data.attachments[i]['filemode_icon'] = !content.data.attachments[i]['is_dir'] &&
(_widget.get_value() == 'share_rw' || _widget.get_value() == 'share_ro') ? 'link' : _widget.get_value();
}
this.et2.setArrayMgr('content', content);
attachments.set_value({content:content.data.attachments});
}
}, },
/** /**

View File

@ -100,6 +100,7 @@
</hbox> </hbox>
<grid id="attachments" width="100%" maxheight="165" class="egwGridView_grid" resize_ratio="0"> <grid id="attachments" width="100%" maxheight="165" class="egwGridView_grid" resize_ratio="0">
<columns> <columns>
<column width= "3%"/>
<column disabled="!@showtempname" width="10%"/> <column disabled="!@showtempname" width="10%"/>
<column width="85%"/> <column width="85%"/>
<column width="8%"/> <column width="8%"/>
@ -107,6 +108,7 @@
</columns> </columns>
<rows> <rows>
<row class="row attachmentRow"> <row class="row attachmentRow">
<image src="$row_cont[filemode_icon]"/>
<description id="${row}[tmp_name]"/> <description id="${row}[tmp_name]"/>
<description class="useEllipsis et2_link" id="${row}[name]" no_lang="1" onclick="app.mail.displayUploadedFile"/> <description class="useEllipsis et2_link" id="${row}[name]" no_lang="1" onclick="app.mail.displayUploadedFile"/>
<vfs-size align="right" id="${row}[size]" /> <vfs-size align="right" id="${row}[size]" />