From db093699e9739e05887d54874119e5d02358eb9e Mon Sep 17 00:00:00 2001 From: BTWS2 <56451049+BTWS2@users.noreply.github.com> Date: Sun, 24 Oct 2021 16:51:04 +0200 Subject: [PATCH 1/7] add-type-icon --- app/views/activities/show.html.erb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/views/activities/show.html.erb b/app/views/activities/show.html.erb index 5581d2bfda..1b1d676de9 100644 --- a/app/views/activities/show.html.erb +++ b/app/views/activities/show.html.erb @@ -38,6 +38,12 @@ end %>

+ <% if @activity.exercise? %> + " title="<%= "#{t "activities.index.type.exercise_language", language: @activity.programming_language&.name&.titleize}" %>"> + <% elsif @activity.content_page? %> + "> + <% end %> +   <%= @activity.name %>

<% if @series.present? %> From fc1939a04d9dd2cf19dbdd62bc3183b8e60c2e5b Mon Sep 17 00:00:00 2001 From: BTWS2 <56451049+BTWS2@users.noreply.github.com> Date: Sun, 24 Oct 2021 17:52:16 +0200 Subject: [PATCH 2/7] add icon to edit and info page of activity --- app/views/activities/edit.html.erb | 10 +++++++++- app/views/activities/info.html.erb | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/app/views/activities/edit.html.erb b/app/views/activities/edit.html.erb index 4f5d516319..13c3377546 100644 --- a/app/views/activities/edit.html.erb +++ b/app/views/activities/edit.html.erb @@ -3,7 +3,15 @@
-

<%= @activity.name %>

+

+ <% if @activity.exercise? %> + " title="<%= "#{t "activities.index.type.exercise_language", language: @activity.programming_language&.name&.titleize}" %>"> + <% elsif @activity.content_page? %> + "> + <% end %> +   + <%= @activity.name %> +

<%= render 'application/fab_button', form: "edit_activity_#{@activity.id}", icon: 'check' %>
diff --git a/app/views/activities/info.html.erb b/app/views/activities/info.html.erb index a61d044c39..61801a2deb 100644 --- a/app/views/activities/info.html.erb +++ b/app/views/activities/info.html.erb @@ -11,7 +11,15 @@
-

<%= @activity.name %>

+

+ <% if @activity.exercise? %> + " title="<%= "#{t "activities.index.type.exercise_language", language: @activity.programming_language&.name&.titleize}" %>"> + <% elsif @activity.content_page? %> + "> + <% end %> +   + <%= @activity.name %> +

From 1c708fe570c0164f691a24c65defbd4097c98c46 Mon Sep 17 00:00:00 2001 From: BTWS2 <56451049+BTWS2@users.noreply.github.com> Date: Sun, 24 Oct 2021 21:54:16 +0200 Subject: [PATCH 3/7] helper function and replace --- app/helpers/activity_helper.rb | 8 ++++++++ app/views/activities/_activities_table.html.erb | 6 +----- .../activities/_series_activities_add_table.html.erb | 3 +-- app/views/activities/_series_activities_table.html.erb | 6 +----- app/views/activities/edit.html.erb | 6 +----- app/views/activities/info.html.erb | 6 +----- app/views/activities/show.html.erb | 6 +----- app/views/evaluations/_exercises_progress_table.html.erb | 2 +- app/views/evaluations/_exercises_table.html.erb | 2 +- 9 files changed, 16 insertions(+), 29 deletions(-) diff --git a/app/helpers/activity_helper.rb b/app/helpers/activity_helper.rb index f31cdc6ea3..93e657ce45 100644 --- a/app/helpers/activity_helper.rb +++ b/app/helpers/activity_helper.rb @@ -99,6 +99,14 @@ def compare_solutions(a, b) end end + def show_type_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 diff --git a/app/views/activities/_activities_table.html.erb b/app/views/activities/_activities_table.html.erb index a8539015ca..40af967aff 100644 --- a/app/views/activities/_activities_table.html.erb +++ b/app/views/activities/_activities_table.html.erb @@ -51,11 +51,7 @@ - <% if activity.exercise? %> - " title="<%= "#{t "activities.index.type.exercise_language", language: activity.programming_language&.name&.titleize}" %>"> - <% elsif activity.content_page? %> - "> - <% end %> + <%= show_type_icon(activity) %> diff --git a/app/views/activities/_series_activities_add_table.html.erb b/app/views/activities/_series_activities_add_table.html.erb index 2133371422..f576b2f767 100644 --- a/app/views/activities/_series_activities_add_table.html.erb +++ b/app/views/activities/_series_activities_add_table.html.erb @@ -21,8 +21,7 @@ <%= raw "" if activity.access_private? %> <%= raw "" if activity.removed? %> <%= raw "" if activity.not_valid? %> - <%= raw "" if activity.exercise? %> - <%= raw "" if activity.content_page? %> + <%= show_type_icon(activity) %> diff --git a/app/views/activities/_series_activities_table.html.erb b/app/views/activities/_series_activities_table.html.erb index 47aba42e1c..67fba36795 100644 --- a/app/views/activities/_series_activities_table.html.erb +++ b/app/views/activities/_series_activities_table.html.erb @@ -46,11 +46,7 @@ - <% if activity.exercise? %> - " title="<%= "#{t "activities.index.type.exercise_language", language: activity.programming_language&.name&.titleize}" %>"> - <% elsif activity.content_page? %> - "> - <% end %> + <%= show_type_icon(activity) %> diff --git a/app/views/activities/edit.html.erb b/app/views/activities/edit.html.erb index 13c3377546..51e97c5f1e 100644 --- a/app/views/activities/edit.html.erb +++ b/app/views/activities/edit.html.erb @@ -4,11 +4,7 @@

- <% if @activity.exercise? %> - " title="<%= "#{t "activities.index.type.exercise_language", language: @activity.programming_language&.name&.titleize}" %>"> - <% elsif @activity.content_page? %> - "> - <% end %> + <%= show_type_icon(@activity, 24) %>   <%= @activity.name %>

diff --git a/app/views/activities/info.html.erb b/app/views/activities/info.html.erb index 61801a2deb..b4fdd1c835 100644 --- a/app/views/activities/info.html.erb +++ b/app/views/activities/info.html.erb @@ -12,11 +12,7 @@

- <% if @activity.exercise? %> - " title="<%= "#{t "activities.index.type.exercise_language", language: @activity.programming_language&.name&.titleize}" %>"> - <% elsif @activity.content_page? %> - "> - <% end %> + <%= show_type_icon(@activity, 24) %>   <%= @activity.name %>

diff --git a/app/views/activities/show.html.erb b/app/views/activities/show.html.erb index 1b1d676de9..2e019ff0bb 100644 --- a/app/views/activities/show.html.erb +++ b/app/views/activities/show.html.erb @@ -38,11 +38,7 @@ end %>

- <% if @activity.exercise? %> - " title="<%= "#{t "activities.index.type.exercise_language", language: @activity.programming_language&.name&.titleize}" %>"> - <% elsif @activity.content_page? %> - "> - <% end %> + <%= show_type_icon(@activity, 24) %>   <%= @activity.name %>

diff --git a/app/views/evaluations/_exercises_progress_table.html.erb b/app/views/evaluations/_exercises_progress_table.html.erb index 26ee861123..bfc3048db4 100644 --- a/app/views/evaluations/_exercises_progress_table.html.erb +++ b/app/views/evaluations/_exercises_progress_table.html.erb @@ -12,7 +12,7 @@ <% local_assigns[:metadata][:per_exercise].each do |meta| %> - " title="<%= "#{t "activities.index.type.exercise_language", language: meta[:exercise].programming_language&.name&.titleize}" %>"> + <%= show_type_icon(meta[:exercise]) %> diff --git a/app/views/evaluations/_exercises_table.html.erb b/app/views/evaluations/_exercises_table.html.erb index 57a318ccdf..ce2ca0ef79 100644 --- a/app/views/evaluations/_exercises_table.html.erb +++ b/app/views/evaluations/_exercises_table.html.erb @@ -11,7 +11,7 @@ <% local_assigns[:exercises].each do |exercise| %> - " title="<%= "#{t "activities.index.type.exercise_language", language: exercise.programming_language&.name&.titleize}" %>"> + <%= show_type_icon(meta[:exercise]) %> From 6116c3015b09e58662f45249a6df3e9a9330b6f9 Mon Sep 17 00:00:00 2001 From: BTWS2 <56451049+BTWS2@users.noreply.github.com> Date: Sun, 24 Oct 2021 21:58:54 +0200 Subject: [PATCH 4/7] fix copy paste error --- app/views/evaluations/_exercises_table.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/evaluations/_exercises_table.html.erb b/app/views/evaluations/_exercises_table.html.erb index ce2ca0ef79..cfeb00be04 100644 --- a/app/views/evaluations/_exercises_table.html.erb +++ b/app/views/evaluations/_exercises_table.html.erb @@ -11,7 +11,7 @@ <% local_assigns[:exercises].each do |exercise| %> - <%= show_type_icon(meta[:exercise]) %> + <%= show_type_icon(exercise) %> From ffcaac0ecc05a095a022acc942519ef9ca27f495 Mon Sep 17 00:00:00 2001 From: BTWS2 <56451049+BTWS2@users.noreply.github.com> Date: Sun, 24 Oct 2021 22:17:09 +0200 Subject: [PATCH 5/7] add space --- app/helpers/activity_helper.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/helpers/activity_helper.rb b/app/helpers/activity_helper.rb index 93e657ce45..6ffdf5b404 100644 --- a/app/helpers/activity_helper.rb +++ b/app/helpers/activity_helper.rb @@ -101,9 +101,9 @@ def compare_solutions(a, b) def show_type_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}") + 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'}") + content_tag(:i, '', class: "mdi mdi-book-open-variant mdi-#{size}", title: "#{t 'activities.index.type.content'}") end end From 817c0482d58bae6cceb8412629389bd9a24ee73c Mon Sep 17 00:00:00 2001 From: BTWS2 <56451049+BTWS2@users.noreply.github.com> Date: Mon, 25 Oct 2021 10:12:07 +0200 Subject: [PATCH 6/7] change name --- app/helpers/activity_helper.rb | 2 +- app/views/activities/_activities_table.html.erb | 2 +- app/views/activities/_series_activities_add_table.html.erb | 2 +- app/views/activities/_series_activities_table.html.erb | 2 +- app/views/activities/edit.html.erb | 2 +- app/views/activities/info.html.erb | 2 +- app/views/activities/show.html.erb | 2 +- app/views/evaluations/_exercises_progress_table.html.erb | 2 +- app/views/evaluations/_exercises_table.html.erb | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/helpers/activity_helper.rb b/app/helpers/activity_helper.rb index 6ffdf5b404..fce5c0fe9d 100644 --- a/app/helpers/activity_helper.rb +++ b/app/helpers/activity_helper.rb @@ -99,7 +99,7 @@ def compare_solutions(a, b) end end - def show_type_icon(activity, size = 18) + 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? diff --git a/app/views/activities/_activities_table.html.erb b/app/views/activities/_activities_table.html.erb index 40af967aff..5993562456 100644 --- a/app/views/activities/_activities_table.html.erb +++ b/app/views/activities/_activities_table.html.erb @@ -51,7 +51,7 @@ - <%= show_type_icon(activity) %> + <%= activity_icon(activity) %> diff --git a/app/views/activities/_series_activities_add_table.html.erb b/app/views/activities/_series_activities_add_table.html.erb index f576b2f767..c0765a484a 100644 --- a/app/views/activities/_series_activities_add_table.html.erb +++ b/app/views/activities/_series_activities_add_table.html.erb @@ -21,7 +21,7 @@ <%= raw "" if activity.access_private? %> <%= raw "" if activity.removed? %> <%= raw "" if activity.not_valid? %> - <%= show_type_icon(activity) %> + <%= activity_icon(activity) %> diff --git a/app/views/activities/_series_activities_table.html.erb b/app/views/activities/_series_activities_table.html.erb index 67fba36795..de2c7777b8 100644 --- a/app/views/activities/_series_activities_table.html.erb +++ b/app/views/activities/_series_activities_table.html.erb @@ -46,7 +46,7 @@ - <%= show_type_icon(activity) %> + <%= activity_icon(activity) %> diff --git a/app/views/activities/edit.html.erb b/app/views/activities/edit.html.erb index 51e97c5f1e..8520a4aa5f 100644 --- a/app/views/activities/edit.html.erb +++ b/app/views/activities/edit.html.erb @@ -4,7 +4,7 @@

- <%= show_type_icon(@activity, 24) %> + <%= activity_icon(@activity, 24) %>   <%= @activity.name %>

diff --git a/app/views/activities/info.html.erb b/app/views/activities/info.html.erb index b4fdd1c835..b02f90df4f 100644 --- a/app/views/activities/info.html.erb +++ b/app/views/activities/info.html.erb @@ -12,7 +12,7 @@

- <%= show_type_icon(@activity, 24) %> + <%= activity_icon(@activity, 24) %>   <%= @activity.name %>

diff --git a/app/views/activities/show.html.erb b/app/views/activities/show.html.erb index 2e019ff0bb..6c8f6ad3c0 100644 --- a/app/views/activities/show.html.erb +++ b/app/views/activities/show.html.erb @@ -38,7 +38,7 @@ end %>

- <%= show_type_icon(@activity, 24) %> + <%= activity_icon(@activity, 24) %>   <%= @activity.name %>

diff --git a/app/views/evaluations/_exercises_progress_table.html.erb b/app/views/evaluations/_exercises_progress_table.html.erb index bfc3048db4..e3a312c750 100644 --- a/app/views/evaluations/_exercises_progress_table.html.erb +++ b/app/views/evaluations/_exercises_progress_table.html.erb @@ -12,7 +12,7 @@ <% local_assigns[:metadata][:per_exercise].each do |meta| %> - <%= show_type_icon(meta[:exercise]) %> + <%= activity_icon(meta[:exercise]) %> diff --git a/app/views/evaluations/_exercises_table.html.erb b/app/views/evaluations/_exercises_table.html.erb index cfeb00be04..29c65c92f7 100644 --- a/app/views/evaluations/_exercises_table.html.erb +++ b/app/views/evaluations/_exercises_table.html.erb @@ -11,7 +11,7 @@ <% local_assigns[:exercises].each do |exercise| %> - <%= show_type_icon(exercise) %> + <%= activity_icon(exercise) %> From 3e0286f01b8b1c55d7f1f29839fd6ba1bef20f3c Mon Sep 17 00:00:00 2001 From: Charlotte Van Petegem Date: Mon, 25 Oct 2021 12:02:22 +0200 Subject: [PATCH 7/7] Lint --- app/helpers/activity_helper.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/helpers/activity_helper.rb b/app/helpers/activity_helper.rb index fce5c0fe9d..847c808ac2 100644 --- a/app/helpers/activity_helper.rb +++ b/app/helpers/activity_helper.rb @@ -101,9 +101,9 @@ def compare_solutions(a, b) 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}") + 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'}") + content_tag(:i, '', class: "mdi mdi-book-open-variant mdi-#{size}", title: t('activities.index.type.content')) end end