app/views/participants/_column_controls.html.erb
<section>
<h3>Include columns</h3>
<div>
<% for field_name in @ordinary_fields %>
<%= labeled_field(field_name.humanize, check_box_tag('column_' + field_name, '1', @visible_columns.include?(field_name)), :order => :label_last, :super_class => "checkbox") %>
<% end %>
<% for field in @extra_fields %>
<%= extra_field_checkbox('column_', field, @visible_columns.include?(field.name)) %>
<% end %>
<%=
options = options_for_select([["(Don't show)", ""]] + @courses.map {|c| [c.name, c.id]}, params['group_completion_course_id'])
select = select_tag('group_completion_course_id', options)
labeled_field('Completion for each exercise group', select)
%>
<%=
checkbox = check_box_tag('show_with_no_points', '1', params['show_with_no_points'])
labeled_field('Show users with no points', checkbox, :order => :label_last, :super_class => "checkbox")
%>
<script type="text/javascript">
$(document).ready(function() {
var savedValue = null;
function updateShowWithNoPoints() {
var checkbox = $('#show_with_no_points');
var control = checkbox.parent();
var enable = $('#group_completion_course_id > option:selected').attr('value') != '';
var enabled = checkbox.is(':enabled');
if (enable == enabled) {
return;
}
if (enable) {
checkbox.removeAttr('disabled');
control.css({ opacity: 1 });
if (savedValue !== null) {
checkbox.attr('checked', savedValue);
}
} else {
checkbox.attr('disabled', 'disabled');
control.css({ opacity: 0.5 });
savedValue = checkbox.is(':checked');
checkbox.attr('checked', true);
}
}
$('#group_completion_course_id').change(updateShowWithNoPoints);
updateShowWithNoPoints();
});
</script>
</div>
</section>