(js) Move 'Reply All' action to a distinct button

This commit is contained in:
Francis Lachapelle
2015-11-24 16:30:36 -05:00
parent 5a5b4cc829
commit b6930fde26
2 changed files with 26 additions and 7 deletions
@@ -31,10 +31,17 @@
<md-button class="sg-icon-button"
ng-hide="viewer.message.isDraft"
ng-click="viewer.reply($event)"
label:aria-label="reply">
label:aria-label="Reply">
<md-tooltip md-direction="bottom"><var:string label:value="Reply to Sender Only"/></md-tooltip>
<md-icon>reply</md-icon>
</md-button>
<md-button class="sg-icon-button"
ng-show="viewer.message.allowReplyAll()"
ng-click="viewer.replyAll($event)"
label:aria-label="Reply All">
<md-tooltip md-direction="bottom"><var:string label:value="Reply to sender and all recipients"/></md-tooltip>
<md-icon>reply_all</md-icon>
</md-button>
<md-button class="sg-icon-button" label:aria-label="Forward"
ng-hide="viewer.message.isDraft"
ng-click="viewer.forward($event)">
@@ -62,12 +69,6 @@
<md-icon>more_vert</md-icon>
</md-button>
<md-menu-content width="4">
<md-menu-item ng-hide="viewer.message.isDraft">
<md-button label:aria-label="Reply All"
ng-click="viewer.replyAll($event)">
<var:string label:value="Reply All"/>
</md-button>
</md-menu-item>
<md-menu-item>
<md-button label:aria-label="Save As..."
ng-click="viewer.saveMessage()">
@@ -212,6 +212,24 @@
return address;
};
/**
* @function allowReplyAll
* @memberof Message.prototype
* @desc Check if 'Reply to All' is an appropriate action on the message.
* @returns true if the message is not a draft and has more than one recipient
*/
Message.prototype.allowReplyAll = function() {
var recipientsCount = 0;
recipientsCount = _.reduce(['to', 'cc'], function(count, type) {
if (this[type])
return count + this[type].length;
else
return count;
}, recipientsCount, this);
return !this.isDraft && recipientsCount > 1;
};
/**
* @function loadUnsafeContent
* @memberof Message.prototype