Sha256: 93b72d31fb1f37b225df42816f01a1ef877330731e5232913c1b5471db69d292

Contents?: true

Size: 1.89 KB

Versions: 20

Compression:

Stored size: 1.89 KB

Contents

<%= turbo_frame_tag 'attach_modal' do %>
  <%
    url = Avo::Services::URIService.parse(avo.root_url.to_s)
      .append_paths('resources', params[:resource_name], params[:id], params[:related_name])
      .append_query(
        {
          view: @resource&.view&.to_s,
          for_attribute: @field&.try(:for_attribute)
        }.compact
      )
      .to_s
  %>
  <%= form_with scope: 'fields',
    url: url,
    local: true,
    data: {
      'turbo-frame': '_top'
    } do |form| %>
    <%= render Avo::ModalComponent.new do |c| %>
      <% c.with_heading do %>
        <%= t 'avo.choose_item', item: @related_resource.name.downcase %>
      <% end %>

      <div class="flex-1 flex items-center justify-center px-0 lg:px-8 text-lg mt-8 mb-12">
        <% if @field.is_searchable? %>
          <%= render Avo::Pro::SearchableAssociations::AutocompleteComponent.new form: form,
            classes: input_classes("w-full"),
            field: @field,
            model_key: @field.target_resource&.model_key,
            foreign_key: 'related_id',
            resource: @resource,
            view: :new
          %>
        <% else %>
          <div class="flex-1 flex flex-col items-center justify-center px-0 md:px-24 text-base">
            <%= form.select :related_id, options_for_select(@options, nil),
              {
                include_blank: t('avo.choose_an_option'),
              },
              {
                class: input_classes('w-full'),
              }
            %>
          </div>
        <% end %>
      </div>

      <% c.with_controls do %>
        <%= a_button 'data-action': 'click->modal#close', type: :button, size: :sm, style: :outline, color: :gray do %>
          <%= t('avo.cancel') %>
        <% end %>
        <%= a_button type: :submit, style: :primary, color: :green, size: :sm do %>
          <%= t('avo.attach') %>
        <% end %>
      <% end %>
    <% end %>
  <% end %>
<% end %>

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
avo-3.10.10 app/views/avo/associations/new.html.erb
avo-3.10.9 app/views/avo/associations/new.html.erb
avo-3.10.8 app/views/avo/associations/new.html.erb
avo-3.10.7 app/views/avo/associations/new.html.erb
avo-3.10.6 app/views/avo/associations/new.html.erb
avo-3.10.5 app/views/avo/associations/new.html.erb
avo-3.10.4 app/views/avo/associations/new.html.erb
avo-3.10.3 app/views/avo/associations/new.html.erb
avo-3.10.2 app/views/avo/associations/new.html.erb
avo-3.10.1 app/views/avo/associations/new.html.erb
avo-3.10.0 app/views/avo/associations/new.html.erb
avo-3.9.2 app/views/avo/associations/new.html.erb
avo-3.9.1 app/views/avo/associations/new.html.erb
avo-3.8.2 app/views/avo/associations/new.html.erb
avo-3.9.0 app/views/avo/associations/new.html.erb
avo-3.8.1 app/views/avo/associations/new.html.erb
avo-3.8.0 app/views/avo/associations/new.html.erb
avo-3.6.4 app/views/avo/associations/new.html.erb
avo-3.6.3 app/views/avo/associations/new.html.erb
avo-3.6.2 app/views/avo/associations/new.html.erb