So now there's no need to edit each phase individually to enable/disable them. We aren't doing the same thing in the form to edit a budget because we aren't sure about possible usability issues. On one hand, in some tables we automatically update records when we mark a checkbox, so users might expect that. On the other hand, having a checkbox in the middle of a form which updates the database automatically is counter-intuitive, particularly when right below that table there are other checkboxes which don't update the database until the form is submitted. So, either way, chances are users would think they've updated the phases (or kept them intact) while the opposite would be true. In the form within the wizard to create a budget that problem isn't that important because there aren't any other fields in the form and it's pretty intuitive that what users do will have no effect until they press the "Finish" button. Co-Authored-By: Julian Nicolas Herrero <microweb10@gmail.com>
27 lines
568 B
Ruby
27 lines
568 B
Ruby
class Admin::BudgetsWizard::PhasesController < Admin::BaseController
|
|
include Admin::BudgetPhasesActions
|
|
|
|
def index
|
|
end
|
|
|
|
def update_all
|
|
@budget.update!(phases_params)
|
|
|
|
redirect_to admin_budgets_path, notice: t("admin.budgets_wizard.phases.update_all.notice")
|
|
end
|
|
|
|
private
|
|
|
|
def phases_index
|
|
admin_budgets_wizard_budget_budget_phases_path(@phase.budget)
|
|
end
|
|
|
|
def phases_params
|
|
params.require(:budget).permit(allowed_phases_params)
|
|
end
|
|
|
|
def allowed_phases_params
|
|
{ phases_attributes: [:id, :enabled] }
|
|
end
|
|
end
|