mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-08-05 05:25:24 +02:00
Scaffold out rules domain
This commit is contained in:
parent
b2d8da8857
commit
f12fc1efd7
16 changed files with 129 additions and 28 deletions
27
app/controllers/rule/actions_controller.rb
Normal file
27
app/controllers/rule/actions_controller.rb
Normal file
|
@ -0,0 +1,27 @@
|
|||
class Rule::ActionsController < ApplicationController
|
||||
before_action :set_rule
|
||||
before_action :set_action, only: [ :update, :destroy ]
|
||||
|
||||
def create
|
||||
end
|
||||
|
||||
def update
|
||||
end
|
||||
|
||||
def destroy
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_rule
|
||||
@rule = Current.family.rules.find(params[:rule_id])
|
||||
end
|
||||
|
||||
def set_action
|
||||
@action = @rule.actions.find(params[:id])
|
||||
end
|
||||
|
||||
def action_params
|
||||
params.require(:action).permit(:action_type)
|
||||
end
|
||||
end
|
27
app/controllers/rule/triggers_controller.rb
Normal file
27
app/controllers/rule/triggers_controller.rb
Normal file
|
@ -0,0 +1,27 @@
|
|||
class Rule::TriggersController < ApplicationController
|
||||
before_action :set_rule
|
||||
before_action :set_trigger, only: [ :update, :destroy ]
|
||||
|
||||
def create
|
||||
end
|
||||
|
||||
def update
|
||||
end
|
||||
|
||||
def destroy
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_rule
|
||||
@rule = Current.family.rules.find(params[:rule_id])
|
||||
end
|
||||
|
||||
def set_trigger
|
||||
@trigger = @rule.triggers.find(params[:id])
|
||||
end
|
||||
|
||||
def trigger_params
|
||||
params.require(:trigger).permit(:trigger_type)
|
||||
end
|
||||
end
|
0
app/controllers/rules_controller.b
Normal file
0
app/controllers/rules_controller.b
Normal file
36
app/controllers/rules_controller.rb
Normal file
36
app/controllers/rules_controller.rb
Normal file
|
@ -0,0 +1,36 @@
|
|||
class RulesController < ApplicationController
|
||||
before_action :set_rule, only: [ :show, :edit, :update, :destroy ]
|
||||
|
||||
def index
|
||||
@rules = Current.family.rules
|
||||
render layout: "settings"
|
||||
end
|
||||
|
||||
def show
|
||||
end
|
||||
|
||||
def new
|
||||
end
|
||||
|
||||
def create
|
||||
end
|
||||
|
||||
def edit
|
||||
end
|
||||
|
||||
def update
|
||||
end
|
||||
|
||||
def destroy
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_rule
|
||||
@rule = Current.family.rules.find(params[:id])
|
||||
end
|
||||
|
||||
def rule_params
|
||||
params.require(:rule).permit(:effective_date, :active)
|
||||
end
|
||||
end
|
|
@ -9,6 +9,7 @@ module SettingsHelper
|
|||
{ name: I18n.t("settings.settings_nav.imports_label"), path: :imports_path },
|
||||
{ name: I18n.t("settings.settings_nav.tags_label"), path: :tags_path },
|
||||
{ name: I18n.t("settings.settings_nav.categories_label"), path: :categories_path },
|
||||
{ name: "Rules", path: :rules_path },
|
||||
{ name: I18n.t("settings.settings_nav.merchants_label"), path: :merchants_path },
|
||||
{ name: I18n.t("settings.settings_nav.whats_new_label"), path: :changelog_path },
|
||||
{ name: I18n.t("settings.settings_nav.feedback_label"), path: :feedback_path }
|
||||
|
|
7
app/models/rule.rb
Normal file
7
app/models/rule.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
class Rule < ApplicationRecord
|
||||
belongs_to :family
|
||||
has_many :triggers, dependent: :destroy
|
||||
has_many :actions, dependent: :destroy
|
||||
|
||||
validates :effective_date, presence: true
|
||||
end
|
5
app/models/rule/action.rb
Normal file
5
app/models/rule/action.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
class Rule::Action < ApplicationRecord
|
||||
belongs_to :rule
|
||||
|
||||
validates :action_type, presence: true
|
||||
end
|
7
app/models/rule/trigger.rb
Normal file
7
app/models/rule/trigger.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
class Rule::Trigger < ApplicationRecord
|
||||
self.table_name = "rule_triggers"
|
||||
|
||||
belongs_to :rule
|
||||
|
||||
validates :trigger_type, presence: true
|
||||
end
|
2
app/views/rules/_form.html.erb
Normal file
2
app/views/rules/_form.html.erb
Normal file
|
@ -0,0 +1,2 @@
|
|||
<p>Placeholder: rules/_form partial</p>
|
||||
|
2
app/views/rules/edit.html.erb
Normal file
2
app/views/rules/edit.html.erb
Normal file
|
@ -0,0 +1,2 @@
|
|||
<p>Placeholder: rules#edit</p>
|
||||
|
3
app/views/rules/index.html.erb
Normal file
3
app/views/rules/index.html.erb
Normal file
|
@ -0,0 +1,3 @@
|
|||
<% content_for :page_title, "Rules" %>
|
||||
|
||||
<p>Placeholder: rules#index</p>
|
2
app/views/rules/new.html.erb
Normal file
2
app/views/rules/new.html.erb
Normal file
|
@ -0,0 +1,2 @@
|
|||
<p>Placeholder: rules#new</p>
|
||||
|
2
app/views/rules/show.html.erb
Normal file
2
app/views/rules/show.html.erb
Normal file
|
@ -0,0 +1,2 @@
|
|||
<p>Placeholder: rules#show</p>
|
||||
|
|
@ -60,6 +60,9 @@
|
|||
<li>
|
||||
<%= render "settings/settings_nav_item", name: t(".categories_label"), path: categories_path, icon: "shapes" %>
|
||||
</li>
|
||||
<li>
|
||||
<%= render "settings/settings_nav_item", name: "Rules", path: rules_path, icon: "git-branch" %>
|
||||
</li>
|
||||
<li>
|
||||
<%= render "settings/settings_nav_item", name: t(".merchants_label"), path: merchants_path, icon: "store" %>
|
||||
</li>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue