Template.groupItem.events({
  'click .deleteGroup': function() {
    Meteor.call("removeGroupById", this._id);
  },
  'input .email': function(event, template) {
    var filter = $(event.target).val();
    var user = Meteor.users.findOne({
      emails: {
        $elemMatch: {
          address: filter
        }
      }
    });

    var existingMember = _.find(template.data.members, function(member){ return member.name == filter; });
    if (existingMember) return;

    if (user && user._id != Meteor.userId()) {
      $(event.target).css("border-color", "greenyellow");
    } else {
      $(event.target).css("border-color", "");
    }
  },

  'keypress .addMember': function(event, template) {
    if (event.charCode == 13) {
      if (Meteor.userId() == this.creator) {
        var filter = $(event.target).val();

        var existingMember = _.find(template.data.members, function(member){ return member.name == filter; });
        if (existingMember) return;

        var user = Meteor.users.findOne({
          emails: {
            $elemMatch: {
              address: filter
            }
          }
        });
        if (user && user._id != Meteor.userId()) {
          Meteor.call("addMember", this._id, user._id, user.emails[0].address);
        }
      }
      event.stopPropagation();
      return false;
    }
  },
  'click .btn-delete-member': function(e) {
    e.preventDefault();
    var name = this.name;
    var group = Groups.findOne(this.idGroup);
    var message = "";
    var id = this.id;
    var idGroup = this.idGroup;
    if (Meteor.userId() == this.id) {
      message = "You are no longer a member of " + group.name + ".";
    } else {
      message = "You have been kicked out of " + group.name + ".";
    }
    bootbox.dialog({
      message: "Do you want delete this member",
      title: "Warning",
      buttons: {
        main: {
          label: "Cancel",
          className: "btn-primary"
        },
        danger: {
          label: "Delete",
          className: "btn-danger",
          callback: function() {
            Meteor.call("createDesinscriptionNotification", id, group, message);
            Meteor.call("removeMember", idGroup, name);
          }
        }
      }
    });
  }
});

Template.groupItem.helpers({
  'allMembers': function() {
    return this.members;
  },
  'isCreator': function() {
    if (Meteor.userId() == this.creator) {
      return true;
    } else {
      return false;
    }
  },
  'nameCreator': function() {
    var user = Meteor.users.findOne({
      _id: this.creator
    });
    if (user) {
      if (user.profile && user.profile.name) {
        return user.profile.name;
      } else {
        return user.emails[0].address;
      }
    } else {
      return "author undefined";
    }
  }
});

Template.member.helpers({
  'isMember': function() {
    var group = Groups.findOne(this.idGroup);
    if (!group) {
      return false;
    }

    var userId = Meteor.userId();
    if (userId == group.creator || userId == this.id) {
      return true;
    } else {
      return false;
    }
  }
})
@@ -66,47 +66,434 @@
     
-Meteor.call(%22removeGroupById%22, this._id
+var idDelete = this._id;%0A    bootbox.dialog(%7B%0A      message: %22Do you want delete this Group%22,%0A      title: %22Warning%22,%0A      buttons: %7B%0A        main: %7B%0A          label: %22Cancel%22,%0A          className: %22btn-primary%22%0A        %7D,%0A        danger: %7B%0A          label: %22Delete%22,%0A          className: %22btn-danger%22,%0A          callback: function() %7B%0A            Meteor.call(%22removeGroupById%22, idDelete);%0A          %7D%0A        %7D%0A      %7D%0A    %7D
 );%0A 
@@ -774,33 +774,40 @@
 function(member)
-%7B
+ %7B%0A     
  return member.n
@@ -812,32 +812,36 @@
 .name == filter;
+%0A   
  %7D);%0A    if (exi
@@ -1289,17 +1289,28 @@
 (member)
-%7B
+ %7B%0A         
  return 
@@ -1331,16 +1331,24 @@
  filter;
+%0A       
  %7D);%0A   
@@ -3482,20 +3482,21 @@
  false;%0A    %7D%0A  %7D%0A%7D)
+%0A

Add confirm to delete a group