make template editor header native

This commit is contained in:
Alex Turchyn authored and Pete Matsyburka committed 2026-09-23 10:59:54 +03:00
1 parent 9abdb68bc5
commit d36f40cafd
4 files changed
+65 -13

No files matched your search

+2 -1
View File
@@ -209,7 +209,8 @@ safeRegisterElement('template-builder', class extends HTMLElement {
withDownload: true, withDownload: true,
currencies: (this.dataset.currencies || '').split(',').filter(Boolean), currencies: (this.dataset.currencies || '').split(',').filter(Boolean),
acceptFileTypes: this.dataset.acceptFileTypes, acceptFileTypes: this.dataset.acceptFileTypes,
showTourStartForm: this.dataset.showTourStartForm === 'true' showTourStartForm: this.dataset.showTourStartForm === 'true',
nativeApp: this.dataset.nativeApp === 'true'
}) })
this.component = this.app.mount(this.appElem) this.component = this.app.mount(this.appElem)
+58 -7
View File
@@ -79,7 +79,7 @@
v-if="$slots.buttons || withTitle" v-if="$slots.buttons || withTitle"
id="title_container" id="title_container"
class="flex justify-between py-1.5 items-center pr-4 top-0 z-10 title-container" class="flex justify-between py-1.5 items-center pr-4 top-0 z-10 title-container"
:class="{ sticky: withStickySubmitters || isBreakpointLg }" :class="{ sticky: withStickySubmitters || isBreakpointLg, hidden: nativeApp }"
:style="{ backgroundColor }" :style="{ backgroundColor }"
> >
<div class="flex items-center space-x-3"> <div class="flex items-center space-x-3">
@@ -104,8 +104,12 @@
name="buttons" name="buttons"
/> />
<template v-else> <template v-else>
<form <native-action
v-if="withSignYourselfButton && undefinedSubmitters.length < 2 && (!template.variables_schema || Object.keys(template.variables_schema).length === 0)" v-if="withSignYourselfButton && undefinedSubmitters.length < 2 && (!template.variables_schema || Object.keys(template.variables_schema).length === 0)"
:data-label="t('sign_yourself')"
data-icon="writing"
>
<form
target="_blank" target="_blank"
data-turbo="false" data-turbo="false"
class="inline" class="inline"
@@ -138,8 +142,13 @@
</span> </span>
</button> </button>
</form> </form>
<a </native-action>
<native-action
v-else-if="withSignYourselfButton" v-else-if="withSignYourselfButton"
:data-label="t('sign_yourself')"
data-icon="writing"
>
<a
id="sign_yourself_button" id="sign_yourself_button"
:href="`/templates/${template.id}/submissions/new?selfsign=true`" :href="`/templates/${template.id}/submissions/new?selfsign=true`"
class="btn btn-primary btn-ghost text-base hidden md:flex" class="btn btn-primary btn-ghost text-base hidden md:flex"
@@ -154,11 +163,17 @@
{{ t('sign_yourself') }} {{ t('sign_yourself') }}
</span> </span>
</a> </a>
<a </native-action>
<native-action
v-if="withSendButton" v-if="withSendButton"
:data-label="t('send')"
data-icon="users_plus"
data-placement="bar"
>
<a
id="send_button" id="send_button"
:href="`/templates/${template.id}/submissions/new?with_link=true`" :href="`/templates/${template.id}/submissions/new?with_link=true`"
:data-turbo-frame="isMobile && isBreakpointLg ? '_top' : 'modal'" :data-turbo-frame="!nativeApp && isMobile && isBreakpointLg ? '_top' : 'modal'"
class="white-button md:!px-6" class="white-button md:!px-6"
@click="maybeShowErrorTemplateAlert" @click="maybeShowErrorTemplateAlert"
> >
@@ -170,10 +185,16 @@
{{ t('send') }} {{ t('send') }}
</span> </span>
</a> </a>
</native-action>
<span <span
v-if="editable" v-if="editable"
id="save_button_container" id="save_button_container"
class="flex" class="flex"
>
<native-action
:data-label="t('save')"
data-icon="device_floppy"
data-placement="bar"
> >
<button <button
class="base-button !rounded-r-none !pr-2" class="base-button !rounded-r-none !pr-2"
@@ -194,6 +215,7 @@
{{ t('save') }} {{ t('save') }}
</span> </span>
</button> </button>
</native-action>
<div <div
class="dropdown dropdown-end" class="dropdown dropdown-end"
:class="{ 'dropdown-open': isDownloading || isPreviewLoading }" :class="{ 'dropdown-open': isDownloading || isPreviewLoading }"
@@ -211,6 +233,10 @@
class="dropdown-content p-2 mt-2 shadow menu text-base bg-base-100 rounded-box text-right" class="dropdown-content p-2 mt-2 shadow menu text-base bg-base-100 rounded-box text-right"
> >
<li> <li>
<native-action
:data-label="t('save_and_preview')"
data-icon="eye"
>
<a <a
:href="`/templates/${template.id}/form`" :href="`/templates/${template.id}/form`"
data-turbo="false" data-turbo="false"
@@ -227,19 +253,29 @@
/> />
<span class="whitespace-nowrap">{{ t('save_and_preview') }}</span> <span class="whitespace-nowrap">{{ t('save_and_preview') }}</span>
</a> </a>
</native-action>
</li> </li>
<li> <li>
<native-action
:data-label="t('preferences')"
data-icon="adjustments_horizontal"
>
<a <a
:href="`/templates/${template.id}/preferences`" :href="`/templates/${template.id}/preferences`"
:data-turbo-frame="isMobile && isBreakpointLg ? '_top' : 'modal'" :data-turbo-frame="!nativeApp && isMobile && isBreakpointLg ? '_top' : 'modal'"
class="flex space-x-2" class="flex space-x-2"
@click="closeDropdown" @click="closeDropdown"
> >
<IconAdjustments class="w-6 h-6 flex-shrink-0" /> <IconAdjustments class="w-6 h-6 flex-shrink-0" />
<span class="whitespace-nowrap">{{ t('preferences') }}</span> <span class="whitespace-nowrap">{{ t('preferences') }}</span>
</a> </a>
</native-action>
</li> </li>
<li v-if="withRevisionsMenu"> <li v-if="withRevisionsMenu">
<native-action
:data-label="t('revisions')"
data-icon="history"
>
<button <button
class="flex space-x-2" class="flex space-x-2"
@click.prevent="openRevisionsModal" @click.prevent="openRevisionsModal"
@@ -250,8 +286,13 @@
</span> </span>
<span class="whitespace-nowrap">{{ t('revisions') }}</span> <span class="whitespace-nowrap">{{ t('revisions') }}</span>
</button> </button>
</native-action>
</li> </li>
<li v-if="withDownload"> <li v-if="withDownload">
<native-action
:data-label="t('download')"
data-icon="download"
>
<button <button
class="flex space-x-2" class="flex space-x-2"
:disabled="isDownloading" :disabled="isDownloading"
@@ -274,6 +315,7 @@
class="whitespace-nowrap" class="whitespace-nowrap"
>{{ t('download') }}</span> >{{ t('download') }}</span>
</button> </button>
</native-action>
</li> </li>
</ul> </ul>
</div> </div>
@@ -297,7 +339,7 @@
<div <div
id="main_container" id="main_container"
class="flex main-container" class="flex main-container"
:class="$slots.buttons || withTitle ? (isMobile ? 'max-h-[calc(100%_-_60px)]' : 'md:max-h-[calc(100%_-_60px)]') : (isMobile ? 'max-h-[100%]' : 'md:max-h-[100%]')" :class="($slots.buttons || withTitle) && !nativeApp ? (isMobile ? 'max-h-[calc(100%_-_60px)]' : 'md:max-h-[calc(100%_-_60px)]') : (isMobile ? 'max-h-[100%]' : 'md:max-h-[100%]')"
> >
<div <div
v-if="withDocumentsList" v-if="withDocumentsList"
@@ -1008,6 +1050,11 @@ export default {
required: false, required: false,
default: true default: true
}, },
nativeApp: {
type: Boolean,
required: false,
default: false
},
withFieldsSearch: { withFieldsSearch: {
type: Boolean, type: Boolean,
required: false, required: false,
@@ -1665,6 +1712,10 @@ export default {
this.debouncedSave() this.debouncedSave()
}, },
download () { download () {
const download = window.webkit?.messageHandlers?.download
if (download) return download.postMessage({ src: `/templates/${this.template.id}/documents` })
this.isDownloading = true this.isDownloading = true
this.baseFetch(`/templates/${this.template.id}/documents`).then(async (response) => { this.baseFetch(`/templates/${this.template.id}/documents`).then(async (response) => {
+4 -4
View File
@@ -78,8 +78,8 @@
<% end %> <% end %>
<ul class="z-10 dropdown-content p-2 mt-2 shadow menu text-base bg-base-100 rounded-box text-right"> <ul class="z-10 dropdown-content p-2 mt-2 shadow menu text-base bg-base-100 rounded-box text-right">
<% if show_combined_download %> <% if show_combined_download %>
<native-action data-label="<%= t('download_combined_pdf') %>" data-icon="download">
<li> <li>
<native-action data-label="<%= t('download_combined_pdf') %>" data-icon="download">
<download-button role="button" tabindex="0" data-src="<%= local_assigns[:is_preview] ? (@sig_submitter ? submit_form_documents_path(@sig_submitter.slug, { sig: params[:sig], combined: true }.compact) : submissions_preview_download_index_path(@submission.slug, combined: true)) : submission_download_index_path(@submission, combined: true) %>" class="flex items-center"> <download-button role="button" tabindex="0" data-src="<%= local_assigns[:is_preview] ? (@sig_submitter ? submit_form_documents_path(@sig_submitter.slug, { sig: params[:sig], combined: true }.compact) : submissions_preview_download_index_path(@submission.slug, combined: true)) : submission_download_index_path(@submission, combined: true) %>" class="flex items-center">
<span class="flex items-center justify-center space-x-2" data-target="download-button.defaultButton"> <span class="flex items-center justify-center space-x-2" data-target="download-button.defaultButton">
<%= svg_icon('download', class: 'w-6 h-6 flex-shrink-0') %> <%= svg_icon('download', class: 'w-6 h-6 flex-shrink-0') %>
@@ -90,18 +90,18 @@
<span><%= t('downloading') %></span> <span><%= t('downloading') %></span>
</span> </span>
</download-button> </download-button>
</li>
</native-action> </native-action>
</li>
<% end %> <% end %>
<% if show_unarchive %> <% if show_unarchive %>
<native-action data-label="<%= t('unarchive') %>" data-icon="rotate">
<li> <li>
<native-action data-label="<%= t('unarchive') %>" data-icon="rotate">
<button form="submission_unarchive_form"> <button form="submission_unarchive_form">
<%= button_title(title: t('unarchive'), disabled_with: t('unarchive'), icon: svg_icon('rotate', class: 'w-6 h-6 flex-shrink-0')) %> <%= button_title(title: t('unarchive'), disabled_with: t('unarchive'), icon: svg_icon('rotate', class: 'w-6 h-6 flex-shrink-0')) %>
</button> </button>
</native-action>
<%= button_to '', submission_unarchive_index_path(@submission), form: { id: 'submission_unarchive_form' }, form_class: 'hidden' %> <%= button_to '', submission_unarchive_index_path(@submission), form: { id: 'submission_unarchive_form' }, form_class: 'hidden' %>
</li> </li>
</native-action>
<% end %> <% end %>
</ul> </ul>
</div> </div>
+1 -1
View File
@@ -10,4 +10,4 @@
<% account_configs = current_account.account_configs.where(key: [AccountConfig::TEMPLATE_CUSTOM_FIELDS_KEY, AccountConfig::TEMPLATE_DATE_FORMATS_KEY]).to_a %> <% account_configs = current_account.account_configs.where(key: [AccountConfig::TEMPLATE_CUSTOM_FIELDS_KEY, AccountConfig::TEMPLATE_DATE_FORMATS_KEY]).to_a %>
<% custom_fields = account_configs.find { |e| e.key == AccountConfig::TEMPLATE_CUSTOM_FIELDS_KEY }&.value || [] %> <% custom_fields = account_configs.find { |e| e.key == AccountConfig::TEMPLATE_CUSTOM_FIELDS_KEY }&.value || [] %>
<% date_formats = account_configs.find { |e| e.key == AccountConfig::TEMPLATE_DATE_FORMATS_KEY }&.value || [] %> <% date_formats = account_configs.find { |e| e.key == AccountConfig::TEMPLATE_DATE_FORMATS_KEY }&.value || [] %>
<template-builder class="grid" data-template="<%= @template_data.to_json %>" data-custom-fields="<%= custom_fields.to_json %>" data-date-formats="<%= date_formats.to_json %>" data-with-sign-yourself-button="<%= !@template.archived_at? %>" data-with-fields-detection="true" data-with-send-button="<%= !@template.archived_at? && can?(:create, @template.submissions.new(account: current_account)) %>" data-with-revisions-menu="<%= @template.template_versions.exists? %>" data-locale="<%= I18n.locale %>" data-show-tour-start-form="<%= @show_tour_start_form %>"></template-builder> <template-builder data-native-app="<%= turbo_native_app? %>" class="grid" data-template="<%= @template_data.to_json %>" data-custom-fields="<%= custom_fields.to_json %>" data-date-formats="<%= date_formats.to_json %>" data-with-sign-yourself-button="<%= !@template.archived_at? %>" data-with-fields-detection="true" data-with-send-button="<%= !@template.archived_at? && can?(:create, @template.submissions.new(account: current_account)) %>" data-with-revisions-menu="<%= @template.template_versions.exists? %>" data-locale="<%= I18n.locale %>" data-show-tour-start-form="<%= @show_tour_start_form %>"></template-builder>