1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-08-02 20:15:22 +02:00

Improve rules - add name, allow sorting, improve UI (#2177)

* Add ability to name a rule

* Add sorting by name and date,

* Improve rule page and form design

* Small header tweak

* Improve sorting click areas by including icon

* Fix brakeman

* Use icon helper instead of lucide_icon helper

* Fix double headers with new DialogComponent

* Use updated_at for sorting instead of created_at

* Use copy-plus icon for compound rules

* Remove icons and change IF/THEN/FOR font in edit form

* Use text-secondary on disabled rules

* First pass at redesigning the sorting menu

* New rule list

* Borders instead of shadows

* Apply proper text color to TO in edit form

* Improve dark mode with proper background color classes

* Use border-secondary

* Add touch: true to conditions and actions of a rule, so updated_at works as expected

* Fix db schema

* Change sort direction to be a LinkComponent outside of the form for better sort behavior

* Clean up dropdown design to match figma

* Match tags/categories design

* Fix name text color, add bg-divider background for dividers

* Fix family subscription tests (thanks zach!)
This commit is contained in:
Alex Hatzenbuhler 2025-05-13 14:53:13 -05:00 committed by GitHub
parent 050d5ebaad
commit bebe7b40d6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 176 additions and 79 deletions

View file

@ -8,7 +8,10 @@ class Rule < ApplicationRecord
accepts_nested_attributes_for :conditions, allow_destroy: true
accepts_nested_attributes_for :actions, allow_destroy: true
before_validation :normalize_name
validates :resource_type, presence: true
validates :name, length: { minimum: 1 }, allow_nil: true
validate :no_nested_compound_conditions
# Every rule must have at least 1 action
@ -99,4 +102,8 @@ class Rule < ApplicationRecord
end
end
end
def normalize_name
self.name = nil if name.is_a?(String) && name.strip.empty?
end
end

View file

@ -1,5 +1,5 @@
class Rule::Action < ApplicationRecord
belongs_to :rule
belongs_to :rule, touch: true
validates :action_type, presence: true

View file

@ -1,5 +1,5 @@
class Rule::Condition < ApplicationRecord
belongs_to :rule, optional: -> { where.not(parent_id: nil) }
belongs_to :rule, touch: true, optional: -> { where.not(parent_id: nil) }
belongs_to :parent, class_name: "Rule::Condition", optional: true, inverse_of: :sub_conditions
has_many :sub_conditions, class_name: "Rule::Condition", foreign_key: :parent_id, dependent: :destroy, inverse_of: :parent