app/views/chargeback_rate/_cb_rate_edit_table.html.haml
- url = url_for_only_path(:action => 'form_field_changed', :id => @edit[:rec_id] || "new")
- breakdown_present = @edit[:new][:details].any? { |d| d[:sub_metric].present? }
%table.table.table-bordered{:id => "chargeback_rate_edit_form"}
%thead
%tr
%th{:rowspan => "2"}= _('Group')
%th{:rowspan => "2"}
= _('Description')
%br
= _('(Column Name in Report)')
- if breakdown_present
%th{:rowspan => '2'}= _('Sub Metric')
%th{:rowspan => "2"}= _('Per Time')
%th{:rowspan => "2"}= _('Per Unit')
%th{:colspan => "2"}= _('Range')
= render :partial => 'cb_rate_currency'
%th{:rowspan => "2"}= _('Actions')
%tr
%th= _("Start")
%th= _("Finish")
%th= _("Fixed")
%th= _("Variable")
%tbody
- @edit[:new][:details].sort_by { |rd| [rd[:group], rd[:description], rd[:sub_metric].to_s] }.each_with_index do |detail, detail_index|
- @cur_group = detail[:group] if @cur_group.nil?
- if @cur_group != detail[:group]
- @cur_group = detail[:group]
%tr
%td{:colspan => "10", :style => "background-color: #f5f5f5;"}
- if params[:pressed] == "chargeback_rates_edit"
- detail_index = @edit[:new][:tiers].index { |x| x.detect { |tier_hash| tier_hash['chargeback_rate_detail_id'] == detail[:id] }.present? }
- num_tiers = @edit[:new][:tiers][detail_index].blank? ? "1" : @edit[:new][:tiers][detail_index].length.to_s
%tr.rdetail{:id => "rate_detail_row_#{detail_index}_0"}
%td{:rowspan => num_tiers}
= h(rate_detail_group(detail[:group]))
%td{:rowspan => num_tiers}
= detail[:description]
%br
= "(#{detail[:report_column_name]})"
- if breakdown_present
%td{:rowspan => num_tiers}
- sub_metrics = detail[:sub_metrics]
- if sub_metrics.present?
= detail[:sub_metric_human]
%td{:rowspan => num_tiers}
= select_tag("per_time_#{detail_index}",
options_for_select(@edit[:new][:per_time_types].invert, detail[:per_time]),
"data-miq_observe" => {:url => url}.to_json)
- measure = detail[:detail_measure]
- if measure.nil?
/if the rate detail don't have a metric associated, display the per_unit_display
%td{:rowspan => num_tiers}
= detail[:per_unit_display]
- else
/if the rate detail have a metric associated, display an options field with per_unit selected
%td{:rowspan => num_tiers}
= select_tag("per_unit_#{detail_index}", options_for_select(measure[:measures], detail[:per_unit]), "data-miq_observe" => {:url => url}.to_json)
= render :partial => 'cb_tier_edit_values', :locals => {:detail_index => detail_index, :url => url, :row_within_rate => 0}
%td.action-cell
= button_tag(_("Add"), :class => "btn btn-default", :alt => t = _("Add a new tier"), :title => t,
:onclick => "miqAjaxButton('#{url_for_only_path(:action => "tier_add",
:detail_index => detail_index,
:button => "add")}');")
- (1..num_tiers.to_i - 1).each do |tier_index|
- tier = @edit[:new][:tiers][detail_index][tier_index]
%tr.rdetail{:id => "rate_detail_row_#{detail_index}_#{tier_index}"}
= render :partial => 'cb_tier_edit_values', :locals => {:detail_index => detail_index, :url => url, :row_within_rate => tier_index}
%td.action-cell
= button_tag(_("Delete"), :class => "btn btn-default", :alt => t = _("Remove the tier"), :title => t,
:onclick => "miqAjaxButton('#{url_for_only_path(:action => "tier_remove",
:index => "#{detail_index}-#{tier_index}",
:button => "remove")}');")
:javascript
$('tbody tr.rdetail').hover( function(){hoverRowIn(this)}, function(row){hoverRowOut(this)});
function hoverRowIn(row) {
$("tr[id ^= '"+row.id.substr(0, row.id.lastIndexOf("_"))+"']").addClass("active");
}
function hoverRowOut(row) {
$("tr[id ^= '"+row.id.substr(0, row.id.lastIndexOf("_"))+"']").removeClass("active");
}