From c2d1e3865f4fc210cdba57dd11156c2d3318f2eb Mon Sep 17 00:00:00 2001 From: Joe Fiorini Date: Wed, 29 Jul 2015 16:12:18 -0400 Subject: [PATCH] Fix checkbox value assignment --- awx/ui/client/src/helpers/Groups.js | 12 +++++------- awx/ui/client/src/helpers/Hosts.js | 10 ++++------ awx/ui/client/src/helpers/Lookup.js | 8 +++----- awx/ui/client/src/helpers/Selection.js | 9 +++------ 4 files changed, 15 insertions(+), 24 deletions(-) diff --git a/awx/ui/client/src/helpers/Groups.js b/awx/ui/client/src/helpers/Groups.js index 3ec0ad2a86..dbbb038356 100644 --- a/awx/ui/client/src/helpers/Groups.js +++ b/awx/ui/client/src/helpers/Groups.js @@ -1887,22 +1887,20 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', listGenerator.name list = GroupList; scope[list.name].forEach( function(row, i) { if (row.id === id) { - if (row.checked === '0') { - scope[list.name][i].checked = '1'; + if (row.checked) { scope[list.name][i].success_class = 'success'; } else { - scope[list.name][i].checked = '0'; scope[list.name][i].success_class = ''; } } else { - scope[list.name][i].checked = '0'; + scope[list.name][i].checked = 0; scope[list.name][i].success_class = ''; } }); // Check if any rows are checked scope[list.name].forEach(function(row) { - if (row.checked === '1') { + if (row.checked) { count++; } }); @@ -1924,7 +1922,7 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', listGenerator.name // check for group selection $('#group-copy-ok-button').attr('disabled','disabled'); scope[list.name].every(function(row) { - if (row.checked === '1') { + if (row.checked === 1) { $('#group-copy-ok-button').removeAttr('disabled'); return false; } @@ -1945,7 +1943,7 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', listGenerator.name } else { scope[list.name].every(function(row) { - if (row.checked === '1') { + if (row.checked === 1) { target = row; return false; } diff --git a/awx/ui/client/src/helpers/Hosts.js b/awx/ui/client/src/helpers/Hosts.js index 2189c60d69..f228a8d5df 100644 --- a/awx/ui/client/src/helpers/Hosts.js +++ b/awx/ui/client/src/helpers/Hosts.js @@ -906,22 +906,20 @@ angular.module('HostsHelper', [ 'RestServices', 'Utilities', listGenerator.name, list = GroupList; scope[list.name].forEach( function(row, i) { if (row.id === id) { - if (row.checked === '0') { - scope[list.name][i].checked = '1'; + if (row.checked) { scope[list.name][i].success_class = 'success'; } else { - scope[list.name][i].checked = '0'; scope[list.name][i].success_class = ''; } } else { - scope[list.name][i].checked = '0'; + scope[list.name][i].checked = 0; scope[list.name][i].success_class = ''; } }); // Check if any rows are checked scope[list.name].forEach(function(row) { - if (row.checked === '1') { + if (row.checked) { count++; } }); @@ -945,7 +943,7 @@ angular.module('HostsHelper', [ 'RestServices', 'Utilities', listGenerator.name, } else { scope[list.name].every(function(row) { - if (row.checked === '1') { + if (row.checked === 1) { target = row; return false; } diff --git a/awx/ui/client/src/helpers/Lookup.js b/awx/ui/client/src/helpers/Lookup.js index 56fa671d0c..e6e2559f04 100644 --- a/awx/ui/client/src/helpers/Lookup.js +++ b/awx/ui/client/src/helpers/Lookup.js @@ -277,22 +277,20 @@ export default var count = 0; scope[list.name].forEach( function(row, i) { if (row.id === id) { - if (row.checked === '0') { - scope[list.name][i].checked = '1'; + if (row.checked) { scope[list.name][i].success_class = 'success'; } else { - scope[list.name][i].checked = '0'; scope[list.name][i].success_class = ''; } } else { - scope[list.name][i].checked = '0'; + scope[list.name][i].checked = 0; scope[list.name][i].success_class = ''; } }); // Check if any rows are checked scope[list.name].forEach(function(row) { - if (row.checked === '1') { + if (row.checked) { count++; } }); diff --git a/awx/ui/client/src/helpers/Selection.js b/awx/ui/client/src/helpers/Selection.js index b45d1e4ee2..3fa4fa826b 100644 --- a/awx/ui/client/src/helpers/Selection.js +++ b/awx/ui/client/src/helpers/Selection.js @@ -45,9 +45,8 @@ export default var i, j, found; for (i = 0; i < scope[list.name].length; i++) { if (scope[list.name][i].id === id) { - if ((scope[list.name][i].checked === "0" && !ischeckbox) || (scope[list.name][i].checked === "0" && ischeckbox)) { - // select the row - scope[list.name][i].checked = '1'; + var control = scope[list.name][i]; + if (ischeckbox && control.checked) { scope[list.name][i].success_class = 'success'; // add selected object to the array found = false; @@ -60,9 +59,7 @@ export default if (!found) { selected.push(scope[list.name][i]); } - } else { - // unselect the row - scope[list.name][i].checked = '0'; + } else if (ischeckbox) { scope[list.name][i].success_class = ''; // remove selected object from the array