Skip to content

Commit

Permalink
Merge from docusealco/wip
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexBTurchyn authored Jan 20, 2025
2 parents 288d204 + b0aabd9 commit 2da059d
Show file tree
Hide file tree
Showing 19 changed files with 135 additions and 35 deletions.
10 changes: 10 additions & 0 deletions app/javascript/submission_form/area.vue
Original file line number Diff line number Diff line change
Expand Up @@ -450,8 +450,18 @@ export default {
}
},
formatNumber (number, format) {
if (!number && number !== 0) {
return ''
}
if (format === 'comma') {
return new Intl.NumberFormat('en-US').format(number)
} else if (format === 'usd') {
return new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD', minimumFractionDigits: 2, maximumFractionDigits: 2 }).format(number)
} else if (format === 'gbp') {
return new Intl.NumberFormat('en-GB', { style: 'currency', currency: 'GBP', minimumFractionDigits: 2, maximumFractionDigits: 2 }).format(number)
} else if (format === 'eur') {
return new Intl.NumberFormat('fr-FR', { style: 'currency', currency: 'EUR', minimumFractionDigits: 2, maximumFractionDigits: 2 }).format(number)
} else if (format === 'dot') {
return new Intl.NumberFormat('de-DE').format(number)
} else if (format === 'space') {
Expand Down
6 changes: 4 additions & 2 deletions app/javascript/submission_form/areas.vue
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,15 @@ export default {
const formContainer = root.getElementById('form_container')
const container = root.body || root.querySelector('div')
const padding = 64
const isAndroid = /android/i.test(navigator.userAgent)
const padding = isAndroid ? 128 : 64
const scrollboxTop = isAndroid ? scrollbox.getBoundingClientRect().top : 0
const boxRect = scrollbox.children[0].getBoundingClientRect()
const targetRect = target.getBoundingClientRect()
const targetTopRelativeToBox = targetRect.top - boxRect.top
scrollbox.scrollTo({ top: targetTopRelativeToBox - container.offsetHeight + formContainer.offsetHeight + target.offsetHeight + padding, behavior: 'smooth' })
scrollbox.scrollTo({ top: targetTopRelativeToBox + scrollboxTop - container.offsetHeight + formContainer.offsetHeight + target.offsetHeight + padding, behavior: 'smooth' })
},
setAreaRef (el) {
if (el) {
Expand Down
4 changes: 2 additions & 2 deletions app/javascript/submission_form/form.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1113,9 +1113,9 @@ export default {
this.minimizeForm()
}
const isMobileSafariIos = 'ontouchstart' in window && navigator.maxTouchPoints > 0 && /AppleWebKit/i.test(navigator.userAgent)
const isMobile = 'ontouchstart' in window && navigator.maxTouchPoints > 0 && /AppleWebKit|android/i.test(navigator.userAgent)
if (isMobileSafariIos || /iPhone|iPad|iPod/i.test(navigator.userAgent)) {
if (isMobile || /iPhone|iPad|iPod/i.test(navigator.userAgent)) {
this.$nextTick(() => {
const root = this.$root.$el.parentNode.getRootNode()
const scrollbox = root.getElementById('scrollbox')
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/submission_form/phone_step.vue
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ export default {
const data = await resp.json()
if (resp.status === 422) {
alert(this.t('number_phone_is_invalid').replace('{number}', this.fullInternationalPhoneValue))
alert(data.error || this.t('number_phone_is_invalid').replace('{number}', this.fullInternationalPhoneValue))
} else if (resp.status === 429) {
alert(data.error)
}
Expand Down
8 changes: 7 additions & 1 deletion app/javascript/template_builder/area.vue
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ export default {
methods: {
buildDefaultName: Field.methods.buildDefaultName,
closeDropdown () {
document.activeElement.blur()
this.$el.getRootNode().activeElement.blur()
},
maybeToggleDefaultValue () {
if (['text', 'number'].includes(this.field.type)) {
Expand Down Expand Up @@ -521,6 +521,12 @@ export default {
formatNumber (number, format) {
if (format === 'comma') {
return new Intl.NumberFormat('en-US').format(number)
} else if (format === 'usd') {
return new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD', minimumFractionDigits: 2, maximumFractionDigits: 2 }).format(number)
} else if (format === 'gbp') {
return new Intl.NumberFormat('en-GB', { style: 'currency', currency: 'GBP', minimumFractionDigits: 2, maximumFractionDigits: 2 }).format(number)
} else if (format === 'eur') {
return new Intl.NumberFormat('fr-FR', { style: 'currency', currency: 'EUR', minimumFractionDigits: 2, maximumFractionDigits: 2 }).format(number)
} else if (format === 'dot') {
return new Intl.NumberFormat('de-DE').format(number)
} else if (format === 'space') {
Expand Down
36 changes: 20 additions & 16 deletions app/javascript/template_builder/builder.vue
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,8 @@
</div>
<div
id="pages_container"
class="w-full overflow-y-hidden overflow-x-hidden mt-0.5 pt-0.5"
:class="isMobile ? 'overflow-y-auto' : 'md:overflow-y-auto'"
class="w-full overflow-x-hidden mt-0.5 pt-0.5"
:class="isMobile ? 'overflow-y-auto' : 'overflow-y-hidden md:overflow-y-auto'"
>
<div
ref="documents"
Expand Down Expand Up @@ -1320,7 +1320,11 @@ export default {
if (!this.fieldsDragFieldRef.value) {
if (['select', 'multiple', 'radio'].includes(field.type)) {
field.options = [{ value: '', uuid: v4() }]
if (this.dragField?.options?.length) {
field.options = this.dragField.options.map(option => ({ value: option, uuid: v4() }))
} else {
field.options = [{ value: '', uuid: v4() }]
}
}
if (['stamp', 'heading'].includes(field.type)) {
Expand Down Expand Up @@ -1510,29 +1514,29 @@ export default {
onDocumentRemove (item) {
if (window.confirm(this.t('are_you_sure_'))) {
this.template.schema.splice(this.template.schema.indexOf(item), 1)
}
const removedFieldUuids = []
const removedFieldUuids = []
this.template.fields.forEach((field) => {
[...(field.areas || [])].forEach((area) => {
if (area.attachment_uuid === item.attachment_uuid) {
field.areas.splice(field.areas.indexOf(area), 1)
this.template.fields.forEach((field) => {
[...(field.areas || [])].forEach((area) => {
if (area.attachment_uuid === item.attachment_uuid) {
field.areas.splice(field.areas.indexOf(area), 1)
removedFieldUuids.push(field.uuid)
}
removedFieldUuids.push(field.uuid)
}
})
})
})
this.template.fields =
this.template.fields.filter((f) => !removedFieldUuids.includes(f.uuid) || f.areas?.length)
this.template.fields =
this.template.fields.filter((f) => !removedFieldUuids.includes(f.uuid) || f.areas?.length)
this.save()
this.save()
}
},
onDocumentReplace (data) {
const { replaceSchemaItem, schema, documents } = data
this.template.schema.splice(this.template.schema.indexOf(replaceSchemaItem), 1, schema[0])
this.template.schema.splice(this.template.schema.indexOf(replaceSchemaItem), 1, { ...replaceSchemaItem, ...schema[0] })
this.template.documents.push(...documents)
if (data.fields) {
Expand Down
10 changes: 5 additions & 5 deletions app/javascript/template_builder/field.vue
Original file line number Diff line number Diff line change
Expand Up @@ -192,14 +192,14 @@
class="w-full input input-primary input-xs text-sm bg-transparent"
:placeholder="`${t('option')} ${index + 1}`"
type="text"
:readonly="!editable"
:readonly="!editable || defaultField"
required
dir="auto"
@focus="maybeFocusOnOptionArea(option)"
@blur="save"
>
<button
v-if="editable"
v-if="editable && !defaultField"
class="text-sm w-3.5"
tabindex="-1"
@click="removeOption(option)"
Expand All @@ -208,11 +208,11 @@
</button>
</div>
<div
v-if="field.options && !editable"
v-if="field.options && (!editable || defaultField)"
class="pb-1"
/>
<button
v-else-if="field.options && editable"
v-else-if="field.options && editable && !defaultField"
class="text-center text-sm w-full pb-1"
@click="addOption"
>
Expand Down Expand Up @@ -392,7 +392,7 @@ export default {
return this.sortedAreas[0] && this.$emit('scroll-to', this.sortedAreas[0])
},
closeDropdown () {
document.activeElement.blur()
this.$el.getRootNode().activeElement.blur()
},
addOption () {
this.field.options.push({ value: '', uuid: v4() })
Expand Down
38 changes: 37 additions & 1 deletion app/javascript/template_builder/field_settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,33 @@
{{ t('format') }}
</label>
</div>
<div
v-if="field.type === 'verification'"
class="py-1.5 px-1 relative"
@click.stop
>
<select
:placeholder="t('method')"
class="select select-bordered select-xs font-normal w-full max-w-xs !h-7 !outline-0 bg-transparent"
@change="[field.preferences ||= {}, field.preferences.method = $event.target.value, save()]"
>
<option
v-for="method in ['QeS', 'AeS']"
:key="method"
:value="method.toLowerCase()"
:selected="method.toLowerCase() === field.preferences?.method || (method === 'QeS' && !field.preferences?.method)"
>
{{ method }}
</option>
</select>
<label
:style="{ backgroundColor }"
class="absolute -top-1 left-2.5 px-1 h-4"
style="font-size: 8px"
>
{{ t('method') }}
</label>
</div>
<div
v-if="['number', 'cells'].includes(field.type)"
class="py-1.5 px-1 relative"
Expand Down Expand Up @@ -229,7 +256,7 @@
</label>
</div>
<li
v-if="withRequired && field.type != 'phone' && field.type != 'stamp'"
v-if="withRequired && field.type !== 'phone' && field.type !== 'stamp' && field.type !== 'verification'"
@click.stop
>
<label class="cursor-pointer py-1.5">
Expand Down Expand Up @@ -461,6 +488,9 @@ export default {
numberFormats () {
return [
'none',
'usd',
'eur',
'gbp',
'comma',
'dot',
'space'
Expand Down Expand Up @@ -541,6 +571,12 @@ export default {
formatNumber (number, format) {
if (format === 'comma') {
return new Intl.NumberFormat('en-US').format(number)
} else if (format === 'usd') {
return new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD', minimumFractionDigits: 2, maximumFractionDigits: 2 }).format(number)
} else if (format === 'gbp') {
return new Intl.NumberFormat('en-GB', { style: 'currency', currency: 'GBP', minimumFractionDigits: 2, maximumFractionDigits: 2 }).format(number)
} else if (format === 'eur') {
return new Intl.NumberFormat('fr-FR', { style: 'currency', currency: 'EUR', minimumFractionDigits: 2, maximumFractionDigits: 2 }).format(number)
} else if (format === 'dot') {
return new Intl.NumberFormat('de-DE').format(number)
} else if (format === 'space') {
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/template_builder/field_submitter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ export default {
this.$emit('new-submitter', newSubmitter)
},
closeDropdown () {
document.activeElement.blur()
this.$el.getRootNode().activeElement.blur()
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/template_builder/field_type.vue
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ export default {
},
methods: {
closeDropdown () {
document.activeElement.blur()
this.$el.getRootNode().activeElement.blur()
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions app/javascript/template_builder/i18n.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const en = {
method: 'Method',
reorder_fields: 'Reorder fields',
verify_id: 'Verify ID',
obtain_qualified_electronic_signature_with_the_trusted_provider_click_to_learn_more: 'Obtain qualified electronic signature (QeS) with the trusted provider. Click to learn more.',
Expand Down Expand Up @@ -159,6 +160,7 @@ const en = {
}

const es = {
method: 'Método',
reorder_fields: 'Reordenar campos',
verify_id: 'Verificar ID',
obtain_qualified_electronic_signature_with_the_trusted_provider_click_to_learn_more: 'Obtenga una firma electrónica cualificada (QeS) con el proveedor de confianza. Haga clic para obtener más información.',
Expand Down Expand Up @@ -319,6 +321,7 @@ const es = {
}

const it = {
method: 'Metodo',
reorder_fields: 'Riordina i campi',
verify_id: 'Verifica ID',
obtain_qualified_electronic_signature_with_the_trusted_provider_click_to_learn_more: 'Ottieni una firma elettronica qualificata (QeS) con il fornitore di fiducia. Clicca per saperne di più.',
Expand Down Expand Up @@ -479,6 +482,7 @@ const it = {
}

const pt = {
method: 'Método',
reorder_fields: 'Reorganizar campos',
verify_id: 'Verificar ID',
obtain_qualified_electronic_signature_with_the_trusted_provider_click_to_learn_more: 'Obtenha a assinatura eletrônica qualificada (QeS) com o provedor confiável. Clique para saber mais.',
Expand Down Expand Up @@ -639,6 +643,7 @@ const pt = {
}

const fr = {
method: 'Méthode',
reorder_fields: 'Réorganiser les champs',
verify_id: "Vérifier l'ID",
obtain_qualified_electronic_signature_with_the_trusted_provider_click_to_learn_more: 'Obtenez une signature électronique qualifiée (QeS) avec le fournisseur de confiance. Cliquez pour en savoir plus.',
Expand Down Expand Up @@ -799,6 +804,7 @@ const fr = {
}

const de = {
method: 'Verfahren',
reorder_fields: 'Felder neu anordnen',
verify_id: 'ID überprüfen',
obtain_qualified_electronic_signature_with_the_trusted_provider_click_to_learn_more: 'Erhalten Sie eine qualifizierte elektronische Signatur (QeS) beim vertrauenswürdigen Anbieter. Klicken Sie hier, um mehr zu erfahren.',
Expand Down
Empty file.
1 change: 1 addition & 0 deletions app/views/accounts/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@
<% end %>
</div>
<% end %>
<%= render 'compliances' %>
<%= render 'integrations' %>
<% if can?(:manage, current_account) && Docuseal.multitenant? && true_user == current_user %>
<div class="px-1 mt-8">
Expand Down
2 changes: 1 addition & 1 deletion app/views/esign_settings/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@
<%= t('document_download_filename_format') %>
</span>
<div class="mt-3">
<%= f.select :value, [["#{I18n.t('document_name')}.pdf", '{document.name}'], ["#{I18n.t('document_name')} - [email protected]", '{document.name} - {submission.submitters}'], ["#{I18n.t('document_name')} - [email protected] - #{I18n.l(Time.current.beginning_of_year.in_time_zone(current_account.timezone), format: :short)}.pdf", '{document.name} - {submission.submitters} - {submission.completed_at}']], {}, class: 'base-select', onchange: 'this.form.requestSubmit()' %>
<%= f.select :value, [["#{I18n.t('document_name')}.pdf", '{document.name}'], ["#{I18n.t('document_name')} - #{I18n.t(:signed)}.pdf", '{document.name} - {submission.status}'], ["#{I18n.t('document_name')} - [email protected]", '{document.name} - {submission.submitters}'], ["#{I18n.t('document_name')} - [email protected] - #{I18n.l(Time.current.beginning_of_year.in_time_zone(current_account.timezone), format: :short)}.pdf", '{document.name} - {submission.submitters} - {submission.completed_at}']], {}, class: 'base-select', onchange: 'this.form.requestSubmit()' %>
</div>
</div>
<% end %>
Expand Down
2 changes: 2 additions & 0 deletions app/views/submissions/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,8 @@
</div>
<% elsif field['type'] == 'checkbox' %>
<%= svg_icon('check', class: 'w-6 h-6') %>
<% elsif field['type'] == 'number' %>
<%= NumberUtils.format_number(value, field.dig('preferences', 'format')) %>
<% elsif field['type'] == 'date' %>
<%= TimeUtils.format_date_string(value, field.dig('preferences', 'format'), @submission.account.locale) %>
<% else %>
Expand Down
6 changes: 6 additions & 0 deletions config/locales/i18n.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ en: &en
pending_by_me: Pending by me
partially_completed: Partially completed
unarchive: Unarchive
signed: Signed
first_party: 'First Party'
remove_filter: Remove filter
add: Add
Expand Down Expand Up @@ -725,6 +726,7 @@ en: &en
read: Read your data

es: &es
signed: Firmado
reply_to: Responder a
partially_completed: Parcialmente completado
pending_by_me: Pendiente por mi
Expand Down Expand Up @@ -1432,6 +1434,7 @@ es: &es
read: Leer tus datos

it: &it
signed: Firmato
reply_to: Rispondi a
pending_by_me: In sospeso da me
add: Aggiungi
Expand Down Expand Up @@ -2138,6 +2141,7 @@ it: &it
read: Leggi i tuoi dati

fr: &fr
signed: Signé
reply_to: Répondre à
partially_completed: Partiellement complété
pending_by_me: En attente par moi
Expand Down Expand Up @@ -2846,6 +2850,7 @@ fr: &fr
read: Lire vos données

pt: &pt
signed: Assinado
reply_to: Responder a
partially_completed: Parcialmente concluído
pending_by_me: Pendente por mim
Expand Down Expand Up @@ -3553,6 +3558,7 @@ pt: &pt
read: Ler seus dados

de: &de
signed: Unterschrieben
reply_to: Antworten auf
partially_completed: Teilweise abgeschlossen
pending_by_me: Ausstehend von mir
Expand Down
Loading

0 comments on commit 2da059d

Please sign in to comment.