Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display superadmin settings when user has appropriate permissions #2411

Merged
merged 1 commit into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/controllers/admin/accounts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ def update
private

def account_params
params.require(:account).permit(:name, :cname, :title, *@account.public_settings.keys)
is_superadmin = current_ability.superadmin?
params.require(:account).permit(:name, :cname, :title, *@account.public_settings(is_superadmin: is_superadmin).keys)
end

def set_current_account
Expand Down
9 changes: 3 additions & 6 deletions app/views/admin/accounts/edit.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<% content_for :page_header do %>
<h1><span class="fa fa-gears"></span> Editing Account</h1>
<% end %>

<div class="row">
<div class="col-md-12">
<div class="card account-form">
Expand All @@ -17,21 +16,19 @@
</ul>
</div>
<% end %>

<div class="form-group">
<%= f.label :tenant %><br>
<%= f.text_field :tenant, class: 'form-control', readonly: @account.persisted? %>
</div>

<% current_account.public_settings.each do |key, value| %>
<% is_superadmin = current_ability.superadmin? %>
<% current_account.public_settings(is_superadmin: is_superadmin).each do |key, value| %>
<%= render 'shared/settings', f: f, key: key, value: value %>
<% end %>

<div class="card-footer">
<%= f.submit class: 'btn btn-secondary float-right' %>
</div>
</div>
<% end %>
</div>
</div>
</div>
</div>
Loading