From edec5a98bee422d5ea6e366e76fe7237caad01d1 Mon Sep 17 00:00:00 2001 From: Andrew Kvalheim Date: Fri, 18 Mar 2022 08:35:07 -0700 Subject: [PATCH 1/2] Removed unused data and columns from datatables --- app/datatables/registration_datatable.rb | 2 -- app/datatables/user_datatable.rb | 4 +--- app/views/admin/registrations/index.html.haml | 10 ---------- 3 files changed, 1 insertion(+), 15 deletions(-) diff --git a/app/datatables/registration_datatable.rb b/app/datatables/registration_datatable.rb index 7384933c..ce0b37d4 100644 --- a/app/datatables/registration_datatable.rb +++ b/app/datatables/registration_datatable.rb @@ -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 } diff --git a/app/datatables/user_datatable.rb b/app/datatables/user_datatable.rb index b21f6fea..fdee7340 100644 --- a/app/datatables/user_datatable.rb +++ b/app/datatables/user_datatable.rb @@ -21,9 +21,7 @@ class UserDatatable < AjaxDatatablesRails::ActiveRecord email: { source: 'User.email' }, 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 } + roles: { source: 'Role.name' } } end diff --git a/app/views/admin/registrations/index.html.haml b/app/views/admin/registrations/index.html.haml index 09f674e9..f5a7343e 100644 --- a/app/views/admin/registrations/index.html.haml +++ b/app/views/admin/registrations/index.html.haml @@ -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" }, @@ -94,5 +85,4 @@ }); registrationsDataTable.columns(3).visible(codeOfConductPresent); - registrationsDataTable.columns(2).visible(false); }); From 2a93d09d226041bcd5ee3689247f80a771ae2be9 Mon Sep 17 00:00:00 2001 From: Andrew Kvalheim Date: Fri, 18 Mar 2022 08:46:52 -0700 Subject: [PATCH 2/2] Update datatables for ajax-datatables-rails 1 Resolves: - inability to filter, order, or paginate datatables - exception AjaxDatatablesRails::Error::InvalidSearchColumn Continues: - 81853d1ef91c2328e28ea676079428adbba33765 - 83636afee015863568dafe21aef5c8187e339a34 --- app/controllers/admin/registrations_controller.rb | 2 +- app/controllers/admin/users_controller.rb | 2 +- app/datatables/registration_datatable.rb | 2 +- app/datatables/user_datatable.rb | 3 ++- app/views/admin/registrations/index.html.haml | 4 ++-- app/views/admin/users/index.html.haml | 6 +++--- 6 files changed, 10 insertions(+), 9 deletions(-) diff --git a/app/controllers/admin/registrations_controller.rb b/app/controllers/admin/registrations_controller.rb index 0fa8a8af..88027bbd 100644 --- a/app/controllers/admin/registrations_controller.rb +++ b/app/controllers/admin/registrations_controller.rb @@ -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 diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb index b980540c..9820cef1 100644 --- a/app/controllers/admin/users_controller.rb +++ b/app/controllers/admin/users_controller.rb @@ -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 diff --git a/app/datatables/registration_datatable.rb b/app/datatables/registration_datatable.rb index ce0b37d4..965aa822 100644 --- a/app/datatables/registration_datatable.rb +++ b/app/datatables/registration_datatable.rb @@ -51,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 diff --git a/app/datatables/user_datatable.rb b/app/datatables/user_datatable.rb index fdee7340..d7e102d2 100644 --- a/app/datatables/user_datatable.rb +++ b/app/datatables/user_datatable.rb @@ -21,7 +21,8 @@ class UserDatatable < AjaxDatatablesRails::ActiveRecord email: { source: 'User.email' }, name: { source: 'User.name' }, attended: { source: 'attended_count', searchable: false }, - roles: { source: 'Role.name' } + roles: { source: 'Role.name' }, + actions: { source: 'User.id', searchable: false, orderable: false } } end diff --git a/app/views/admin/registrations/index.html.haml b/app/views/admin/registrations/index.html.haml index f5a7343e..512899a2 100644 --- a/app/views/admin/registrations/index.html.haml +++ b/app/views/admin/registrations/index.html.haml @@ -71,13 +71,13 @@ "searchable": false }, { - "data": null, + "data": "actions", "className": "actions", "searchable": false, "sortable": false, "render": function (data, type, row, meta) { return '
'+ - 'Edit'+ + 'Edit'+ '
'; } } diff --git a/app/views/admin/users/index.html.haml b/app/views/admin/users/index.html.haml index e2b47504..2fb1c72a 100644 --- a/app/views/admin/users/index.html.haml +++ b/app/views/admin/users/index.html.haml @@ -61,13 +61,13 @@ } }, { - "data": null, + "data": "actions", "className": "actions", "sortable": false, "render": function (data, type, row, meta) { return '
'+ - 'View'+ - 'Edit'+ + 'View'+ + 'Edit'+ '
'; } }