show shared link enable button on disabled link page
This commit is contained in:
committed by
Pete Matsyburka
parent
a6715d4034
commit
7b1b4bcf2c
@@ -10,7 +10,11 @@ class TemplatesShareLinkController < ApplicationController
|
|||||||
|
|
||||||
@template.update!(template_params)
|
@template.update!(template_params)
|
||||||
|
|
||||||
head :ok
|
if params[:redir].present?
|
||||||
|
redirect_to params[:redir]
|
||||||
|
else
|
||||||
|
head :ok
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
export default class extends HTMLElement {
|
export default class extends HTMLElement {
|
||||||
connectedCallback () {
|
connectedCallback () {
|
||||||
this.addEventListener('click', () => {
|
this.addEventListener('click', () => {
|
||||||
if (!this.element.checked) {
|
if (this.element && !this.element.disabled && !this.element.checked) {
|
||||||
this.element.checked = true
|
this.element.checked = true
|
||||||
this.element.dispatchEvent(new Event('change', { bubbles: true }))
|
this.element.dispatchEvent(new Event('change', { bubbles: true }))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,29 +2,30 @@
|
|||||||
<% I18n.with_locale(@template.account.locale) do %>
|
<% I18n.with_locale(@template.account.locale) do %>
|
||||||
<% content_for(:html_description, t('share_link_is_currently_disabled')) %>
|
<% content_for(:html_description, t('share_link_is_currently_disabled')) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<div class="max-w-md mx-auto px-2 mt-12 mb-4">
|
<div class="max-w-md space-y-6 mx-auto px-2 mt-12 mb-4">
|
||||||
<div class="space-y-6 mx-auto">
|
<div class="text-center w-full space-y-6">
|
||||||
<div class="space-y-6">
|
<%= render 'banner' %>
|
||||||
<div class="text-center w-full space-y-6">
|
<p class="text-xl font-semibold text-center">
|
||||||
<%= render 'banner' %>
|
<%= t('share_link_is_currently_disabled') %>
|
||||||
<p class="text-xl font-semibold text-center">
|
</p>
|
||||||
<%= t('share_link_is_currently_disabled') %>
|
</div>
|
||||||
</p>
|
<div class="flex items-center bg-base-200 rounded-xl p-4 mb-4">
|
||||||
|
<div class="flex items-center">
|
||||||
|
<div class="mr-3">
|
||||||
|
<%= svg_icon('writing_sign', class: 'w-10 h-10') %>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex items-center bg-base-200 rounded-xl p-4 mb-4">
|
<div>
|
||||||
<div class="flex items-center">
|
<p class="text-lg font-bold mb-1"><%= @template.name %></p>
|
||||||
<div class="mr-3">
|
<% if @template.archived_at? %>
|
||||||
<%= svg_icon('writing_sign', class: 'w-10 h-10') %>
|
<p dir="auto" class="text-sm"><%= t('form_has_been_deleted_by_html', name: @template.account.name) %></p>
|
||||||
</div>
|
<% end %>
|
||||||
<div>
|
|
||||||
<p class="text-lg font-bold mb-1"><%= @template.name %></p>
|
|
||||||
<% if @template.archived_at? %>
|
|
||||||
<p dir="auto" class="text-sm"><%= t('form_has_been_deleted_by_html', name: @template.account.name) %></p>
|
|
||||||
<% end %>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<% if can?(:update, @template) %>
|
||||||
|
<toggle-submit class="block">
|
||||||
|
<%= button_to button_title(title: t('enable_shared_link'), icon: svg_icon('lock_open', class: 'w-6 h-6')), template_share_link_path(@template), params: { template: { shared_link: true }, redir: start_form_path(slug: @template.slug) }, method: :post, class: 'white-button w-full' %>
|
||||||
|
</toggle-submit>
|
||||||
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<%= render 'shared/attribution', link_path: '/start', account: @template.account %>
|
<%= render 'shared/attribution', link_path: '/start', account: @template.account %>
|
||||||
|
|||||||
@@ -848,6 +848,33 @@ RSpec.describe 'Signing Form' do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'when the template shared link is disabled' do
|
||||||
|
let(:template) do
|
||||||
|
create(:template, shared_link: false, account:, author:, only_field_types: %w[text])
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when user is logged in' do
|
||||||
|
before do
|
||||||
|
login_as author
|
||||||
|
visit start_form_path(slug: template.slug)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'shows a warning that the shared link is disabled and provides an option to enable it' do
|
||||||
|
expect(page).to have_content('Share link is currently disabled')
|
||||||
|
expect(page).to have_content(template.name)
|
||||||
|
expect(page).to have_button('Enable shared link')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'enables the shared link' do
|
||||||
|
expect do
|
||||||
|
click_button 'Enable shared link'
|
||||||
|
end.to change { template.reload.shared_link }.from(false).to(true)
|
||||||
|
|
||||||
|
expect(page).to have_content('You have been invited to submit a form')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
it 'sends completed email' do
|
it 'sends completed email' do
|
||||||
template = create(:template, account:, author:, only_field_types: %w[text signature])
|
template = create(:template, account:, author:, only_field_types: %w[text signature])
|
||||||
submission = create(:submission, template:)
|
submission = create(:submission, template:)
|
||||||
|
|||||||
Reference in New Issue
Block a user