mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-08-04 21:15:19 +02:00
New Settings Menu, Routes and Controllers Organization (#641)
* Add new settings routes and controllers * Add new settings view, restructure controllers and routes * Fix lint errors
This commit is contained in:
parent
39d57a167e
commit
9bda7efc3f
52 changed files with 771 additions and 203 deletions
|
@ -2,6 +2,18 @@ class AccountsController < ApplicationController
|
|||
include Filterable
|
||||
before_action :set_account, only: %i[ show update destroy sync ]
|
||||
|
||||
def index
|
||||
@accounts = Current.family.accounts
|
||||
end
|
||||
|
||||
def summary
|
||||
snapshot = Current.family.snapshot(@period)
|
||||
@net_worth_series = snapshot[:net_worth_series]
|
||||
@asset_series = snapshot[:asset_series]
|
||||
@liability_series = snapshot[:liability_series]
|
||||
@account_groups = Current.family.accounts.by_group(period: @period, currency: Current.family.currency)
|
||||
end
|
||||
|
||||
def new
|
||||
@account = Account.new(
|
||||
balance: nil,
|
||||
|
|
|
@ -8,4 +8,13 @@ class PagesController < ApplicationController
|
|||
@liability_series = snapshot[:liability_series]
|
||||
@account_groups = Current.family.accounts.by_group(period: @period, currency: Current.family.currency)
|
||||
end
|
||||
|
||||
def changelog
|
||||
end
|
||||
|
||||
def feedback
|
||||
end
|
||||
|
||||
def invites
|
||||
end
|
||||
end
|
||||
|
|
7
app/controllers/settings/billings_controller.rb
Normal file
7
app/controllers/settings/billings_controller.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
class Settings::BillingsController < ApplicationController
|
||||
def edit
|
||||
end
|
||||
|
||||
def update
|
||||
end
|
||||
end
|
46
app/controllers/settings/hostings_controller.rb
Normal file
46
app/controllers/settings/hostings_controller.rb
Normal file
|
@ -0,0 +1,46 @@
|
|||
class Settings::HostingsController < ApplicationController
|
||||
before_action :verify_hosting_mode
|
||||
|
||||
def show
|
||||
end
|
||||
|
||||
def update
|
||||
if all_updates_valid?
|
||||
hosting_params.keys.each do |key|
|
||||
Setting.send("#{key}=", hosting_params[key].strip)
|
||||
end
|
||||
|
||||
redirect_to settings_hosting_path, notice: t(".success")
|
||||
else
|
||||
flash.now[:error] = @errors.first.message
|
||||
render :edit, status: :unprocessable_entity
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def all_updates_valid?
|
||||
@errors = ActiveModel::Errors.new(Setting)
|
||||
hosting_params.keys.each do |key|
|
||||
setting = Setting.new(var: key)
|
||||
setting.value = hosting_params[key].strip
|
||||
|
||||
unless setting.valid?
|
||||
@errors.merge!(setting.errors)
|
||||
end
|
||||
end
|
||||
|
||||
if hosting_params[:upgrades_mode] == "auto" && hosting_params[:render_deploy_hook].blank?
|
||||
@errors.add(:render_deploy_hook, t("settings.hostings.update.render_deploy_hook_error"))
|
||||
end
|
||||
|
||||
@errors.empty?
|
||||
end
|
||||
|
||||
def hosting_params
|
||||
params.require(:setting).permit(:render_deploy_hook, :upgrades_mode, :upgrades_target)
|
||||
end
|
||||
|
||||
def verify_hosting_mode
|
||||
head :not_found unless self_hosted?
|
||||
end
|
||||
end
|
7
app/controllers/settings/notifications_controller.rb
Normal file
7
app/controllers/settings/notifications_controller.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
class Settings::NotificationsController < ApplicationController
|
||||
def edit
|
||||
end
|
||||
|
||||
def update
|
||||
end
|
||||
end
|
7
app/controllers/settings/preferences_controller.rb
Normal file
7
app/controllers/settings/preferences_controller.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
class Settings::PreferencesController < ApplicationController
|
||||
def edit
|
||||
end
|
||||
|
||||
def update
|
||||
end
|
||||
end
|
|
@ -1,5 +1,5 @@
|
|||
class SettingsController < ApplicationController
|
||||
def edit
|
||||
class Settings::ProfilesController < ApplicationController
|
||||
def show
|
||||
end
|
||||
|
||||
def update
|
7
app/controllers/settings/securities_controller.rb
Normal file
7
app/controllers/settings/securities_controller.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
class Settings::SecuritiesController < ApplicationController
|
||||
def edit
|
||||
end
|
||||
|
||||
def update
|
||||
end
|
||||
end
|
|
@ -1,46 +0,0 @@
|
|||
class Settings::SelfHostingController < ApplicationController
|
||||
before_action :verify_self_hosting_enabled
|
||||
|
||||
def edit
|
||||
end
|
||||
|
||||
def update
|
||||
if all_updates_valid?
|
||||
self_hosting_params.keys.each do |key|
|
||||
Setting.send("#{key}=", self_hosting_params[key].strip)
|
||||
end
|
||||
|
||||
redirect_to edit_settings_self_hosting_path, notice: t(".success")
|
||||
else
|
||||
flash.now[:error] = @errors.first.message
|
||||
render :edit, status: :unprocessable_entity
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def all_updates_valid?
|
||||
@errors = ActiveModel::Errors.new(Setting)
|
||||
self_hosting_params.keys.each do |key|
|
||||
setting = Setting.new(var: key)
|
||||
setting.value = self_hosting_params[key].strip
|
||||
|
||||
unless setting.valid?
|
||||
@errors.merge!(setting.errors)
|
||||
end
|
||||
end
|
||||
|
||||
if self_hosting_params[:upgrades_mode] == "auto" && self_hosting_params[:render_deploy_hook].blank?
|
||||
@errors.add(:render_deploy_hook, t("settings.self_hosting.update.render_deploy_hook_error"))
|
||||
end
|
||||
|
||||
@errors.empty?
|
||||
end
|
||||
|
||||
def self_hosting_params
|
||||
params.require(:setting).permit(:render_deploy_hook, :upgrades_mode, :upgrades_target)
|
||||
end
|
||||
|
||||
def verify_self_hosting_enabled
|
||||
head :not_found unless self_hosted?
|
||||
end
|
||||
end
|
|
@ -1,6 +1,9 @@
|
|||
class Transactions::CategoriesController < ApplicationController
|
||||
before_action :set_category, only: [ :update, :destroy ]
|
||||
|
||||
def index
|
||||
end
|
||||
|
||||
def create
|
||||
if Current.family.transaction_categories.create(category_params)
|
||||
redirect_to transactions_path, notice: t(".success")
|
||||
|
|
4
app/controllers/transactions/merchants_controller.rb
Normal file
4
app/controllers/transactions/merchants_controller.rb
Normal file
|
@ -0,0 +1,4 @@
|
|||
class Transactions::MerchantsController < ApplicationController
|
||||
def index
|
||||
end
|
||||
end
|
4
app/controllers/transactions/rules_controller.rb
Normal file
4
app/controllers/transactions/rules_controller.rb
Normal file
|
@ -0,0 +1,4 @@
|
|||
class Transactions::RulesController < ApplicationController
|
||||
def index
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue