From 1734a6385f1da8b2985863c77cbb579611209b78 Mon Sep 17 00:00:00 2001 From: opi Date: Sun, 1 Jun 2014 20:23:05 +0200 Subject: [PATCH] [enh] Add domain list on edit user form, for email field #34 --- js/app.js | 31 ++++++++++++++++++++++++++++++- views/user/user_edit.ms | 16 +++++++++++++--- 2 files changed, 43 insertions(+), 4 deletions(-) diff --git a/js/app.js b/js/app.js index 4db6a547..50b1d8c4 100644 --- a/js/app.js +++ b/js/app.js @@ -536,12 +536,41 @@ app = Sammy('#main', function (sam) { sam.get('#/users/:user/edit', function (c) { c.api('/users/'+ c.params['user'], function(data) { // http://api.yunohost.org/#!/user/user_info_get_0 - c.view('user/user_edit', data); + c.api('/domains', function(dataDomains) { // http://api.yunohost.org/#!/domain/domain_list_get_2 + + email = data.mail.split('@'); + data.email = { + username : email[0], + domain : email[1] + } + + + data.domains = [] + $.each(dataDomains.domains, function(key, value) { + data.domains.push({ + domain: value, + selected: (value == data.email.domain) ? true : false + }) + }); + + c.view('user/user_edit', data); + }); }); }); sam.put('#/users/:user', function (c) { params = {} + + // concat email/domain pseudo field + if (c.params['mail'] !== c.params['email'] + c.params['domain']) { + c.params['mail'] = c.params['email'] + c.params['domain']; + } + else { + c.params['mail'] = ''; + } + c.params['email'] = ''; + c.params['domain'] = ''; + $.each(c.params.toHash(), function(key, value) { if (value !== '' && key !== 'user') { params[key] = value; } }); diff --git a/views/user/user_edit.ms b/views/user/user_edit.ms index e272b273..4354b385 100644 --- a/views/user/user_edit.ms +++ b/views/user/user_edit.ms @@ -29,10 +29,20 @@
- -
- + +
+ +
+
+
+ +
+