mirror of
https://github.com/we-promise/sure.git
synced 2026-04-19 12:04:08 +00:00
Rules: Fix no action conditions (#447)
* Fix Rules page when no action on rule * Reject new rules without actions * Rule with no action translation * Easy one to keep translations going * Fix tests * Learn something new every day --------- Co-authored-by: Juan José Mata <juanjo.mata@gmail.com>
This commit is contained in:
@@ -155,14 +155,14 @@ module LanguagesHelper
|
||||
|
||||
# Locales with complete/extensive translations
|
||||
SUPPORTED_LOCALES = [
|
||||
"en", # English - 61 translation files
|
||||
"en", # English - 62 translation files
|
||||
"de", # German - 62 translation files
|
||||
"es", # Spanish - 60 translation files
|
||||
"tr", # Turkish - 57 translation files
|
||||
"nb", # Norwegian Bokmål - 56 translation files
|
||||
"ca", # Catalan - 56 translation files
|
||||
"ro", # Romanian - 61 translation files
|
||||
"pt-BR" # Brazilian Portuguese - 60 translation files
|
||||
"es", # Spanish - 61 translation files
|
||||
"tr", # Turkish - 58 translation files
|
||||
"nb", # Norwegian Bokmål - 57 translation files
|
||||
"ca", # Catalan - 57 translation files
|
||||
"ro", # Romanian - 62 translation files
|
||||
"pt-BR" # Brazilian Portuguese - 60 translation files
|
||||
].freeze
|
||||
|
||||
COUNTRY_MAPPING = {
|
||||
|
||||
@@ -101,7 +101,7 @@ class Rule < ApplicationRecord
|
||||
end
|
||||
|
||||
def min_actions
|
||||
return if new_record? && actions.empty?
|
||||
return if new_record? && !actions.empty?
|
||||
|
||||
if actions.reject(&:marked_for_destruction?).empty?
|
||||
errors.add(:base, "must have at least one action")
|
||||
|
||||
@@ -30,10 +30,14 @@
|
||||
</div>
|
||||
<p class="flex items-center flex-wrap gap-1.5 m-0">
|
||||
<span class="px-2 py-1 border border-secondary rounded-full">
|
||||
<% if rule.actions.first.value && rule.actions.first.options %>
|
||||
<%= rule.actions.first.executor.label %> to <%= rule.actions.first.value_display %>
|
||||
<% if rule.actions.first.nil? %>
|
||||
<%= t("rules.no_action") %>
|
||||
<% else %>
|
||||
<%= 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 %>
|
||||
<% end %>
|
||||
</span>
|
||||
<% if rule.actions.count > 1 %>
|
||||
|
||||
Reference in New Issue
Block a user