Files
once-campfire/app/views/accounts/edit.html.erb
T
Marcello Costagliola f864403c2c List one page of account members at a time
Since administrators were grouped apart from members (b52c318), the account
settings page loads every user to split them and renders all of them. The
lazy next page still starts at the 501st user, so on an account with more
than 500 people, scrolling down lists those users a second time.

Load administrators on their own and page only members, both on the settings
page and on the pages that follow it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0142qgjggdJ2KDdGk7RF9Xm9
2026-10-05 14:56:22 +02:00

119 lines
5.3 KiB
Plaintext

<% @page_title = "Account settings" %>
<% content_for :nav do %>
<div class="flex-item-justify-start">
<%= link_back_to_last_room_visited %>
</div>
<% if Current.user.administrator? %>
<div class="flex align-center gap flex-item-justify-end">
<%= link_to account_bots_path, class: "btn", style: "view-transition-name: chat-bots" do %>
<%= image_tag "bot.svg", aria: { hidden: "true" }, size: 20 %>
<span class="for-screen-reader">Set up chat bots</span>
<% end %>
<%= link_to edit_account_custom_styles_path, class: "btn", style: "view-transition-name: custom-styles" do %>
<%= image_tag "art.svg", size: 20, aria: { hidden: "true" } %>
<span class="for-screen-reader">Custom styles</span>
<% end %>
</div>
<% end %>
<% end %>
<section class="panel txt-align-center flex flex-column gap" style="view-transition-name: account-settings">
<% if Current.user.can_administer? %>
<div class="align-center center avatar__form gap" data-controller="upload-preview">
<%= form_with model: @account, method: :patch, class: "txt--medium", data: { controller: "form" } do |form| %>
<label class="btn input--file">
<%= image_tag "camera.svg", aria: { hidden: "true" }, size: 20 %>
<%= form.file_field :logo, class: "input", accept: "image/*",
data: { action: "upload-preview#previewImage change->form#submit" } %>
<span class="for-screen-reader">Upload logo</span>
</label>
<% end %>
<%= form_with model: @account, method: :patch, data: { controller: "form" } do |form| %>
<label class="btn avatar input--file account-logo txt-xx-large">
<%= image_tag fresh_account_logo_path, role: "presentation", size: 48, data: { upload_preview_target: "image" } %>
<%= form.file_field :logo, class: "input", accept: "image/*",
data: { action: "upload-preview#previewImage change->form#submit" } %>
<span class="for-screen-reader">Upload logo</span>
</label>
<% end %>
<% if @account.logo.attached? %>
<%= button_to fresh_account_logo_path, method: :delete, class: "btn btn--negative txt-small avatar__delete-btn" do %>
<%= image_tag "minus.svg", aria: { hidden: "true" }, size: 20 %>
<span class="for-screen-reader">Delete logo</span>
<% end %>
<% end %>
</div>
<%= form_with model: @account, data: { controller: "form" }, class: "flex flex-column gap" do |form| %>
<div class="flex align-center gap">
<%= translation_button(:account_name) %>
<label class="flex align-center gap flex-item-grow">
<%= form.text_field :name, class: "input txt-large", autocomplete: "off", placeholder: "Name this account", autofocus: true,
data: { action: "keydown.enter->form#submit" } %>
</label>
<%= form.button class: "btn btn--reversed center", type: "submit" do %>
<%= image_tag "check.svg", aria: { hidden: "true" }, size: 20 %>
<span class="for-screen-reader">Save changes</span>
<% end %>
</div>
<% 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", class: "colorize--black", 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>
<% end %>
<div class="margin-block pad-inline pad-block-start fill-shade border-radius">
<%= render "accounts/invite" %>
<hr class="margin-block separator full-width" style="--border-style: solid">
<menu class="flex flex-column gap margin-none pad">
<turbo-frame id="account_users">
<%= render partial: "accounts/users/user", collection: @administrators, as: :user %>
<% if @administrators.any? && @page.records.any? %>
<hr class="separator full-width" style="--border-style: solid">
<% end %>
<%= render partial: "accounts/users/user", collection: @page.records, as: :user %>
<%= render "accounts/users/next_page_container", page: @page.next_param unless @page.last? %>
</turbo-frame>
</menu>
</div>
</section>
<% content_for :footer do %>
<div class="txt-align-center center margin-block-double txt-subtle">Campfire&trade; version <%= version_badge %></div>
<% end %>