Show More
Commit Description:
problem manage
Commit Description:
problem manage
References:
File last commit:
Show/Diff file:
Action:
app/views/problems/manage.html.haml
| 182 lines
| 6.7 KiB
| text/x-haml
| HamlLexer
|
|
r201 | %h1 Manage problems | ||
r678 | %p= link_to '[Back to problem list]', problems_path | |||
|
r201 | |||
r881 | = form_with url: do_manage_problems_path, class: 'align-items-center' do |f| | |||
r880 | .card.border-primary.mb-2 | |||
.card-header.text-bg-primary.border-primary | ||||
r678 | Action | |||
r880 | .card-body | |||
r881 | What do you want to do to the selected problem? | |||
%br/ | ||||
(You can shift-click to select a range of problems) | ||||
.row | ||||
.col-md-6 | ||||
.row.my-3.align-items-center | ||||
.col-md-auto | ||||
.form-check | ||||
= f.label :change_date_added, 'Change "Date added" to' | ||||
= f.check_box :change_date_added, class: 'form-check-input' | ||||
.col-md-auto | ||||
= f.text_field :date_added, class: 'form-control' | ||||
.row.mb-3.align-items-center | ||||
.col-md-auto | ||||
.form-check | ||||
= f.label :change_enable, 'Set "Available" to' | ||||
= f.check_box :change_enable, class: 'form-check-input' | ||||
.col-md-auto | ||||
= f.radio_button :enable, "yes", class: 'form-check-input' | ||||
= f.label :enable_yes, "yes" | ||||
.col-md-auto | ||||
= f.radio_button :enable, "no", class: 'form-check-input' | ||||
= f.label :enable_no, "no" | ||||
.row.mb-3.align-items-center | ||||
.col-md-auto | ||||
.form-check | ||||
= f.label :add_group, 'Add selected problems to user group' | ||||
= f.check_box :add_group, class: 'form-check-input' | ||||
.col-md-auto | ||||
= f.select "group_id", options_from_collection_for_select( Group.all, 'id','name',params[:group_name]), {}, class: 'select2 form-control' | ||||
.col-md-6 | ||||
.row.mb-3.align-items-center | ||||
.col-md-auto | ||||
.form-check | ||||
= f.label :add_tags, 'Add the following tags to the selected problems' | ||||
= f.check_box :add_tags, class: 'form-check-input' | ||||
.col-md-auto | ||||
= f.select "tag_ids", options_from_collection_for_select( Tag.all, 'id','name'), {},class: 'select2', multiple: true, data: {placeholder: 'Select tags by clicking', width: "400px"} | ||||
- if GraderConfiguration.multicontests? | ||||
.row.mb-3.align-items-center | ||||
.col-md-auto | ||||
.form-check | ||||
= f.label :add_contest, 'Add selected problems to contest' | ||||
= f.check_box :add_contest, class: 'form-check-input' | ||||
.col-md-auto | ||||
= f.select "contest_id", options_from_collection_for_select( Contest.all, :id,:title), {}, class: 'select2 form-control' | ||||
.row.mb-3 | ||||
.col-auto | ||||
= f.submit :go, class: 'btn btn-primary' | ||||
-# | ||||
r692 | %ul.form-inline | |||
r678 | %li | |||
r700 | Change "Date added" to | |||
r692 | .input-group.date | |||
= text_field_tag :date_added, class: 'form-control' | ||||
%span.input-group-addon | ||||
%span.glyphicon.glyphicon-calendar | ||||
-# = select_date Date.current, :prefix => 'date_added' | ||||
r678 | | |||
r692 | = submit_tag 'Change', :name => 'change_date_added', class: 'btn btn-primary btn-sm' | |||
r678 | %li | |||
r700 | Set "Available" to | |||
r692 | = submit_tag 'True', :name => 'enable_problem', class: 'btn btn-primary btn-sm' | |||
= submit_tag 'False', :name => 'disable_problem', class: 'btn btn-primary btn-sm' | ||||
|
r279 | |||
r678 | - if GraderConfiguration.multicontests? | |||
%li | ||||
r700 | Add selected problems to contest | |||
r678 | = select("contest","id",Contest.all.collect {|c| [c.title, c.id]}) | |||
r692 | = submit_tag 'Add', :name => 'add_to_contest', class: 'btn btn-primary btn-sm' | |||
r678 | %li | |||
r700 | Add selected problems to user group | |||
r678 | = select_tag "group_id", options_from_collection_for_select( Group.all, 'id','name',params[:group_name]), id: 'group_name',class: 'select2' | |||
r700 | = submit_tag 'Add', name: 'add_group', class: 'btn btn-primary' | |||
%li | ||||
Add the following tags to the selected problems | ||||
= select_tag "tag_ids", options_from_collection_for_select( Tag.all, 'id','name'), id: 'tags_name',class: 'select2', multiple: true, data: {placeholder: 'Select tags by clicking', width: "200px"} | ||||
= submit_tag 'Add', name: 'add_tags', class: 'btn btn-primary' | ||||
|
r279 | |||
r700 | %table.table.table-hover.datatable | |||
%thead | ||||
%tr{style: "text-align: left;"} | ||||
%th= check_box_tag 'select_all' | ||||
%th Name | ||||
%th Full name | ||||
%th Tags | ||||
%th Available | ||||
%th Date added | ||||
- if GraderConfiguration.multicontests? | ||||
%th Contests | ||||
|
r201 | |||
r700 | %tbody | |||
- num = 0 | ||||
- for problem in @problems | ||||
- num += 1 | ||||
%tr{:id => "row-prob-#{problem.id}", :name=> "prob-#{problem.id}"} | ||||
%td= check_box_tag "prob-#{problem.id}-#{num}" | ||||
%td= problem.name | ||||
%td= problem.full_name | ||||
|
r279 | %td | ||
r700 | - problem.tags.each do |t| | |||
%span.label.label-default= t.name | ||||
%td= problem.available | ||||
%td= problem.date_added | ||||
- if GraderConfiguration.multicontests? | ||||
%td | ||||
- problem.contests.each do |contest| | ||||
= "(#{contest.name} [#{link_to 'x', :action => 'remove_contest', :id => problem.id, :contest_id => contest.id }])" | ||||
r692 | ||||
:javascript | ||||
r880 | ||||
$(document).on('import-map-loaded', function() { | ||||
function shiftclick(start,stop,value) { | ||||
$('tr input').each( function(id,input) { | ||||
var $input=$(input); | ||||
var iid=parseInt($input.attr('id').split('-')[2]); | ||||
if(iid>=start&&iid<=stop){ | ||||
$input.prop('checked',value) | ||||
} | ||||
}); | ||||
} | ||||
r692 | ||||
r880 | $('tr input').click( function(e) { | |||
if (e.shiftKey) { | ||||
stop = parseInt($(this).attr('id').split('-')[2]); | ||||
var orig_stop = stop | ||||
if (typeof start !== 'undefined') { | ||||
if (start > stop) { | ||||
var tmp = start; | ||||
start = stop; | ||||
stop = tmp; | ||||
} | ||||
shiftclick(start,stop,$(this).is(':checked') ) | ||||
} | ||||
start = orig_stop | ||||
} else { | ||||
start = parseInt($(this).attr('id').split('-')[2]); | ||||
} | ||||
}); | ||||
$('.input-group.date').datetimepicker({ | ||||
format: 'DD/MMM/YYYY', | ||||
showTodayButton: true, | ||||
locale: 'en', | ||||
widgetPositioning: {horizontal: 'auto', vertical: 'bottom'}, | ||||
}); | ||||
$('.datatable').DataTable({ | ||||
paging: false | ||||
}); | ||||
r881 | $('.select2').select2(); | |||
new TempusDominus(document.getElementById('date_added'), { | ||||
display: { | ||||
icons: { | ||||
time: 'mi mi-td-time', | ||||
date: 'mi mi-td-date', | ||||
up: 'mi mi-td-up', | ||||
down: 'mi mi-td-down', | ||||
previous: 'bi bi-chevron-left', | ||||
next: 'bi bi-chevron-right', | ||||
today: 'bi bi-calendar-check', | ||||
clear: 'bi bi-trash', | ||||
close: 'bi bi-x', | ||||
}, | ||||
} | ||||
}); | ||||
r692 | }); | |||