diff --git a/i18n/en-US.json b/i18n/en-US.json index cbe4941..1acebcb 100644 --- a/i18n/en-US.json +++ b/i18n/en-US.json @@ -416,8 +416,6 @@ "addFromSpare": "Add from Spare Numbers", "addFromSpareDevices": "Add from Spare Devices", "buy": "Buy Numbers", - "confirmDeleteAdmin": "You're about to delete an ADMIN! Deleting an admin will delete his Kazoo user, as well as his voicemail boxes and numbers, it will also prevent him from managing this UI. Do you want to continue?", - "confirmDeleteUser": "Deleting a user will delete this user and his Voicemail Box, and unassign the devices and numbers that were assigned to this user. Do you want to continue?", "dialogChangePassword": { "help": "You can set a new password by just typing any password you want, along with the Email address!", "password": "Password", @@ -672,7 +670,20 @@ "__comment": "UI-1888: ", "__version": "4.0", - "confirmMobileUnAssignment": "You are about to un-assign a Mobile device. Be aware the phone number associated with this device ({{variable}}) will also be un-assigned from this user. Are you sure?" + "confirmMobileUnAssignment": "You are about to un-assign a Mobile device. Be aware the phone number associated with this device ({{variable}}) will also be un-assigned from this user. Are you sure?", + + "__comment": "UI-2138: Delete User new Dialog", + "__version": "3.22", + "deleteDialog": { + "title": "Remove {{ name }} from the system", + "headerAdmin": "You're about to delete an ADMIN! Deleting an admin will delete his user, voicemail boxes and unassign his devices. It will also prevent him from managing this UI. Do you want to continue?", + "headerUser": "Deleting a user will delete this user and his Voicemail Box, and unassign the devices and numbers that were assigned to this user. Do you want to continue?", + "deleteUser": "Delete", + "deleteUserName": "Delete \"{{variable}}\"", + "proceed": "Proceed", + "deleteDevices": "Also remove this user's devices from the system", + "deleteDevicesHelp": "If you leave this option unchecked, we'll just unassign these devices and they will show up in the list of Spare Devices" + } }, "strategy": { diff --git a/submodules/users/users.css b/submodules/users/users.css index 6b062c1..5968ce9 100644 --- a/submodules/users/users.css +++ b/submodules/users/users.css @@ -853,6 +853,10 @@ width: 400px; } +.presence-id-change-wrapper .cancel-link { + margin-right: 5px; +} + .presence-id-change-wrapper .list-choices { margin-bottom: 20px; margin-top: 20px; @@ -879,6 +883,7 @@ margin-top: 10px; } -.presence-id-change-wrapper #save-presence-id { - margin-left: 5px; +/**** CSS for delete user dialog ****/ +.delete-user-wrapper .dialog-text { + margin-top: 10px; } \ No newline at end of file diff --git a/submodules/users/users.js b/submodules/users/users.js index 44342a3..7d0bbd4 100644 --- a/submodules/users/users.js +++ b/submodules/users/users.js @@ -420,6 +420,36 @@ define(function(require){ return dataTemplate; }, + usersDeleteDialog: function(user, callback) { + var self = this, + dataTemplate = { + user: user + }, + dialogTemplate = $(monster.template(self, 'users-deleteDialog', dataTemplate)); + + monster.ui.tooltips(dialogTemplate); + + dialogTemplate.find('#confirm_button').on('click', function() { + var removeDevices = dialogTemplate.find('#delete_devices').is(':checked'); + + self.usersDelete(user.id, removeDevices, function(data) { + popup.dialog('close').remove(); + + callback && callback(data); + }); + }); + + dialogTemplate.find('#cancel_button').on('click', function() { + popup.dialog('close').remove(); + }); + + var popup = monster.ui.dialog(dialogTemplate, { + title: '', + position: ['center', 20], + dialogClass: 'monster-alert' + }); + }, + usersBindEvents: function(template, parent, data) { var self = this, currentNumberSearch = '', @@ -753,13 +783,11 @@ define(function(require){ }); template.on('click', '#delete_user', function() { - var dataUser = $(this).parents('.grid-row').data(), - deleteType = dataUser.priv_level === 'admin' ? 'confirmDeleteAdmin' : 'confirmDeleteUser'; + var dataUser = $(this).parents('.grid-row').data(); - monster.ui.confirm(self.i18n.active().users[deleteType], function() { - self.usersDelete(dataUser.id, function(data) { - toastr.success(monster.template(self, '!' + toastrMessages.userDeleted)); - }); + self.usersDeleteDialog(dataUser, function(data) { + toastr.success(monster.template(self, '!' + self.i18n.active().users.toastrMessages.userDelete, { name: data.first_name + ' ' + data.last_name })); + self.usersRender(); }); }); @@ -2893,7 +2921,7 @@ define(function(require){ }, /* Utils */ - usersDelete: function(userId, callback) { + usersDelete: function(userId, removeDevices, callback) { var self = this; monster.parallel({ @@ -2918,10 +2946,16 @@ define(function(require){ _.each(results.devices, function(device) { listFnDelete.push(function(callback) { - // self.usersDeleteDevice(device.id, function(data) { - self.usersUnassignDevice(device.id, function(data) { - callback(null, ''); - }); + if(removeDevices) { + self.usersDeleteDevice(device.id, function(data) { + callback(null, ''); + }); + } + else { + self.usersUnassignDevice(device.id, function(data) { + callback(null, ''); + }); + } }); }); @@ -2986,8 +3020,7 @@ define(function(require){ monster.parallel(listFnDelete, function(err, resultsDelete) { self.usersDeleteUser(userId, function(data) { - toastr.success(monster.template(self, '!' + self.i18n.active().users.toastrMessages.userDelete, { name: data.first_name + ' ' + data.last_name })); - self.usersRender(); + callback && callback(data); }); }); } diff --git a/views/users-deleteDialog.html b/views/users-deleteDialog.html new file mode 100644 index 0000000..330c82f --- /dev/null +++ b/views/users-deleteDialog.html @@ -0,0 +1,27 @@ +