Skip to content

Commit 84e3bab

Browse files
committed
Make long pre-reqs/learning objectives expandable. Fixes #1096
1 parent 8282173 commit 84e3bab

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

app/helpers/materials_helper.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def display_difficulty_level(resource)
101101
end
102102
end
103103

104-
def display_attribute(resource, attribute, show_label: true, title: nil, markdown: false, list: false)
104+
def display_attribute(resource, attribute, show_label: true, title: nil, markdown: false, list: false, expandable: false)
105105
return if [
106106
TeSS::Config.feature['disabled'].include?(attribute.to_s),
107107
(TeSS::Config.feature['materials_disabled'].include?(attribute.to_s) && resource.is_a?(Material)),
@@ -120,6 +120,9 @@ def display_attribute(resource, attribute, show_label: true, title: nil, markdow
120120
string << "<li>#{block_given? ? yield(v) : v}</li>"
121121
end
122122
string << '</ul>'
123+
elsif expandable
124+
height_limit = expandable.is_a?(Numeric) ? expandable : nil
125+
string << "<div class=\"tess-expandable\"#{" data-height-limit=\"#{height_limit}\"" if height_limit}>" + value.to_s + '</div>'
123126
else
124127
string << value.to_s
125128
end

app/views/common/_extra_metadata.html.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@
6868
<% if resource.is_a?(LearningPath) %>
6969
<%= display_attribute(resource, :status) { |value| material_status_title_for_label(value) } %>
7070
<%= display_attribute(resource, :target_audience) { |values| values.map { |x| target_audience_title_for_label(x) }.join(', ') } %>
71-
<%= display_attribute(resource, :prerequisites, markdown: true) %>
72-
<%= display_attribute(resource, :learning_objectives, markdown: true) %>
71+
<%= display_attribute(resource, :prerequisites, markdown: true, expandable: 150) %>
72+
<%= display_attribute(resource, :learning_objectives, markdown: true, expandable: 150) %>
7373
<% end %>
7474

7575
<% if resource.respond_to?(:operations) -%>

0 commit comments

Comments
 (0)