Skip to content

Open-source live-chat, email support, omni-channel desk. An alternative to Intercom, Zendesk, Salesforce Service Cloud etc. 🔥💬

1.3 KB
Raw Blame
<%#
# Account User Form Partial

Adds a user to an account from either side of the relationship.
Used by both account and user show pages.
%>
<%# locals: (page:, resource_type:) -%>

<% account_user_page = Administrate::Page::Form.new(AccountUserDashboard.new, AccountUser.new) %>
<%= form_for([namespace, account_user_page.resource], html: { class: "rounded-xl border border-n-weak bg-n-solid-1" }) do |f| %>
  <div class="flex min-h-11 items-center border-b border-n-weak px-4 py-2">
    <h2 class="text-xs font-medium uppercase tracking-wider text-n-slate-10"><%= resource_type == 'account' ? t('super_admin.accounts.add_user') : t('super_admin.users.add_account') %></h2>
  </div>

  <%# The field rows stack their label over the control here so the form fits one line. %>
  <div class="grid grid-cols-1 gap-4 p-4 sm:grid-cols-[minmax(0,1fr)_12rem_auto] sm:items-end [&_[data-field]]:block [&_[data-field]]:space-y-1.5 [&_[data-field]]:p-0">
    <% account_user_page.attributes.each_value do |attributes| %>
      <% attributes.each do |attribute| %>
        <% if attribute.name == resource_type %>
          <%= f.hidden_field("#{resource_type}_id", value: page.resource.id) %>
        <% else %>
          <%= render_field attribute, f: f %>
        <% end %>
      <% end %>
    <% end %>

    <%= render "button", submit: f %>
  </div>
<% end %>