app/views/checklists/_topic.html.erb
<% topic_key = topic.id unless topic_key %>
<div class="topicContainer rounded form-group">
<%= hidden_field_tag "topics[#{topic_key}][id]", topic.id || "new", :class => 'topic_id' %>
<%= hidden_field_tag "topics[#{topic_key}][ordering]", topic.ordering, :class => 'topic_ordering' %>
<div class="topic_handle">
<%= topic.title %>
<button type="button" class="btn-link expandable collapsed" data-toggle="collapse" data-target="#edit_topic_panel_<%= topic_key %>">
Edit topic
</button>
</div>
<div id="edit_topic_panel_<%= topic_key %>" class="panel panel-default collapse">
<div class="panel-body">
<div class="form-group">
Name
<%= text_field_tag "topics[#{topic_key}][title]", topic.title %>
</div>
<div class="form-group">
Score type
<%= collection_select("topics[#{topic_key}]", :scoretype_id, Scoretype.all, :id, :name, :selected => topic.scoretype_id) %>
</div>
<div class="row">
<div class="col-sm-6">
<p>Javascript code to call before evaluating the score and feedback of this topic.</p>
<%= text_area_tag "topics[#{topic_key}][init_callback]", topic.init_callback, :rows => 10, :cols => 80 %>
</div>
<div class="col-sm-6">
<p>Javascript code to call after evaluating the score and feedback of this topic.</p>
<%= text_area_tag "topics[#{topic_key}][update_callback]", topic.update_callback, :rows => 10, :cols => 80 %>
</div>
</div>
<div>
<button type="button" class="deleteTopic btn btn-danger">Delete this topic</button>
</div>
</div>
</div>
<table class="checklist_table values_table table table-striped table-condensed table-bordered" id="topic_<%= topic_key %>">
<colgroup>
<col span="1" style="">
<col span="1" style="">
<col span="1" style="">
<col span="1" style="width: 50px;">
<col span="1" style="width: 50px;">
</colgroup>
<thead>
<tr>
<th class="name">Check</th>
<th class="feedbacks">Checked feedback</th>
<th class="feedbacks">Unchecked feedback</th>
<th class="scores">Checked</th>
<th class="scores">Unchecked</th>
<th>More</th>
</tr>
</thead>
<tbody>
<% topic.topics_checks.includes(:check).each do |link| %>
<%= render partial: "check", locals: {link: link, topic_key: topic_key} %>
<% end %>
</tbody>
<tfoot>
<tr>
<th colspan="3" class="spanOverFeedbacks">Totals</th>
<th>Max: <span class="max"></span></th>
<th>Min: <span class="min"></span></th>
<th></th>
</tr>
<tr>
<th colspan="3" class="spanOverFeedbacks">
<%= check_box_tag("topics[#{topic_key}][scale_score]", 1, !topic.score_target.nil?, :class => :scale_score) +
label_tag("topics[#{topic_key}][scale_score]", "Scale score total to a maximum/minimum of") %>
<%= number_field_tag "topics[#{topic_key}][score_target]", show_val(topic.score_target), :step=> :any, :class => :score_target %>
points
<%= hidden_field_tag "topics[#{topic_key}][scale_numerator]", topic.scale_numerator, :class => :scale_num %>
<%= hidden_field_tag "topics[#{topic_key}][scale_denominator]", topic.scale_denominator, :class => :scale_denom %>
<span class="pull-right">Scaled values:</span>
</th>
<th>Max: <span class="max_scaled"></span></th>
<th>Min: <span class="min_scaled"></span></th>
<th></th>
</tr>
</tfoot>
</table>
<div class="new_check_form_container">
<p>
<%= label_tag 'new_check_title', 'New check' %>:
<%= text_field_tag :new_check_title, nil %>
<button class="new_check" type="button" class="btn btn-primary">Create</button>
<%= label_tag 'import_check', 'Import check' %>:
<%= grouped_collection_select :import_check, nil, ChecklistTopic.includes(:checklist).order("checklists.title","checklist_topics.ordering"), :checks, :checlist_name_and_title, :id, :check, :class => "nosubmit" %>
<button class="import_check" type="button" class="btn btn-primary">Import</button>
</p>
</div>
</div>