From d989b61d191b161953ed974277b23e2334992098 Mon Sep 17 00:00:00 2001 From: Pete Matsyburka Date: Fri, 15 Mar 2024 22:46:07 +0200 Subject: [PATCH] fix font size --- app/javascript/submission_form/area.vue | 20 +++++++++++-------- app/javascript/template_builder/area.vue | 20 +++++++++++-------- .../generate_result_attachments.rb | 2 +- 3 files changed, 25 insertions(+), 17 deletions(-) diff --git a/app/javascript/submission_form/area.vue b/app/javascript/submission_form/area.vue index c27f0d80..479dc33a 100644 --- a/app/javascript/submission_form/area.vue +++ b/app/javascript/submission_form/area.vue @@ -338,18 +338,22 @@ export default { }, watch: { modelValue () { - if (this.field.type === 'text' && this.$refs.textContainer && (this.textOverflowChars === 0 || (this.textOverflowChars - 4) > this.modelValue.length)) { - this.textOverflowChars = this.$refs.textContainer.scrollHeight > this.$refs.textContainer.clientHeight ? this.modelValue.length : 0 - } - } - }, - mounted () { - if (this.field.type === 'text' && this.$refs.textContainer) { this.$nextTick(() => { - this.textOverflowChars = this.$refs.textContainer.scrollHeight > this.$refs.textContainer.clientHeight ? this.modelValue.length : 0 + if (['date', 'text', 'number'].includes(this.field.type) && this.$refs.textContainer && (this.textOverflowChars === 0 || (this.textOverflowChars - 4) > this.modelValue.length)) { + this.textOverflowChars = this.$refs.textContainer.scrollHeight > this.$refs.textContainer.clientHeight ? this.modelValue.length : 0 + } }) } }, + mounted () { + this.$nextTick(() => { + if (['date', 'text', 'number'].includes(this.field.type) && this.$refs.textContainer) { + this.$nextTick(() => { + this.textOverflowChars = this.$refs.textContainer.scrollHeight > this.$refs.textContainer.clientHeight ? this.modelValue.length : 0 + }) + } + }) + }, methods: { optionValue (option) { if (option) { diff --git a/app/javascript/template_builder/area.vue b/app/javascript/template_builder/area.vue index 931f69c4..c071e499 100644 --- a/app/javascript/template_builder/area.vue +++ b/app/javascript/template_builder/area.vue @@ -301,18 +301,22 @@ export default { }, watch: { 'field.default_value' () { - if (this.field.type === 'text' && this.field.default_value && this.$refs.textContainer && (this.textOverflowChars === 0 || (this.textOverflowChars - 4) > this.field.default_value.length)) { - this.textOverflowChars = this.$el.clientHeight < this.$refs.textContainer.clientHeight ? this.field.default_value.length : 0 - } - } - }, - mounted () { - if (this.field.type === 'text' && this.field.default_value && this.$refs.textContainer && (this.textOverflowChars === 0 || (this.textOverflowChars - 4) > this.field.default_value)) { this.$nextTick(() => { - this.textOverflowChars = this.$el.clientHeight < this.$refs.textContainer.clientHeight ? this.field.default_value.length : 0 + if (['date', 'text', 'number'].includes(this.field.type) && this.field.default_value && this.$refs.textContainer && (this.textOverflowChars === 0 || (this.textOverflowChars - 4) > this.field.default_value.length)) { + this.textOverflowChars = this.$el.clientHeight < this.$refs.textContainer.clientHeight ? this.field.default_value.length : 0 + } }) } }, + mounted () { + this.$nextTick(() => { + if (['date', 'text', 'number'].includes(this.field.type) && this.field.default_value && this.$refs.textContainer && (this.textOverflowChars === 0 || (this.textOverflowChars - 4) > this.field.default_value)) { + this.$nextTick(() => { + this.textOverflowChars = this.$el.clientHeight < this.$refs.textContainer.clientHeight ? this.field.default_value.length : 0 + }) + } + }) + }, methods: { buildDefaultName: Field.methods.buildDefaultName, onNameFocus (e) { diff --git a/lib/submissions/generate_result_attachments.rb b/lib/submissions/generate_result_attachments.rb index b09f42f8..8249e4e0 100644 --- a/lib/submissions/generate_result_attachments.rb +++ b/lib/submissions/generate_result_attachments.rb @@ -71,7 +71,7 @@ module Submissions width = page.box.width height = page.box.height - font_size = ((page.box.width / A4_SIZE[0].to_f) * FONT_SIZE).to_i + font_size = (([page.box.width, page.box.height].min / A4_SIZE[0].to_f) * FONT_SIZE).to_i value = submitter.values[field['uuid']]