From dc8e8cc5c91436ee7aac972e5dfbf951b8e02596 Mon Sep 17 00:00:00 2001 From: Pete Matsyburka Date: Sat, 6 Jan 2024 21:16:27 +0200 Subject: [PATCH] draw field on field type click --- app/javascript/template_builder/builder.vue | 29 +++++++++++++++++---- app/javascript/template_builder/fields.vue | 4 +-- app/javascript/template_builder/i18n.js | 1 + 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/app/javascript/template_builder/builder.vue b/app/javascript/template_builder/builder.vue index dd3ffd39..2ebcc1e8 100644 --- a/app/javascript/template_builder/builder.vue +++ b/app/javascript/template_builder/builder.vue @@ -217,14 +217,22 @@

{{ t('draw_field_on_the_document').replace('{field}', drawField.name) }}

-

+

-

+ + {{ t('or_add_field_without_drawing') }} + +
@@ -577,10 +585,21 @@ export default { ref.$el.scrollIntoView({ behavior: 'smooth', block: 'start' }) }, + clearDrawField () { + if (this.drawField && !this.drawOption && this.drawField.areas.length === 0) { + const fieldIndex = this.template.fields.indexOf(this.drawField) + + if (fieldIndex !== -1) { + this.template.fields.splice(fieldIndex, 1) + } + } + this.drawField = null + this.drawOption = null + }, onKeyUp (e) { if (e.code === 'Escape') { - this.drawField = null - this.drawOption = null + this.clearDrawField() + this.selectedAreaRef.value = null } diff --git a/app/javascript/template_builder/fields.vue b/app/javascript/template_builder/fields.vue index d7e26a0c..79f911a5 100644 --- a/app/javascript/template_builder/fields.vue +++ b/app/javascript/template_builder/fields.vue @@ -131,7 +131,7 @@ Drag & drop any other field type on the page
  • - Click on the field type above to add it to the form without drawing it on the document + Click on the field type above to start drawing it
  • @@ -295,7 +295,7 @@ export default { this.fields.push(field) - if (['signature', 'initials', 'cells', 'stamp'].includes(type)) { + if (!['payment', 'file'].includes(type)) { this.$emit('set-draw', { field }) } diff --git a/app/javascript/template_builder/i18n.js b/app/javascript/template_builder/i18n.js index 81b4d9df..29b5d35e 100644 --- a/app/javascript/template_builder/i18n.js +++ b/app/javascript/template_builder/i18n.js @@ -30,6 +30,7 @@ const en = { ninth_party: 'Ninth Party', tenth_party: 'Tenth Party', add: 'Add', + or_add_field_without_drawing: 'Or add field without drawing', text: 'Text', signature: 'Signature', initials: 'Initials',