diff options
author | Brice Maron <brice@bmaron.net> | 2012-05-07 21:27:03 +0000 |
---|---|---|
committer | Brice Maron <brice@bmaron.net> | 2012-05-07 21:27:03 +0000 |
commit | 5962a0d4ac9f9fabd9fcb604476ec7c353477e94 (patch) | |
tree | cc9ec240a6416854838906fae1d1eaf0893b47fc /settings | |
parent | 43978abd80b37abc44a015a87b22dc72800977cf (diff) | |
download | nextcloud-server-5962a0d4ac9f9fabd9fcb604476ec7c353477e94.tar.gz nextcloud-server-5962a0d4ac9f9fabd9fcb604476ec7c353477e94.zip |
Enhance user creation (avoid create+delete row), clear create user form after action
Diffstat (limited to 'settings')
-rw-r--r-- | settings/js/users.js | 56 |
1 files changed, 29 insertions, 27 deletions
diff --git a/settings/js/users.js b/settings/js/users.js index 33872ceaf7b..971da7abe98 100644 --- a/settings/js/users.js +++ b/settings/js/users.js @@ -167,32 +167,7 @@ $(document).ready(function(){ } var password=$('#newuserpassword').val(); var groups=$('#newusergroups').prev().children('div').data('settings').checked; - var tr=$('#content table tbody tr').first().clone(); - tr.attr('data-uid',username); - tr.find('td.name').text(username); - var select=$('<select multiple="multiple" data-placehoder="Groups" title="Groups">'); - select.data('username',username); - select.data('userGroups',groups.join(', ')); - tr.find('td.groups').empty(); - var allGroups=$('#content table').data('groups').split(', '); - for(var i=0;i<groups.length;i++){ - if(allGroups.indexOf(groups[i])==-1){ - allGroups.push(groups[i]); - } - } - $.each(allGroups,function(i,group){ - select.append($('<option value="'+group+'">'+group+'</option>')); - }); - tr.find('td.groups').append(select); - if(tr.find('td.remove img').length==0){ - tr.find('td.remove').append($('<img alt="Delete" title="'+t('settings','Delete')+'" class="svg action" src="'+OC.imagePath('core','actions/delete')+'"/>')); - } - applyMultiplySelect(select); - $('#content table tbody').last().append(tr); - - tr.find('select.quota option').attr('selected',null); - tr.find('select.quota option').first().attr('selected','selected'); - tr.find('select.quota').data('previous','default'); + $('#newuser').get(0).reset(); $.post( OC.filePath('settings','ajax','createuser.php'), { @@ -202,9 +177,36 @@ $(document).ready(function(){ }, function(result){ if(result.status!='success'){ - tr.remove(); OC.dialogs.alert(result.data.message, 'Error creating user'); } + else { + var tr=$('#content table tbody tr').first().clone(); + tr.attr('data-uid',username); + tr.find('td.name').text(username); + var select=$('<select multiple="multiple" data-placehoder="Groups" title="Groups">'); + select.data('username',username); + select.data('userGroups',groups.join(', ')); + tr.find('td.groups').empty(); + var allGroups=$('#content table').data('groups').split(', '); + for(var i=0;i<groups.length;i++){ + if(allGroups.indexOf(groups[i])==-1){ + allGroups.push(groups[i]); + } + } + $.each(allGroups,function(i,group){ + select.append($('<option value="'+group+'">'+group+'</option>')); + }); + tr.find('td.groups').append(select); + if(tr.find('td.remove img').length==0){ + tr.find('td.remove').append($('<img alt="Delete" title="'+t('settings','Delete')+'" class="svg action" src="'+OC.imagePath('core','actions/delete')+'"/>')); + } + applyMultiplySelect(select); + $('#content table tbody').last().append(tr); + + tr.find('select.quota option').attr('selected',null); + tr.find('select.quota option').first().attr('selected','selected'); + tr.find('select.quota').data('previous','default'); + } } ); }); |