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

Added changes to show Catalog Item type #165

Merged
Merged
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
2 changes: 2 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -880,6 +880,8 @@ def view_to_hash(view)
celltext = Dictionary.gettext(row[col], :type => :model, :notfound => :titleize)
when 'approval_state'
celltext = _(PROV_STATES[row[col]])
when 'prov_type'
celltext = row[col] ? _(ServiceTemplate::CATALOG_ITEM_TYPES[row[col]]) : ''
when "result"
new_row[:cells] << {:span => result_span_class(row[col]), :text => row[col].titleize}
when "severity"
Expand Down
16 changes: 0 additions & 16 deletions app/controllers/catalog_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ def atomic_st_edit
@edit[:new] ||= {}
@edit[:current] ||= {}
@edit[:key] = "prov_edit__new"
@edit[:st_prov_types] = catalog_item_types
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should not be putting constants in the session. I cannot imagine a reason to do this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@martinpovolny moved constant out of session.

@edit[:new][:st_prov_type] = @record.prov_type if @record.prov_type.present?
# set name and description for ServiceTemplate record
Expand All @@ -127,21 +126,6 @@ def atomic_st_edit
end
end

def catalog_item_types
{
"amazon" => "Amazon",
"azure" => "Azure",
"generic" => "Generic",
"generic_orchestration" => "Orchestration",
"generic_ansible_tower" => "AnsibleTower",
"google" => "Google",
"microsoft" => "SCVMM",
"openstack" => "OpenStack",
"redhat" => "RHEV",
"vmware" => "VMware"
}
end

def atomic_form_field_changed
# need to check req_id in session since we are using common code for prov requests and atomic ST screens
id = session[:edit][:req_id] || "new"
Expand Down
7 changes: 7 additions & 0 deletions app/views/catalog/_form_basic_info.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@
:class => "selectpicker")
:javascript
miqSelectPickerEvent('dialog_id', '#{url}')
- if @edit[:new][:st_prov_type]
.form-group
%label.col-md-2.control-label
= _('Item Type')
.col-md-4
%p.form-control-static
= h(ServiceTemplate::CATALOG_ITEM_TYPES[@edit[:new][:st_prov_type]])
- if @edit[:new][:st_prov_type] == "generic"
.form-group
%label.col-md-2.control-label
Expand Down
6 changes: 6 additions & 0 deletions app/views/catalog/_sandt_tree_show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@
= _('Dialog')
.col-md-8
= h(@sb[:dialog_label])
- if @record.prov_type
.form-group
%label.col-md-2.control-label
= _('Item Type')
.col-md-8
= h(ServiceTemplate::CATALOG_ITEM_TYPES[@record.prov_type])
- if @record.prov_type == "generic"
.form-group
%label.col-md-2.control-label
Expand Down
2 changes: 1 addition & 1 deletion app/views/catalog/_st_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
.form-group
%label.col-md-2.control-label= _('Catalog Item Type')
.col-md-8
- array = Array(@edit[:st_prov_types].invert).sort_by { |a| a.first.downcase }
- array = Array(ServiceTemplate::CATALOG_ITEM_TYPES.invert).sort_by { |a| a.first.downcase }
= select_tag('st_prov_type',
options_for_select(([["<#{_('Choose')}>",nil]]) + array, nil),
"data-miq_sparkle_on" => true,
Expand Down