mirror of
https://github.com/basecamp/once-campfire.git
synced 2026-02-21 12:10:34 +09:00
Rework toggle as switch
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -65,11 +65,29 @@
|
||||
</div>
|
||||
<% 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 %>
|
||||
<div class="margin-block-start pad-block pad-inline-double fill-shade border-radius">
|
||||
<%= form_with model: @account, method: :put, data: { controller: "form" }, class: "flex align-center gap center" do |form| %>
|
||||
<div class="flex-item-grow flex align-center gap txt-align-start">
|
||||
<%= image_tag "crown.svg", aria: { hidden: "true" }, size: 18 %> Must be admin to create new rooms
|
||||
</div>
|
||||
<%= 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 %>
|
||||
|
||||
<label class="switch">
|
||||
<input type="checkbox"
|
||||
class="switch__input"
|
||||
<%= "checked" if Current.account.settings.restrict_room_creation_to_administrators? %>
|
||||
data-action="change->form#submit">
|
||||
<span class="switch__btn round"></span>
|
||||
<span class="for-screen-reader">
|
||||
Must be admin to create new rooms
|
||||
</span>
|
||||
</label>
|
||||
|
||||
<% end %>
|
||||
</div>
|
||||
<% else %>
|
||||
<%= account_logo_tag style: "txt-xx-large center" %>
|
||||
<h1 class="flex-item-grow txt-x-large"><%= @account.name %></h1>
|
||||
|
||||
Reference in New Issue
Block a user