Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Fixed reconfigure button #8428

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 28 additions & 5 deletions app/controllers/service_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ def button
service_retire
when 'service_retire_now'
service_retire_now
when 'service_reconfigure'
service_reconfigure
end
end

Expand Down Expand Up @@ -58,13 +60,31 @@ def edit
drop_breadcrumb(:name => _("Edit Service\"%{name}\"") % {:name => @service.name}, :url => "/service/edit/#{@service.id}")
end

def service_reconfigure
def reconfigure_dialog
service = Service.find_by(:id => params[:id])
service_template = service.service_template
resource_action = service_template.resource_actions.find_by(:action => 'Reconfigure') if service_template

@right_cell_text = _("Reconfigure Service \"%{name}\"") % {:name => service.name}
service_template = ServiceTemplate.find_by(:id => service.service_template_id)
#resource_action = service_template.resource_actions.find_by(:action => 'Reconfigure') if service_template
resource_action = service_template.resource_actions.first
dialog_locals = {:resource_action_id => resource_action.id, :target_id => service.id}
@resource_action_id = resource_action.id
@target_id = service.id
@angular_form = true
@in_a_form = true
drop_breadcrumb(:name => _("Reconfigure Service\"%{name}\"") % {:name => service.name})
end

def service_reconfigure
service = Service.find_by(:id => params[:id])
# service_template = ServiceTemplate.find_by(:id => service.service_template_id)
# #resource_action = service_template.resource_actions.find_by(:action => 'Reconfigure') if service_template
# resource_action = service_template.resource_actions.first
# dialog_locals = {:resource_action_id => resource_action.id, :target_id => service.id}
# @resource_action_id = resource_action.id
# @target_id = service.id
# @angular_form = true
# @in_a_form = true
drop_breadcrumb(:name => _("Reconfigure Service\"%{name}\"") % {:name => service.name})
javascript_redirect(:action => 'reconfigure_dialog', :id => checked_item_id)
end

def service_form_fields
Expand Down Expand Up @@ -204,6 +224,8 @@ def set_right_cell_vars(action)
partial = "shared/dialogs/reconfigure_dialog"
header = @right_cell_text
action = nil
puts "params=====#{params.inspect}"
locals = params[:dialog_locals]
when "service_edit"
partial = "service_form"
header = _("Editing Service \"%{name}\"") % {:name => @service.name}
Expand All @@ -215,6 +237,7 @@ def set_right_cell_vars(action)
else
action = nil
end
locals ||= {}
return partial, action, header
end

Expand Down
4 changes: 2 additions & 2 deletions app/helpers/application_helper/toolbar/service_center.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ class ApplicationHelper::Toolbar::ServiceCenter < ApplicationHelper::Toolbar::Ba
'pficon pficon-edit fa-lg',
N_('Reconfigure the options of this Service'),
N_('Reconfigure this Service'),
:klass => ApplicationHelper::Button::GenericFeatureButton,
:options => {:feature => :reconfigure}
#:klass => ApplicationHelper::Button::GenericFeatureButton,
#:options => {:feature => :reconfigure}
),
]
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ ManageIQ.angular.app.controller('dialogUserReconfigureController', ['API', 'dial
};

function init(data) {
vm.dialogId = data.reconfigure_dialog[0].id;
vm.dialog = data.reconfigure_dialog[0];
if(data.reconfigure_dialog) {
vm.dialogId = data.reconfigure_dialog[0].id;
vm.dialog = data.reconfigure_dialog[0];
}
vm.dialogLoaded = true;
}

Expand Down
26 changes: 26 additions & 0 deletions app/views/service/_reconfigure_form.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
= resource_action_id
#main_div
.row.wrapper{"ng-controller" => "dialogUserReconfigureController as vm"}
.spinner{'ng-show' => "!vm.dialogLoaded"}

.col-md-12.col-lg-12{'ng-if' => 'vm.dialog'}
%dialog-user{"dialog" => "vm.dialog", "refresh-field" => "vm.refreshField(field)", "on-update" => "vm.setDialogData(data)", "reconfigure-mode" => true}

.clearfix
.pull-right.button-group{'ng-show' => "vm.dialogLoaded"}
%miq-button{:name => t = _("Submit"),
:title => t,
:alt => t,
:enabled => 'vm.saveable()',
'on-click' => "vm.submitButtonClicked()",
:primary => 'true'}
%miq-button{:name => t = _("Cancel"),
:title => t,
:alt => t,
:enabled => 'true',
'on-click' => "vm.cancelClicked($event)"}

:javascript
ManageIQ.angular.app.value('resourceActionId', #{ resource_action_id });
ManageIQ.angular.app.value('targetId', #{ target_id });
miq_bootstrap('.wrapper');
2 changes: 2 additions & 0 deletions app/views/service/reconfigure_dialog.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
= render :partial => "service/reconfigure_form", :locals => {:resource_action_id => @resource_action_id, :target_id => @target_id}
= @resource_action_id
2 changes: 2 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2736,6 +2736,7 @@
show
show_list
edit
reconfigure_dialog
ownership
tagging_edit
),
Expand All @@ -2745,6 +2746,7 @@
quick_search
reload
edit
reconfigure_dialog
show
button
show_list
Expand Down