prefillable fields

This commit is contained in:
Pete Matsyburka
2025-07-27 10:27:12 +03:00
committed by GitHub
parent 2974e6a64f
commit b2b97a313a
21 changed files with 208 additions and 35 deletions
@@ -0,0 +1,16 @@
<% select_fields = template.fields.filter_map { |f| [f['name'], f['uuid']] if f['name'].present? && f['type'].in?(TemplatesPrefillableFieldsController::PREFILLABLE_FIELD_TYPES) } %>
<% if select_fields.present? %>
<div class="border-b pb-4 mb-4">
<%= form_for '', url: template_prefillable_fields_path(template), method: :post, data: { close_on_submit: false } do |f| %>
<div class="form-control">
<%= f.hidden_field :prefillable, value: 'true' %>
<%= f.label :field_uuid, t(:invite_form_fields), class: 'label' %>
<div class="join w-full">
<%= select_tag :field_uuid, options_for_select(select_fields), prompt: t(:select_field), class: 'base-select w-full join-item', dir: 'auto', required: true %>
<%= f.button button_title(title: t('add'), disabled_with: t('add')), class: 'base-button join-item !px-6' %>
</div>
</div>
<% end %>
<%= render partial: 'templates_prefillable_fields/list', locals: { template: } %>
</div>
<% end %>
@@ -0,0 +1,6 @@
<div id="prefillable_fields_list" class="flex gap-1 px-0.5 mt-2 flex-wrap">
<% template.fields.each do |f| %>
<% next unless f['prefillable'] %>
<%= button_to button_title(title: f['name'].presence || f['type'].capitalize, disabled_with: f['name'].presence || f['type'].capitalize, icon: svg_icon('x', class: 'w-4 h-4'), icon_disabled: svg_icon('loader', class: 'w-4 h-4 animate-spin')), template_prefillable_fields_path(template), params: { field_uuid: f['uuid'], prefillable: 'false' }, class: 'badge badge-lg badge-primary space-x-1 pr-3 pl-2', form: { data: { close_on_submit: false } } %>
<% end %>
</div>