mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-28 01:29:39 +02:00
Add more descriptive labels to rule rows
This commit is contained in:
parent
04ee1e73be
commit
bcfbc4b324
3 changed files with 41 additions and 1 deletions
|
@ -11,6 +11,18 @@ class Rule::Action < ApplicationRecord
|
||||||
executor.options
|
executor.options
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def value_display
|
||||||
|
if value.present?
|
||||||
|
if options
|
||||||
|
options.find { |option| option.last == value }&.first
|
||||||
|
else
|
||||||
|
""
|
||||||
|
end
|
||||||
|
else
|
||||||
|
""
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def executor
|
def executor
|
||||||
rule.registry.get_executor!(action_type)
|
rule.registry.get_executor!(action_type)
|
||||||
end
|
end
|
||||||
|
|
|
@ -35,6 +35,18 @@ class Rule::Condition < ApplicationRecord
|
||||||
end
|
end
|
||||||
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
|
def options
|
||||||
filter.options
|
filter.options
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,9 +2,25 @@
|
||||||
|
|
||||||
<div class="flex justify-between items-center gap-4 bg-white shadow-border-xs rounded-md p-4">
|
<div class="flex justify-between items-center gap-4 bg-white shadow-border-xs rounded-md p-4">
|
||||||
<div class="text-sm space-y-1.5">
|
<div class="text-sm space-y-1.5">
|
||||||
|
<% if rule.conditions.any? %>
|
||||||
|
<p class="flex items-center flex-wrap gap-1.5">
|
||||||
|
<span class="px-2 py-1 border border-alpha-black-200 rounded-full">
|
||||||
|
If <%= rule.conditions.first.filter.label %> <%= rule.conditions.first.operator %> <%= rule.conditions.first.value_display %>
|
||||||
|
</span>
|
||||||
|
|
||||||
|
<% if rule.conditions.count > 1 %>
|
||||||
|
and <%= rule.conditions.count - 1 %> more <%= rule.conditions.count - 1 == 1 ? "condition" : "conditions" %>
|
||||||
|
<% end %>
|
||||||
|
</p>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<p class="flex items-center flex-wrap gap-1.5">
|
<p class="flex items-center flex-wrap gap-1.5">
|
||||||
<span class="px-2 py-1 border border-alpha-black-200 rounded-full">
|
<span class="px-2 py-1 border border-alpha-black-200 rounded-full">
|
||||||
<%= 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 %>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<% if rule.actions.count > 1 %>
|
<% if rule.actions.count > 1 %>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue