mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
Merge pull request #2972 from AndrewKvalheim/ajax-datatables-rails-1_part-2
Update datatables for ajax-datatables-rails 1
This commit is contained in:
commit
d471d9eb23
6 changed files with 9 additions and 22 deletions
|
|
@ -20,7 +20,7 @@ module Admin
|
|||
respond_to do |format|
|
||||
format.html
|
||||
format.json do
|
||||
render json: RegistrationDatatable.new({}, conference: @conference, view_context: view_context)
|
||||
render json: RegistrationDatatable.new(params, conference: @conference, view_context: view_context)
|
||||
end
|
||||
format.pdf { render 'index', layout: false }
|
||||
format.xlsx do
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ module Admin
|
|||
respond_to do |format|
|
||||
format.html
|
||||
format.json do
|
||||
render json: UserDatatable.new({}, view_context: view_context)
|
||||
render json: UserDatatable.new(params, view_context: view_context)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ class RegistrationDatatable < AjaxDatatablesRails::ActiveRecord
|
|||
@view_columns ||= {
|
||||
id: { source: 'Registration.id', cond: :eq },
|
||||
name: { source: 'User.name' },
|
||||
roles: { source: 'Role.name' },
|
||||
email: { source: 'User.email' },
|
||||
accepted_code_of_conduct: { source: 'Registration.accepted_code_of_conduct', searchable: false },
|
||||
actions: { source: 'Registration.id', searchable: false, orderable: false }
|
||||
|
|
@ -41,7 +40,6 @@ class RegistrationDatatable < AjaxDatatablesRails::ActiveRecord
|
|||
roles: conference_role_titles(record.user),
|
||||
email: record.email,
|
||||
accepted_code_of_conduct: !!record.accepted_code_of_conduct, # rubocop:disable Style/DoubleNegation
|
||||
questions: {},
|
||||
edit_url: edit_admin_conference_registration_path(conference, record),
|
||||
DT_RowId: record.id
|
||||
}
|
||||
|
|
@ -53,7 +51,7 @@ class RegistrationDatatable < AjaxDatatablesRails::ActiveRecord
|
|||
end
|
||||
|
||||
# override upstream santitation, which converts everything to strings
|
||||
def sanitize(records)
|
||||
def sanitize_data(records)
|
||||
records
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -22,8 +22,7 @@ class UserDatatable < AjaxDatatablesRails::ActiveRecord
|
|||
name: { source: 'User.name' },
|
||||
attended: { source: 'attended_count', searchable: false },
|
||||
roles: { source: 'Role.name' },
|
||||
view_url: { source: 'User.id', searchable: false, orderable: false },
|
||||
edit_url: { source: 'User.id', searchable: false, orderable: false }
|
||||
actions: { source: 'User.id', searchable: false, orderable: false }
|
||||
}
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@
|
|||
%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
|
||||
|
|
@ -63,14 +62,6 @@
|
|||
return content;
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "roles",
|
||||
"data": "roles",
|
||||
"className": "truncate",
|
||||
"render": function(data, type, row) {
|
||||
return data.join(', ');
|
||||
}
|
||||
},
|
||||
{
|
||||
"data": "email"
|
||||
},
|
||||
|
|
@ -80,13 +71,13 @@
|
|||
"searchable": false
|
||||
},
|
||||
{
|
||||
"data": null,
|
||||
"data": "actions",
|
||||
"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>'+
|
||||
'<a class="btn-primary" href="'+row.edit_url+'">Edit</a>'+
|
||||
'</div>';
|
||||
}
|
||||
}
|
||||
|
|
@ -94,5 +85,4 @@
|
|||
});
|
||||
|
||||
registrationsDataTable.columns(3).visible(codeOfConductPresent);
|
||||
registrationsDataTable.columns(2).visible(false);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -61,13 +61,13 @@
|
|||
}
|
||||
},
|
||||
{
|
||||
"data": null,
|
||||
"data": "actions",
|
||||
"className": "actions",
|
||||
"sortable": false,
|
||||
"render": function (data, type, row, meta) {
|
||||
return '<div class="btn-group">'+
|
||||
'<a class="btn-info" href="'+data.view_url+'">View</a>'+
|
||||
'<a class="btn-primary" href="'+data.edit_url+'">Edit</a>'+
|
||||
'<a class="btn-info" href="'+row.view_url+'">View</a>'+
|
||||
'<a class="btn-primary" href="'+row.edit_url+'">Edit</a>'+
|
||||
'</div>';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue