mirror of
https://github.com/YunoHost/yunohost-admin.git
synced 2024-09-03 20:06:15 +02:00
[enh] Add domain list on edit user form, for email field #34
This commit is contained in:
parent
62f74cb148
commit
1734a6385f
2 changed files with 43 additions and 4 deletions
31
js/app.js
31
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; }
|
||||
});
|
||||
|
|
|
@ -29,10 +29,20 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="mail" class="col-sm-3 control-label">{{t 'user_email'}}</label>
|
||||
<div class="col-sm-9">
|
||||
<input type="email" id="mail" name="mail" class="form-control" placeholder="{{mail}}">
|
||||
<label for="email" class="col-sm-3 control-label">{{t 'user_email'}}</label>
|
||||
<div class="clearfix visible-xs"></div>
|
||||
<input type="hidden" id="mail" name="mail" class="form-control" value="{{mail}}">
|
||||
<div class="col-sm-4 col-xs-6">
|
||||
<input type="text" id="email" name="email" class="form-control" placeholder="{{email.username}}" value="{{email.username}}">
|
||||
</div>
|
||||
<div class="col-sm-5 col-xs-6">
|
||||
<select class="form-control" name="domain">
|
||||
{{#domains}}
|
||||
<option {{#if selected}}selected="selected"{{/if}}>@{{domain}}</option>
|
||||
{{/domains}}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<hr>
|
||||
<div class="form-group">
|
||||
|
|
Loading…
Reference in a new issue