osem-fcy/app/views/admin/registrations/index.html.haml
James Mason d7a0936dd7 Convert admin/registrations datatable to AJAX-backed
Supercedes https://github.com/openSUSE/osem/pull/2031 .

Note:

* "Questions" modals have been dropped from this view; questions are no
  longer asked on registration, since Surveys(PR#1100)  were added.
2018-10-10 21:57:22 +02:00

116 lines
3.8 KiB
Text

= javascript_include_tag 'Chart.min'
.row
.col-md-12
.page-header
%h1
Registrations
= "(#{@registrations.length})" if @registrations
.btn-group.pull-right
- if can? :read, Registration
= link_to 'Export CSV', { format: :csv }, class: 'btn btn-success'
= link_to 'Export PDF', { format: :pdf }, class: 'btn btn-success'
= link_to 'Export XLS', { format: :xlsx }, class: 'btn btn-success'
%p.text-muted
All the people who registered to your event
.col-md-4
= render partial: 'admin/conferences/doughnut_chart', locals: {title: 'Affiliation', data: @affiliation_distribution}
- unless @conference.pending?
.col-md-4
= render partial: 'admin/conferences/doughnut_chart', locals: {title: 'Attended registrations', data: @registration_distribution}
.row
.col-md-12
%div.margin-event-table
%table.datatable#registrations{ data: { source: admin_conference_registrations_path(conference_id: @conference, format: :json) } }
%thead
%tr
%th{ width: '0' } ID#
%th{ width: '25%' } Name
%th{ width: '0' } Roles
%th{ width: '0' } E-Mail
%th{ width: '0' }
%abbr{ title: 'Code of Conduct' } CoC
%th{ width: '0' } Arrival
%th{ width: '0' } Departure
%th{ width: '0' } Actions
%tbody
:javascript
$(function () {
var codeOfConductPresent = #{@code_of_conduct ? 'true' : 'false'};
var registrationsDataTable = $('#registrations.datatable').DataTable({
"processing": true,
"serverSide": true,
"ajax": $('#registrations.datatable').data('source'),
"drawCallback": function(settings) {
checkboxSwitch("[class='switch-checkbox']");
if (codeOfConductPresent) {
iconize("td.code-of-conduct", "true", "check", "accepted");
iconize("td.code-of-conduct", "false", "exclamation-circle", "Has not accepted Code of Conduct");
};
// truncatify("td.truncate");
},
"columns": [
{
"data": "id"
},
{
"data": "name",
"className": "truncate",
"render": function(data, type, row) {
var content = '<span data-toggle="tooltip" title="' + data + '">' + data + '</span><br/>';
$.each(row.roles, function(index, role){
content += ' <span class="label label-info">' + role + '</span>'
});
return content;
}
},
{
"name": "roles",
"data": "roles",
"className": "truncate",
"render": function(data, type, row) {
return data.join(', ');
}
},
{
"data": "email"
},
{
"data": "accepted_code_of_conduct",
"className": "code-of-conduct text-center",
"searchable": false
},
{
"data": "arrival",
"searchable": false,
"render": function(data, type, row) {
if (data) { return moment(data).format('ll LT'); }
return '';
}
},
{
"data": "departure",
"searchable": false,
"render": function(data, type, row) {
if (data) { return moment(data).format('ll LT'); }
return '';
}
},
{
"data": null,
"className": "actions",
"searchable": false,
"sortable": false,
"render": function (data, type, row, meta) {
return '<div class="btn-group">'+
'<a class="btn-primary" href="'+data.edit_url+'">Edit</a>'+
'</div>';
}
}
]
});
registrationsDataTable.columns(3).visible(codeOfConductPresent);
registrationsDataTable.columns(2).visible(false);
});