Skip to content

Commit

Permalink
Address Rubocop and CC
Browse files Browse the repository at this point in the history
  • Loading branch information
AparnaKarve committed Oct 31, 2017
1 parent b2a2d85 commit 0622cd8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,6 @@ function mainCustomButtonFormController(API, miqService, $q, $http) {
var dataPromise = API.get('/api/custom_buttons/' + vm.customButtonRecordId + '?attributes=resource_action')
.then(getCustomButtonFormData)
.catch(miqService.handleFailure);


} else {
vm.newRecord = true;
vm.modelCopy = angular.copy( vm.customButtonModel );
Expand Down Expand Up @@ -166,10 +164,11 @@ function mainCustomButtonFormController(API, miqService, $q, $http) {
ae_attributes: vm.customButtonModel.resource_action.ae_attributes,
};

if (vm.customButtonModel.current_visibility === 'role')
vm.customButtonModel.roles = _.pluck(_.filter(vm.customButtonModel.available_roles, function(role) {
if (vm.customButtonModel.current_visibility === 'role') {
vm.customButtonModel.roles = _.pluck(_.filter(vm.customButtonModel.available_roles, function(role) {
return role.value === true;
}), 'name');
}

vm.customButtonModel.visibility = {
roles: vm.customButtonModel.roles,
Expand Down Expand Up @@ -197,7 +196,7 @@ function mainCustomButtonFormController(API, miqService, $q, $http) {
$http.post('/generic_object_definition/add_button_in_group/' + vm.customButtonGroupRecordId + '?button_id=' + response.results[0].id)
.then(miqService.redirectBack.bind(vm, saveMsgBtnInGrp, 'success', vm.redirectUrl))
.catch(miqService.handleFailure);
})
});
} else {
API[method](url, saveObject)
.then(miqService.redirectBack.bind(vm, saveMsg, 'success', vm.redirectUrl))
Expand Down Expand Up @@ -228,7 +227,7 @@ function mainCustomButtonFormController(API, miqService, $q, $http) {

optionsPromise.then(function() {
if (vm.customButtonModel.current_visibility === 'role') {
_.forEach(vm.customButtonModel.available_roles, function (role, index) {
_.forEach(vm.customButtonModel.available_roles, function(role, index) {
if (_.includes(response.visibility.roles, role.name)) {
vm.customButtonModel.available_roles[index].value = true;
}
Expand Down Expand Up @@ -279,10 +278,6 @@ function mainCustomButtonFormController(API, miqService, $q, $http) {
_.forEach(response.data.custom_button_types, function(name, id) {
vm.button_types.push({id: id, name: name});
});

_.forEach(response.data.distinct_instances_across_domains, function(item) {
vm.ae_instances.push({id: item, name: item});
});
}

function getServiceDialogs(response) {
Expand Down
8 changes: 6 additions & 2 deletions app/controllers/generic_object_definition_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ def button
tag(GenericObject)
return
end
button_actions
end

def button_actions
javascript_redirect(
case params[:pressed]
when 'generic_object_definition_new'
Expand Down Expand Up @@ -192,7 +196,7 @@ def custom_button_group_node_info
@custom_button_group_node = true
@record = CustomButtonSet.find(from_cid(node.split("-").last))
@right_cell_text = _("Custom Button Set %{record_name}") % {:record_name => @record.name}
rescue Exception => _err
rescue StandardError => _err
root_node_info
end

Expand All @@ -201,7 +205,7 @@ def custom_button_node_info
@custom_button_node = true
@record = CustomButton.find(from_cid(node.split("-").last))
@right_cell_text = _("Custom Button %{record_name}") % {:record_name => @record.name}
rescue Exception => _err
rescue StandardError => _err
root_node_info
end

Expand Down

0 comments on commit 0622cd8

Please sign in to comment.