Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Textarea for formula #973

Merged
merged 21 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions app/assets/stylesheets/components/form.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
18 changes: 18 additions & 0 deletions app/javascript/controllers/textarea_controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Controller } from "@hotwired/stimulus";

export default class extends Controller {
static targets = ["textarea"];

connect() {
this.resize(this.element);
}

resize(textarea) {
textarea.style.height = "auto";
textarea.style.height = `${textarea.scrollHeight}px`; // Adjust height based on scrollHeight
}

input(event) {
this.resize(event.target);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
<div>
<%= 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: "formula",
data: { controller: "textarea", action: "input->textarea#input" }
} %>

<%= f.input :uk_unit, label: "Uk Unit Label:" %>
<%= f.input :en_unit, label: "Unit Label:" %>
Expand Down
2 changes: 2 additions & 0 deletions spec/rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand Down
Loading