From f5c00ada3102c98ecd294ef0743c939263cf4e7b Mon Sep 17 00:00:00 2001 From: Alex Turchyn Date: Sun, 4 Jun 2023 01:08:45 +0300 Subject: [PATCH] add field area controls --- app/javascript/application.js | 8 + app/javascript/submission_form/form.vue | 2 +- app/javascript/template_builder/area.vue | 151 +++++++++++++----- app/javascript/template_builder/builder.vue | 101 +++++++++++- .../template_builder/contenteditable.vue | 11 +- app/javascript/template_builder/document.vue | 5 +- app/javascript/template_builder/field.vue | 108 ++++--------- .../template_builder/field_type.vue | 90 +++++++++++ app/javascript/template_builder/fields.vue | 35 ++-- app/javascript/template_builder/i18n.js | 10 ++ app/javascript/template_builder/page.vue | 22 ++- app/views/shared/_navbar.html.erb | 2 +- .../generate_result_attachments.rb | 2 +- 13 files changed, 382 insertions(+), 165 deletions(-) create mode 100644 app/javascript/template_builder/field_type.vue create mode 100644 app/javascript/template_builder/i18n.js diff --git a/app/javascript/application.js b/app/javascript/application.js index 1674bdc4..5b03bb9e 100644 --- a/app/javascript/application.js +++ b/app/javascript/application.js @@ -14,6 +14,12 @@ document.addEventListener('turbo:before-cache', () => { window.flash?.remove() }) +document.addEventListener('keyup', (e) => { + if (e.code === 'Escape') { + document.activeElement?.blur() + } +}) + window.customElements.define('toggle-visible', ToggleVisible) window.customElements.define('disable-hidden', DisableHidden) window.customElements.define('turbo-modal', TurboModal) @@ -29,6 +35,8 @@ window.customElements.define('template-builder', class extends HTMLElement { template: reactive(JSON.parse(this.dataset.template)) }) + this.app.config.globalProperties.$t = (key) => TemplateBuilder.i18n[key] || key + this.app.mount(this.appElem) this.appendChild(this.appElem) diff --git a/app/javascript/submission_form/form.vue b/app/javascript/submission_form/form.vue index 9e91c2ed..a3585094 100644 --- a/app/javascript/submission_form/form.vue +++ b/app/javascript/submission_form/form.vue @@ -130,7 +130,7 @@ @attached="attachments.push($event)" />
- {{ field?.name || field?.type }} + + +
+
diff --git a/app/javascript/template_builder/fields.vue b/app/javascript/template_builder/fields.vue index 9eb25214..9345eac8 100644 --- a/app/javascript/template_builder/fields.vue +++ b/app/javascript/template_builder/fields.vue @@ -1,5 +1,5 @@