Sha256: ec4eaaec50f30d6a6fe34e6c8e2e2d007f1c258486524d2206618d3a029f48eb

Contents?: true

Size: 1.54 KB

Versions: 22

Compression:

Stored size: 1.54 KB

Contents

class QuestionnaireDatatable < AjaxDatatablesRails::Base
  def_delegators :@view, :link_to, :manage_questionnaire_path, :manage_school_path, :current_user

  def view_columns
    @view_columns ||= {
      id: { source: 'Questionnaire.id', cond: :eq },
      first_name: { source: 'Questionnaire.first_name' },
      last_name: { source: 'Questionnaire.last_name' },
      email: { source: 'User.email' },
      admin: { source: 'User.admin', cond: :eq, searchable: false },
      acc_status: { source: 'Questionnaire.acc_status', searchable: false },
      checked_in: { source: 'Questionnaire.checked_in_at', searchable: false },
      school: { source: 'School.name' }
    }
  end

  private

  def data
    records.map do |record|
      {
        bulk: current_user.admin_limited_access ? '' : "<input type=\"checkbox\" data-bulk-row-edit=\"#{record.id}\">".html_safe,
        link: link_to('<i class="fa fa-search"></i>'.html_safe, manage_questionnaire_path(record)),
        id: record.id,
        first_name: record.first_name,
        last_name: record.last_name,
        email: record.email,
        acc_status: "<span class=\"acc-status-#{record.acc_status}\">#{record.acc_status.titleize}</span>".html_safe,
        checked_in: record.checked_in? ? '<span class="acc-status-accepted">Yes</span>'.html_safe : 'No',
        school: link_to(record.school.name, manage_school_path(record.school))
      }
    end
  end

  # rubocop:disable Style/AccessorMethodName
  def get_raw_records
    Questionnaire.includes(:user, :school).references(:user, :school)
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
hackathon_manager-0.5.10 app/datatables/questionnaire_datatable.rb
hackathon_manager-0.5.9 app/datatables/questionnaire_datatable.rb
hackathon_manager-0.5.8 app/datatables/questionnaire_datatable.rb
hackathon_manager-0.5.7 app/datatables/questionnaire_datatable.rb
hackathon_manager-0.5.6 app/datatables/questionnaire_datatable.rb
hackathon_manager-0.5.5 app/datatables/questionnaire_datatable.rb
hackathon_manager-0.5.4 app/datatables/questionnaire_datatable.rb
hackathon_manager-0.5.3 app/datatables/questionnaire_datatable.rb
hackathon_manager-0.5.2 app/datatables/questionnaire_datatable.rb
hackathon_manager-0.5.1 app/datatables/questionnaire_datatable.rb
hackathon_manager-0.5.0 app/datatables/questionnaire_datatable.rb
hackathon_manager-0.4.4 app/datatables/questionnaire_datatable.rb
hackathon_manager-0.4.3 app/datatables/questionnaire_datatable.rb
hackathon_manager-0.4.2 app/datatables/questionnaire_datatable.rb
hackathon_manager-0.4.1 app/datatables/questionnaire_datatable.rb
hackathon_manager-0.4.0 app/datatables/questionnaire_datatable.rb
hackathon_manager-0.3.3 app/datatables/questionnaire_datatable.rb
hackathon_manager-0.3.2 app/datatables/questionnaire_datatable.rb
hackathon_manager-0.3.1 app/datatables/questionnaire_datatable.rb
hackathon_manager-0.3.0 app/datatables/questionnaire_datatable.rb