diff options
author | Christoph Wurst <christoph@winzerhof-wurst.at> | 2016-04-24 16:47:28 +0300 |
---|---|---|
committer | Christoph Wurst <christoph@winzerhof-wurst.at> | 2016-04-27 20:32:45 +0300 |
commit | d97bcb6c3620f6161804535d39dfb125d3536587 (patch) | |
tree | b8fcbcf7499ae08467f623e442f552234d9e641f | |
parent | ccdb37d0a0f94f54a65288cd471cd9d0c08e6650 (diff) |
hide 'save all to files' if there is one or zero attachments
-rw-r--r-- | js/templates/message-attachments.html | 36 | ||||
-rw-r--r-- | js/views/messageattachments.js | 5 | ||||
-rwxr-xr-x | lib/controller/messagescontroller.php | 3 | ||||
-rw-r--r-- | lib/model/imapmessage.php | 7 |
4 files changed, 8 insertions, 43 deletions
diff --git a/js/templates/message-attachments.html b/js/templates/message-attachments.html index 1748d2231..48855fe4c 100644 --- a/js/templates/message-attachments.html +++ b/js/templates/message-attachments.html @@ -1,40 +1,8 @@ <div class="attachments"> </div> +{{#if moreThanOne}} <p> <button data-message-id="{{id}}" class="icon-folder attachments-save-to-cloud">{{ t 'Save all to Files' }}</button> </p> - -<!-- {{#if attachment}} -<ul> - <li class="mail-message-attachment mail-message-attachment-single" data-message-id="{{attachment.messageId}}" data-attachment-id="{{attachment.id}}" data-attachment-mime="{{attachment.mime}}"> - {{#if attachment.isImage}} - <img class="mail-attached-image" src="{{attachment.downloadUrl}}"> - <br> - {{/if}} - <img class="attachment-icon" src="{{attachment.mimeUrl}}" /> - {{attachment.fileName}} <span class="attachment-size">({{humanFileSize attachment.size}})</span><br/> - <a class="button icon-download attachment-download" href="{{attachment.downloadUrl}}">{{ t 'Download attachment' }}</a> - <button class="icon-folder attachment-save-to-cloud">{{ t 'Save to Files' }}</button> - </li> -</ul> -{{/if}} -{{#if attachments}} -<ul> - {{#each attachments}} - <li class="mail-message-attachment {{#if isImage}}mail-message-attachment-image{{/if}}" data-message-id="{{messageId}}" data-attachment-id="{{id}}" data-attachment-mime="{{mime}}"> - {{#if isImage}} - <img class="mail-attached-image" src="{{downloadUrl}}"> - <br> - {{/if}} - <a class="button icon-download attachment-download" href="{{downloadUrl}}" title="{{ t 'Download attachment' }}"></a> - <button class="icon-folder attachment-save-to-cloud" title="{{ t 'Save to Files' }}"></button> - <img class="attachment-icon" src="{{mimeUrl}}" /> - {{fileName}} <span class="attachment-size">({{humanFileSize size}})</span> - </li> - {{/each}} -</ul> -<p> - <button data-message-id="{{id}}" class="icon-folder attachments-save-to-cloud">{{ t 'Save all to Files' }}</button> -</p> -{{/if}} -->
\ No newline at end of file +{{/if}}
\ No newline at end of file diff --git a/js/views/messageattachments.js b/js/views/messageattachments.js index 3dca28ec0..b24771e9a 100644 --- a/js/views/messageattachments.js +++ b/js/views/messageattachments.js @@ -33,6 +33,11 @@ define(function(require) { * @lends Marionette.CompositeView */ template: Handlebars.compile(AttachmentsTemplate), + templateHelpers: function() { + return { + moreThanOne: this.collection.length > 1 + }; + }, childView: AttachmentView, childViewContainer: '.attachments' }); diff --git a/lib/controller/messagescontroller.php b/lib/controller/messagescontroller.php index 4f258077b..82da0e25d 100755 --- a/lib/controller/messagescontroller.php +++ b/lib/controller/messagescontroller.php @@ -459,9 +459,6 @@ class MessagesController extends Controller { $json['htmlBodyUrl'] = $this->buildHtmlBodyUrl($accountId, $folderId, $id); } - if (isset($json['attachment'])) { - $json['attachment'] = $this->enrichDownloadUrl($accountId, $folderId, $id, $json['attachment']); - } if (isset($json['attachments'])) { $json['attachments'] = array_map(function ($a) use ($accountId, $folderId, $id) { return $this->enrichDownloadUrl($accountId, $folderId, $id, $a); diff --git a/lib/model/imapmessage.php b/lib/model/imapmessage.php index d0de3fa4e..9f0e61a32 100644 --- a/lib/model/imapmessage.php +++ b/lib/model/imapmessage.php @@ -486,12 +486,7 @@ class IMAPMessage implements IMessage { $data['signature'] = $signature; } - if (count($this->attachments) === 1) { - $data['attachment'] = $this->attachments[0]; - } - if (count($this->attachments) > 1) { - $data['attachments'] = $this->attachments; - } + $data['attachments'] = $this->attachments; if ($specialRole === 'sent') { $data['replyToList'] = $this->getToList(true); |