Skip to content

Commit

Permalink
Merge pull request #232 from rfrei/patch-1
Browse files Browse the repository at this point in the history
Allow write to multiple contacts using 'to', 'cc' or 'bcc'.

Fixes #3548.
  • Loading branch information
cgx committed Jan 30, 2017
2 parents 0500499 + 1b264ef commit a020286
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 10 deletions.
5 changes: 4 additions & 1 deletion UI/Contacts/English.lproj/Localizable.strings
Expand Up @@ -41,6 +41,9 @@
"Move To" = "Move To";
"Copy To" = "Copy To";
"Add to" = "Add to";
"To" = "To";
"Carbon Copy (Cc)" = "Carbon Copy (Cc)";
"Blind Carbon Copy (Bcc)" = "Blind Carbon Copy (Bcc)";

/* Subheader of empty addressbook */
"No contact" = "No contact";
Expand Down Expand Up @@ -258,4 +261,4 @@
"key_create_card" = "c";

/* Hotkey to create a new list */
"key_create_list" = "l";
"key_create_list" = "l";
27 changes: 23 additions & 4 deletions UI/Templates/ContactsUI/UIxContactFoldersView.wox
Expand Up @@ -364,10 +364,29 @@
</md-button>
<md-menu-content width="3">
<md-menu-item>
<md-button ng-click="addressbook.newMessageWithSelectedCards($event)">
<var:string label:value="Write"/>
</md-button>
</md-menu-item>
<md-menu>
<md-button label:aria-label="Write" ng-click="$mdMenu.open($event)">
<var:string label:value="Write"/>
</md-button>
<md-menu-content class="md-dense" width="3">
<md-menu-item>
<md-button ng-click="addressbook.newMessageWithSelectedCards($event, 'to')">
<var:string label:value="To"/>
</md-button>
</md-menu-item>
<md-menu-item>
<md-button ng-click="addressbook.newMessageWithSelectedCards($event, 'cc')">
<var:string label:value="Carbon Copy (Cc)"/>
</md-button>
</md-menu-item>
<md-menu-item>
<md-button ng-click="addressbook.newMessageWithSelectedCards($event, 'bcc')">
<var:string label:value="Blind Carbon Copy (Bcc)"/>
</md-button>
</md-menu-item>
</md-menu-content>
</md-menu>
</md-menu-item>
<md-menu-item ng-hide="addressbook.selectedFolder.isRemote">
<md-button ng-click="addressbook.selectedFolder.exportCards(true)">
<var:string label:value="Export"/>
Expand Down
10 changes: 5 additions & 5 deletions UI/WebServerResources/js/Contacts/AddressBookController.js
Expand Up @@ -319,7 +319,7 @@
vm.selectedFolder.$filter('');
}

function newMessage($event, recipients) {
function newMessage($event, recipients, recipientsField) {
Account.$findAll().then(function(accounts) {
var account = _.find(accounts, function(o) {
if (o.id === 0)
Expand All @@ -330,7 +330,7 @@
// list before proceeding with message's creation
account.$getMailboxes().then(function(mailboxes) {
account.$newMessage().then(function(message) {
angular.extend(message.editable, { to: recipients });
message.editable[recipientsField] = recipients;
$mdDialog.show({
parent: angular.element(document.body),
targetEvent: $event,
Expand All @@ -351,12 +351,12 @@

function newMessageWithRecipient($event, recipient, fn) {
var recipients = [fn + ' <' + recipient + '>'];
vm.newMessage($event, recipients);
vm.newMessage($event, recipients, 'to');
$event.stopPropagation();
$event.preventDefault();
}

function newMessageWithSelectedCards($event) {
function newMessageWithSelectedCards($event, recipientsField) {
var selectedCards = _.filter(vm.selectedFolder.$cards, function(card) { return card.selected; });
var promises = [], recipients = [];

Expand Down Expand Up @@ -386,7 +386,7 @@
$q.all(promises).then(function() {
recipients = _.uniq(recipients);
if (recipients.length)
vm.newMessage($event, recipients);
vm.newMessage($event, recipients, recipientsField);
});
}
}
Expand Down

0 comments on commit a020286

Please sign in to comment.