diff --git a/app/controllers/application_controller/filter/expression.rb b/app/controllers/application_controller/filter/expression.rb index 2412a457457..382cedaefec 100644 --- a/app/controllers/application_controller/filter/expression.rb +++ b/app/controllers/application_controller/filter/expression.rb @@ -1,4 +1,8 @@ module ApplicationController::Filter + EXP_TODAY = "Today".freeze + EXP_FROM = "FROM".freeze + EXP_IS = "IS".freeze + Expression = Struct.new( :alias, :expression, diff --git a/app/controllers/report_controller/reports/editor.rb b/app/controllers/report_controller/reports/editor.rb index 2ef155a6510..4275b03e3fb 100644 --- a/app/controllers/report_controller/reports/editor.rb +++ b/app/controllers/report_controller/reports/editor.rb @@ -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 diff --git a/app/helpers/ui_constants.rb b/app/helpers/ui_constants.rb index ab2d0e298ec..85d8491d9b5 100644 --- a/app/helpers/ui_constants.rb +++ b/app/helpers/ui_constants.rb @@ -8,11 +8,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 diff --git a/app/views/layouts/exp_atom/_edit_field.html.haml b/app/views/layouts/exp_atom/_edit_field.html.haml index 56917d184a9..864915902cd 100644 --- a/app/views/layouts/exp_atom/_edit_field.html.haml +++ b/app/views/layouts/exp_atom/_edit_field.html.haml @@ -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 diff --git a/app/views/layouts/exp_atom/_edit_find.html.haml b/app/views/layouts/exp_atom/_edit_find.html.haml index 8be009ba4d1..4a2f1defdc2 100644 --- a/app/views/layouts/exp_atom/_edit_find.html.haml +++ b/app/views/layouts/exp_atom/_edit_find.html.haml @@ -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", @@ -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 : ""