mirror of
https://github.com/docusealco/docuseal
synced 2026-11-11 07:42:32 -05:00
adjust native
This commit is contained in:
1 parent
a86f896694
commit
d35538e2ba
17 files changed
+121
-96
No files matched your search
@@ -1,5 +1,5 @@
|
|||||||
import '@hotwired/turbo-rails'
|
import '@hotwired/turbo-rails'
|
||||||
import './elements/native_bridge'
|
import './native'
|
||||||
|
|
||||||
import { createApp, reactive } from 'vue'
|
import { createApp, reactive } from 'vue'
|
||||||
import TemplateBuilder from './template_builder/builder'
|
import TemplateBuilder from './template_builder/builder'
|
||||||
@@ -81,63 +81,12 @@ document.addEventListener('keyup', (e) => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
if (window.webkit?.messageHandlers?.native) {
|
|
||||||
const staleSnapshots = new Set()
|
|
||||||
let isRestoring = false
|
|
||||||
|
|
||||||
window.Turbo.session.view.clearSnapshotCache = function () {
|
|
||||||
this.snapshotCache.keys.forEach((key) => staleSnapshots.add(key))
|
|
||||||
}
|
|
||||||
|
|
||||||
document.addEventListener('turbo:submit-end', (e) => {
|
|
||||||
if (e.detail.success && !e.detail.formSubmission.isSafe) {
|
|
||||||
window.webkit.messageHandlers.native.postMessage({ type: 'stale' })
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
document.addEventListener('native:pull-to-refresh', (event) => {
|
|
||||||
const { session } = window.Turbo
|
|
||||||
const url = new URL(document.baseURI)
|
|
||||||
|
|
||||||
url.searchParams.delete('limit')
|
|
||||||
|
|
||||||
session.history.replace(url, session.history.restorationIdentifier)
|
|
||||||
session.view.lastRenderedLocation = url
|
|
||||||
|
|
||||||
event.detail.result = new Promise((resolve) => {
|
|
||||||
document.addEventListener('turbo:render', () => resolve(true), { once: true })
|
|
||||||
document.addEventListener('turbo:fetch-request-error', () => resolve(true), { once: true })
|
|
||||||
|
|
||||||
session.refresh(document.baseURI)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
document.addEventListener('native:refresh', () => {
|
|
||||||
window.Turbo.session.refresh(document.baseURI)
|
|
||||||
})
|
|
||||||
|
|
||||||
document.addEventListener('native:turbo-stream', (e) => {
|
|
||||||
if (!e.detail.body?.trimStart().startsWith('<turbo-stream')) return
|
|
||||||
|
|
||||||
window.Turbo.renderStreamMessage(e.detail.body)
|
|
||||||
})
|
|
||||||
|
|
||||||
document.addEventListener('turbo:visit', (e) => {
|
|
||||||
isRestoring = e.detail.action === 'restore'
|
|
||||||
})
|
|
||||||
|
|
||||||
document.addEventListener('turbo:load', () => {
|
|
||||||
if (staleSnapshots.delete(window.location.href.split('#')[0]) && isRestoring && window.location.pathname !== '/search') {
|
|
||||||
setTimeout(() => window.Turbo.session.refresh(document.baseURI))
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
document.addEventListener('turbo:before-fetch-response', (event) => {
|
document.addEventListener('turbo:before-fetch-response', (event) => {
|
||||||
if (event.detail.fetchResponse.header('content-disposition')?.includes('attachment')) {
|
if (event.detail.fetchResponse.header('content-disposition')?.includes('attachment')) {
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
document.addEventListener('turbo:submit-end', async (event) => {
|
document.addEventListener('turbo:submit-end', async (event) => {
|
||||||
const resp = event.detail?.formSubmission?.result?.fetchResponse?.response
|
const resp = event.detail?.formSubmission?.result?.fetchResponse?.response
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
let counter = 0
|
|
||||||
|
|
||||||
export default class extends HTMLElement {
|
export default class extends HTMLElement {
|
||||||
connectedCallback () {
|
connectedCallback () {
|
||||||
const bridge = window.webkit?.messageHandlers?.native
|
const bridge = window.webkit?.messageHandlers?.native
|
||||||
@@ -10,7 +8,7 @@ export default class extends HTMLElement {
|
|||||||
|
|
||||||
if (!target && !this.dataset.native) return
|
if (!target && !this.dataset.native) return
|
||||||
|
|
||||||
this.nativeId ||= `native-action-${++counter}`
|
this.nativeId ||= `native-action-${Math.random().toString(32).split('.')[1]}`
|
||||||
this.id = this.nativeId
|
this.id = this.nativeId
|
||||||
|
|
||||||
if (target) target.dataset.nativeId = this.nativeId
|
if (target) target.dataset.nativeId = this.nativeId
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
let counter = 0
|
|
||||||
|
|
||||||
export default class extends HTMLElement {
|
export default class extends HTMLElement {
|
||||||
connectedCallback () {
|
connectedCallback () {
|
||||||
if (window.webkit?.messageHandlers?.native) {
|
if (window.webkit?.messageHandlers?.native) {
|
||||||
@@ -28,7 +26,7 @@ export default class extends HTMLElement {
|
|||||||
const items = [...this.querySelectorAll('native-menu-action')].map((action) => {
|
const items = [...this.querySelectorAll('native-menu-action')].map((action) => {
|
||||||
const target = action.querySelector('a, button, [role="button"]') || action.firstElementChild
|
const target = action.querySelector('a, button, [role="button"]') || action.firstElementChild
|
||||||
|
|
||||||
target.dataset.nativeId ||= `native-menu-${++counter}`
|
target.dataset.nativeId ||= `native-menu-${Math.random().toString(32).split('.')[1]}`
|
||||||
|
|
||||||
return {
|
return {
|
||||||
id: target.dataset.nativeId,
|
id: target.dataset.nativeId,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import './elements/native_bridge'
|
import './native'
|
||||||
|
|
||||||
import { createApp, reactive } from 'vue'
|
import { createApp, reactive } from 'vue'
|
||||||
|
|
||||||
@@ -45,6 +45,7 @@ safeRegisterElement('submission-form', class extends HTMLElement {
|
|||||||
withSignatureId: this.dataset.withSignatureId === 'true',
|
withSignatureId: this.dataset.withSignatureId === 'true',
|
||||||
requireSigningReason: this.dataset.requireSigningReason === 'true',
|
requireSigningReason: this.dataset.requireSigningReason === 'true',
|
||||||
withConfetti: this.dataset.withConfetti === 'true',
|
withConfetti: this.dataset.withConfetti === 'true',
|
||||||
|
nativePlatform: this.dataset.nativePlatform,
|
||||||
withFieldLabels: this.dataset.withFieldLabels !== 'false',
|
withFieldLabels: this.dataset.withFieldLabels !== 'false',
|
||||||
withDisclosure: this.dataset.withDisclosure === 'true',
|
withDisclosure: this.dataset.withDisclosure === 'true',
|
||||||
reuseSignature: this.dataset.reuseSignature !== 'false',
|
reuseSignature: this.dataset.reuseSignature !== 'false',
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ if (handlers?.native && window === window.top) {
|
|||||||
reportPageFlash()
|
reportPageFlash()
|
||||||
|
|
||||||
document.addEventListener('click', (event) => {
|
document.addEventListener('click', (event) => {
|
||||||
const link = event.target.closest?.('a[href]')
|
const link = event.target.closest('a[href]')
|
||||||
|
|
||||||
if (!link) return
|
if (!link) return
|
||||||
|
|
||||||
@@ -52,7 +52,7 @@ if (handlers?.native && window === window.top) {
|
|||||||
document.addEventListener('click', (event) => {
|
document.addEventListener('click', (event) => {
|
||||||
if (document.querySelector('native-modal')) return
|
if (document.querySelector('native-modal')) return
|
||||||
|
|
||||||
const link = event.target.closest?.('a[data-turbo-frame="modal"], a[data-turbo-frame="drawer"]')
|
const link = event.target.closest('a[data-turbo-frame="modal"], a[data-turbo-frame="drawer"]')
|
||||||
|
|
||||||
if (!link?.href) return
|
if (!link?.href) return
|
||||||
|
|
||||||
@@ -72,3 +72,55 @@ if (handlers?.native && window === window.top) {
|
|||||||
event.detail.result = rect?.height ? rect.bottom - document.documentElement.getBoundingClientRect().top : null
|
event.detail.result = rect?.height ? rect.bottom - document.documentElement.getBoundingClientRect().top : null
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (handlers?.native && window.Turbo) {
|
||||||
|
const staleSnapshots = new Set()
|
||||||
|
let isRestoring = false
|
||||||
|
|
||||||
|
window.Turbo.session.view.clearSnapshotCache = function () {
|
||||||
|
this.snapshotCache.keys.forEach((key) => staleSnapshots.add(key))
|
||||||
|
}
|
||||||
|
|
||||||
|
document.addEventListener('turbo:submit-end', (e) => {
|
||||||
|
if (e.detail.success && !e.detail.formSubmission.isSafe) {
|
||||||
|
handlers.native.postMessage({ type: 'stale' })
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
document.addEventListener('native:pull-to-refresh', (event) => {
|
||||||
|
const { session } = window.Turbo
|
||||||
|
const url = new URL(document.baseURI)
|
||||||
|
|
||||||
|
url.searchParams.delete('limit')
|
||||||
|
|
||||||
|
session.history.replace(url, session.history.restorationIdentifier)
|
||||||
|
session.view.lastRenderedLocation = url
|
||||||
|
|
||||||
|
event.detail.result = new Promise((resolve) => {
|
||||||
|
document.addEventListener('turbo:render', () => resolve(true), { once: true })
|
||||||
|
document.addEventListener('turbo:fetch-request-error', () => resolve(true), { once: true })
|
||||||
|
|
||||||
|
session.refresh(document.baseURI)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
document.addEventListener('native:refresh', () => {
|
||||||
|
window.Turbo.session.refresh(document.baseURI)
|
||||||
|
})
|
||||||
|
|
||||||
|
document.addEventListener('native:turbo-stream', (e) => {
|
||||||
|
if (!e.detail.body?.trimStart().startsWith('<turbo-stream')) return
|
||||||
|
|
||||||
|
window.Turbo.renderStreamMessage(e.detail.body)
|
||||||
|
})
|
||||||
|
|
||||||
|
document.addEventListener('turbo:visit', (e) => {
|
||||||
|
isRestoring = e.detail.action === 'restore'
|
||||||
|
})
|
||||||
|
|
||||||
|
document.addEventListener('turbo:load', () => {
|
||||||
|
if (staleSnapshots.delete(window.location.href.split('#')[0]) && isRestoring && window.location.pathname !== '/search') {
|
||||||
|
setTimeout(() => window.Turbo.session.refresh(document.baseURI))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -126,7 +126,7 @@ export default {
|
|||||||
IconLogin,
|
IconLogin,
|
||||||
IconDownload
|
IconDownload
|
||||||
},
|
},
|
||||||
inject: ['baseUrl', 't'],
|
inject: ['baseUrl', 't', 'nativePlatform'],
|
||||||
props: {
|
props: {
|
||||||
submitterSlug: {
|
submitterSlug: {
|
||||||
type: String,
|
type: String,
|
||||||
@@ -196,7 +196,7 @@ export default {
|
|||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
isNativeApp () {
|
isNativeApp () {
|
||||||
return !!window.webkit?.messageHandlers?.download
|
return !!this.nativePlatform && !!window.webkit?.messageHandlers?.download
|
||||||
},
|
},
|
||||||
isWebView () {
|
isWebView () {
|
||||||
return /webview|wv|ip((?!.*Safari)|(?=.*like Safari))/i.test(window.navigator.userAgent)
|
return /webview|wv|ip((?!.*Safari)|(?=.*like Safari))/i.test(window.navigator.userAgent)
|
||||||
|
|||||||
@@ -774,6 +774,7 @@ export default {
|
|||||||
baseUrl: this.baseUrl,
|
baseUrl: this.baseUrl,
|
||||||
scrollIntoArea: this.scrollIntoArea,
|
scrollIntoArea: this.scrollIntoArea,
|
||||||
scrollIntoField: this.scrollIntoField,
|
scrollIntoField: this.scrollIntoField,
|
||||||
|
nativePlatform: this.nativePlatform,
|
||||||
t: this.t
|
t: this.t
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -909,6 +910,11 @@ export default {
|
|||||||
required: false,
|
required: false,
|
||||||
default: false
|
default: false
|
||||||
},
|
},
|
||||||
|
nativePlatform: {
|
||||||
|
type: String,
|
||||||
|
required: false,
|
||||||
|
default: ''
|
||||||
|
},
|
||||||
autoscrollFields: {
|
autoscrollFields: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
required: false,
|
required: false,
|
||||||
@@ -1767,7 +1773,9 @@ export default {
|
|||||||
this.isCompleted = true
|
this.isCompleted = true
|
||||||
this.isFormVisible = true
|
this.isFormVisible = true
|
||||||
|
|
||||||
window.webkit?.messageHandlers?.native?.postMessage({ type: 'stale' })
|
if (this.nativePlatform) {
|
||||||
|
window.webkit?.messageHandlers?.native?.postMessage({ type: 'stale' })
|
||||||
|
}
|
||||||
|
|
||||||
if (resp?.text) {
|
if (resp?.text) {
|
||||||
const respData = await resp.text()
|
const respData = await resp.text()
|
||||||
|
|||||||
@@ -376,7 +376,7 @@ export default {
|
|||||||
IconSignature,
|
IconSignature,
|
||||||
IconArrowsDiagonalMinimize2
|
IconArrowsDiagonalMinimize2
|
||||||
},
|
},
|
||||||
inject: ['baseUrl', 't'],
|
inject: ['baseUrl', 't', 'nativePlatform'],
|
||||||
props: {
|
props: {
|
||||||
field: {
|
field: {
|
||||||
type: Object,
|
type: Object,
|
||||||
@@ -580,10 +580,14 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
lockSwipe () {
|
lockSwipe () {
|
||||||
window.webkit?.messageHandlers?.native?.postMessage({ type: 'swipe', op: 'lock' })
|
if (this.nativePlatform) {
|
||||||
|
window.webkit?.messageHandlers?.native?.postMessage({ type: 'swipe', op: 'lock' })
|
||||||
|
}
|
||||||
},
|
},
|
||||||
unlockSwipe () {
|
unlockSwipe () {
|
||||||
window.webkit?.messageHandlers?.native?.postMessage({ type: 'swipe', op: 'unlock' })
|
if (this.nativePlatform) {
|
||||||
|
window.webkit?.messageHandlers?.native?.postMessage({ type: 'swipe', op: 'unlock' })
|
||||||
|
}
|
||||||
},
|
},
|
||||||
setCanvasSize () {
|
setCanvasSize () {
|
||||||
const canvas = this.$refs.canvas
|
const canvas = this.$refs.canvas
|
||||||
|
|||||||
@@ -272,7 +272,7 @@ export default {
|
|||||||
FieldSubmitter,
|
FieldSubmitter,
|
||||||
IconX
|
IconX
|
||||||
},
|
},
|
||||||
inject: ['t', 'isMobile'],
|
inject: ['t', 'isMobile', 'nativePlatform'],
|
||||||
props: {
|
props: {
|
||||||
template: {
|
template: {
|
||||||
type: Object,
|
type: Object,
|
||||||
@@ -387,28 +387,28 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
openFormulaModal () {
|
openFormulaModal () {
|
||||||
if (window.webkit?.messageHandlers?.modal) {
|
if (this.nativePlatform && window.webkit?.messageHandlers?.modal) {
|
||||||
window.webkit.messageHandlers.modal.postMessage({ action: 'sheet', name: 'formula', detent: 'medium', uuid: this.field.uuid })
|
window.webkit.messageHandlers.modal.postMessage({ action: 'sheet', name: 'formula', detent: 'medium', uuid: this.field.uuid })
|
||||||
} else {
|
} else {
|
||||||
this.isShowFormulaModal = true
|
this.isShowFormulaModal = true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
openFontModal () {
|
openFontModal () {
|
||||||
if (window.webkit?.messageHandlers?.modal) {
|
if (this.nativePlatform && window.webkit?.messageHandlers?.modal) {
|
||||||
window.webkit.messageHandlers.modal.postMessage({ action: 'sheet', name: 'font', detent: 'medium', uuid: this.field.uuid })
|
window.webkit.messageHandlers.modal.postMessage({ action: 'sheet', name: 'font', detent: 'medium', uuid: this.field.uuid })
|
||||||
} else {
|
} else {
|
||||||
this.isShowFontModal = true
|
this.isShowFontModal = true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
openConditionsModal () {
|
openConditionsModal () {
|
||||||
if (window.webkit?.messageHandlers?.modal) {
|
if (this.nativePlatform && window.webkit?.messageHandlers?.modal) {
|
||||||
window.webkit.messageHandlers.modal.postMessage({ action: 'sheet', name: 'conditions', detent: 'medium', uuid: this.field.uuid })
|
window.webkit.messageHandlers.modal.postMessage({ action: 'sheet', name: 'conditions', detent: 'medium', uuid: this.field.uuid })
|
||||||
} else {
|
} else {
|
||||||
this.isShowConditionsModal = true
|
this.isShowConditionsModal = true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
openDescriptionModal () {
|
openDescriptionModal () {
|
||||||
if (window.webkit?.messageHandlers?.modal) {
|
if (this.nativePlatform && window.webkit?.messageHandlers?.modal) {
|
||||||
window.webkit.messageHandlers.modal.postMessage({ action: 'sheet', name: 'description', detent: 'medium', uuid: this.field.uuid })
|
window.webkit.messageHandlers.modal.postMessage({ action: 'sheet', name: 'description', detent: 'medium', uuid: this.field.uuid })
|
||||||
} else {
|
} else {
|
||||||
this.isShowDescriptionModal = true
|
this.isShowDescriptionModal = true
|
||||||
|
|||||||
@@ -1929,7 +1929,7 @@ export default {
|
|||||||
download () {
|
download () {
|
||||||
const download = window.webkit?.messageHandlers?.download
|
const download = window.webkit?.messageHandlers?.download
|
||||||
|
|
||||||
if (download) return download.postMessage({ src: `/templates/${this.template.id}/documents` })
|
if (this.nativePlatform && download) return download.postMessage({ src: `/templates/${this.template.id}/documents` })
|
||||||
|
|
||||||
this.isDownloading = true
|
this.isDownloading = true
|
||||||
|
|
||||||
@@ -2203,7 +2203,7 @@ export default {
|
|||||||
this.loadRevisionsPromise ||= this.baseFetch(`/templates/${this.template.id}/versions`)
|
this.loadRevisionsPromise ||= this.baseFetch(`/templates/${this.template.id}/versions`)
|
||||||
},
|
},
|
||||||
openRevisionsModal () {
|
openRevisionsModal () {
|
||||||
if (window.webkit?.messageHandlers?.modal) {
|
if (this.nativePlatform && window.webkit?.messageHandlers?.modal) {
|
||||||
return window.webkit.messageHandlers.modal.postMessage({ action: 'sheet', name: 'revisions', detent: 'medium' })
|
return window.webkit.messageHandlers.modal.postMessage({ action: 'sheet', name: 'revisions', detent: 'medium' })
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2220,7 +2220,7 @@ export default {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
openDocumentsEditor (item) {
|
openDocumentsEditor (item) {
|
||||||
if (window.webkit?.messageHandlers?.modal) {
|
if (this.nativePlatform && window.webkit?.messageHandlers?.modal) {
|
||||||
window.webkit.messageHandlers.modal.postMessage({ action: 'sheet', name: 'documents', viewport: 'fixed', uuid: item.attachment_uuid })
|
window.webkit.messageHandlers.modal.postMessage({ action: 'sheet', name: 'documents', viewport: 'fixed', uuid: item.attachment_uuid })
|
||||||
} else {
|
} else {
|
||||||
this.editModalDocumentUuid = item.attachment_uuid
|
this.editModalDocumentUuid = item.attachment_uuid
|
||||||
@@ -2438,7 +2438,9 @@ export default {
|
|||||||
ref?.$el.scrollIntoView({ behavior: 'smooth', block: 'start' })
|
ref?.$el.scrollIntoView({ behavior: 'smooth', block: 'start' })
|
||||||
},
|
},
|
||||||
postNativeEvent (name, detail, dismiss = false) {
|
postNativeEvent (name, detail, dismiss = false) {
|
||||||
window.webkit?.messageHandlers?.modal?.postMessage({ action: 'dispatch', name, detail: JSON.stringify(detail), dismiss: dismiss ? 'true' : 'false' })
|
if (this.nativePlatform) {
|
||||||
|
window.webkit?.messageHandlers?.modal?.postMessage({ action: 'dispatch', name, detail: JSON.stringify(detail), dismiss: dismiss ? 'true' : 'false' })
|
||||||
|
}
|
||||||
},
|
},
|
||||||
onDrawerScrollTo (item) {
|
onDrawerScrollTo (item) {
|
||||||
if (this.nativeView) {
|
if (this.nativeView) {
|
||||||
|
|||||||
@@ -209,7 +209,7 @@ export default {
|
|||||||
IconTrashX,
|
IconTrashX,
|
||||||
FieldType
|
FieldType
|
||||||
},
|
},
|
||||||
inject: ['backgroundColor', 't', 'isMobile'],
|
inject: ['backgroundColor', 't', 'isMobile', 'nativePlatform'],
|
||||||
props: {
|
props: {
|
||||||
field: {
|
field: {
|
||||||
type: Object,
|
type: Object,
|
||||||
@@ -261,21 +261,21 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
openFormulaModal () {
|
openFormulaModal () {
|
||||||
if (window.webkit?.messageHandlers?.modal) {
|
if (this.nativePlatform && window.webkit?.messageHandlers?.modal) {
|
||||||
window.webkit.messageHandlers.modal.postMessage({ action: 'sheet', name: 'formula', detent: 'medium', custom_field_uuid: this.field.uuid })
|
window.webkit.messageHandlers.modal.postMessage({ action: 'sheet', name: 'formula', detent: 'medium', custom_field_uuid: this.field.uuid })
|
||||||
} else {
|
} else {
|
||||||
this.isShowFormulaModal = true
|
this.isShowFormulaModal = true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
openFontModal () {
|
openFontModal () {
|
||||||
if (window.webkit?.messageHandlers?.modal) {
|
if (this.nativePlatform && window.webkit?.messageHandlers?.modal) {
|
||||||
window.webkit.messageHandlers.modal.postMessage({ action: 'sheet', name: 'font', detent: 'medium', custom_field_uuid: this.field.uuid })
|
window.webkit.messageHandlers.modal.postMessage({ action: 'sheet', name: 'font', detent: 'medium', custom_field_uuid: this.field.uuid })
|
||||||
} else {
|
} else {
|
||||||
this.isShowFontModal = true
|
this.isShowFontModal = true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
openDescriptionModal () {
|
openDescriptionModal () {
|
||||||
if (window.webkit?.messageHandlers?.modal) {
|
if (this.nativePlatform && window.webkit?.messageHandlers?.modal) {
|
||||||
window.webkit.messageHandlers.modal.postMessage({ action: 'sheet', name: 'description', detent: 'medium', custom_field_uuid: this.field.uuid })
|
window.webkit.messageHandlers.modal.postMessage({ action: 'sheet', name: 'description', detent: 'medium', custom_field_uuid: this.field.uuid })
|
||||||
} else {
|
} else {
|
||||||
this.isShowDescriptionModal = true
|
this.isShowDescriptionModal = true
|
||||||
|
|||||||
@@ -38,7 +38,12 @@
|
|||||||
v-if="withDescription"
|
v-if="withDescription"
|
||||||
class="text-sm"
|
class="text-sm"
|
||||||
>
|
>
|
||||||
<span class="font-medium">{{ t('click_to_upload') }}</span> {{ t('or_drag_and_drop_files') }}
|
<template v-if="isMobile">
|
||||||
|
{{ t('click_to_upload') }}
|
||||||
|
</template>
|
||||||
|
<template v-else>
|
||||||
|
<span class="font-medium">{{ t('click_to_upload') }}</span> {{ t('or_drag_and_drop_files') }}
|
||||||
|
</template>
|
||||||
</div>
|
</div>
|
||||||
<button
|
<button
|
||||||
v-if="withGoogleDrive"
|
v-if="withGoogleDrive"
|
||||||
@@ -83,7 +88,7 @@ export default {
|
|||||||
IconFiles,
|
IconFiles,
|
||||||
IconBrandGoogleDrive
|
IconBrandGoogleDrive
|
||||||
},
|
},
|
||||||
inject: ['baseFetch', 't'],
|
inject: ['baseFetch', 't', 'isMobile'],
|
||||||
props: {
|
props: {
|
||||||
templateId: {
|
templateId: {
|
||||||
type: [Number, String],
|
type: [Number, String],
|
||||||
|
|||||||
@@ -424,7 +424,7 @@ export default {
|
|||||||
IconMathFunction,
|
IconMathFunction,
|
||||||
FieldType
|
FieldType
|
||||||
},
|
},
|
||||||
inject: ['template', 'backgroundColor', 'selectedAreasRef', 't', 'locale', 'getFieldTypeIndex', 'dateFormats', 'isMobile'],
|
inject: ['template', 'backgroundColor', 'selectedAreasRef', 't', 'locale', 'getFieldTypeIndex', 'dateFormats', 'isMobile', 'nativePlatform'],
|
||||||
props: {
|
props: {
|
||||||
field: {
|
field: {
|
||||||
type: Object,
|
type: Object,
|
||||||
@@ -559,28 +559,28 @@ export default {
|
|||||||
this.$emit('save')
|
this.$emit('save')
|
||||||
},
|
},
|
||||||
openFormulaModal () {
|
openFormulaModal () {
|
||||||
if (window.webkit?.messageHandlers?.modal) {
|
if (this.nativePlatform && window.webkit?.messageHandlers?.modal) {
|
||||||
window.webkit.messageHandlers.modal.postMessage({ action: 'sheet', name: 'formula', detent: 'medium', uuid: this.field.uuid })
|
window.webkit.messageHandlers.modal.postMessage({ action: 'sheet', name: 'formula', detent: 'medium', uuid: this.field.uuid })
|
||||||
} else {
|
} else {
|
||||||
this.isShowFormulaModal = true
|
this.isShowFormulaModal = true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
openFontModal () {
|
openFontModal () {
|
||||||
if (window.webkit?.messageHandlers?.modal) {
|
if (this.nativePlatform && window.webkit?.messageHandlers?.modal) {
|
||||||
window.webkit.messageHandlers.modal.postMessage({ action: 'sheet', name: 'font', detent: 'medium', uuid: this.field.uuid })
|
window.webkit.messageHandlers.modal.postMessage({ action: 'sheet', name: 'font', detent: 'medium', uuid: this.field.uuid })
|
||||||
} else {
|
} else {
|
||||||
this.isShowFontModal = true
|
this.isShowFontModal = true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
openConditionsModal () {
|
openConditionsModal () {
|
||||||
if (window.webkit?.messageHandlers?.modal) {
|
if (this.nativePlatform && window.webkit?.messageHandlers?.modal) {
|
||||||
window.webkit.messageHandlers.modal.postMessage({ action: 'sheet', name: 'conditions', detent: 'medium', uuid: this.field.uuid })
|
window.webkit.messageHandlers.modal.postMessage({ action: 'sheet', name: 'conditions', detent: 'medium', uuid: this.field.uuid })
|
||||||
} else {
|
} else {
|
||||||
this.isShowConditionsModal = true
|
this.isShowConditionsModal = true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
openDescriptionModal () {
|
openDescriptionModal () {
|
||||||
if (window.webkit?.messageHandlers?.modal) {
|
if (this.nativePlatform && window.webkit?.messageHandlers?.modal) {
|
||||||
window.webkit.messageHandlers.modal.postMessage({ action: 'sheet', name: 'description', detent: 'medium', uuid: this.field.uuid })
|
window.webkit.messageHandlers.modal.postMessage({ action: 'sheet', name: 'description', detent: 'medium', uuid: this.field.uuid })
|
||||||
} else {
|
} else {
|
||||||
this.isShowDescriptionModal = true
|
this.isShowDescriptionModal = true
|
||||||
|
|||||||
@@ -874,7 +874,9 @@ export default {
|
|||||||
|
|
||||||
this.save()
|
this.save()
|
||||||
|
|
||||||
window.webkit?.messageHandlers?.flash?.postMessage({ style: 'notice', message: this.t('fields_detected').replace('{count}', (data.fields || fields).length) })
|
if (this.nativePlatform) {
|
||||||
|
window.webkit?.messageHandlers?.flash?.postMessage({ style: 'notice', message: this.t('fields_detected').replace('{count}', (data.fields || fields).length) })
|
||||||
|
}
|
||||||
|
|
||||||
break
|
break
|
||||||
} else if (data.fields) {
|
} else if (data.fields) {
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ export default {
|
|||||||
RevisionsModal,
|
RevisionsModal,
|
||||||
IconInnerShadowTop
|
IconInnerShadowTop
|
||||||
},
|
},
|
||||||
inject: ['t', 'template', 'locale', 'baseFetch', 'getFieldTypeIndex', 'save'],
|
inject: ['t', 'template', 'locale', 'baseFetch', 'getFieldTypeIndex', 'save', 'nativePlatform'],
|
||||||
props: {
|
props: {
|
||||||
defaultFields: {
|
defaultFields: {
|
||||||
type: Array,
|
type: Array,
|
||||||
@@ -203,7 +203,9 @@ export default {
|
|||||||
document.body.style.overflow = ''
|
document.body.style.overflow = ''
|
||||||
},
|
},
|
||||||
close () {
|
close () {
|
||||||
window.webkit?.messageHandlers?.modal?.postMessage({ action: 'closeSheet' })
|
if (this.nativePlatform) {
|
||||||
|
window.webkit?.messageHandlers?.modal?.postMessage({ action: 'closeSheet' })
|
||||||
|
}
|
||||||
},
|
},
|
||||||
onSave () {
|
onSave () {
|
||||||
if (this.modal?.custom_field_uuid) {
|
if (this.modal?.custom_field_uuid) {
|
||||||
@@ -222,7 +224,9 @@ export default {
|
|||||||
|
|
||||||
this.customFields.splice(0, this.customFields.length, ...fields)
|
this.customFields.splice(0, this.customFields.length, ...fields)
|
||||||
|
|
||||||
window.webkit?.messageHandlers?.modal?.postMessage({ action: 'dispatch', name: 'template-builder:sync-custom-fields', detail: JSON.stringify(fields), dismiss: 'false' })
|
if (this.nativePlatform) {
|
||||||
|
window.webkit?.messageHandlers?.modal?.postMessage({ action: 'dispatch', name: 'template-builder:sync-custom-fields', detail: JSON.stringify(fields), dismiss: 'false' })
|
||||||
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
loadRevisions () {
|
loadRevisions () {
|
||||||
@@ -233,7 +237,9 @@ export default {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
applyRevision (revision) {
|
applyRevision (revision) {
|
||||||
window.webkit?.messageHandlers?.modal?.postMessage({ action: 'dispatch', name: 'template-builder:apply-revision', detail: JSON.stringify(revision), dismiss: 'true' })
|
if (this.nativePlatform) {
|
||||||
|
window.webkit?.messageHandlers?.modal?.postMessage({ action: 'dispatch', name: 'template-builder:apply-revision', detail: JSON.stringify(revision), dismiss: 'true' })
|
||||||
|
}
|
||||||
},
|
},
|
||||||
onDocumentsSaved (data) {
|
onDocumentsSaved (data) {
|
||||||
this.$emit('documents-modified', data)
|
this.$emit('documents-modified', data)
|
||||||
|
|||||||
@@ -211,7 +211,7 @@ export default {
|
|||||||
IconBolt,
|
IconBolt,
|
||||||
IconPencil
|
IconPencil
|
||||||
},
|
},
|
||||||
inject: ['t', 'getFieldTypeIndex', 'baseFetch', 'isMobile'],
|
inject: ['t', 'getFieldTypeIndex', 'baseFetch', 'isMobile', 'nativePlatform'],
|
||||||
props: {
|
props: {
|
||||||
item: {
|
item: {
|
||||||
type: Object,
|
type: Object,
|
||||||
@@ -290,7 +290,7 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
openConditionsModal () {
|
openConditionsModal () {
|
||||||
if (window.webkit?.messageHandlers?.modal) {
|
if (this.nativePlatform && window.webkit?.messageHandlers?.modal) {
|
||||||
window.webkit.messageHandlers.modal.postMessage({ action: 'sheet', name: 'conditions', detent: 'medium', attachment_uuid: this.item.attachment_uuid })
|
window.webkit.messageHandlers.modal.postMessage({ action: 'sheet', name: 'conditions', detent: 'medium', attachment_uuid: this.item.attachment_uuid })
|
||||||
} else {
|
} else {
|
||||||
this.isShowConditionsModal = true
|
this.isShowConditionsModal = true
|
||||||
|
|||||||
@@ -2,4 +2,4 @@
|
|||||||
<% data_fields = Submissions.filtered_conditions_fields(submitter).to_json %>
|
<% data_fields = Submissions.filtered_conditions_fields(submitter).to_json %>
|
||||||
<% invite_submitters = (submitter.submission.template_submitters || submitter.submission.template.submitters).select { |s| s['invite_by_uuid'] == submitter.uuid && submitter.submission.submitters.none? { |e| e.uuid == s['uuid'] } }.to_json %>
|
<% invite_submitters = (submitter.submission.template_submitters || submitter.submission.template.submitters).select { |s| s['invite_by_uuid'] == submitter.uuid && submitter.submission.submitters.none? { |e| e.uuid == s['uuid'] } }.to_json %>
|
||||||
<% optional_invite_submitters = (submitter.submission.template_submitters || submitter.submission.template.submitters).select { |s| s['optional_invite_by_uuid'] == submitter.uuid && submitter.submission.submitters.none? { |e| e.uuid == s['uuid'] } }.to_json %>
|
<% optional_invite_submitters = (submitter.submission.template_submitters || submitter.submission.template.submitters).select { |s| s['optional_invite_by_uuid'] == submitter.uuid && submitter.submission.submitters.none? { |e| e.uuid == s['uuid'] } }.to_json %>
|
||||||
<submission-form data-attribution="<%= !turbo_native_app? %>" data-is-demo="<%= Docuseal.demo? %>" data-schema="<%= schema.to_json %>" data-reuse-signature="<%= configs[:reuse_signature] %>" data-require-signing-reason="<%= configs[:require_signing_reason] %>" data-with-signature-id="<%= configs[:with_signature_id] %>" data-with-field-labels="<%= configs[:with_field_labels] %>" data-with-confetti="<%= configs[:with_confetti] %>" data-completed-redirect-url="<%= submitter.preferences['completed_redirect_url'].presence || submitter.submission.template&.preferences&.dig('completed_redirect_url') %>" data-completed-message="<%= (configs[:completed_message]&.compact_blank.presence || submitter.submission.template&.preferences&.dig('completed_message') || {}).to_json %>" data-completed-button="<%= configs[:completed_button].to_json %>" data-go-to-last="<%= submitter.preferences.key?('go_to_last') ? submitter.preferences['go_to_last'] : submitter.opened_at? %>" data-submitter="<%= submitter.to_json(only: %i[uuid slug name phone email]) %>" data-can-send-email="<%= Docuseal.multitenant? || Accounts.can_send_emails?(submitter.submission.account) %>" data-optional-invite-submitters="<%= optional_invite_submitters %>" data-invite-submitters="<%= invite_submitters %>" data-attachments="<%= data_attachments %>" data-fields="<%= data_fields %>" data-values="<%= submitter.values.to_json %>" data-with-typed-signature="<%= configs[:with_typed_signature] %>" data-signature-text="<%= params[:signature] %>" data-previous-signature-value="<%= local_assigns[:signature_attachment]&.uuid %>" data-remember-signature="<%= configs[:prefill_signature] %>" data-dry-run="<%= local_assigns[:dry_run] %>" data-expand="<%= local_assigns[:expand] %>" data-scroll-padding="<%= local_assigns[:scroll_padding] %>" data-language="<%= I18n.locale.to_s.split('-').first %>"></submission-form>
|
<submission-form data-native-platform="<%= turbo_native_ios? ? 'ios' : (turbo_native_android? ? 'android' : '') %>" data-attribution="<%= !turbo_native_app? %>" data-is-demo="<%= Docuseal.demo? %>" data-schema="<%= schema.to_json %>" data-reuse-signature="<%= configs[:reuse_signature] %>" data-require-signing-reason="<%= configs[:require_signing_reason] %>" data-with-signature-id="<%= configs[:with_signature_id] %>" data-with-field-labels="<%= configs[:with_field_labels] %>" data-with-confetti="<%= configs[:with_confetti] %>" data-completed-redirect-url="<%= submitter.preferences['completed_redirect_url'].presence || submitter.submission.template&.preferences&.dig('completed_redirect_url') %>" data-completed-message="<%= (configs[:completed_message]&.compact_blank.presence || submitter.submission.template&.preferences&.dig('completed_message') || {}).to_json %>" data-completed-button="<%= configs[:completed_button].to_json %>" data-go-to-last="<%= submitter.preferences.key?('go_to_last') ? submitter.preferences['go_to_last'] : submitter.opened_at? %>" data-submitter="<%= submitter.to_json(only: %i[uuid slug name phone email]) %>" data-can-send-email="<%= Docuseal.multitenant? || Accounts.can_send_emails?(submitter.submission.account) %>" data-optional-invite-submitters="<%= optional_invite_submitters %>" data-invite-submitters="<%= invite_submitters %>" data-attachments="<%= data_attachments %>" data-fields="<%= data_fields %>" data-values="<%= submitter.values.to_json %>" data-with-typed-signature="<%= configs[:with_typed_signature] %>" data-signature-text="<%= params[:signature] %>" data-previous-signature-value="<%= local_assigns[:signature_attachment]&.uuid %>" data-remember-signature="<%= configs[:prefill_signature] %>" data-dry-run="<%= local_assigns[:dry_run] %>" data-expand="<%= local_assigns[:expand] %>" data-scroll-padding="<%= local_assigns[:scroll_padding] %>" data-language="<%= I18n.locale.to_s.split('-').first %>"></submission-form>
|
||||||
Reference in new issue
Block a user