From 553e6bf24af7ea3379c7ee778129db05204a2e40 Mon Sep 17 00:00:00 2001 From: Jefferson Stachelski Date: Wed, 28 Oct 2015 17:45:56 -0200 Subject: Issue #493 - Fixed bug delete recipient by buttona Fixed bug when try delete recipient by clicking on the 'x' button, that was not deleting the recipient inside the flightjs component --- web-ui/app/js/mail_view/ui/recipients/recipients.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'web-ui/app/js') diff --git a/web-ui/app/js/mail_view/ui/recipients/recipients.js b/web-ui/app/js/mail_view/ui/recipients/recipients.js index 3dfd6661..966f4ba8 100644 --- a/web-ui/app/js/mail_view/ui/recipients/recipients.js +++ b/web-ui/app/js/mail_view/ui/recipients/recipients.js @@ -58,7 +58,7 @@ define( this.attr.iterator = null; var mailAddr = recipient.getMailAddress(); - var position = recipient.$node.closest('.recipients-area').find('.fixed-recipient').index(recipient.$node); + var position = this.getRecipientPosition(recipient); this.attr.recipients.splice(position, 1); recipient.destroy(); @@ -67,6 +67,10 @@ define( this.attr.input.$node.val(mailAddr).focus(); }; + this.getRecipientPosition = function(recipient) { + return recipient.$node.closest('.recipients-area').find('.fixed-recipient').index(recipient.$node); + } + this.unselectAllRecipients = function() { this.$node.find('.recipient-value.selected').removeClass('selected'); } @@ -96,14 +100,13 @@ define( }; this.deleteRecipient = function (event, recipient) { - var iter = new Iterator(this.attr.recipients, /*startingIndex=*/-1); + this.attr.iterator = null; + var position = this.getRecipientPosition(recipient); - while(iter.hasNext() && iter.next()) { - if (iter.current().isSelected() && iter.current().address === recipient.address) { - iter.removeCurrent().destroy(); - break; - } - } + this.attr.recipients.splice(position, 1); + recipient.destroy(); + + this.addressesUpdated(); }; this.deleteLastRecipient = function () { -- cgit v1.2.3