Skip to content

Commit

Permalink
Merge pull request #2158 from europ/remove-ui-constants-58
Browse files Browse the repository at this point in the history
Remove EXP_TODAY, EXP_FROM, EXP_IS from UiConstants
  • Loading branch information
mzazrivec authored Sep 11, 2017
2 parents 14524e4 + 2a85010 commit d1fb3fa
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 9 deletions.
4 changes: 4 additions & 0 deletions app/controllers/application_controller/filter/expression.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
module ApplicationController::Filter
EXP_TODAY = "Today".freeze
EXP_FROM = "FROM".freeze
EXP_IS = "IS".freeze

Expression = Struct.new(
:alias,
:expression,
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/report_controller/reports/editor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ def gfv_key_style(key, value)
elsif value.include?("NIL") || value.include?("EMPTY")
@edit[:new][:col_options][field_name][:style][s_idx].delete(:value) # Remove value key
elsif [:datetime, :date].include?(field_data_type)
@edit[:new][:col_options][field_name][:style][s_idx][:value] = EXP_TODAY # Set default date value
@edit[:new][:col_options][field_name][:style][s_idx][:value] = ApplicationController::Filter::EXP_TODAY # Set default date value
elsif [:boolean].include?(field_data_type)
@edit[:new][:col_options][field_name][:style][s_idx][:value] = true # Set default boolean value
else
Expand Down
5 changes: 0 additions & 5 deletions app/helpers/ui_constants.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@ module UiConstants
(1..6).each { |a| SNAPSHOT_AGES[a.days.to_i] = (a.to_s + (a < 2 ? _(" Day") : _(" Days"))) }
(1..4).each { |a| SNAPSHOT_AGES[a.weeks.to_i] = (a.to_s + (a < 2 ? _(" Week") : _(" Weeks"))) }

# Expression constants
EXP_TODAY = "Today"
EXP_FROM = "FROM"
EXP_IS = "IS"

end

# Make these constants globally available
Expand Down
2 changes: 1 addition & 1 deletion app/views/layouts/exp_atom/_edit_field.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
"data-miq_sparkle_on" => true,
"data-miq_sparkle_off" => true)
- if @edit[@expkey][:exp_key] == EXP_FROM && @edit[@expkey][:exp_value][0]
- if @edit[@expkey][:exp_key] == ApplicationController::Filter::EXP_FROM && @edit[@expkey][:exp_value][0]
%br
= _('THROUGH')
%br
Expand Down
4 changes: 2 additions & 2 deletions app/views/layouts/exp_atom/_edit_find.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"data-miq_sparkle_on" => true,
"data-miq_sparkle_off" => true)

- if @edit[@expkey][:exp_skey] == EXP_FROM && @edit[@expkey][:exp_value][0]
- if @edit[@expkey][:exp_skey] == ApplicationController::Filter::EXP_FROM && @edit[@expkey][:exp_value][0]
= ('THROUGH')
- if @edit[@expkey][:val1][:date_format] == 's'
= datepicker_input_tag("miq_date_1_1",
Expand Down Expand Up @@ -184,7 +184,7 @@
"data-miq_sparkle_on" => true,
"data-miq_sparkle_off" => true)

- if @edit[@expkey][:exp_ckey] == EXP_FROM && @edit[@expkey][:exp_cvalue][0]
- if @edit[@expkey][:exp_ckey] == ApplicationController::Filter::EXP_FROM && @edit[@expkey][:exp_cvalue][0]
= _('THROUGH')
- if @edit[@expkey][:val2][:date_format] == 's'
- val = @edit[@expkey][:exp_cvalue][1] ? @edit[@expkey][:exp_cvalue][1].split(" ").first : ""
Expand Down

0 comments on commit d1fb3fa

Please sign in to comment.