Skip to content

Commit

Permalink
UI-2040: Fixed an issue where you couldn't unassign a device if that …
Browse files Browse the repository at this point in the history
…user had more than 2 assigned devices
  • Loading branch information
JRMaitre committed Feb 11, 2016
1 parent 1a00cad commit 57e21e5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 23 deletions.
42 changes: 20 additions & 22 deletions submodules/users/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
});

Expand Down Expand Up @@ -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')
Expand Down
4 changes: 3 additions & 1 deletion views/users-row.html
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
Expand Down

0 comments on commit 57e21e5

Please sign in to comment.