Use separate actions to select/deselect proposals

This is consistent to what we usually do. Also, we're applying the same
criteria mentioned in commit 72704d776:

> We're also making these actions idempotent, so sending many requests
> to the same action will get the same result, which wasn't the case
> with the `toggle` action. Although it's a low probability case, the
> `toggle` action could result in [selecting a proposal] when trying to
> [deselect] it if someone else has [deselected it] it between the time
> the page loaded and the time the admin clicked on the "[Selected]"
> button.
This commit is contained in:
Javi Martín
2024-10-06 12:29:20 +02:00
parent fec44c146c
commit 4a2fc50c76
4 changed files with 34 additions and 9 deletions

View File

@@ -8,7 +8,11 @@ class Admin::Proposals::ToggleSelectionComponent < ApplicationComponent
private
def action
:toggle_selection
if selected?
:deselect
else
:select
end
end
def selected?