adjust template preferences

pull/267/head
Pete Matsyburka 2 years ago
parent 7adeaf93cd
commit 859892d1fd

@ -37,7 +37,7 @@
</div> </div>
<% if !template.archived_at? %> <% if !template.archived_at? %>
<div class="flex items-center space-x-2"> <div class="flex items-center space-x-2">
<% if can?(:update, template) && (Docuseal.multitenant? || current_account.testing? || current_account.id == 1) %> <% if can?(:update, template) %>
<div class="tooltip" data-tip="Preferences"> <div class="tooltip" data-tip="Preferences">
<%= link_to template_preferences_path(template), class: 'btn border border-base-200 bg-base-200 hover:bg-base-300 hover:border-base-300 btn-sm flex-1 hidden md:flex', data: { turbo_frame: :modal } do %> <%= link_to template_preferences_path(template), class: 'btn border border-base-200 bg-base-200 hover:bg-base-300 hover:border-base-300 btn-sm flex-1 hidden md:flex', data: { turbo_frame: :modal } do %>
<span class="flex items-center justify-center space-x-2"> <span class="flex items-center justify-center space-x-2">

@ -1,17 +1,21 @@
<%= render 'shared/turbo_modal_large', title: 'Preferences', close_after_submit: false do %> <%= render 'shared/turbo_modal_large', title: 'Preferences', close_after_submit: false do %>
<% options = [['General', 'general'], ['API and Embedding', 'api']] %> <% show_api = Docuseal.multitenant? || current_account.testing? || !current_account.linked_account_account %>
<toggle-visible data-element-ids="<%= options.map(&:last).to_json %>" class="relative text-center mt-3 block"> <% options = [%w[General general]] %>
<div class="join"> <% options << ['API and Embedding', 'api'] if show_api %>
<% options.each_with_index do |(label, value), index| %> <% if options.size > 1 %>
<span> <toggle-visible data-element-ids="<%= options.map(&:last).to_json %>" class="relative text-center mt-3 block">
<%= radio_button_tag 'option', value, value == 'general', class: 'peer hidden', data: { action: 'change:toggle-visible#trigger' } %> <div class="join">
<label for="option_<%= value %>" class="<%= '!rounded-s-full' if index.zero? %> btn btn-focus btn-sm join-item md:w-48 peer-checked:btn-active normal-case <%= 'px-8 md:px-0' if value == 'general' %>"> <% options.each_with_index do |(label, value), index| %>
<%= label %> <span>
</label> <%= radio_button_tag 'option', value, value == 'general', class: 'peer hidden', data: { action: 'change:toggle-visible#trigger' } %>
</span> <label for="option_<%= value %>" class="<%= '!rounded-s-full' if index.zero? %> btn btn-focus btn-sm join-item md:w-48 peer-checked:btn-active normal-case <%= 'px-8 md:px-0' if value == 'general' %>">
<% end %> <%= label %>
</div> </label>
</toggle-visible> </span>
<% end %>
</div>
</toggle-visible>
<% end %>
<div id="general" class="px-5 mb-4"> <div id="general" class="px-5 mb-4">
<%= form_for @template, url: template_preferences_path(@template), method: :post, html: { autocomplete: 'off', class: 'mt-1' } do |f| %> <%= form_for @template, url: template_preferences_path(@template), method: :post, html: { autocomplete: 'off', class: 'mt-1' } do |f| %>
<toggle-on-submit data-element-id="email_saved_alert"></toggle-on-submit> <toggle-on-submit data-element-id="email_saved_alert"></toggle-on-submit>
@ -62,39 +66,41 @@
<% end %> <% end %>
<%= render 'templates_code_modal/preferences' %> <%= render 'templates_code_modal/preferences' %>
</div> </div>
<div id="api" class="hidden mt-2 mb-4 px-5"> <% if show_api %>
<div> <div id="api" class="hidden mt-2 mb-4 px-5">
<label class="text-sm font-semibold" for="template_id"> <div>
Template ID <label class="text-sm font-semibold" for="template_id">
</label> Template ID
<div class="flex gap-2 mb-4 mt-2"> </label>
<input id="template_id" type="text" value="<%= @template.id %>" class="base-input w-full" autocomplete="off" readonly> <div class="flex gap-2 mb-4 mt-2">
<%= render 'shared/clipboard_copy', icon: 'copy', text: @template.id, class: 'base-button', icon_class: 'w-6 h-6 text-white', copy_title: 'Copy', copied_title: 'Copied' %> <input id="template_id" type="text" value="<%= @template.id %>" class="base-input w-full" autocomplete="off" readonly>
<%= render 'shared/clipboard_copy', icon: 'copy', text: @template.id, class: 'base-button', icon_class: 'w-6 h-6 text-white', copy_title: 'Copy', copied_title: 'Copied' %>
</div>
</div> </div>
</div> <div>
<div> <label class="text-sm font-semibold" for="embedding_url">
<label class="text-sm font-semibold" for="embedding_url"> Embedding URL
Embedding URL </label>
</label> <div class="flex gap-2 mb-4 mt-2">
<div class="flex gap-2 mb-4 mt-2"> <input id="embedding_url" type="text" value="<%= start_form_url(slug: @template.slug) %>" class="base-input w-full" autocomplete="off" readonly>
<input id="embedding_url" type="text" value="<%= start_form_url(slug: @template.slug) %>" class="base-input w-full" autocomplete="off" readonly> <%= render 'shared/clipboard_copy', icon: 'copy', text: start_form_url(slug: @template.slug), class: 'base-button', icon_class: 'w-6 h-6 text-white', copy_title: 'Copy', copied_title: 'Copied' %>
<%= render 'shared/clipboard_copy', icon: 'copy', text: start_form_url(slug: @template.slug), class: 'base-button', icon_class: 'w-6 h-6 text-white', copy_title: 'Copy', copied_title: 'Copied' %> </div>
</div> </div>
</div> <%= render 'templates_code_modal/placeholder' %>
<%= render 'templates_code_modal/placeholder' %> <%= render 'templates/embedding', template: @template %>
<%= render 'templates/embedding', template: @template %> <% if can?(:manage, TemplateSharing.new(template: @template)) %>
<% if can?(:manage, TemplateSharing.new(template: @template)) %> <%= form_for '', url: template_sharings_testing_index_path, method: :post, html: { class: 'mt-1' } do |f| %>
<%= form_for '', url: template_sharings_testing_index_path, method: :post, html: { class: 'mt-1' } do |f| %> <%= f.hidden_field :template_id, value: @template.id %>
<%= f.hidden_field :template_id, value: @template.id %> <div class="flex items-center justify-between">
<div class="flex items-center justify-between"> <span>
<span> Share template with Test Environment
Share template with Test Environment </span>
</span> <%= f.check_box :value, class: 'toggle', checked: @template.template_sharings.exists?(account_id: current_account.testing_accounts), onchange: 'this.form.requestSubmit()' %>
<%= f.check_box :value, class: 'toggle', checked: @template.template_sharings.exists?(account_id: current_account.testing_accounts), onchange: 'this.form.requestSubmit()' %> </div>
<% end %>
<div class="mb-4">
</div> </div>
<% end %> <% end %>
<div class="mb-4"> </div>
</div> <% end %>
<% end %>
</div>
<% end %> <% end %>

Loading…
Cancel
Save