Use a switch to enable/disable budget phases

In the past it would have been confusing to add a way to directly
enable/disable a phase in the phases table because it was in the middle
of the form. So we would have had next to each other controls that don't
do anything until the form is sent and controls which modify the
database immediately. That's why we couldn't add the checkboxes we used
when using the wizard.

Now the phases aren't on the same page as the budget form, so we can
edit them independently. We're using a switch, so it's consistent with
the way we enable/disable features. We could have used checkboxes, but
with checkboxes, users expect they aren't changing anything until they
click on a button to send the form, so we'd have to add a button, and it
might be missed since we're going to add "buttons" for headings and
groups to this page which won't send a form but will be links.

Since we're changing the element with JavaScript after an AJAX call, we
need a way to find the button we're changing. The easiest way is adding
an ID attribute to all admin actions buttons/links.
This commit is contained in:
Javi Martín
2021-08-23 02:23:09 +02:00
parent 349dbb74d7
commit 46d8bc4f0e
17 changed files with 137 additions and 89 deletions

View File

@@ -69,7 +69,9 @@ namespace :admin do
resources :progress_bars, except: :show, controller: "budget_investment_progress_bars"
end
resources :budget_phases, only: [:edit, :update]
resources :budget_phases, only: [:edit, :update] do
member { patch :toggle_enabled }
end
end
namespace :budgets_wizard do
@@ -79,7 +81,7 @@ namespace :admin do
end
resources :phases, as: "budget_phases", only: [:index, :edit, :update] do
collection { patch :update_all }
member { patch :toggle_enabled }
end
end
end