Browse Source

UI-2040: Fixed an issue where you couldn't unassign a device if that user had more than 2 assigned devices

4.3
Jean-Roch Maitre 10 years ago
parent
commit
f6f2c4fd7c
2 changed files with 23 additions and 23 deletions
  1. +20
    -22
      submodules/users/users.js
  2. +3
    -1
      views/users-row.html

+ 20
- 22
submodules/users/users.js View File

@ -391,34 +391,33 @@ define(function(require){
if(userId in mapUsers) {
var isRegistered = _.find(data.deviceStatus, function(status){ return (status.device_id === device.id && status.registered === true); }) ? true : false;
if(mapUsers[userId].extra.devices.length == 2) {
if(mapUsers[userId].extra.additionalDevices) {
mapUsers[userId].extra.additionalDevices.count++;
mapUsers[userId].extra.additionalDevices.tooltip += '<br><i class=\"device-popover-icon '+self.deviceIcons[device.device_type]+(isRegistered?' monster-green':' monster-red')+'\"></i>'
+ device.name + ' (' + device.device_type.replace('_', ' ') + ')';
} else {
if(mapUsers[userId].extra.devices.length >= 2) {
if(mapUsers[userId].extra.additionalDevices === 0) {
mapUsers[userId].extra.additionalDevices = {
count: 1,
tooltip: '<i class=\"device-popover-icon '+self.deviceIcons[device.device_type]+(isRegistered?' monster-green':' monster-red')+'\"></i>'
+ device.name + ' (' + device.device_type.replace('_', ' ') + ')'
count: 0,
tooltip: ''
};
}
mapUsers[userId].extra.additionalDevices.count++;
mapUsers[userId].extra.additionalDevices.tooltip += '<i class=\"device-popover-icon '+self.deviceIcons[device.device_type]+(isRegistered?' monster-green':' monster-red')+'\"></i>'
+ device.name + ' (' + device.device_type.replace('_', ' ') + ')<br>';
}
else {
var deviceDataToTemplate = {
id: device.id,
name: device.name + ' (' + device.device_type.replace('_', ' ') + ')',
type: device.device_type,
registered: isRegistered,
icon: self.deviceIcons[device.device_type]
};
if (device.device_type === 'mobile') {
deviceDataToTemplate.mobile = device.mobile;
}
var deviceDataToTemplate = {
id: device.id,
name: device.name + ' (' + device.device_type.replace('_', ' ') + ')',
type: device.device_type,
registered: isRegistered,
icon: self.deviceIcons[device.device_type]
};
mapUsers[userId].extra.devices.push(deviceDataToTemplate);
if (device.device_type === 'mobile') {
deviceDataToTemplate.mobile = device.mobile;
}
mapUsers[userId].extra.devices.push(deviceDataToTemplate);
}
});
@ -1005,7 +1004,6 @@ define(function(require){
});
});
template.on('click', '.detail-devices .edit-device-link', function() {
var row = $(this).parents('.item-row'),
id = row.data('id')


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

@ -25,7 +25,9 @@
</div>
<div class="devices grid-cell" data-type="devices">
{{#each extra.devices}}
<i class="{{this.icon}} {{#if this.registered}}monster-green{{else}}monster-red{{/if}} help-popover" data-toggle="tooltip" data-placement="top" data-original-title="{{ this.name }}"></i>
{{#compare @index "<" 2}}
<i class="{{this.icon}} {{#if this.registered}}monster-green{{else}}monster-red{{/if}} help-popover" data-toggle="tooltip" data-placement="top" data-original-title="{{ this.name }}"></i>
{{/compare}}
{{else}}
{{ i18n.users.noUserDevices }}
{{/each}}


Loading…
Cancel
Save