Updated save button as shared save action

Necessary to keep all actions within the same shared namespace. This was the last of them to be refactored. This also sets defaults for the following to reduce duplication further:

* `verb`: `:post`
* `target`: "closest .bit-page"

Milestone: minor
This commit is contained in:
Brooke Kuhlmann
2026-01-06 13:24:52 -07:00
parent e84c466ee5
commit b2c6d9d832
13 changed files with 20 additions and 56 deletions
+2 -3
View File
@@ -33,11 +33,10 @@
errors: %>
<div class="form-actions">
<%= render "shared/save_button",
<%= render "shared/actions/save",
form:,
verb: :put,
path: routes.path(:device_update, id: device.id),
target: ".bit-page" %>
path: routes.path(:device_update, id: device.id) %>
<a href="<%= routes.path :device, id: device.id %>"
class="bit-button-decline"
+1 -6
View File
@@ -22,12 +22,7 @@
errors: %>
<div class="form-actions">
<%= render "shared/save_button",
form:,
verb: :post,
path: routes.path(:device_create),
target: ".bit-page" %>
<%= render "shared/actions/save", form:, path: routes.path(:device_create) %>
<%= link_to "Cancel", routes.path(:devices), class: "bit-button-decline" %>
</div>
<% end %>
+1 -6
View File
@@ -24,12 +24,7 @@
errors: %>
<div class="form-actions">
<%= render "shared/save_button",
form:,
verb: :post,
path: routes.path(:extension_create),
target: ".bit-page" %>
<%= render "shared/actions/save", form:, path: routes.path(:extension_create) %>
<%= link_to "Cancel", routes.path(:extensions), class: "bit-button-decline" %>
</div>
<% end %>
+2 -3
View File
@@ -24,11 +24,10 @@
<%= render "models/shared/fields", form:, model:, fields: fields.value, errors: %>
<div class="form-actions">
<%= render "shared/save_button",
<%= render "shared/actions/save",
form:,
verb: :put,
path: routes.path(:model_update, id: model.id),
target: ".bit-page" %>
path: routes.path(:model_update, id: model.id) %>
<a href="<%= routes.path :model, id: model.id %>"
class="bit-button-decline"
+1 -6
View File
@@ -16,12 +16,7 @@
<%= render "models/shared/fields", form:, model:, fields: fields.value, errors: %>
<div class="form-actions">
<%= render "shared/save_button",
form:,
verb: :post,
path: routes.path(:model_create),
target: ".bit-page" %>
<%= render "shared/actions/save", form:, path: routes.path(:model_create) %>
<%= link_to "Cancel", routes.path(:models), class: "bit-button-decline" %>
</div>
<% end %>
+2 -3
View File
@@ -26,11 +26,10 @@
<%= render "playlists/shared/fields", form:, playlist:, fields: fields.value, errors: %>
<div class="form-actions">
<%= render "shared/save_button",
<%= render "shared/actions/save",
form:,
verb: :put,
path: routes.path(:playlist_update, id: playlist.id),
target: ".bit-page" %>
path: routes.path(:playlist_update, id: playlist.id) %>
<a href="<%= routes.path :playlist, id: playlist.id %>"
class="bit-button-decline"
+2 -3
View File
@@ -36,11 +36,10 @@
</fieldset>
<div class="form-actions">
<%= render "shared/save_button",
<%= render "shared/actions/save",
form:,
verb: :put,
path: routes.path(:playlist_mirror_update, playlist_id: playlist.id),
target: ".bit-page" %>
path: routes.path(:playlist_mirror_update, playlist_id: playlist.id) %>
<%= link_to "Cancel",
routes.path(:playlist, id: playlist.id),
+1 -6
View File
@@ -22,12 +22,7 @@
<%= render "playlists/shared/fields", form:, playlist:, fields: fields.value, errors: %>
<div class="form-actions">
<%= render "shared/save_button",
form:,
verb: :post,
path: routes.path(:playlist_create),
target: ".bit-page" %>
<%= render "shared/actions/save", form:, path: routes.path(:playlist_create) %>
<%= link_to "Cancel", routes.path(:playlists), class: "bit-button-decline" %>
</div>
<% end %>
+2 -3
View File
@@ -25,11 +25,10 @@
<%= render "screens/shared/fields", form:, models:, screen:, fields: fields.value, errors: %>
<div class="form-actions">
<%= render "shared/save_button",
<%= render "shared/actions/save",
form:,
verb: :put,
path: routes.path(:screen_update, id: screen.id),
target: ".bit-page" %>
path: routes.path(:screen_update, id: screen.id) %>
<%= link_to "Cancel",
routes.path(:screen, id: screen.id),
+1 -6
View File
@@ -16,12 +16,7 @@
<%= render "screens/shared/fields", form:, models:, screen:, fields: fields.value, errors: %>
<div class="form-actions">
<%= render "shared/save_button",
form:,
verb: :post,
path: routes.path(:screen_create),
target: ".bit-page" %>
<%= render "shared/actions/save", form:, path: routes.path(:screen_create) %>
<%= link_to "Cancel", routes.path(:screens), class: "bit-button-decline" %>
</div>
<% end %>
@@ -1,9 +1,9 @@
<%= form.submit "Save",
class: "bit-button-accept",
**HTMX[
verb => path,
locals.fetch(:verb, :post) => path,
trigger: "click, keyup[ctrlKey&&key=='s'] from:body",
target: "closest #{target}",
target: locals.fetch(:target, "closest .bit-page"),
disabled_elt: "this",
push_url: "true"
] %>
+2 -3
View File
@@ -24,11 +24,10 @@
<%= render "users/shared/fields", form:, user:, statuses:, fields: fields.value, errors: %>
<div class="form-actions">
<%= render "shared/save_button",
<%= render "shared/actions/save",
form:,
verb: :put,
path: routes.path(:user_update, id: user.id),
target: ".bit-page" %>
path: routes.path(:user_update, id: user.id) %>
<%= link_to "Cancel",
routes.path(:user, id: user.id),
+1 -6
View File
@@ -16,12 +16,7 @@
<%= render "users/shared/fields", form:, user:, statuses:, fields: fields.value, errors: %>
<div class="form-actions">
<%= render "shared/save_button",
form:,
verb: :post,
path: routes.path(:user_create),
target: ".bit-page" %>
<%= render "shared/actions/save", form:, path: routes.path(:user_create) %>
<%= link_to "Cancel", routes.path(:users), class: "bit-button-decline" %>
</div>
<% end %>