From 7b6924e44d63178b7ea164a46ea323901b5f6ea7 Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Fri, 14 Dec 2012 02:47:51 +0100 Subject: [PATCH] Contacts: If a group is selected when adding a contact add it to that group. --- js/contacts.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/js/contacts.js b/js/contacts.js index 327be3f1..2ad98e00 100644 --- a/js/contacts.js +++ b/js/contacts.js @@ -403,6 +403,20 @@ OC.Contacts = OC.Contacts || {}; self.id = parseInt(jsondata.data.id); self.access.id = parseInt(jsondata.data.aid); self.data = jsondata.data.details; + // Add contact to current group + if(self.groupprops && self.groupprops.currentgroup.name !== 'all' + && self.groupprops.currentgroup.name !== 'fav') { + if(!self.data.CATEGORIES) { + self.data.CATEGORIES = [{value:[self.groupprops.currentgroup.name], parameters:[]}]; + // Save to vCard + self.saveProperty({name:'CATEGORIES', value:self.data.CATEGORIES[0].value.join(',') }); + // Tell OC.Contacts to save in backend + $(document).trigger('request.contact.addtogroup', { + id: self.id, + groupid: self.groupprops.currentgroup.id, + }); + } + } $(document).trigger('status.contact.added', { id: self.id, contact: self,