fix dynamic document preview
This commit is contained in:
@@ -13,6 +13,8 @@ class TemplatesFormPreviewController < ApplicationController
|
|||||||
|
|
||||||
@submitter.submission.submitters = @template.submitters.map { |item| Submitter.new(uuid: item['uuid']) }
|
@submitter.submission.submitters = @template.submitters.map { |item| Submitter.new(uuid: item['uuid']) }
|
||||||
|
|
||||||
|
Submissions::CreateFromSubmitters.maybe_set_dynamic_documents(@submitter.submission, preview: true)
|
||||||
|
|
||||||
Submissions.preload_with_pages(@submitter.submission)
|
Submissions.preload_with_pages(@submitter.submission)
|
||||||
|
|
||||||
@attachments_index = ActiveStorage::Attachment.where(record: @submitter.submission.submitters, name: :attachments)
|
@attachments_index = ActiveStorage::Attachment.where(record: @submitter.submission.submitters, name: :attachments)
|
||||||
|
|||||||
@@ -202,7 +202,7 @@
|
|||||||
</button>
|
</button>
|
||||||
<div
|
<div
|
||||||
class="dropdown dropdown-end"
|
class="dropdown dropdown-end"
|
||||||
:class="{ 'dropdown-open': isDownloading }"
|
:class="{ 'dropdown-open': isDownloading || isPreviewLoading }"
|
||||||
>
|
>
|
||||||
<label
|
<label
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
@@ -221,8 +221,16 @@
|
|||||||
:href="`/templates/${template.id}/form`"
|
:href="`/templates/${template.id}/form`"
|
||||||
data-turbo="false"
|
data-turbo="false"
|
||||||
class="flex items-center justify-center space-x-2"
|
class="flex items-center justify-center space-x-2"
|
||||||
|
@click.exact="isPreviewLoading = true"
|
||||||
>
|
>
|
||||||
<IconEye class="w-6 h-6 flex-shrink-0" />
|
<IconInnerShadowTop
|
||||||
|
v-if="isPreviewLoading"
|
||||||
|
class="animate-spin w-6 h-6 flex-shrink-0"
|
||||||
|
/>
|
||||||
|
<IconEye
|
||||||
|
v-else
|
||||||
|
class="w-6 h-6 flex-shrink-0"
|
||||||
|
/>
|
||||||
<span class="whitespace-nowrap">{{ t('save_and_preview') }}</span>
|
<span class="whitespace-nowrap">{{ t('save_and_preview') }}</span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
@@ -1122,6 +1130,7 @@ export default {
|
|||||||
documentRefs: [],
|
documentRefs: [],
|
||||||
isBreakpointLg: false,
|
isBreakpointLg: false,
|
||||||
isDownloading: false,
|
isDownloading: false,
|
||||||
|
isPreviewLoading: false,
|
||||||
isLoadingBlankPage: false,
|
isLoadingBlankPage: false,
|
||||||
isSaving: false,
|
isSaving: false,
|
||||||
isDetectingPageFields: false,
|
isDetectingPageFields: false,
|
||||||
|
|||||||
@@ -130,13 +130,13 @@ module Submissions
|
|||||||
submission
|
submission
|
||||||
end
|
end
|
||||||
|
|
||||||
def maybe_set_dynamic_documents(submission)
|
def maybe_set_dynamic_documents(submission, preview: false)
|
||||||
return submission unless submission.template_id?
|
return submission unless submission.template_id?
|
||||||
|
|
||||||
template = submission.template
|
template = submission.template
|
||||||
|
|
||||||
return submission if template.variables_schema.present? ||
|
return submission if !preview && (template.variables_schema.present? ||
|
||||||
submission.variables_schema.present?
|
submission.variables_schema.present?)
|
||||||
|
|
||||||
return submission if template.schema.none? { |e| e['dynamic'] }
|
return submission if template.schema.none? { |e| e['dynamic'] }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user