From d9b7d57e542ab754e064eac7e164b76a5761c2b8 Mon Sep 17 00:00:00 2001
From: DanielVajnagi <82052651+DanielVajnagi@users.noreply.github.com>
Date: Sun, 24 Nov 2024 20:15:37 +0200
Subject: [PATCH 01/20] Textarea for formula
---
app/javascript/application.js | 1 +
app/javascript/helpers/auto_resize_textarea.js | 12 ++++++++++++
.../calculators/partials/_formula_fields.html.erb | 4 ++--
spec/rails_helper.rb | 2 ++
4 files changed, 17 insertions(+), 2 deletions(-)
create mode 100644 app/javascript/helpers/auto_resize_textarea.js
diff --git a/app/javascript/application.js b/app/javascript/application.js
index e7797754a..ee3bc533e 100644
--- a/app/javascript/application.js
+++ b/app/javascript/application.js
@@ -8,3 +8,4 @@ import "@rails/request.js";
import "@rails/actioncable";
import "turbo_streams/toast";
import "@oddcamp/cocoon-vanilla-js"
+import "./helpers/auto_resize_textarea"
diff --git a/app/javascript/helpers/auto_resize_textarea.js b/app/javascript/helpers/auto_resize_textarea.js
new file mode 100644
index 000000000..06c928988
--- /dev/null
+++ b/app/javascript/helpers/auto_resize_textarea.js
@@ -0,0 +1,12 @@
+document.addEventListener("DOMContentLoaded", function () {
+ const textareas = document.querySelectorAll('.resize-auto');
+
+ textareas.forEach(textarea => {
+ textarea.addEventListener('input', function () {
+ this.style.overflow = 'hidden';
+ this.style.resize = 'none';
+ this.style.height = 'auto'; // Reset height to auto
+ this.style.height = (this.scrollHeight) + 'px'; // Set height based on scrollHeight
+ });
+ });
+});
diff --git a/app/views/account/calculators/partials/_formula_fields.html.erb b/app/views/account/calculators/partials/_formula_fields.html.erb
index a0787f159..bda8526f0 100644
--- a/app/views/account/calculators/partials/_formula_fields.html.erb
+++ b/app/views/account/calculators/partials/_formula_fields.html.erb
@@ -1,10 +1,10 @@
<%= f.input :en_label, label: "Formula Label:" %>
<%= f.input :uk_label, label: "Uk Formula Label:" %>
- <%= f.input :expression, label: "Formula Expression:" %>
+ <%= f.input :expression, as: :text, label: "Formula Expression:", input_html: { class: "resize-auto", rows: 3 } %>
<%= f.input :uk_unit, label: "Uk Unit Label:" %>
<%= f.input :en_unit, label: "Unit Label:" %>
<%= link_to_remove_association "- Remove Formula", f, class: "text-red-500 underline" %>
-
+
diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb
index 01d857619..29f931450 100644
--- a/spec/rails_helper.rb
+++ b/spec/rails_helper.rb
@@ -83,6 +83,8 @@
config.add_formatter "Fuubar"
config.fuubar_output_pending_results = false
+
+ Capybara.default_max_wait_time = 10 # Increase wait time (in seconds), so test don't fail locally
end
Shoulda::Matchers.configure do |config|
From 6393b2766beab9b14f78930ca637c281423b8317 Mon Sep 17 00:00:00 2001
From: DanielVajnagi <82052651+DanielVajnagi@users.noreply.github.com>
Date: Sun, 24 Nov 2024 20:27:43 +0200
Subject: [PATCH 02/20] moved js
---
app/javascript/application.js | 4 ++--
.../{helpers => components}/auto_resize_textarea.js | 0
2 files changed, 2 insertions(+), 2 deletions(-)
rename app/javascript/{helpers => components}/auto_resize_textarea.js (100%)
diff --git a/app/javascript/application.js b/app/javascript/application.js
index ee3bc533e..cf30ed327 100644
--- a/app/javascript/application.js
+++ b/app/javascript/application.js
@@ -7,5 +7,5 @@ import "@fortawesome/fontawesome-free";
import "@rails/request.js";
import "@rails/actioncable";
import "turbo_streams/toast";
-import "@oddcamp/cocoon-vanilla-js"
-import "./helpers/auto_resize_textarea"
+import "@oddcamp/cocoon-vanilla-js";
+import "./components/auto_resize_textarea";
diff --git a/app/javascript/helpers/auto_resize_textarea.js b/app/javascript/components/auto_resize_textarea.js
similarity index 100%
rename from app/javascript/helpers/auto_resize_textarea.js
rename to app/javascript/components/auto_resize_textarea.js
From 22f049b0393292e9da76f1ec43f03c233e450496 Mon Sep 17 00:00:00 2001
From: DanielVajnagi <82052651+DanielVajnagi@users.noreply.github.com>
Date: Sun, 24 Nov 2024 20:34:29 +0200
Subject: [PATCH 03/20] add to importmap
---
config/importmap.rb | 1 +
1 file changed, 1 insertion(+)
diff --git a/config/importmap.rb b/config/importmap.rb
index 26f31b8e1..77f50474a 100644
--- a/config/importmap.rb
+++ b/config/importmap.rb
@@ -14,3 +14,4 @@
pin "@rails/actioncable", to: "actioncable.esm.js", preload: true
pin "toastify-js", to: "https://ga.jspm.io/npm:toastify-js@1.12.0/src/toastify.js", preload: true
pin "@oddcamp/cocoon-vanilla-js", to: "https://ga.jspm.io/npm:@oddcamp/cocoon-vanilla-js@1.1.3/index.js"
+pin "auto_resize_textarea", to: "components/auto_resize_textarea.js"
\ No newline at end of file
From 1a7e5752bc8325e70ffd77fdd9fec8bbeb27fd3c Mon Sep 17 00:00:00 2001
From: DanielVajnagi <82052651+DanielVajnagi@users.noreply.github.com>
Date: Sun, 24 Nov 2024 20:51:28 +0200
Subject: [PATCH 04/20] now works for all folrmula fields
---
.../components/auto_resize_textarea.js | 19 ++++++++-----------
1 file changed, 8 insertions(+), 11 deletions(-)
diff --git a/app/javascript/components/auto_resize_textarea.js b/app/javascript/components/auto_resize_textarea.js
index 06c928988..4d3f4d5f9 100644
--- a/app/javascript/components/auto_resize_textarea.js
+++ b/app/javascript/components/auto_resize_textarea.js
@@ -1,12 +1,9 @@
-document.addEventListener("DOMContentLoaded", function () {
- const textareas = document.querySelectorAll('.resize-auto');
-
- textareas.forEach(textarea => {
- textarea.addEventListener('input', function () {
- this.style.overflow = 'hidden';
- this.style.resize = 'none';
- this.style.height = 'auto'; // Reset height to auto
- this.style.height = (this.scrollHeight) + 'px'; // Set height based on scrollHeight
- });
- });
+document.addEventListener('input', function (event) {
+ if (event.target && event.target.classList.contains('resize-auto') && event.target.tagName === 'TEXTAREA') {
+ const textarea = event.target;
+ textarea.style.overflow = 'hidden';
+ textarea.style.resize = 'none';
+ textarea.style.height = 'auto';
+ textarea.style.height = (textarea.scrollHeight) + 'px';
+ }
});
From 63ac15bb6f922d12a8bb258b01230a98f22c6e4c Mon Sep 17 00:00:00 2001
From: DanielVajnagi <82052651+DanielVajnagi@users.noreply.github.com>
Date: Sun, 24 Nov 2024 20:53:23 +0200
Subject: [PATCH 05/20] rubocop
---
config/importmap.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/config/importmap.rb b/config/importmap.rb
index 77f50474a..799efb8c4 100644
--- a/config/importmap.rb
+++ b/config/importmap.rb
@@ -14,4 +14,4 @@
pin "@rails/actioncable", to: "actioncable.esm.js", preload: true
pin "toastify-js", to: "https://ga.jspm.io/npm:toastify-js@1.12.0/src/toastify.js", preload: true
pin "@oddcamp/cocoon-vanilla-js", to: "https://ga.jspm.io/npm:@oddcamp/cocoon-vanilla-js@1.1.3/index.js"
-pin "auto_resize_textarea", to: "components/auto_resize_textarea.js"
\ No newline at end of file
+pin "auto_resize_textarea", to: "components/auto_resize_textarea.js"
From f06eb2c5fdb8080bdf8edb32210844624cfa8c0b Mon Sep 17 00:00:00 2001
From: DanielVajnagi <82052651+DanielVajnagi@users.noreply.github.com>
Date: Mon, 25 Nov 2024 11:00:15 +0200
Subject: [PATCH 06/20] Update importmap.rb
---
config/importmap.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/config/importmap.rb b/config/importmap.rb
index 799efb8c4..bee4f0b49 100644
--- a/config/importmap.rb
+++ b/config/importmap.rb
@@ -14,4 +14,4 @@
pin "@rails/actioncable", to: "actioncable.esm.js", preload: true
pin "toastify-js", to: "https://ga.jspm.io/npm:toastify-js@1.12.0/src/toastify.js", preload: true
pin "@oddcamp/cocoon-vanilla-js", to: "https://ga.jspm.io/npm:@oddcamp/cocoon-vanilla-js@1.1.3/index.js"
-pin "auto_resize_textarea", to: "components/auto_resize_textarea.js"
+pin "auto_resize_textarea", to: "app/javascript/components/auto_resize_textarea.js"
From 114a84bdd69e58274f5efee0e173b92a8861cc48 Mon Sep 17 00:00:00 2001
From: DanielVajnagi <82052651+DanielVajnagi@users.noreply.github.com>
Date: Mon, 25 Nov 2024 11:08:44 +0200
Subject: [PATCH 07/20] Update ci.yml
---
.github/workflows/ci.yml | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index cea3e33d5..e09b814f5 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -66,7 +66,10 @@ jobs:
- name: Prepare config
run: |
mv config/database.yml.docker config/database.yml
-
+
+ - name: Clean assets
+ run: bin/rails assets:clobber
+
- name: Precompile assets
run: |
bundle exec rails assets:precompile
From a921e5076fc427c247d8ed5472ffe977bf90f9cc Mon Sep 17 00:00:00 2001
From: DanielVajnagi <82052651+DanielVajnagi@users.noreply.github.com>
Date: Mon, 25 Nov 2024 11:17:08 +0200
Subject: [PATCH 08/20] Update ci.yml
---
.github/workflows/ci.yml | 3 ---
1 file changed, 3 deletions(-)
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index e09b814f5..9bbc0ca24 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -67,9 +67,6 @@ jobs:
run: |
mv config/database.yml.docker config/database.yml
- - name: Clean assets
- run: bin/rails assets:clobber
-
- name: Precompile assets
run: |
bundle exec rails assets:precompile
From e16324a0027ef8df7270251caf24c84dacea8eea Mon Sep 17 00:00:00 2001
From: DanielVajnagi <82052651+DanielVajnagi@users.noreply.github.com>
Date: Mon, 25 Nov 2024 11:20:45 +0200
Subject: [PATCH 09/20] Update ci.yml
---
.github/workflows/ci.yml | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 9bbc0ca24..f7f294a54 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -68,8 +68,7 @@ jobs:
mv config/database.yml.docker config/database.yml
- name: Precompile assets
- run: |
- bundle exec rails assets:precompile
+ run: RAILS_ENV=test bin/rails assets:precompile
- name: Run tests
run: |
From db4db71aa95166603171b2cb575d856338ba0432 Mon Sep 17 00:00:00 2001
From: DanielVajnagi <82052651+DanielVajnagi@users.noreply.github.com>
Date: Mon, 25 Nov 2024 11:23:41 +0200
Subject: [PATCH 10/20] Update ci.yml
---
.github/workflows/ci.yml | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index f7f294a54..9bbc0ca24 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -68,7 +68,8 @@ jobs:
mv config/database.yml.docker config/database.yml
- name: Precompile assets
- run: RAILS_ENV=test bin/rails assets:precompile
+ run: |
+ bundle exec rails assets:precompile
- name: Run tests
run: |
From 038f714f13fbde54afc47d70aa2ad10c7406718e Mon Sep 17 00:00:00 2001
From: DanielVajnagi <82052651+DanielVajnagi@users.noreply.github.com>
Date: Mon, 25 Nov 2024 11:24:06 +0200
Subject: [PATCH 11/20] Update ci.yml
---
.github/workflows/ci.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 9bbc0ca24..cea3e33d5 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -66,7 +66,7 @@ jobs:
- name: Prepare config
run: |
mv config/database.yml.docker config/database.yml
-
+
- name: Precompile assets
run: |
bundle exec rails assets:precompile
From a7d58e2008dc63546f1de4941b4001658324fea0 Mon Sep 17 00:00:00 2001
From: DanielVajnagi <82052651+DanielVajnagi@users.noreply.github.com>
Date: Mon, 25 Nov 2024 11:24:19 +0200
Subject: [PATCH 12/20] Update application.js
---
app/javascript/application.js | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/app/javascript/application.js b/app/javascript/application.js
index cf30ed327..e7797754a 100644
--- a/app/javascript/application.js
+++ b/app/javascript/application.js
@@ -7,5 +7,4 @@ import "@fortawesome/fontawesome-free";
import "@rails/request.js";
import "@rails/actioncable";
import "turbo_streams/toast";
-import "@oddcamp/cocoon-vanilla-js";
-import "./components/auto_resize_textarea";
+import "@oddcamp/cocoon-vanilla-js"
From 9df25ef93e9584c2d09ead65cd65bd68c05f79e8 Mon Sep 17 00:00:00 2001
From: DanielVajnagi <82052651+DanielVajnagi@users.noreply.github.com>
Date: Mon, 25 Nov 2024 14:04:00 +0200
Subject: [PATCH 13/20] fix
---
app/javascript/application.js | 3 ++-
config/importmap.rb | 2 +-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/app/javascript/application.js b/app/javascript/application.js
index e7797754a..cf30ed327 100644
--- a/app/javascript/application.js
+++ b/app/javascript/application.js
@@ -7,4 +7,5 @@ import "@fortawesome/fontawesome-free";
import "@rails/request.js";
import "@rails/actioncable";
import "turbo_streams/toast";
-import "@oddcamp/cocoon-vanilla-js"
+import "@oddcamp/cocoon-vanilla-js";
+import "./components/auto_resize_textarea";
diff --git a/config/importmap.rb b/config/importmap.rb
index bee4f0b49..9273cca14 100644
--- a/config/importmap.rb
+++ b/config/importmap.rb
@@ -14,4 +14,4 @@
pin "@rails/actioncable", to: "actioncable.esm.js", preload: true
pin "toastify-js", to: "https://ga.jspm.io/npm:toastify-js@1.12.0/src/toastify.js", preload: true
pin "@oddcamp/cocoon-vanilla-js", to: "https://ga.jspm.io/npm:@oddcamp/cocoon-vanilla-js@1.1.3/index.js"
-pin "auto_resize_textarea", to: "app/javascript/components/auto_resize_textarea.js"
+# pin "resize_textarea", to: "app/javascript/components/auto_resize_textarea.js"
From bc3be49a1a07715d14415140498e891ea8143885 Mon Sep 17 00:00:00 2001
From: DanielVajnagi <82052651+DanielVajnagi@users.noreply.github.com>
Date: Mon, 25 Nov 2024 14:13:56 +0200
Subject: [PATCH 14/20] fix2
---
app/javascript/application.js | 2 +-
config/importmap.rb | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/javascript/application.js b/app/javascript/application.js
index cf30ed327..3f0343603 100644
--- a/app/javascript/application.js
+++ b/app/javascript/application.js
@@ -8,4 +8,4 @@ import "@rails/request.js";
import "@rails/actioncable";
import "turbo_streams/toast";
import "@oddcamp/cocoon-vanilla-js";
-import "./components/auto_resize_textarea";
+import "resize_textarea";
diff --git a/config/importmap.rb b/config/importmap.rb
index 9273cca14..90e261f59 100644
--- a/config/importmap.rb
+++ b/config/importmap.rb
@@ -14,4 +14,4 @@
pin "@rails/actioncable", to: "actioncable.esm.js", preload: true
pin "toastify-js", to: "https://ga.jspm.io/npm:toastify-js@1.12.0/src/toastify.js", preload: true
pin "@oddcamp/cocoon-vanilla-js", to: "https://ga.jspm.io/npm:@oddcamp/cocoon-vanilla-js@1.1.3/index.js"
-# pin "resize_textarea", to: "app/javascript/components/auto_resize_textarea.js"
+pin "resize_textarea", to: "components/auto_resize_textarea.js"
From 43164ae47e0fdab4a6f9028224933f19bc26d911 Mon Sep 17 00:00:00 2001
From: DanielVajnagi <82052651+DanielVajnagi@users.noreply.github.com>
Date: Tue, 26 Nov 2024 13:11:13 +0200
Subject: [PATCH 15/20] stimulus
---
app/javascript/application.js | 3 +--
.../controllers/textarea_controller.js | 20 +++++++++++++++++++
.../partials/_formula_fields.html.erb | 5 +++--
config/importmap.rb | 1 -
4 files changed, 24 insertions(+), 5 deletions(-)
create mode 100644 app/javascript/controllers/textarea_controller.js
diff --git a/app/javascript/application.js b/app/javascript/application.js
index 3f0343603..f61ad387c 100644
--- a/app/javascript/application.js
+++ b/app/javascript/application.js
@@ -7,5 +7,4 @@ import "@fortawesome/fontawesome-free";
import "@rails/request.js";
import "@rails/actioncable";
import "turbo_streams/toast";
-import "@oddcamp/cocoon-vanilla-js";
-import "resize_textarea";
+import "@oddcamp/cocoon-vanilla-js"
\ No newline at end of file
diff --git a/app/javascript/controllers/textarea_controller.js b/app/javascript/controllers/textarea_controller.js
new file mode 100644
index 000000000..112ec8b2a
--- /dev/null
+++ b/app/javascript/controllers/textarea_controller.js
@@ -0,0 +1,20 @@
+import { Controller } from "@hotwired/stimulus";
+
+export default class extends Controller {
+ static targets = ["textarea"];
+
+ connect() {
+ this.resize(this.element);
+ }
+
+ resize(textarea) {
+ textarea.style.overflow = "hidden"; // Prevent scrollbars
+ textarea.style.resize = "none"; // Prevent manual resizing
+ textarea.style.height = "auto"; // Reset height
+ textarea.style.height = `${textarea.scrollHeight}px`; // Adjust height based on scrollHeight
+ }
+
+ input(event) {
+ this.resize(event.target);
+ }
+}
diff --git a/app/views/account/calculators/partials/_formula_fields.html.erb b/app/views/account/calculators/partials/_formula_fields.html.erb
index bda8526f0..54dbc3da0 100644
--- a/app/views/account/calculators/partials/_formula_fields.html.erb
+++ b/app/views/account/calculators/partials/_formula_fields.html.erb
@@ -1,8 +1,9 @@
<%= f.input :en_label, label: "Formula Label:" %>
<%= f.input :uk_label, label: "Uk Formula Label:" %>
- <%= f.input :expression, as: :text, label: "Formula Expression:", input_html: { class: "resize-auto", rows: 3 } %>
-
+ <%= f.input :expression, as: :text, label: "Formula Expression:", input_html: {
+ data: { controller: "textarea", action: "input->textarea#input" }
+ } %>
<%= f.input :uk_unit, label: "Uk Unit Label:" %>
<%= f.input :en_unit, label: "Unit Label:" %>
diff --git a/config/importmap.rb b/config/importmap.rb
index 90e261f59..26f31b8e1 100644
--- a/config/importmap.rb
+++ b/config/importmap.rb
@@ -14,4 +14,3 @@
pin "@rails/actioncable", to: "actioncable.esm.js", preload: true
pin "toastify-js", to: "https://ga.jspm.io/npm:toastify-js@1.12.0/src/toastify.js", preload: true
pin "@oddcamp/cocoon-vanilla-js", to: "https://ga.jspm.io/npm:@oddcamp/cocoon-vanilla-js@1.1.3/index.js"
-pin "resize_textarea", to: "components/auto_resize_textarea.js"
From 12c49a31284dc73b8e2865bc93e7618cc7fbfe06 Mon Sep 17 00:00:00 2001
From: DanielVajnagi <82052651+DanielVajnagi@users.noreply.github.com>
Date: Tue, 26 Nov 2024 17:29:45 +0200
Subject: [PATCH 16/20] script delete
---
app/javascript/components/auto_resize_textarea.js | 9 ---------
1 file changed, 9 deletions(-)
delete mode 100644 app/javascript/components/auto_resize_textarea.js
diff --git a/app/javascript/components/auto_resize_textarea.js b/app/javascript/components/auto_resize_textarea.js
deleted file mode 100644
index 4d3f4d5f9..000000000
--- a/app/javascript/components/auto_resize_textarea.js
+++ /dev/null
@@ -1,9 +0,0 @@
-document.addEventListener('input', function (event) {
- if (event.target && event.target.classList.contains('resize-auto') && event.target.tagName === 'TEXTAREA') {
- const textarea = event.target;
- textarea.style.overflow = 'hidden';
- textarea.style.resize = 'none';
- textarea.style.height = 'auto';
- textarea.style.height = (textarea.scrollHeight) + 'px';
- }
-});
From ba1ade19c7afa9acf9f292a782b6ba857cdf5245 Mon Sep 17 00:00:00 2001
From: DanielVajnagi <82052651+DanielVajnagi@users.noreply.github.com>
Date: Tue, 26 Nov 2024 18:13:37 +0200
Subject: [PATCH 17/20] Update application.js
---
app/javascript/application.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/javascript/application.js b/app/javascript/application.js
index f61ad387c..e7797754a 100644
--- a/app/javascript/application.js
+++ b/app/javascript/application.js
@@ -7,4 +7,4 @@ import "@fortawesome/fontawesome-free";
import "@rails/request.js";
import "@rails/actioncable";
import "turbo_streams/toast";
-import "@oddcamp/cocoon-vanilla-js"
\ No newline at end of file
+import "@oddcamp/cocoon-vanilla-js"
From 7877a0553b371cd6399d9a687dec558033a8f7ea Mon Sep 17 00:00:00 2001
From: DanielVajnagi <82052651+DanielVajnagi@users.noreply.github.com>
Date: Tue, 3 Dec 2024 11:15:17 +0200
Subject: [PATCH 18/20] Update textarea_controller.js
---
app/javascript/controllers/textarea_controller.js | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/app/javascript/controllers/textarea_controller.js b/app/javascript/controllers/textarea_controller.js
index 112ec8b2a..fd41bed06 100644
--- a/app/javascript/controllers/textarea_controller.js
+++ b/app/javascript/controllers/textarea_controller.js
@@ -8,9 +8,9 @@ export default class extends Controller {
}
resize(textarea) {
- textarea.style.overflow = "hidden"; // Prevent scrollbars
- textarea.style.resize = "none"; // Prevent manual resizing
- textarea.style.height = "auto"; // Reset height
+ textarea.style.overflow = "hidden";
+ textarea.style.resize = "none";
+ textarea.style.height = "auto";
textarea.style.height = `${textarea.scrollHeight}px`; // Adjust height based on scrollHeight
}
From 919b4256934ede42732152e89be4b26acf9e5f44 Mon Sep 17 00:00:00 2001
From: DanielVajnagi <82052651+DanielVajnagi@users.noreply.github.com>
Date: Tue, 3 Dec 2024 11:39:01 +0200
Subject: [PATCH 19/20] Update _formula_fields.html.erb
---
app/views/account/calculators/partials/_formula_fields.html.erb | 2 --
1 file changed, 2 deletions(-)
diff --git a/app/views/account/calculators/partials/_formula_fields.html.erb b/app/views/account/calculators/partials/_formula_fields.html.erb
index 66fa2413f..c99af49aa 100644
--- a/app/views/account/calculators/partials/_formula_fields.html.erb
+++ b/app/views/account/calculators/partials/_formula_fields.html.erb
@@ -1,4 +1,3 @@
-
-
From 9e63cbb4bce054a25ac29f4832c89f41ea73f1b9 Mon Sep 17 00:00:00 2001
From: DanielVajnagi <82052651+DanielVajnagi@users.noreply.github.com>
Date: Tue, 3 Dec 2024 20:37:57 +0200
Subject: [PATCH 20/20] formula field styling
---
app/assets/stylesheets/components/form.css | 8 ++++++++
app/javascript/controllers/textarea_controller.js | 2 --
.../account/calculators/partials/_formula_fields.html.erb | 2 +-
3 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/app/assets/stylesheets/components/form.css b/app/assets/stylesheets/components/form.css
index 5bff0c355..3895f6780 100644
--- a/app/assets/stylesheets/components/form.css
+++ b/app/assets/stylesheets/components/form.css
@@ -36,4 +36,12 @@
.auth-login-links {
@apply flex items-center justify-center gap-4 text-center border-t border-solid text-gray border-light_gray;
}
+
+ /* Formula field */
+ .formula{
+ border-radius: inherit !important;
+ border-color: #6b7280 !important;
+ overflow: hidden;
+ resize: none !important;
+ }
}
diff --git a/app/javascript/controllers/textarea_controller.js b/app/javascript/controllers/textarea_controller.js
index fd41bed06..33e25e146 100644
--- a/app/javascript/controllers/textarea_controller.js
+++ b/app/javascript/controllers/textarea_controller.js
@@ -8,8 +8,6 @@ export default class extends Controller {
}
resize(textarea) {
- textarea.style.overflow = "hidden";
- textarea.style.resize = "none";
textarea.style.height = "auto";
textarea.style.height = `${textarea.scrollHeight}px`; // Adjust height based on scrollHeight
}
diff --git a/app/views/account/calculators/partials/_formula_fields.html.erb b/app/views/account/calculators/partials/_formula_fields.html.erb
index c99af49aa..bee217020 100644
--- a/app/views/account/calculators/partials/_formula_fields.html.erb
+++ b/app/views/account/calculators/partials/_formula_fields.html.erb
@@ -3,7 +3,7 @@
<%= f.input :en_label, label: "Formula Label:" %>
<%= f.input :uk_label, label: "Uk Formula Label:" %>
- <%= f.input :expression, as: :text, label: "Formula Expression:", input_html: {
+ <%= f.input :expression, as: :text, label: "Formula Expression:", input_html: { class: "formula",
data: { controller: "textarea", action: "input->textarea#input" }
} %>