1
0
mirror of https://github.com/ansible/awx.git synced 2024-11-01 16:51:11 +03:00

Fix checkbox value assignment

This commit is contained in:
Joe Fiorini 2015-07-29 16:12:18 -04:00
parent a037063a22
commit c2d1e3865f
4 changed files with 15 additions and 24 deletions

View File

@ -1887,22 +1887,20 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', listGenerator.name
list = GroupList; list = GroupList;
scope[list.name].forEach( function(row, i) { scope[list.name].forEach( function(row, i) {
if (row.id === id) { if (row.id === id) {
if (row.checked === '0') { if (row.checked) {
scope[list.name][i].checked = '1';
scope[list.name][i].success_class = 'success'; scope[list.name][i].success_class = 'success';
} }
else { else {
scope[list.name][i].checked = '0';
scope[list.name][i].success_class = ''; scope[list.name][i].success_class = '';
} }
} else { } else {
scope[list.name][i].checked = '0'; scope[list.name][i].checked = 0;
scope[list.name][i].success_class = ''; scope[list.name][i].success_class = '';
} }
}); });
// Check if any rows are checked // Check if any rows are checked
scope[list.name].forEach(function(row) { scope[list.name].forEach(function(row) {
if (row.checked === '1') { if (row.checked) {
count++; count++;
} }
}); });
@ -1924,7 +1922,7 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', listGenerator.name
// check for group selection // check for group selection
$('#group-copy-ok-button').attr('disabled','disabled'); $('#group-copy-ok-button').attr('disabled','disabled');
scope[list.name].every(function(row) { scope[list.name].every(function(row) {
if (row.checked === '1') { if (row.checked === 1) {
$('#group-copy-ok-button').removeAttr('disabled'); $('#group-copy-ok-button').removeAttr('disabled');
return false; return false;
} }
@ -1945,7 +1943,7 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', listGenerator.name
} }
else { else {
scope[list.name].every(function(row) { scope[list.name].every(function(row) {
if (row.checked === '1') { if (row.checked === 1) {
target = row; target = row;
return false; return false;
} }

View File

@ -906,22 +906,20 @@ angular.module('HostsHelper', [ 'RestServices', 'Utilities', listGenerator.name,
list = GroupList; list = GroupList;
scope[list.name].forEach( function(row, i) { scope[list.name].forEach( function(row, i) {
if (row.id === id) { if (row.id === id) {
if (row.checked === '0') { if (row.checked) {
scope[list.name][i].checked = '1';
scope[list.name][i].success_class = 'success'; scope[list.name][i].success_class = 'success';
} }
else { else {
scope[list.name][i].checked = '0';
scope[list.name][i].success_class = ''; scope[list.name][i].success_class = '';
} }
} else { } else {
scope[list.name][i].checked = '0'; scope[list.name][i].checked = 0;
scope[list.name][i].success_class = ''; scope[list.name][i].success_class = '';
} }
}); });
// Check if any rows are checked // Check if any rows are checked
scope[list.name].forEach(function(row) { scope[list.name].forEach(function(row) {
if (row.checked === '1') { if (row.checked) {
count++; count++;
} }
}); });
@ -945,7 +943,7 @@ angular.module('HostsHelper', [ 'RestServices', 'Utilities', listGenerator.name,
} }
else { else {
scope[list.name].every(function(row) { scope[list.name].every(function(row) {
if (row.checked === '1') { if (row.checked === 1) {
target = row; target = row;
return false; return false;
} }

View File

@ -277,22 +277,20 @@ export default
var count = 0; var count = 0;
scope[list.name].forEach( function(row, i) { scope[list.name].forEach( function(row, i) {
if (row.id === id) { if (row.id === id) {
if (row.checked === '0') { if (row.checked) {
scope[list.name][i].checked = '1';
scope[list.name][i].success_class = 'success'; scope[list.name][i].success_class = 'success';
} }
else { else {
scope[list.name][i].checked = '0';
scope[list.name][i].success_class = ''; scope[list.name][i].success_class = '';
} }
} else { } else {
scope[list.name][i].checked = '0'; scope[list.name][i].checked = 0;
scope[list.name][i].success_class = ''; scope[list.name][i].success_class = '';
} }
}); });
// Check if any rows are checked // Check if any rows are checked
scope[list.name].forEach(function(row) { scope[list.name].forEach(function(row) {
if (row.checked === '1') { if (row.checked) {
count++; count++;
} }
}); });

View File

@ -45,9 +45,8 @@ export default
var i, j, found; var i, j, found;
for (i = 0; i < scope[list.name].length; i++) { for (i = 0; i < scope[list.name].length; i++) {
if (scope[list.name][i].id === id) { if (scope[list.name][i].id === id) {
if ((scope[list.name][i].checked === "0" && !ischeckbox) || (scope[list.name][i].checked === "0" && ischeckbox)) { var control = scope[list.name][i];
// select the row if (ischeckbox && control.checked) {
scope[list.name][i].checked = '1';
scope[list.name][i].success_class = 'success'; scope[list.name][i].success_class = 'success';
// add selected object to the array // add selected object to the array
found = false; found = false;
@ -60,9 +59,7 @@ export default
if (!found) { if (!found) {
selected.push(scope[list.name][i]); selected.push(scope[list.name][i]);
} }
} else { } else if (ischeckbox) {
// unselect the row
scope[list.name][i].checked = '0';
scope[list.name][i].success_class = ''; scope[list.name][i].success_class = '';
// remove selected object from the array // remove selected object from the array