From 0294d704a3f8cd186a5caa6f42029f172316dbf9 Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Sat, 22 Dec 2012 02:01:08 +0100 Subject: [PATCH] Contacts: Add group select to contact popup. --- js/contacts.js | 18 +++++++++++++++++- templates/contacts.php | 1 + 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/js/contacts.js b/js/contacts.js index 9ec60727..f4a06990 100644 --- a/js/contacts.js +++ b/js/contacts.js @@ -638,8 +638,19 @@ OC.Contacts = OC.Contacts || {}; * @return A jquery object to be inserted in the DOM */ Contact.prototype.renderContact = function(groupprops) { - this.groupprops = groupprops; var self = this; + this.groupprops = groupprops; + + var buildGroupSelect = function($groupSelect, availableGroups) { + $.each(availableGroups, function(idx, group) { + var $option = $(''); + if(self.inGroup(group.name)) { + $option.attr('selected', 'selected'); + } + $groupSelect.append($option); + }); + }; + var n = this.getPreferredValue('N', ['', '', '', '', '']); //console.log('Contact.renderContact', this.data); var values = this.data @@ -667,6 +678,11 @@ OC.Contacts = OC.Contacts || {}; this.$fullelem.on('submit', function() { return false; }); + + this.$groupSelect = this.$fullelem.find('#contactgroups'); + buildGroupSelect(this.$groupSelect, groupprops.groups); + this.$groupSelect.multiSelect(); + this.$addMenu = this.$fullelem.find('#addproperty'); this.$addMenu.on('change', function(event) { //console.log('add', $(this).val()); diff --git a/templates/contacts.php b/templates/contacts.php index e2972384..90c2c683 100644 --- a/templates/contacts.php +++ b/templates/contacts.php @@ -173,6 +173,7 @@ +