diff --git a/src/sunstone/public/app/tabs/vmgroup-tab/utils/affinity-role-tab.js b/src/sunstone/public/app/tabs/vmgroup-tab/utils/affinity-role-tab.js index ac755054e1..bbfd02bde4 100644 --- a/src/sunstone/public/app/tabs/vmgroup-tab/utils/affinity-role-tab.js +++ b/src/sunstone/public/app/tabs/vmgroup-tab/utils/affinity-role-tab.js @@ -19,12 +19,9 @@ define(function(require) { var Locale = require('utils/locale'); var Tips = require('utils/tips'); var GroupRoleAffinity = require('tabs/vmgroup-tab/utils/group-role-affinity'); - var TemplateHTML = require('hbs!./affinity-role-tab/html'); var Notifier = require('utils/notifier'); - - function AffinityRoleTab(list_roles) { this.list_roles = list_roles; return this; @@ -39,6 +36,7 @@ define(function(require) { 'refresh': _refresh, 'removeRole': _remove_role }; + AffinityRoleTab.prototype.constructor = AffinityRoleTab; return AffinityRoleTab; @@ -54,9 +52,9 @@ define(function(require) { $("#tf_btn_host_anti_affined").bind("click", function(){ var rolesSt = ""; var numRoles = 0; - $(".roles",context).each(function(){ - if($(this)[0].checked){ - rolesSt+= $(this)[0].id+","; + $(".roles", context).each(function(){ + if($(this)[0].selected){ + rolesSt += $(this)[0].id + ","; numRoles++; } }); @@ -64,17 +62,16 @@ define(function(require) { _add_group_affinity_box(rolesSt.slice(0,-1), context, group_roles_index, that.group_roles_affinity, "ANTI_AFFINED"); group_roles_index++; } - else{ + else Notifier.notifyError(Locale.tr("You have to choose at least two roles.")); - } }); $("#tf_btn_host_affined").bind("click", function(){ var rolesSt = ""; var numRoles = 0; $(".roles",context).each(function(){ - if($(this)[0].checked){ - rolesSt+= $(this)[0].id+","; + if($(this)[0].selected){ + rolesSt += $(this)[0].id + ","; numRoles++; } }); @@ -82,13 +79,13 @@ define(function(require) { _add_group_affinity_box(rolesSt.slice(0,-1), context, group_roles_index, that.group_roles_affinity, "AFFINED"); group_roles_index++; } - else{ + else Notifier.notifyError(Locale.tr("You have to choose at least two roles.")); - } }); } function _onShow(){ + } function _retrieve(context){ @@ -116,11 +113,11 @@ define(function(require) { if(affinity == "AFFINED" || affinity == "ANTI_AFFINED"){ if(Array.isArray(value)){ for(dbs in value){ - _add_group_affinity_box(value[dbs],context, group_roles_index, that.group_roles_affinity, affinity); + _add_group_affinity_box(value[dbs], context, group_roles_index, that.group_roles_affinity, affinity); group_roles_index++; } } - else{ + else { _add_group_affinity_box(value, context, group_roles_index, that.group_roles_affinity, affinity); group_roles_index++; } @@ -133,18 +130,16 @@ define(function(require) { if(name){ var index_role = this.list_roles.indexOf(oldName); if(index_role != -1){ - var input = $("#list_roles_select #"+oldName); + var input = $("#list_roles_select #" + oldName); input[0].id = name; input[0].value = name; - var label = $("#label_"+oldName)[0]; - label.id = "label_"+name; - label.innerHTML = name; + input[0].innerHTML = name; for(group in this.group_roles_affinity){ var index = this.group_roles_affinity[group].equal(oldName); if(index != -1){ this.group_roles_affinity[group].changeGroup(index, name); $("#group_role_" + group)[0].innerHTML = this.group_roles_affinity[group].html(); - $(".group_roles").on("click", "i.remove_group_affinity", function() { + $(".group_roles").on("click", "i.remove_group_affinity", function() { $(this.parentElement.parentElement).remove(); delete that.group_roles_affinity[index]; return false; @@ -153,13 +148,15 @@ define(function(require) { } this.list_roles[index_role] = name; } - else{ + else { this.list_roles.push(name); - var html = "