timothyandrew/blink

View on GitHub
app/views/students/show.html.erb

Summary

Maintainability
Test Coverage
<% title "Goals for #{@student.name}" %>

<h1 class="student-name-header"><%= @student.name %> - IEP</h1>

<div class="student-actions pull-right">
  <%= link_to "Add #{goal_name_for_depth(0)}", new_student_goal_path(@student), class: "btn btn-info" %>
  <%= link_to "Notes", student_notes_path(@student), class: "btn btn-danger" %>
  <%= link_to "Edit Student", edit_student_path(@student), class: "btn btn-primary" %>
  <div class="btn-group">
    <%= link_to "Show All", "#", class: "show-all btn btn-success" %>
    <%= link_to "Hide All", "#", class: "hide-all btn btn-warning" %>
  </div>

  <div class="second-row">

    <%= link_to "Tree Edit", tree_student_goals_path(@student), class: "btn btn-warning" %>
    <%= link_to "Template", generate_iep_template_student_path(@student), class: "btn btn-info" %>
    <%= link_to "Log", student_audits_path(@student), class: "btn btn-secondary" %>
    <%= link_to "Delete", student_path(@student), method: :delete, class: "btn btn-danger",
      data: {confirm: "Are you sure? This will destroy this goal and all sub-goals, and there's no undo!"} %>

  </div>
</div>



<% if @student.goals.present? %>

  <%= render partial: "goals", locals: {goals: Goal.sort(Goal.roots.where(student_id: @student.id).decorate), depth: 0, parent_id: nil} %>

  <%= render "show_hide_all_js" %>
<% else %>
  <div class="alert alert-warning student-goals-alert">
    You need to add some goals before you see anything here.
  </div>
<% end %>


<script type="text/javascript">
 $(".student_goals").each(function(i, elem) {
   var parent_id = elem.dataset.parentId;
   new ReorderableList(elem, '<%= "/students/#{@student.id}/goals/reorder" %>',
                       {ajaxQueue: "goalReorder", paramName: "goal_ids",
                       defaultParams: {parent_id: parent_id}}).setup();
 });
</script>