From 54d79ae751eb4dfc7205dbbec48bb76ce1c8df19 Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Thu, 23 Jan 2014 11:50:24 +0100 Subject: [PATCH] Check for dupes when renaming group. Fixes #359 --- js/groups.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/js/groups.js b/js/groups.js index 5c5004d5..9ec2468a 100644 --- a/js/groups.js +++ b/js/groups.js @@ -519,6 +519,13 @@ OC.Contacts = OC.Contacts || {}; addText: t('contacts', 'Save'), ok: function(event, newname) { console.log('New name', newname); + if(self.hasGroup(newname)) { + $(document).trigger('status.contacts.error', { + error: true, + message: t('contacts', 'A group named "{group}" already exists', {group: escapeHTML(newname)}) + }); + return; + } $editInput.addClass('loading'); self.renameGroup(oldname, newname, function(response) { if(response.error) { @@ -595,7 +602,7 @@ OC.Contacts = OC.Contacts || {}; var self = this; if(this.hasGroup(name)) { if(typeof cb === 'function') { - cb({error:true, message:t('contacts', 'A group named {group} already exists', {group: escapeHTML(name)})}); + cb({error:true, message:t('contacts', 'A group named "{group} a"lready exists', {group: escapeHTML(name)})}); } return; }