diff --git a/app/controllers/entries_controller.rb b/app/controllers/entries_controller.rb index 2be0481..b71405e 100644 --- a/app/controllers/entries_controller.rb +++ b/app/controllers/entries_controller.rb @@ -37,6 +37,8 @@ class EntriesController < ApplicationController @completion_percent_by_typ_art = {} @progress_chart_data = {} + @progress_colors = {} + User::PRAKTIKUMSTYPEN.product(User::ENTRY_ARTEN).each do |typ, art| total_required = current_user.required_hours_matrix.to_h.dig(typ, art).to_f remaining_minutes = @remaining_minutes_matrix.dig(typ, art).to_i @@ -50,9 +52,20 @@ class EntriesController < ApplicationController @completion_percent_by_typ_art[[typ, art]] = percent @progress_chart_data["#{typ.capitalize} – #{art}"] = percent else - @completion_percent_by_typ_art[[typ, art]] = 0 - @progress_chart_data["#{typ.capitalize} – #{art}"] = 0 + percent = 0 + @completion_percent_by_typ_art[[typ, art]] = percent + @progress_chart_data["#{typ.capitalize} – #{art}"] = percent end + + @progress_colors["#{typ.capitalize} – #{art}"] = if percent < 50 + '#007bff' # Blau + elsif percent < 90 + '#28a745' # Grün + else + '#dc3545' # Rot + end + + end diff --git a/app/views/entries/index.html.erb b/app/views/entries/index.html.erb index 7aa8a94..ea63427 100644 --- a/app/views/entries/index.html.erb +++ b/app/views/entries/index.html.erb @@ -66,9 +66,11 @@