From 2e43eb189f2da85ef41f3a4a1b542d4bc0b288d4 Mon Sep 17 00:00:00 2001 From: Pete Matsyburka Date: Tue, 7 Jan 2025 13:04:59 +0200 Subject: [PATCH 01/14] fix define submitters order --- app/javascript/template_builder/builder.vue | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/javascript/template_builder/builder.vue b/app/javascript/template_builder/builder.vue index 569d77c08..43f759c6c 100644 --- a/app/javascript/template_builder/builder.vue +++ b/app/javascript/template_builder/builder.vue @@ -770,13 +770,17 @@ export default { } }) + const defineSubmittersUuids = this.defineSubmitters.map((name) => { + return this.template.submitters.find(e => e.name === name)?.uuid + }) + this.defineSubmitters.forEach((name, index) => { const submitter = (this.template.submitters[index] ||= {}) submitter.name = name || this.submitterDefaultNames[index] - if (existingSubmittersUuids.filter(Boolean).length) { - submitter.uuid = existingSubmittersUuids[index] || submitter.uuid || v4() + if (defineSubmittersUuids.filter(Boolean).length || existingSubmittersUuids.filter(Boolean).length) { + submitter.uuid = defineSubmittersUuids[index] || existingSubmittersUuids[index] || submitter.uuid || v4() } else { submitter.uuid ||= v4() } From 6dff6483bf9ae31271bda1fd5f0ce7278a46d241 Mon Sep 17 00:00:00 2001 From: Pete Matsyburka Date: Tue, 7 Jan 2025 17:30:21 +0200 Subject: [PATCH 02/14] fix default field title --- app/javascript/template_builder/area.vue | 4 ++-- app/javascript/template_builder/field.vue | 2 +- app/javascript/template_builder/fields.vue | 9 ++++++++- app/javascript/template_builder/page.vue | 9 ++++++++- 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/app/javascript/template_builder/area.vue b/app/javascript/template_builder/area.vue index 61b1a200f..f2390a73b 100644 --- a/app/javascript/template_builder/area.vue +++ b/app/javascript/template_builder/area.vue @@ -70,7 +70,7 @@ @keydown.enter.prevent="onNameEnter" @focus="onNameFocus" @blur="onNameBlur" - >{{ optionIndexText }} {{ (defaultField ? (field.title || field.name) : field.name) || defaultName }} + >{{ optionIndexText }} {{ (defaultField ? (defaultField.title || field.title || field.name) : field.name) || defaultName }}
15 }, + defaultFieldsIndex () { + return this.defaultFields.reduce((acc, field) => { + acc[field.name] = field + + return acc + }, {}) + }, fieldIconsSorted () { if (this.fieldTypes.length) { return this.fieldTypes.reduce((acc, type) => { diff --git a/app/javascript/template_builder/page.vue b/app/javascript/template_builder/page.vue index bd5e22f96..bd9f20dcc 100644 --- a/app/javascript/template_builder/page.vue +++ b/app/javascript/template_builder/page.vue @@ -25,7 +25,7 @@ :field="item.field" :editable="editable" :with-field-placeholder="withFieldPlaceholder" - :default-field="defaultFields.find((f) => f.name === item.field.name)" + :default-field="defaultFieldsIndex[item.field.name]" :default-submitters="defaultSubmitters" :max-page="totalPages - 1" @start-resize="resizeDirection = $event" @@ -142,6 +142,13 @@ export default { } }, computed: { + defaultFieldsIndex () { + return this.defaultFields.reduce((acc, field) => { + acc[field.name] = field + + return acc + }, {}) + }, defaultFieldType () { if (this.drawFieldType) { return this.drawFieldType From 1f9faddfd02482fc8434535c0ea102e59622916f Mon Sep 17 00:00:00 2001 From: Pete Matsyburka Date: Tue, 7 Jan 2025 20:19:53 +0200 Subject: [PATCH 03/14] add reply to --- app/controllers/templates_preferences_controller.rb | 2 +- app/mailers/submitter_mailer.rb | 6 ++++-- .../_documents_copy_email_form.html.erb | 8 +++++++- app/views/templates_preferences/show.html.erb | 8 +++++++- config/locales/i18n.yml | 6 ++++++ 5 files changed, 25 insertions(+), 5 deletions(-) diff --git a/app/controllers/templates_preferences_controller.rb b/app/controllers/templates_preferences_controller.rb index 24aedbd4b..7e358537a 100644 --- a/app/controllers/templates_preferences_controller.rb +++ b/app/controllers/templates_preferences_controller.rb @@ -22,7 +22,7 @@ def template_params preferences: %i[bcc_completed request_email_subject request_email_body documents_copy_email_subject documents_copy_email_body documents_copy_email_enabled documents_copy_email_attach_audit - documents_copy_email_attach_documents + documents_copy_email_attach_documents documents_copy_email_reply_to completed_notification_email_attach_documents completed_redirect_url submitters_order diff --git a/app/mailers/submitter_mailer.rb b/app/mailers/submitter_mailer.rb index 817732614..2441b1656 100644 --- a/app/mailers/submitter_mailer.rb +++ b/app/mailers/submitter_mailer.rb @@ -121,7 +121,7 @@ def documents_copy_email(submitter, to: nil, sig: false) @body ||= @email_config.value['body'] if @email_config assign_message_metadata('submitter_documents_copy', @submitter) - reply_to = build_submitter_reply_to(submitter) + reply_to = build_submitter_reply_to(submitter, email_config: @email_config, documents_copy_email: true) I18n.with_locale(@current_account.locale) do subject = @@ -140,8 +140,10 @@ def documents_copy_email(submitter, to: nil, sig: false) private - def build_submitter_reply_to(submitter) + def build_submitter_reply_to(submitter, email_config: nil, documents_copy_email: nil) reply_to = submitter.preferences['reply_to'].presence + reply_to ||= submitter.template.preferences['documents_copy_email_reply_to'].presence if documents_copy_email + reply_to ||= email_config.value['reply_to'].presence if email_config if reply_to.blank? && (submitter.submission.created_by_user || submitter.template.author)&.email != submitter.email reply_to = (submitter.submission.created_by_user || submitter.template.author)&.friendly_name&.sub(/\+\w+@/, '@') diff --git a/app/views/personalization_settings/_documents_copy_email_form.html.erb b/app/views/personalization_settings/_documents_copy_email_form.html.erb index 6b9e0fc35..fcb3b18ac 100644 --- a/app/views/personalization_settings/_documents_copy_email_form.html.erb +++ b/app/views/personalization_settings/_documents_copy_email_form.html.erb @@ -8,7 +8,7 @@
<%= form_for AccountConfigs.find_or_initialize_for_key(current_account, AccountConfig::SUBMITTER_DOCUMENTS_COPY_EMAIL_KEY), url: settings_personalization_path, method: :post, html: { autocomplete: 'off', class: 'space-y-4' } do |f| %> <%= f.hidden_field :key %> - <%= f.fields_for :value, Struct.new(:subject, :body, :attach_audit_log, :attach_documents).new(*f.object.value.values_at('subject', 'body', 'attach_audit_log', 'attach_documents')) do |ff| %> + <%= f.fields_for :value, Struct.new(:subject, :body, :reply_to, :attach_audit_log, :attach_documents).new(*f.object.value.values_at('subject', 'body', 'reply_to', 'attach_audit_log', 'attach_documents')) do |ff| %>
<%= ff.label :subject, t('subject'), class: 'label' %> <%= ff.text_field :subject, required: true, class: 'base-input', dir: 'auto' %> @@ -24,6 +24,12 @@ <%= ff.text_area :body, required: true, class: 'base-input w-full py-2', dir: 'auto' %>
+ <% if can?(:manage, :reply_to) %> +
+ <%= ff.label :reply_to, t('reply_to'), class: 'label' %> + <%= ff.email_field :reply_to, class: 'base-input', dir: 'auto', placeholder: t(:email) %> +
+ <% end %>
<%= t('attach_documents') %> diff --git a/app/views/templates_preferences/show.html.erb b/app/views/templates_preferences/show.html.erb index 1cf562871..1a99e6389 100644 --- a/app/views/templates_preferences/show.html.erb +++ b/app/views/templates_preferences/show.html.erb @@ -118,7 +118,7 @@ <%= form_for @template, url: template_preferences_path(@template), method: :post, html: { autocomplete: 'off', class: 'mt-1' }, data: { close_on_submit: false } do |f| %> <% configs = AccountConfigs.find_or_initialize_for_key(current_account, AccountConfig::SUBMITTER_DOCUMENTS_COPY_EMAIL_KEY).value %> - <%= f.fields_for :preferences, Struct.new(:documents_copy_email_subject, :documents_copy_email_body, :documents_copy_email_enabled, :documents_copy_email_attach_audit, :documents_copy_email_attach_documents).new(@template.preferences['documents_copy_email_subject'].presence || configs['subject'], @template.preferences['documents_copy_email_body'].presence || configs['body'], @template.preferences['documents_copy_email_enabled'], configs['attach_audit_log'] != false && @template.preferences['documents_copy_email_attach_audit'] != false, configs['attach_documents'] != false && @template.preferences['documents_copy_email_attach_documents'] != false) do |ff| %> + <%= f.fields_for :preferences, Struct.new(:documents_copy_email_reply_to, :documents_copy_email_subject, :documents_copy_email_body, :documents_copy_email_enabled, :documents_copy_email_attach_audit, :documents_copy_email_attach_documents).new(@template.preferences['documents_copy_email_reply_to'].presence || configs['reply_to'], @template.preferences['documents_copy_email_subject'].presence || configs['subject'], @template.preferences['documents_copy_email_body'].presence || configs['body'], @template.preferences['documents_copy_email_enabled'], configs['attach_audit_log'] != false && @template.preferences['documents_copy_email_attach_audit'] != false, configs['attach_documents'] != false && @template.preferences['documents_copy_email_attach_documents'] != false) do |ff| %>
<%= ff.label :documents_copy_email_subject, t('email_subject'), class: 'label' %> <%= ff.text_field :documents_copy_email_subject, required: true, class: 'base-input', dir: 'auto' %> @@ -134,6 +134,12 @@ <%= ff.text_area :documents_copy_email_body, required: true, class: 'base-input w-full py-2', dir: 'auto' %>
+ <% if can?(:manage, :reply_to) %> +
+ <%= ff.label :documents_copy_email_reply_to, t('reply_to'), class: 'label' %> + <%= ff.email_field :documents_copy_email_reply_to, class: 'base-input', dir: 'auto', placeholder: t(:email) %> +
+ <% end %>
<%= t('attach_documents_to_the_email') %> diff --git a/config/locales/i18n.yml b/config/locales/i18n.yml index 351a58f4f..acd0d6e18 100644 --- a/config/locales/i18n.yml +++ b/config/locales/i18n.yml @@ -20,6 +20,7 @@ en: &en language_ko: 한국어 hi_there: Hi there thanks: Thanks + reply_to: Reply to pending_by_me: Pending by me partially_completed: Partially completed unarchive: Unarchive @@ -720,6 +721,7 @@ en: &en read: Read your data es: &es + reply_to: Responder a partially_completed: Parcialmente completado pending_by_me: Pendiente por mi add: Agregar @@ -1422,6 +1424,7 @@ es: &es read: Leer tus datos it: &it + reply_to: Rispondi a pending_by_me: In sospeso da me add: Aggiungi adding: Aggiungendo @@ -2123,6 +2126,7 @@ it: &it read: Leggi i tuoi dati fr: &fr + reply_to: Répondre à partially_completed: Partiellement complété pending_by_me: En attente par moi add: Ajouter @@ -2826,6 +2830,7 @@ fr: &fr read: Lire vos données pt: &pt + reply_to: Responder a partially_completed: Parcialmente concluído pending_by_me: Pendente por mim add: Adicionar @@ -3528,6 +3533,7 @@ pt: &pt read: Ler seus dados de: &de + reply_to: Antworten auf partially_completed: Teilweise abgeschlossen pending_by_me: Ausstehend von mir add: Hinzufügen From e4c62087d0ca829d61b49edba2d8f806ec020a2a Mon Sep 17 00:00:00 2001 From: Alex Turchyn Date: Wed, 8 Jan 2025 18:06:23 +0200 Subject: [PATCH 04/14] fix translations --- config/locales/i18n.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/config/locales/i18n.yml b/config/locales/i18n.yml index acd0d6e18..8e9e264b8 100644 --- a/config/locales/i18n.yml +++ b/config/locales/i18n.yml @@ -1440,7 +1440,7 @@ it: &it document_name: Nome del Documento unarchive: Ripristina awaiting_completion_by_the_other_party: "In attesa di completamento da parte dell'altra parte" - enforce_recipients_order: Aplicar el orden de los destinatarios + enforce_recipients_order: "Applicare l'ordine dei destinatari" first_party: 'Prima parte' docuseal_trusted_signature: "Firma Fiduciaria DocuSeal" hello_name: Ciao %{name} @@ -2745,11 +2745,11 @@ fr: &fr unverified: Non vérifié document: Document completed_at: Terminé le - edit_recipient: Modifica Destinatario - update_recipient: Aggiorna Destinatario - use_international_format_1xxx_: 'Utilizza il formato internazionale: +1xxx...' - submitter_cannot_be_updated: Il mittente non può essere aggiornato. - at_least_one_field_must_be_filled: Almeno un campo deve essere compilato. + edit_recipient: Modifier le destinataire + update_recipient: Mettre à jour le destinataire + use_international_format_1xxx_: 'Utilisez un format international : +1xxx...' + submitter_cannot_be_updated: Le soumissionnaire ne peut pas être mis à jour. + at_least_one_field_must_be_filled: Au moins un champ doit être rempli. archived_users: Utilisateurs Archivés embedding_users: Utilisateurs Intégrés view_embedding_users: Voir les Utilisateurs Intégrés From 97ecdf2ff064698beb973d92ffa2f03278f0c9a1 Mon Sep 17 00:00:00 2001 From: Pete Matsyburka Date: Thu, 9 Jan 2025 01:09:26 +0200 Subject: [PATCH 05/14] fix invite submitters api order --- lib/submissions/create_from_submitters.rb | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/submissions/create_from_submitters.rb b/lib/submissions/create_from_submitters.rb index 30f3addff..421d431f6 100644 --- a/lib/submissions/create_from_submitters.rb +++ b/lib/submissions/create_from_submitters.rb @@ -31,7 +31,8 @@ def call(template:, user:, submissions_attrs:, source:, submitters_order:, param next if uuid.blank? next if submitter_attrs.slice('email', 'phone', 'name').compact_blank.blank? - submission.template_submitters << template.submitters.find { |e| e['uuid'] == uuid } + template_submitter = template.submitters.find { |e| e['uuid'] == uuid } + submission.template_submitters << template_submitter.except('optional_invite_by_uuid', 'invite_by_uuid') is_order_sent = submitters_order == 'random' || index.zero? @@ -54,11 +55,17 @@ def call(template:, user:, submissions_attrs:, source:, submitters_order:, param # rubocop:enable Metrics/BlockLength def maybe_add_invite_submitters(submission, template) - template.submitters.each do |item| + template.submitters.each_with_index do |item, index| next if item['invite_by_uuid'].blank? && item['optional_invite_by_uuid'].blank? next if submission.template_submitters.any? { |e| e['uuid'] == item['uuid'] } - submission.template_submitters << item + if index.zero? + submission.template_submitters.insert(1, item) + elsif submission.template_submitters.size > index + submission.template_submitters.insert(index, item) + else + submission.template_submitters << item + end end end From fe3e8fba3eb38d1965589f7a4847a868565bf286 Mon Sep 17 00:00:00 2001 From: Pete Matsyburka Date: Thu, 9 Jan 2025 12:26:56 +0200 Subject: [PATCH 06/14] fix readonly formula values --- app/javascript/submission_form/form.vue | 10 +++++++++- app/javascript/submission_form/formula_areas.vue | 7 ++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/app/javascript/submission_form/form.vue b/app/javascript/submission_form/form.vue index 4468e4948..280275ada 100644 --- a/app/javascript/submission_form/form.vue +++ b/app/javascript/submission_form/form.vue @@ -15,7 +15,7 @@ /> { + acc[f.uuid] = (this.values[f.uuid] || f.default_value) + + return acc + }, {}) + }, attachmentConditionsIndex () { return this.schema.reduce((acc, item) => { if (item.conditions?.length) { diff --git a/app/javascript/submission_form/formula_areas.vue b/app/javascript/submission_form/formula_areas.vue index 51632a0e2..02030e77c 100644 --- a/app/javascript/submission_form/formula_areas.vue +++ b/app/javascript/submission_form/formula_areas.vue @@ -38,6 +38,11 @@ export default { required: false, default: () => [] }, + readonlyValues: { + type: Object, + required: false, + default: () => ({}) + }, values: { type: Object, required: false, @@ -87,7 +92,7 @@ export default { }, calculateFormula (field) { const transformedFormula = field.preferences.formula.replace(/{{(.*?)}}/g, (match, uuid) => { - return this.values[uuid] || 0.0 + return this.readonlyValues[uuid] || this.values[uuid] || 0.0 }) return this.math.evaluate(transformedFormula.toLowerCase()) From 1984b99e040d7d38e48510fd55765e04512de301 Mon Sep 17 00:00:00 2001 From: Pete Matsyburka Date: Thu, 9 Jan 2025 22:25:46 +0200 Subject: [PATCH 07/14] fix formula with conditions --- app/javascript/submission_form/area.vue | 5 ++++- lib/submitters/submit_values.rb | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/javascript/submission_form/area.vue b/app/javascript/submission_form/area.vue index d3f7015e6..1c7052289 100644 --- a/app/javascript/submission_form/area.vue +++ b/app/javascript/submission_form/area.vue @@ -197,7 +197,10 @@ {{ formattedDate }} - + {{ formatNumber(modelValue, field.preferences?.format) }} Date: Fri, 10 Jan 2025 11:50:54 +0200 Subject: [PATCH 08/14] verification redirect --- .../submission_form/verification_step.vue | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/app/javascript/submission_form/verification_step.vue b/app/javascript/submission_form/verification_step.vue index dff8ac478..59310714d 100644 --- a/app/javascript/submission_form/verification_step.vue +++ b/app/javascript/submission_form/verification_step.vue @@ -125,12 +125,16 @@ export default { async mounted () { this.isLoading = true - Promise.all([ - import('@eid-easy/eideasy-widget'), - this.start() - ]).finally(() => { - this.isLoading = false - }) + if (new URLSearchParams(window.location.search).get('submit') === 'true') { + this.$emit('submit') + } else { + Promise.all([ + import('@eid-easy/eideasy-widget'), + this.start() + ]).finally(() => { + this.isLoading = false + }) + } }, methods: { start () { From e2b93cbcab1e00c7f59df586dfdd3d1d8a207bbc Mon Sep 17 00:00:00 2001 From: Pete Matsyburka Date: Fri, 10 Jan 2025 15:12:09 +0200 Subject: [PATCH 09/14] fix colors --- app/javascript/template_builder/area.vue | 26 +++---------------- .../template_builder/field_submitter.vue | 20 ++++---------- 2 files changed, 8 insertions(+), 38 deletions(-) diff --git a/app/javascript/template_builder/area.vue b/app/javascript/template_builder/area.vue index f2390a73b..afd6d62c9 100644 --- a/app/javascript/template_builder/area.vue +++ b/app/javascript/template_builder/area.vue @@ -10,7 +10,7 @@
{{ submitter.name }} @@ -101,7 +101,7 @@ >