[Pkg-owncloud-commits] [owncloud] 03/129: Delete last undoable user before user creation
David Prévot
taffit at moszumanska.debian.org
Thu Nov 5 01:04:17 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch stable8
in repository owncloud.
commit f7b62abcce05f2170a3d376ea9f38ea1d0edabfa
Author: Vincent Petry <pvince81 at owncloud.com>
Date: Wed Oct 7 16:17:38 2015 +0200
Delete last undoable user before user creation
---
settings/js/users/deleteHandler.js | 5 +--
settings/js/users/users.js | 69 ++++++++++++++++++++++----------------
2 files changed, 43 insertions(+), 31 deletions(-)
diff --git a/settings/js/users/deleteHandler.js b/settings/js/users/deleteHandler.js
index de87f90..b684aff 100644
--- a/settings/js/users/deleteHandler.js
+++ b/settings/js/users/deleteHandler.js
@@ -172,8 +172,9 @@ DeleteHandler.prototype.cancel = function() {
* it, defaults to false
*/
DeleteHandler.prototype.deleteEntry = function(keepNotification) {
+ var deferred = $.Deferred();
if(this.canceled || this.oidToDelete === false) {
- return false;
+ return deferred.resolve().promise();
}
var dh = this;
@@ -188,7 +189,7 @@ DeleteHandler.prototype.deleteEntry = function(keepNotification) {
var payload = {};
payload[dh.ajaxParamID] = dh.oidToDelete;
- $.ajax({
+ return $.ajax({
type: 'DELETE',
url: OC.generateUrl(dh.ajaxEndpoint+'/'+this.oidToDelete),
// FIXME: do not use synchronous ajax calls as they block the browser !
diff --git a/settings/js/users/users.js b/settings/js/users/users.js
index 519fe96..a99b464 100644
--- a/settings/js/users/users.js
+++ b/settings/js/users/users.js
@@ -9,6 +9,7 @@
var $userList;
var $userListBody;
+var UserDeleteHandler;
var UserList = {
availableGroups: [],
offset: 0,
@@ -785,37 +786,47 @@ $(document).ready(function () {
t('settings', 'Error creating user'));
return false;
}
- var groups = $('#newusergroups').val() || [];
- $.post(
- OC.generateUrl('/settings/users/users'),
- {
- username: username,
- password: password,
- groups: groups,
- email: email
- },
- function (result) {
- if (result.groups) {
- for (var i in result.groups) {
- var gid = result.groups[i];
- if(UserList.availableGroups.indexOf(gid) === -1) {
- UserList.availableGroups.push(gid);
+
+ var promise;
+ if (UserDeleteHandler) {
+ promise = UserDeleteHandler.deleteEntry();
+ } else {
+ promise = $.Deferred().resolve().promise();
+ }
+
+ promise.then(function() {
+ var groups = $('#newusergroups').val() || [];
+ $.post(
+ OC.generateUrl('/settings/users/users'),
+ {
+ username: username,
+ password: password,
+ groups: groups,
+ email: email
+ },
+ function (result) {
+ if (result.groups) {
+ for (var i in result.groups) {
+ var gid = result.groups[i];
+ if(UserList.availableGroups.indexOf(gid) === -1) {
+ UserList.availableGroups.push(gid);
+ }
+ $li = GroupList.getGroupLI(gid);
+ userCount = GroupList.getUserCount($li);
+ GroupList.setUserCount($li, userCount + 1);
}
- $li = GroupList.getGroupLI(gid);
- userCount = GroupList.getUserCount($li);
- GroupList.setUserCount($li, userCount + 1);
}
- }
- if(!UserList.has(username)) {
- UserList.add(result, true);
- }
- $('#newusername').focus();
- GroupList.incEveryoneCount();
- }).fail(function(result, textStatus, errorThrown) {
- OC.dialogs.alert(result.responseJSON.message, t('settings', 'Error creating user'));
- }).success(function(){
- $('#newuser').get(0).reset();
- });
+ if(!UserList.has(username)) {
+ UserList.add(result, true);
+ }
+ $('#newusername').focus();
+ GroupList.incEveryoneCount();
+ }).fail(function(result, textStatus, errorThrown) {
+ OC.dialogs.alert(result.responseJSON.message, t('settings', 'Error creating user'));
+ }).success(function(){
+ $('#newuser').get(0).reset();
+ });
+ });
});
if ($('#CheckboxStorageLocation').is(':checked')) {
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git
More information about the Pkg-owncloud-commits
mailing list