Browse Source

UI-2138: Added a way to delete devices when you delete a user

4.3
Jean-Roch Maitre 10 years ago
parent
commit
806baf95a6
5 changed files with 95 additions and 19 deletions
  1. +14
    -3
      i18n/en-US.json
  2. +7
    -2
      submodules/users/users.css
  3. +46
    -13
      submodules/users/users.js
  4. +27
    -0
      views/users-deleteDialog.html
  5. +1
    -1
      views/users-row.html

+ 14
- 3
i18n/en-US.json View File

@ -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": {


+ 7
- 2
submodules/users/users.css View File

@ -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;
}

+ 46
- 13
submodules/users/users.js View File

@ -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: '<i class="fa fa-question-circle monster-blue"></i>',
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);
});
});
}


+ 27
- 0
views/users-deleteDialog.html View File

@ -0,0 +1,27 @@
<div class="delete-user-wrapper">
<div class="alert-dialog">
<div class="dialog-content">
<div class="dialog-header">{{ replaceVar i18n.users.deleteDialog.deleteUserName user.name }}</div>
<div>
{{#monsterCheckbox i18n.users.deleteDialog.deleteDevices }}
<input id="delete_devices" type="checkbox"></input>
{{/monsterCheckbox}}
<i class="help-popover fa fa-question-circle fa-lg" data-original-title="{{ i18n.users.deleteDialog.deleteDevicesHelp }}" data-placement="left" data-toggle="tooltip"></i>
</div>
<div class="dialog-text">
{{#compare user.priv_level "===" "admin"}}
{{ i18n.users.deleteDialog.headerAdmin }}
{{else}}
{{ i18n.users.deleteDialog.headerUser }}
{{/compare}}
</div>
</div>
<div class="alert-buttons-wrapper clearfix">
<button class="monster-button" id="cancel_button">{{ i18n.cancel }}</button>
<button class="monster-button-success" id="confirm_button">{{ i18n.users.deleteDialog.proceed }}</button>
</div>
</div>
</div>

+ 1
- 1
views/users-row.html View File

@ -1,4 +1,4 @@
<div class="grid-row" data-id="{{id}}" data-priv_level="{{priv_level}}" data-search="{{first_name}} {{last_name}}{{#each extra.listCallerId}} {{formatPhoneNumber this}} {{this}}{{/each}}">
<div class="grid-row" data-id="{{id}}" data-priv_level="{{priv_level}}" data-name="{{first_name}} {{last_name}}" data-search="{{first_name}} {{last_name}}{{#each extra.listCallerId}} {{formatPhoneNumber this}} {{this}}{{/each}}">
<div class="user-cells">
<div class="name grid-cell" data-type="name"><i class="{{#if extra.isAdmin}}icon-telicon-moderator monster-blue{{else}}icon-telicon-user monster-lightgrey{{/if}}"></i> {{ first_name }} {{ last_name }}</div>
<div class="extension grid-cell" data-type="extensions">


Loading…
Cancel
Save