Browse Source

extract js into tasklist-controller

pull/30/head
Kat 4 years ago
parent
commit
c664234568
  1. 8
      app/javascript/controllers/tasklist_controller.js
  2. 5
      app/views/case_logs/edit.html.erb

8
app/javascript/controllers/tasklist_controller.js

@ -0,0 +1,8 @@
import { Controller } from "@hotwired/stimulus"
export default class extends Controller {
addHighlight() {
let section_to_highlight = this.element.dataset.info;
document.getElementById(section_to_highlight).classList.add('tasklist_item_highlight');
}
}

5
app/views/case_logs/edit.html.erb

@ -9,7 +9,10 @@
<p class="govuk-body govuk-!-margin-bottom-7">You've completed <%= get_sections_count(@form, @case_log, :completed) %> of <%= get_sections_count(@form, @case_log, :all) %> sections.</p>
<p class="govuk-body govuk-!-margin-bottom-7">
<% next_incomplete_section=get_next_incomplete_section(@form, @case_log) %>
<a href="#<%= next_incomplete_section %>" onclick="addHighlight('<%= next_incomplete_section %>')">
<a href="#<%= next_incomplete_section %>"
data-controller="tasklist"
data-action="tasklist#addHighlight"
data-info=<%= next_incomplete_section %>>
Skip to next incomplete section
</a>
</p>

Loading…
Cancel
Save