Skip to content

Commit

Permalink
Merge pull request #3747 from h-kataria/report_filter_secondary_expre…
Browse files Browse the repository at this point in the history
…ssion_fixed

Fixed Secondary filter to be added/edited correctly.
(cherry picked from commit e825c3d)

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1578400
  • Loading branch information
mzazrivec authored and simaishi committed May 15, 2018
1 parent cd57a6a commit 6b11a33
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 20 deletions.
4 changes: 2 additions & 2 deletions app/views/report/_form_expression_buttons.html.haml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
- report_id = @edit[:rpt_id] || 'new'
-# FIXME: alt/title incosistency
= link_to({:action => 'filter_change', :button => @expkey, :id => report_id},
= link_to({:action => 'filter_change', :button => exp_key, :id => report_id},
"data-miq_sparkle_on" => true,
"data-miq_sparkle_off" => true,
:remote => true,
Expand All @@ -12,7 +12,7 @@
= display_label
.spacer
- unless @edit[@expkey][:expression].key?('???')
- @edit[@expkey][:exp_table].each do |token|
- @edit[exp_key == "record_filter" ? :record_filter : :display_filter][:exp_table].each do |token|
- single_token = [token].flatten.first
- if %w(AND OR ( )).include?(single_token)
%font{:color => "black"}
Expand Down
34 changes: 18 additions & 16 deletions app/views/report/_form_filter.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,21 @@
= render :partial => 'layouts/exp_editor'
- else
= render :partial => 'report/form_expression_buttons',
:locals => {:create_label => _('Create Record Filter'),
:display_label => _('Edit Record Filter')}
%hr
.form-horizontal
- unless @edit[:display_filter][:exp_available_fields].empty? && @edit[:display_filter][:exp_available_tags].empty?
-# Expression editor for the display filter
%h3= _('Secondary (Display) Filter - Filters the rows based on child table fields')
.form-group
%label.control-label.col-md-2
.col-md-8
- if @expkey == :display_filter
= render :partial => 'layouts/exp_editor'
- else
= render :partial => 'report/form_expression_buttons',
:locals => {:create_label => _('Create Display Filter'),
:display_label => _('Edit Display Filter')}
:locals => {:create_label => _('Create Record Filter'),
:display_label => _('Edit Record Filter'),
:exp_key => 'record_filter'}
%hr
.form-horizontal
- unless @edit[:display_filter][:exp_available_fields].empty? && @edit[:display_filter][:exp_available_tags].empty?
-# Expression editor for the display filter
%h3= _('Secondary (Display) Filter - Filters the rows based on child table fields')
.form-group
%label.control-label.col-md-2
.col-md-8
- if @expkey == :display_filter
= render :partial => 'layouts/exp_editor'
- else
= render :partial => 'report/form_expression_buttons',
:locals => {:create_label => _('Create Display Filter'),
:display_label => _('Edit Display Filter'),
:exp_key => 'display_filter'}
6 changes: 4 additions & 2 deletions spec/views/report/_form_expression_buttons.html.haml_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
it 'renders form expression buttons for other report and Edit Display Filter button' do
render :partial => 'report/form_expression_buttons',
:locals => {:create_label => _('Create Display Filter'),
:display_label => _('Edit Display Filter')}
:display_label => _('Edit Display Filter'),
:exp_key => "record_filter"}
expect(rendered).to match(/Edit Display Filter/)
end

Expand All @@ -23,7 +24,8 @@
it 'renders form expression buttons for other report and Create Display Filter button' do
render :partial => 'report/form_expression_buttons',
:locals => {:create_label => _('Create Display Filter'),
:display_label => _('Edit Display Filter')}
:display_label => _('Edit Display Filter'),
:exp_key => "display_filter"}
expect(rendered).to match(/Create Display Filter/)
end
end
Expand Down

0 comments on commit 6b11a33

Please sign in to comment.