Skip to content

Commit

Permalink
Added changes to show Catalog Item type in UI
Browse files Browse the repository at this point in the history
Show nice display value for Catalog Item type in list view, Catalog Item detail view and as read only text on the add/edit screens. Moved list of catalog item types out of @edit hash, we can directly reference the constant from views.

https://bugzilla.redhat.com/show_bug.cgi?id=1348239
  • Loading branch information
h-kataria committed Jan 19, 2017
1 parent 87a5fa1 commit faf9999
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 17 deletions.
2 changes: 2 additions & 0 deletions app/controllers/application_controller.rb
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
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
@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
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
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
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

0 comments on commit faf9999

Please sign in to comment.