Skip to content

Commit 6c062c5

Browse files
committed
feat: Clean up datatables
1 parent 561755b commit 6c062c5

File tree

6 files changed

+11
-7
lines changed

6 files changed

+11
-7
lines changed

app/datatables/admin_datatable.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def data
2121
email: link_to(bold(record.email), manage_admin_path(record)),
2222
role: record.role.titleize,
2323
active: record.is_active ? '<span class="badge badge-secondary">Active</span>'.html_safe : '<span class="badge badge-danger">Inactive<span>'.html_safe,
24-
receive_weekly_report: record.receive_weekly_report ? '<span class="badge badge-success">Yes</span>'.html_safe : '<span class="badge badge-secondary">No<span>'.html_safe,
24+
receive_weekly_report: yes_no_display(record.receive_weekly_report),
2525
created_at: display_datetime(record.created_at),
2626
}
2727
end

app/datatables/application_datatable.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,8 @@ def initialize(params, opts = {})
66
@view = opts[:view_context]
77
super
88
end
9+
10+
def yes_no_display(value)
11+
value ? '<span class="badge badge-success">Yes</span>'.html_safe : '<span class="badge badge-secondary">No</span>'.html_safe
12+
end
913
end

app/datatables/checkin_datatable.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def data
2525
first_name: record.first_name,
2626
last_name: record.last_name,
2727
about: about(record),
28-
checked_in: record.checked_in? ? "<span class=\"text-success\">Yes</span>".html_safe : "No",
28+
checked_in: yes_no_display(record.checked_in?),
2929
actions: "<a class=\"btn btn-primary btn-sm\" href=\"#{manage_checkin_path(record)}\">View</a>".html_safe,
3030
}
3131
end

app/datatables/questionnaire_datatable.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ def data
5757
phone: record.phone,
5858
gender: record.gender,
5959
date_of_birth: record.date_of_birth_formatted,
60-
acc_status: "<span class=\"text-#{acc_status_class(record.acc_status)}\">#{record.acc_status.titleize}</span>".html_safe,
61-
checked_in: record.checked_in? ? '<span class="badge badge-success">Yes</span>'.html_safe : "No",
62-
boarded_bus: record.boarded_bus? ? '<span class="badge badge-success">Yes</span>'.html_safe : "No",
60+
acc_status: "<span class=\"text-#{acc_status_class(record.acc_status)}\">#{Questionnaire::POSSIBLE_ACC_STATUS[record.acc_status]}</span>".html_safe,
61+
checked_in: yes_no_display(record.checked_in?),
62+
boarded_bus: yes_no_display(record.boarded_bus?),
6363
bus_captain: bus_captain(record),
6464
school: link_to(record.school.name, manage_school_path(record.school)),
6565
created_at: record.created_at.present? ? display_datetime(record.created_at) : "",

app/datatables/school_datatable.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def data
2222
city: record.city,
2323
state: record.state,
2424
questionnaire_count: record.questionnaire_count,
25-
home_school: record.is_home ? '<span class="badge badge-success">Yes</span>'.html_safe : '<span class="badge badge-secondary">No</span>'.html_safe,
25+
home_school: yes_no_display(record.is_home),
2626
}
2727
end
2828
end

app/views/manage/schools/show.html.haml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989

9090
= render "questionnaire_datatable", scope_params: { school_id: @school.id }, page_length: 25, columns: %w(link note first_name last_name email acc_status checked_in created_at)
9191

92-
.row.mt-2.mb-4
92+
.row.mt-4.mb-5
9393
.col-lg-6
9494
%h4.border-bottom.pb-2.mb-3 Change History
9595
= render "model_history", model: @school

0 commit comments

Comments
 (0)