From d4cf253342352313d31ffc51ad4061732c8edfc5 Mon Sep 17 00:00:00 2001 From: Christoph Marzell Date: Fri, 7 Aug 2026 06:38:33 +0200 Subject: [PATCH] fix view --- app/views/entries/index.html.erb | 228 ++++++++++++------------------- 1 file changed, 91 insertions(+), 137 deletions(-) diff --git a/app/views/entries/index.html.erb b/app/views/entries/index.html.erb index caaa8cd..8a3df78 100644 --- a/app/views/entries/index.html.erb +++ b/app/views/entries/index.html.erb @@ -30,7 +30,7 @@ id="showAllCombinations" > @@ -58,82 +58,69 @@ <% Entry::PRAKTIKUMSTYPEN.each do |typ| %> <% Entry::ENTRY_ARTEN.each do |art| %> - <% remaining = @remaining_minutes_matrix.dig(typ, art) %> - <% spent = @spent_minutes_matrix.dig(typ, art) %> - <% soll = current_user.required_hours_matrix.dig(typ, art) %> - <% weekly = current_user.weekly_target_matrix.dig(typ, art) %> + <% remaining = @remaining_minutes_matrix.dig(typ, art).to_i %> + <% spent = @spent_minutes_matrix.dig(typ, art).to_i %> + <% soll = current_user.required_hours_for(typ, art).to_f %> + <% weekly = current_user.weekly_target_for(typ, art).to_f %> <% ende = @estimated_end_by_typ_art.dig(typ, art) %> - <% next if spent.blank? %> - <% next if soll.blank? %> - <% - # Standardmäßig zeigen wir nur Einträge, + # Ohne Sollwert und ohne geleistete Zeit ist die Kombination + # für die Übersicht nicht relevant. + next if soll.zero? && spent.zero? + + # Standardmäßig nur Anforderungen anzeigen, # bei denen tatsächlich noch etwas offen ist. - has_remaining = remaining.to_i.positive? + has_remaining = remaining.positive? %> - <% if remaining.present? || soll.present? || weekly.present? %> - - <%= typ.capitalize %> - - <%= art.capitalize %> - - - <% if remaining.present? %> - <%= remaining / 60 %> h <%= remaining % 60 %> min - <% else %> - — - <% end %> - - - - <% if spent.present? %> - <%= spent / 60 %> h <%= spent % 60 %> min - <% else %> - — - <% end %> - - - - <% if soll.present? %> - <%= soll %> h - <% else %> - — - <% end %> - - - - <% if weekly.present? %> - <%= weekly %> h/Woche - <% else %> - — - <% end %> - - - - <% actual = @actual_hours_per_week[[typ, art]] %> - - <% if actual.present? %> - <%= actual %> h/Woche - <% else %> - — - <% end %> - - - - <%= ende.present? ? ende.strftime("%d.%m.%Y") : "—" %> - - - - <% percent = @completion_percent_by_typ_art[[typ, art]] %> - <%= percent.present? ? "#{percent} %" : "—" %> - - - <% end %> + + <%= typ.capitalize %> + + <%= art %> + + + <%= remaining / 60 %> h <%= remaining % 60 %> min + + + + <%= spent / 60 %> h <%= spent % 60 %> min + + + + <%= number_with_precision(soll, precision: 2, strip_insignificant_zeros: true) %> h + + + + <% if weekly.positive? %> + <%= number_with_precision(weekly, precision: 2, strip_insignificant_zeros: true) %> h/Woche + <% else %> + — + <% end %> + + + + <% actual = @actual_hours_per_week[[typ, art]] %> + + <% if actual.present? %> + <%= actual %> h/Woche + <% else %> + — + <% end %> + + + + <%= ende.present? ? ende.strftime("%d.%m.%Y") : "—" %> + + + + <% percent = @completion_percent_by_typ_art[[typ, art]] %> + <%= percent.nil? ? "—" : "#{percent} %" %> + + <% end %> <% end %> @@ -250,6 +237,7 @@

Total: <%= @total_minutes / 60 %>h <%= @total_minutes % 60 %> min

Propädeutikum: <%= @total_minutes_praktikum_prop / 60 %>h <%= @total_minutes_praktikum_prop % 60 %> min

Fachspezifikum: <%= @total_minutes_praktikum_fach / 60 %>h <%= @total_minutes_praktikum_fach % 60 %> min

+

Mediation: <%= @total_minutes_praktikum_mediation / 60 %>h <%= @total_minutes_praktikum_mediation % 60 %> min

@@ -404,12 +392,12 @@ - <%= entry.praktikums_typ&.capitalize%> + <%= entry.praktikums_typ&.capitalize%> - <%= entry.entry_art&.capitalize %> + <%= entry.entry_art&.capitalize %> @@ -452,9 +440,9 @@
Aktuell angezeigt: 0 · Gesamt: 0
@@ -495,12 +483,12 @@ const entriesCount = document.getElementById("entriesCount"); if ( - !tbody || - !textFilter || - !minYearFilter || - !maxYearFilter || - !columnToggleMenu || - !entriesCount + !tbody || + !textFilter || + !minYearFilter || + !maxYearFilter || + !columnToggleMenu || + !entriesCount ) return; const headers = Array.from(table.querySelectorAll("thead th")); @@ -633,34 +621,34 @@ }).length; entriesCount.textContent = - `Aktuell angezeigt: ${visibleRows} · Gesamt: ${rows.length}`; + `Aktuell angezeigt: ${visibleRows} · Gesamt: ${rows.length}`; }; const applyFilters = () => { const query = textFilter.value.trim().toLowerCase(); const minYear = minYearFilter.value - ? Number(minYearFilter.value) - : null; + ? Number(minYearFilter.value) + : null; const maxYear = maxYearFilter.value - ? Number(maxYearFilter.value) - : null; + ? Number(maxYearFilter.value) + : null; getRows().forEach(row => { const rowYear = Number(row.dataset.year); const matchesQuery = - !query || getVisibleRowText(row).includes(query); + !query || getVisibleRowText(row).includes(query); const matchesMinYear = - minYear === null || rowYear >= minYear; + minYear === null || rowYear >= minYear; const matchesMaxYear = - maxYear === null || rowYear <= maxYear; + maxYear === null || rowYear <= maxYear; row.style.display = - matchesQuery && matchesMinYear && matchesMaxYear - ? "" - : "none"; + matchesQuery && matchesMinYear && matchesMaxYear + ? "" + : "none"; }); updateEntriesCount(); @@ -775,52 +763,19 @@ })(); \ No newline at end of file +