From 7b7b3f8a67c152ce0373fe0a01c2a37b48bd3b14 Mon Sep 17 00:00:00 2001 From: Jason Zimdars Date: Mon, 1 Dec 2025 23:13:54 -0600 Subject: [PATCH] Rework toggle as switch --- app/helpers/accounts_helper.rb | 9 --------- app/views/accounts/edit.html.erb | 28 +++++++++++++++++++++++----- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/app/helpers/accounts_helper.rb b/app/helpers/accounts_helper.rb index 22c6c4a..559e195 100644 --- a/app/helpers/accounts_helper.rb +++ b/app/helpers/accounts_helper.rb @@ -2,13 +2,4 @@ module AccountsHelper def account_logo_tag(style: nil) tag.figure image_tag(fresh_account_logo_path, alt: "Account logo", size: 300), class: "account-logo avatar #{style}" end - - def button_to_toggle_setting(label, setting) - button_to account_path(account: { settings: { setting => !Current.account.settings.send("#{setting}?") } }), - method: :put, - role: "checkbox", aria: { checked: true, labelledby: "#{setting}_account_setting" }, tabindex: 0, - class: "btn" do - tag.span(label, id: "#{setting}_account_setting") - end - end end diff --git a/app/views/accounts/edit.html.erb b/app/views/accounts/edit.html.erb index d4a4ab8..e0c2152 100644 --- a/app/views/accounts/edit.html.erb +++ b/app/views/accounts/edit.html.erb @@ -65,11 +65,29 @@ <% end %> - <% if Current.account.settings.restrict_room_creation_to_administrators? %> - <%= button_to_toggle_setting "Allow everyone to create new rooms", :restrict_room_creation_to_administrators %> - <% else %> - <%= button_to_toggle_setting "Only allow admins to create new rooms", :restrict_room_creation_to_administrators %> - <% end %> +
+ <%= form_with model: @account, method: :put, data: { controller: "form" }, class: "flex align-center gap center" do |form| %> +
+ <%= image_tag "crown.svg", aria: { hidden: "true" }, size: 18 %> Must be admin to create new rooms +
+ <%= form.fields_for :settings, @account.settings do |settings_form| %> + <%= settings_form.hidden_field :restrict_room_creation_to_administrators, + value: !Current.account.settings.restrict_room_creation_to_administrators? %> + <% end %> + + + + <% end %> +
<% else %> <%= account_logo_tag style: "txt-xx-large center" %>

<%= @account.name %>