diff --git a/static/js/directives/settings.js b/static/js/directives/settings.js index 7b58ca20..aebd7fe9 100644 --- a/static/js/directives/settings.js +++ b/static/js/directives/settings.js @@ -36,6 +36,7 @@ define(['jquery', 'underscore', 'text!partials/settings.html'], function($, _, t $scope.withUsers = mediaStream.config.UsersEnabled; $scope.withUsersRegistration = mediaStream.config.UsersAllowRegistration; $scope.withUsersMode = mediaStream.config.UsersMode; + $scope.contactsManager = contactsManager; _.each(availableLanguages, function(name, code) { $scope.availableLanguages.push({ diff --git a/static/js/services/contacts.js b/static/js/services/contacts.js index 258df360..f9c88174 100644 --- a/static/js/services/contacts.js +++ b/static/js/services/contacts.js @@ -18,7 +18,7 @@ * along with this program. If not, see . * */ -define(['underscore', 'jquery', 'modernizr', 'sjcl', 'text!partials/contactsmanager.html', 'text!partials/contactsmanageredit.html'], function(_, $, Modernizr, sjcl, templateContactsManager, templateContactsManagerEdit) { +define(['underscore', 'jquery', 'modernizr', 'sjcl'], function(_, $, Modernizr, sjcl) { var Database = function(name) { this.version = 3; @@ -121,11 +121,7 @@ define(['underscore', 'jquery', 'modernizr', 'sjcl', 'text!partials/contactsmana }; // contacts - return ["appData", "contactData", "mediaStream", "$templateCache", function(appData, contactData, mediaStream, $templateCache) { - - // Inject our templates. - $templateCache.put('/contactsmanager/main.html', templateContactsManager); - $templateCache.put('/contactsmanager/edit.html', templateContactsManagerEdit); + return ["appData", "contactData", "mediaStream", function(appData, contactData, mediaStream) { var Contacts = function() { diff --git a/static/js/services/contactsmanager.js b/static/js/services/contactsmanager.js new file mode 100644 index 00000000..660fae13 --- /dev/null +++ b/static/js/services/contactsmanager.js @@ -0,0 +1,81 @@ +/* + * Spreed WebRTC. + * Copyright (C) 2013-2014 struktur AG + * + * This file is part of Spreed WebRTC. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ +define(['underscore', 'jquery', 'modernizr', 'text!partials/contactsmanager.html', 'text!partials/contactsmanageredit.html'], function(_, $, Modernizr, templateContactsManager, templateContactsManagerEdit) { + + return ["dialogs", "translation", "$templateCache", function(dialogs, translation, $templateCache) { + + // Inject our templates. + $templateCache.put('/contactsmanager/main.html', templateContactsManager); + $templateCache.put('/contactsmanager/edit.html', templateContactsManagerEdit); + + var ContactsManager = {}; + ContactsManager._mainDialog = function() { + return dialogs.create( + "/contactsmanager/main.html", + "ContactsmanagerController", + { + header: translation._("Contacts Manager") + }, { + wc: "contactsmanager" + } + ); + }; + ContactsManager._editDialog = function(contact) { + return dialogs.create( + "/contactsmanager/edit.html", + "ContactsmanagerController", + { + header: translation._("Edit Contact"), + contact: contact, + }, { + wc: "contactsmanager" + } + ); + }; + ContactsManager.setupContactsManager = function() { + var dlgMain = null; + var that = this; + + dlgMain = that._mainDialog(); + dlgMain.result.then(function(contact) { + if(contact && contact.Id) { + that.setupContactsManagerEdit(contact); + } + }); + }; + ContactsManager.setupContactsManagerEdit = function(contact) { + var dlgEdit = null; + var that = this; + + dlgEdit = that._editDialog(contact); + dlgEdit.result.finally(function(final) { + that.setupContactsManager(); + }); + }; + ContactsManager.open = function() { + this.setupContactsManager(); + }; + + return ContactsManager; + + }]; + +}); diff --git a/static/js/services/services.js b/static/js/services/services.js index 0657fafe..ca05c125 100644 --- a/static/js/services/services.js +++ b/static/js/services/services.js @@ -47,6 +47,7 @@ define([ 'services/videolayout', 'services/contactdata', 'services/contacts', + 'services/contactsmanager', 'services/buddysession', 'services/localstorage', 'services/animationframe', @@ -83,6 +84,7 @@ videoWaiter, videoLayout, contactData, contacts, +contactsManager, buddySession, localStorage, animationFrame, @@ -121,6 +123,7 @@ localStatus) { videoLayout: videoLayout, contactData: contactData, contacts: contacts, + contactsManager: contactsManager, buddySession: buddySession, localStorage: localStorage, animationFrame: animationFrame, diff --git a/static/partials/settings.html b/static/partials/settings.html index a3e2719f..8eaf4442 100644 --- a/static/partials/settings.html +++ b/static/partials/settings.html @@ -70,7 +70,7 @@