obdev/app/views/onboardings/index.html.erb

59 lines
1.9 KiB
Plaintext

<div class="container mt-5">
<h1 class="mb-4 text-center">Onboarding</h1>
</div>
<%= form_with(model: [@owner, OnboardingItem.new], url: submit_onboarding_polymorphic_path(@owner), local: true, html: { class: 'needs-validation', novalidate: true }) do |form| %>
<table class="table">
<thead class="table-light">
<tr>
<th>Form Name</th>
<th>Notes</th>
<th>Date Completed</th>
</tr>
</thead>
<tbody>
<% @onboarding_items.each_with_index do |item, index| %>
<tr>
<td><%= item.form.name %></td>
<td>
<%= text_area_tag "onboarding_items[#{index}][note]", item.note, id: "onboarding_items_#{index}_note", class: "form-control", rows: 1 %>
</td>
<td>
<%= date_field_tag "onboarding_items[#{index}][date_completed]", item.date_completed, id: "onboarding_items_#{index}_date_completed", class: "form-control" %>
</td>
<%= hidden_field_tag "onboarding_items[#{index}][id]", item.id %>
</tr>
<% end %>
</tbody>
</table>
<div class="actions mt-4">
<%= form.submit 'Save', class: 'btn btn-dark' %>
</div>
<% end %>
<div class="mt-3 text-center">
<%= link_to 'Back', polymorphic_path(@owner), class: 'btn btn-secondary' %>
</div>
<%# This is for resizing Notes area %>
<script>
document.addEventListener('DOMContentLoaded', function() {
document.querySelectorAll('textarea.form-control').forEach(function(textarea) {
function autoResize() {
// Reset height to ensure shrinking if text is deleted
textarea.style.height = 'auto';
// Set height based on scroll height
textarea.style.height = textarea.scrollHeight + 'px';
}
// Call autoResize on input event
textarea.addEventListener('input', autoResize);
// Initialize autoResize in case of any pre-filled values
autoResize();
});
});
</script>