Allow changes to the Account name

This commit is contained in:
Stanko K.R.
2025-10-31 13:41:44 +01:00
parent 1b1a17b939
commit dd583206ee
5 changed files with 24 additions and 1 deletions
@@ -1,6 +1,17 @@
class Account::SettingsController < ApplicationController
before_action
def show
@account = Account.sole
@users = User.active.alphabetically
end
def update
Account.sole.update!(account_params)
redirect_to account_settings_path
end
private
def account_params
params.expect account: %i[ name ]
end
end
@@ -20,7 +20,7 @@ export default class extends Controller {
const input = this.hasInputTarget ? this.inputTarget : null
if (input) {
const value = (input.value || "").trim()
const value = (input.value || "").trim()
if (value.length === 0) {
event.preventDefault()
}
+2
View File
@@ -5,6 +5,8 @@ class Account < ApplicationRecord
after_create :create_join_code
validates :name, presence: true
class << self
def create_with_admin_user(account:, owner:)
create!(**account).tap do
@@ -0,0 +1,9 @@
<div class="settings__panel settings__panel--entropy panel shadow center">
<h2 class="divider txt-large">Name</h2>
<%= form_with model: account, url: account_settings_path, method: :put, scope: :account, data: { controller: "form" }, class: "flex" do |form| %>
<%= form.text_field :name, required: true, class: "input input--transparent full-width", data: { action: "input->form#disableSubmitWhenInvalid" } %>
<%= form.button data: { form_target: "submit" }, disabled: form.object do %>
Save
<% end %>
<% end %>
</div>
+1
View File
@@ -7,4 +7,5 @@
<section class="settings">
<%= render "account/settings/users", users: @users %>
<%= render "account/settings/entropy_configuration", account: @account %>
<%= render "account/settings/name", account: @account %>
</section>