app/views/chargeback_assignment/_form.html.haml
- nothing = "<#{_('Nothing')}>"
- url = url_for_only_path(:action => 'form_field_changed', :id => @edit[:new][:type])
= render :partial => "layouts/flash_msg"
%h1
= @title
%h3
= _('Basic Info')
.form-horizontal
.form-group
%label.col-md-2.control-label
= _('Assign To')
.col-md-8
- options = TermOfServiceHelper::ASSIGN_TOS[@edit[:new][:type] == "Compute" ? "chargeback_compute".to_sym : "chargeback_storage".to_sym].map do |k, v|
- [_(v), k]
= select_tag("cbshow_typ", options_for_select([[nothing, "nil"]] + options, @edit[:new][:cbshow_typ]),
"aria-label" => _("Select term of service type"),
"data-miq_sparkle_on" => true, "data-miq_sparkle_off" => true, :class => "selectpicker")
:javascript
miqInitSelectPicker();
miqSelectPickerEvent("cbshow_typ", "#{url}", {callback: function() {
if ($('#cbshow_typ').val() == "container_image-labels") {
// trigger dropdown change for when container_image-labels is picked so that the default image will be loaded to the view.
$("#cblabel_key").trigger('change');
}
}});
- if !@edit[:new][:cbshow_typ].blank? && @edit[:new][:cbshow_typ].ends_with?("-tags")
.form-group
%label.col-md-2.control-label
= _('Tag Category')
.col-md-8
- options = Array(@edit[:cb_assign][:cats].invert).sort_by { |a| a.first.downcase }
= select_tag("cbtag_cat", options_for_select([["<#{_('Choose a Category')}>", ""]] + options, @edit[:new][:cbtag_cat].to_s),
"aria-label" => _("Select tag category"),
"data-miq_sparkle_on" => true, "data-miq_sparkle_off" => true, :class => "selectpicker")
:javascript
miqInitSelectPicker();
miqSelectPickerEvent("cbtag_cat", "#{url}")
- if !@edit[:new][:cbshow_typ].blank? && @edit[:new][:cbshow_typ].ends_with?("-labels")
.form-group
%label.col-md-2.control-label
= _('Image Labels')
.col-md-8
- default_options = Array(@edit[:cb_assign][:docker_label_default_keys].invert).sort_by { |a| a.first.downcase }
- options = Array(@edit[:cb_assign][:docker_label_keys].invert).sort_by { |a| a.first.downcase }
= select_tag("cblabel_key", options_for_select(default_options + options, @edit[:new][:cblabel_key].to_s),
"aria-label" => _("Select options for image labels"),
"data-miq_sparkle_on" => true, "data-miq_sparkle_off" => true, :class => "selectpicker")
:javascript
miqInitSelectPicker();
miqSelectPickerEvent("cblabel_key", "#{url}")
- unless @edit[:new][:cbshow_typ].nil? || @edit[:new][:cbshow_typ] == "nil"
- show_type = @edit[:new][:cbshow_typ]
- if !(show_type.ends_with?("-tags") || show_type.ends_with?("-labels")) || @edit[:new][:cbtag_cat].present? || @edit[:new][:cblabel_key].present?
%hr
- if @edit[:new][:cbshow_typ] == "tenant"
%h3
= _('Selections')
%table.table.table-bordered.table-hover.table-treegrid
%thead
%tr
%th= _('Name')
%th= _('Rate')
%tbody
- @edit[:cb_assign][:hierarchy].sort_by(&:first).each do |id, data|
%tr.collapsed{:id => "tenant_#{id}"}
%td.treegrid-node
= h(data[:name])
%td
- options = @edit[:cb_rates].invert.sort
= select_tag("#{@edit[:new][:cbshow_typ]}__#{id}",
options_for_select([[nothing, "nil"]] + options, @edit[:new]["#{@edit[:new][:cbshow_typ]}__#{id}".to_sym].to_s),
"aria-label" => _("Select rate"),
"data-miq_sparkle_on" => true, "data-miq_sparkle_off" => true, :class => "selectpicker")
:javascript
miqInitSelectPicker();
miqSelectPickerEvent("#{@edit[:new][:cbshow_typ]}__#{id}", "#{url}")
- data[:subtenant].each do |tenant|
%tr{:id => "tenant_#{tenant[:id]}", :'data-parent' => "#tenant_#{tenant[:parent]}"}
%td.treegrid-node
= h(tenant[:name])
%td
- options = @edit[:cb_rates].invert.sort
= select_tag("#{@edit[:new][:cbshow_typ]}__#{tenant[:id]}",
options_for_select([[nothing, "nil"]] + options, @edit[:new]["#{@edit[:new][:cbshow_typ]}__#{tenant[:id]}".to_sym].to_s),
"aria-label" => _("Select rate for selections"),
"data-miq_sparkle_on" => true, "data-miq_sparkle_off" => true, :class => "selectpicker")
:javascript
miqInitSelectPicker();
miqSelectPickerEvent("#{@edit[:new][:cbshow_typ]}__#{tenant[:id]}", "#{url}")
:javascript
$('.table-treegrid').treegrid({})
- elsif @edit[:new][:cbshow_typ].ends_with?("-tags")
- if @edit[:current_assignment].try(:first).try(:[], :tag) && "#{@edit[:current_assignment].try(:first).try(:[], :tag).second}-tags" == @edit[:new][:cbshow_typ]
%h3
= _('Saved Items')
%table.table.table-bordered.table-striped
%thead
%tr
%th= _('Tag Category')
%th= _('Tag Name')
%th= _('Rate')
- @edit[:current_assignment].sort_by{|x| x[:tag].first.parent.description }.each do |value|
%tr
%td
= value[:tag].first.parent.description
%td
= value[:tag].first.description
%td
= value[:cb_rate].description
%hr
%h3
= _('Selections')
%table.table.table-bordered.table-striped
%thead
%tr
%th= _('Name')
%th= _('Rate')
%tbody
- @edit[:cb_assign][:tags][@edit[:new][:cbtag_cat].to_i].invert.sort_by { |a| a.first.downcase }.each do |tag, id|
%tr
%td
= h(tag)
%td
- options = @edit[:cb_rates].invert.sort
= select_tag("#{@edit[:new][:cbshow_typ]}__#{id}",
options_for_select([[nothing, "nil"]] + options, @edit[:new]["#{@edit[:new][:cbshow_typ]}__#{id}".to_sym].to_s),
"aria-label" => _("select rate for saved items"),
"data-miq_sparkle_on" => true, "data-miq_sparkle_off" => true, :class => "selectpicker")
:javascript
miqInitSelectPicker();
miqSelectPickerEvent("#{@edit[:new][:cbshow_typ]}__#{id}", "#{url}")
- elsif @edit[:new][:cbshow_typ].ends_with?("-labels")
- if @edit[:current_assignment].try(:first).try(:[], :label)
%h3
= _('Saved Items')
%table.table.table-bordered.table-striped
%thead
%tr
%th= _('Section')
%th= _('Label')
%th= _('Rate')
- @edit[:current_assignment].sort_by{|x| x[:label].first.name }.each do |value|
%tr
%td
= value[:label].first.name
%td
= value[:label].first.value
%td
= value[:cb_rate].description
%hr
%h3
= _('Selections')
%table.table.table-bordered.table-striped
%thead
%tr
%th= _('Name')
%th= _('Rate')
%tbody
- @edit[:cb_assign][:docker_label_values].invert.sort_by { |a| a.first.downcase }.each do |value, id|
%tr
%td
= h(value)
%td
- options = @edit[:cb_rates].invert.sort
= select_tag("#{@edit[:new][:cbshow_typ]}__#{id}",
options_for_select([[nothing, "nil"]] + options, @edit[:new]["#{@edit[:new][:cbshow_typ]}__#{id}".to_sym].to_s),
"aria-label" => _("select Rate1"),
"data-miq_sparkle_on" => true, "data-miq_sparkle_off" => true, :class => "selectpicker")
:javascript
miqInitSelectPicker();
miqSelectPickerEvent("#{@edit[:new][:cbshow_typ]}__#{id}", "#{url}")
- else
%h3
= _('Selections')
%table.table.table-bordered.table-striped
%thead
%tr
%th= _('Name')
%th= _('Rate')
%tbody
- @edit[:cb_assign][:cis].invert.sort_by { |a| a.first.downcase }.each do |ci, id|
%tr
%td
= h(ci)
%td
- options = @edit[:cb_rates].invert.sort
= select_tag("#{@edit[:new][:cbshow_typ]}__#{id}",
options_for_select([[nothing, "nil"]] + options, @edit[:new]["#{@edit[:new][:cbshow_typ]}__#{id}".to_sym].to_s),
"aria-label" => _("select Rate2"),
"data-miq_sparkle_on" => true, "data-miq_sparkle_off" => true, :class => "selectpicker")
:javascript
miqInitSelectPicker();
miqSelectPickerEvent("#{@edit[:new][:cbshow_typ]}__#{id}", "#{url}")
= render :partial => '/layouts/edit_form_buttons',
:locals => {:action_url => "update", :record_id => @edit[:new][:type], :ajax_buttons => true, :no_cancel_button => true}