Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add type icon to reading activities and exercises #3178

Merged
merged 7 commits into from
Oct 25, 2021
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions app/helpers/activity_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,14 @@ def compare_solutions(a, b)
end
end

def activity_icon(activity, size = 18)
if activity.exercise?
content_tag(:i, '', class: "mdi mdi-#{activity.programming_language&.icon} mdi-#{size}", title: "#{t 'activities.index.type.exercise_language', language: activity.programming_language&.name&.titleize}")
elsif activity.content_page?
content_tag(:i, '', class: "mdi mdi-book-open-variant mdi-#{size}", title: "#{t 'activities.index.type.content'}")
end
end

class DescriptionRenderer
require 'nokogiri'
include Rails.application.routes.url_helpers
Expand Down
6 changes: 1 addition & 5 deletions app/views/activities/_activities_table.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,7 @@
</td>

<td class='type-icon'>
<% if activity.exercise? %>
<i class="<%= "mdi mdi-#{activity.programming_language&.icon} mdi-18" %>" title="<%= "#{t "activities.index.type.exercise_language", language: activity.programming_language&.name&.titleize}" %>"></i>
<% elsif activity.content_page? %>
<i class="mdi mdi-book-open-variant mdi-18" title="<%= t "activities.index.type.content" %>"></i>
<% end %>
<%= activity_icon(activity) %>
</td>

<td class="link">
Expand Down
3 changes: 1 addition & 2 deletions app/views/activities/_series_activities_add_table.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
<%= raw "<i class='mdi mdi-eye-off mdi-18' title='#{t("activities.index.private")}'></i>" if activity.access_private? %>
<%= raw "<i class='mdi mdi-delete mdi-18' title='#{t("activities.index.removed")}'></i>" if activity.removed? %>
<%= raw "<i class='mdi mdi-alert-circle mdi-18' title='#{t("activities.index.invalid")}'></i>" if activity.not_valid? %>
<%= raw "<i class='mdi mdi-#{ activity.programming_language&.icon} mdi-18' title='#{t "activities.index.type.exercise_language", language: activity.programming_language&.name&.titleize}'></i>" if activity.exercise? %>
<%= raw "<i class='mdi mdi-book-open-variant mdi-18' title='#{t("activities.index.type.content")}'></i>" if activity.content_page? %>
<%= activity_icon(activity) %>
</td>
<td class="link">
<span class="ellipsis-overflow" title="<%= activity.name %>">
Expand Down
6 changes: 1 addition & 5 deletions app/views/activities/_series_activities_table.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,7 @@
</td>

<td class='type-icon'>
<% if activity.exercise? %>
<i class="<%= "mdi mdi-#{activity.programming_language&.icon} mdi-18" %>" title="<%= "#{t "activities.index.type.exercise_language", language: activity.programming_language&.name&.titleize}" %>"></i>
<% elsif activity.content_page? %>
<i class="mdi mdi-book-open-variant mdi-18" title="<%= t "activities.index.type.content" %>"></i>
<% end %>
<%= activity_icon(activity) %>
</td>

<td>
Expand Down
6 changes: 5 additions & 1 deletion app/views/activities/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
<div class="col-md-10 offset-md-1 col-12">
<div class="card">
<div class="card-title card-title-colored">
<h2 class="card-title-text"><%= @activity.name %></h2>
<h2 class="card-title-text">
<%= activity_icon(@activity, 24) %>
&nbsp;
<%= @activity.name %>
</h2>
<div class="card-title-fab">
<%= render 'application/fab_button', form: "edit_activity_#{@activity.id}", icon: 'check' %>
</div>
Expand Down
6 changes: 5 additions & 1 deletion app/views/activities/info.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
<div class="col-lg-10 offset-lg-1 col-12">
<div class="card activity-info">
<div class="card-title card-title-colored">
<h2 class="card-title-text"><%= @activity.name %></h2>
<h2 class="card-title-text">
<%= activity_icon(@activity, 24) %>
&nbsp;
<%= @activity.name %>
</h2>
</div>

<div class="card-supporting-text card-border">
Expand Down
2 changes: 2 additions & 0 deletions app/views/activities/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ end %>
<div class="card activity-description">
<div class="card-title card-title-colored">
<h2 class="card-title-text">
<%= activity_icon(@activity, 24) %>
&nbsp;
<%= @activity.name %>
</h2>
<% if @series.present? %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/evaluations/_exercises_progress_table.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<% local_assigns[:metadata][:per_exercise].each do |meta| %>
<tr>
<td class='type-icon'>
<i class="<%="mdi mdi-#{meta[:exercise].programming_language&.icon} mdi-18"%>" title="<%= "#{t "activities.index.type.exercise_language", language: meta[:exercise].programming_language&.name&.titleize}" %>"></i>
<%= activity_icon(meta[:exercise]) %>
</td>

<td>
Expand Down
2 changes: 1 addition & 1 deletion app/views/evaluations/_exercises_table.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<% local_assigns[:exercises].each do |exercise| %>
<tr>
<td class='type-icon'>
<i class="<%= "mdi mdi-#{exercise.programming_language&.icon} mdi-18"%>" title="<%= "#{t "activities.index.type.exercise_language", language: exercise.programming_language&.name&.titleize}" %>"></i>
<%= activity_icon(exercise) %>
</td>

<td>
Expand Down