diff --git a/app/models/rule/action.rb b/app/models/rule/action.rb index 00b66e2c..3316c415 100644 --- a/app/models/rule/action.rb +++ b/app/models/rule/action.rb @@ -11,6 +11,18 @@ class Rule::Action < ApplicationRecord executor.options end + def value_display + if value.present? + if options + options.find { |option| option.last == value }&.first + else + "" + end + else + "" + end + end + def executor rule.registry.get_executor!(action_type) end diff --git a/app/models/rule/condition.rb b/app/models/rule/condition.rb index e15115fe..13b622b5 100644 --- a/app/models/rule/condition.rb +++ b/app/models/rule/condition.rb @@ -35,6 +35,18 @@ class Rule::Condition < ApplicationRecord end end + def value_display + if value.present? + if options + options.find { |option| option.last == value }&.first + else + value + end + else + "" + end + end + def options filter.options end diff --git a/app/views/rules/_rule.html.erb b/app/views/rules/_rule.html.erb index 91f4bd92..caaee500 100644 --- a/app/views/rules/_rule.html.erb +++ b/app/views/rules/_rule.html.erb @@ -2,9 +2,25 @@
+ + If <%= rule.conditions.first.filter.label %> <%= rule.conditions.first.operator %> <%= rule.conditions.first.value_display %> + + + <% if rule.conditions.count > 1 %> + and <%= rule.conditions.count - 1 %> more <%= rule.conditions.count - 1 == 1 ? "condition" : "conditions" %> + <% end %> +
+ <% end %> +- <%= rule.actions.first.executor.label %> + <% if rule.actions.first.value && rule.actions.first.options %> + <%= rule.actions.first.executor.label %> to <%= rule.actions.first.value_display %> + <% else%> + <%= rule.actions.first.executor.label %> + <% end %> <% if rule.actions.count > 1 %>