From c696890cf5afc8f789392d61909fd614cf4e403d Mon Sep 17 00:00:00 2001 From: Alex Turchyn Date: Tue, 14 Jan 2025 00:10:50 +0200 Subject: [PATCH 01/17] fix dropdowns in Firefox --- app/javascript/template_builder/area.vue | 2 +- app/javascript/template_builder/field.vue | 2 +- app/javascript/template_builder/field_submitter.vue | 2 +- app/javascript/template_builder/field_type.vue | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/javascript/template_builder/area.vue b/app/javascript/template_builder/area.vue index afd6d62c9..fb9682214 100644 --- a/app/javascript/template_builder/area.vue +++ b/app/javascript/template_builder/area.vue @@ -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)) { diff --git a/app/javascript/template_builder/field.vue b/app/javascript/template_builder/field.vue index 169f2ae36..d581fc7ae 100644 --- a/app/javascript/template_builder/field.vue +++ b/app/javascript/template_builder/field.vue @@ -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() }) diff --git a/app/javascript/template_builder/field_submitter.vue b/app/javascript/template_builder/field_submitter.vue index 68a6e1932..b5949e551 100644 --- a/app/javascript/template_builder/field_submitter.vue +++ b/app/javascript/template_builder/field_submitter.vue @@ -362,7 +362,7 @@ export default { this.$emit('new-submitter', newSubmitter) }, closeDropdown () { - document.activeElement.blur() + this.$el.getRootNode().activeElement.blur() } } } diff --git a/app/javascript/template_builder/field_type.vue b/app/javascript/template_builder/field_type.vue index 8f17d2564..4a72227db 100644 --- a/app/javascript/template_builder/field_type.vue +++ b/app/javascript/template_builder/field_type.vue @@ -170,7 +170,7 @@ export default { }, methods: { closeDropdown () { - document.activeElement.blur() + this.$el.getRootNode().activeElement.blur() } } } From e3f3895aac91a65da056814b266a0a84437d449e Mon Sep 17 00:00:00 2001 From: Alex Turchyn Date: Tue, 14 Jan 2025 23:07:39 +0200 Subject: [PATCH 02/17] fix scrolling to fields on Android devices --- app/javascript/submission_form/form.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/javascript/submission_form/form.vue b/app/javascript/submission_form/form.vue index c1d0d8a1c..cb41d182b 100644 --- a/app/javascript/submission_form/form.vue +++ b/app/javascript/submission_form/form.vue @@ -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') From 92b61992f2b0c1594cce1ccf17a699dbd6149a9d Mon Sep 17 00:00:00 2001 From: Alex Turchyn Date: Wed, 15 Jan 2025 01:19:17 +0200 Subject: [PATCH 03/17] fix vertical scrolling for mobile devices --- app/javascript/template_builder/builder.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/javascript/template_builder/builder.vue b/app/javascript/template_builder/builder.vue index 1e22e3b9b..96670b9da 100644 --- a/app/javascript/template_builder/builder.vue +++ b/app/javascript/template_builder/builder.vue @@ -222,8 +222,8 @@
Date: Wed, 15 Jan 2025 13:57:30 +0200 Subject: [PATCH 04/17] Revert "fix scrolling to fields on Android devices" This reverts commit e3f3895aac91a65da056814b266a0a84437d449e. --- app/javascript/submission_form/form.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/javascript/submission_form/form.vue b/app/javascript/submission_form/form.vue index cb41d182b..c1d0d8a1c 100644 --- a/app/javascript/submission_form/form.vue +++ b/app/javascript/submission_form/form.vue @@ -1113,9 +1113,9 @@ export default { this.minimizeForm() } - const isMobile = 'ontouchstart' in window && navigator.maxTouchPoints > 0 && /AppleWebKit|android/i.test(navigator.userAgent) + const isMobileSafariIos = 'ontouchstart' in window && navigator.maxTouchPoints > 0 && /AppleWebKit/i.test(navigator.userAgent) - if (isMobile || /iPhone|iPad|iPod/i.test(navigator.userAgent)) { + if (isMobileSafariIos || /iPhone|iPad|iPod/i.test(navigator.userAgent)) { this.$nextTick(() => { const root = this.$root.$el.parentNode.getRootNode() const scrollbox = root.getElementById('scrollbox') From 9bd0ad70c4633544144abd3a1eff8225e7ba10e3 Mon Sep 17 00:00:00 2001 From: Pete Matsyburka Date: Thu, 16 Jan 2025 00:40:22 +0200 Subject: [PATCH 05/17] add default field options --- app/javascript/template_builder/builder.vue | 6 +++++- app/javascript/template_builder/field.vue | 8 ++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/app/javascript/template_builder/builder.vue b/app/javascript/template_builder/builder.vue index 96670b9da..ebb0f1912 100644 --- a/app/javascript/template_builder/builder.vue +++ b/app/javascript/template_builder/builder.vue @@ -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)) { diff --git a/app/javascript/template_builder/field.vue b/app/javascript/template_builder/field.vue index d581fc7ae..b4941cf7d 100644 --- a/app/javascript/template_builder/field.vue +++ b/app/javascript/template_builder/field.vue @@ -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" >
<% 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 %> diff --git a/lib/number_utils.rb b/lib/number_utils.rb index d0ab673cc..4cfa3879c 100644 --- a/lib/number_utils.rb +++ b/lib/number_utils.rb @@ -4,7 +4,16 @@ module NumberUtils FORMAT_LOCALES = { 'dot' => 'de', 'space' => 'fr', - 'comma' => 'en' + 'comma' => 'en', + 'usd' => 'en', + 'eur' => 'fr', + 'gbp' => 'en' + }.freeze + + CURRENCY_SYMBOLS = { + 'usd' => '$', + 'eur' => '€', + 'gbp' => '£' }.freeze module_function @@ -12,7 +21,9 @@ module NumberUtils def format_number(number, format) locale = FORMAT_LOCALES[format] - if locale + if CURRENCY_SYMBOLS[format] + ApplicationController.helpers.number_to_currency(number, locale:, precision: 2, unit: CURRENCY_SYMBOLS[format]) + elsif locale ApplicationController.helpers.number_with_delimiter(number, locale:) else number From 794e3394252ce71561f6bc9c98a0322d4cc9187e Mon Sep 17 00:00:00 2001 From: Pete Matsyburka Date: Sat, 18 Jan 2025 16:23:01 +0200 Subject: [PATCH 14/17] add verification settings --- .../template_builder/field_settings.vue | 29 ++++++++++++++++++- app/javascript/template_builder/i18n.js | 6 ++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/app/javascript/template_builder/field_settings.vue b/app/javascript/template_builder/field_settings.vue index 0916f383f..5f7cacc97 100644 --- a/app/javascript/template_builder/field_settings.vue +++ b/app/javascript/template_builder/field_settings.vue @@ -26,6 +26,33 @@ {{ t('format') }}
+
+ + +