Fixed "show-more-btn" toggle logic and added optional "collapseAfter" parameter (#473)
* fixed "show-more-btn" toggle logic * allow customization of number of items to show in "taken courses" when before collapsing * renamed treshold param to collapseAfter Co-authored-by: Fabio Fenoglio <fabio.fenoglio@eng.it>
This commit is contained in:
parent
fea093c187
commit
e3c84e0ba1
3 changed files with 16 additions and 16 deletions
|
@ -54,6 +54,7 @@
|
|||
</div>
|
||||
{{ end }}
|
||||
{{ if .takenCourses }}
|
||||
{{ $collapseAfter := .takenCourses.collapseAfter | default 2 }}
|
||||
<div class="taken-courses">
|
||||
<h6 class="text-muted">{{ i18n "taken_courses"}}</h6>
|
||||
{{ if .takenCourses.showGrades }}
|
||||
|
@ -66,7 +67,7 @@
|
|||
</thead>
|
||||
<tbody>
|
||||
{{ range $index,$course := .takenCourses.courses }}
|
||||
<tr class="course {{ if gt $index 1 }}hidden-course{{ end}}">
|
||||
<tr class="course {{ if ge $index $collapseAfter }}hidden-course{{ end}}">
|
||||
<td>{{ $course.name }}</td>
|
||||
{{ if not $hideScale }}<td>{{ $course.outOf }}</td>{{ end }}
|
||||
<td>{{ $course.achieved }}</td>
|
||||
|
@ -77,11 +78,11 @@
|
|||
{{ else }}
|
||||
<ul>
|
||||
{{ range $index,$course := .takenCourses.courses }}
|
||||
<li class="course {{ if gt $index 1 }}hidden-course{{ end}}">{{ $course.name }}</li>
|
||||
<li class="course {{ if ge $index $collapseAfter }}hidden-course{{ end}}">{{ $course.name }}</li>
|
||||
{{ end }}
|
||||
</ul>
|
||||
{{ end }}
|
||||
{{ if gt (len .takenCourses.courses ) 2 }}
|
||||
{{ if gt (len .takenCourses.courses ) $collapseAfter }}
|
||||
<button type="button" class="btn btn-link show-more-btn pt-0 {{ if .takenCourses.showGrades }}ml-1{{ else }}ml-2{{ end }}"
|
||||
onclick="toggleCourseVisibility(this);" id="show-more-btn">{{ i18n "show_more"}}</button>
|
||||
<button type="button" class="btn btn-link show-more-btn hidden pt-0 {{ if .takenCourses.showGrades }}ml-1{{ else }}ml-2{{ end }}"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue