You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

75 lines
3.2 KiB

<h1 class="mb-3">Kalender – Woche <%= @week %> / <%= @year %></h1>
<div class="row mb-3">
<div class="col-md-6">
<%= link_to "← Vorherige Woche", calendar_week_path(@year, @week - 1, typ: @filter_typ, art: @filter_art), class: "btn btn-outline-primary" %>
<%= link_to "Nächste Woche →", calendar_week_path(@year, @week + 1, typ: @filter_typ, art: @filter_art), class: "btn btn-outline-primary ms-2" %>
</div>
<div class="col-md-6 text-end">
<%= form_with url: calendar_week_path(@year, @week), method: :get, local: true, class: "row g-2 justify-content-end" do %>
<div class="col-auto">
<%= select_tag :typ, options_for_select(User::PRAKTIKUMSTYPEN, @filter_typ), include_blank: "Alle Typen", class: "form-select" %>
</div>
<div class="col-auto">
<%= select_tag :art, options_for_select(User::ENTRY_ARTEN, @filter_art), include_blank: "Alle Arten", class: "form-select" %>
</div>
<div class="col-auto">
<%= submit_tag "Filtern", class: "btn btn-outline-secondary" %>
</div>
<% end %>
</div>
</div>
<div class="row">
<% @days.each do |date| %>
<div class="col border p-2 day-cell" data-date="<%= date %>" data-label="<%= date.strftime('%A %d.%m.%Y') %>">
<div class="fw-bold"><%= date.strftime("%a %d.%m.") %></div>
<div class="day-entries d-none">
<% if @entries[date] %>
<% @entries[date].each do |entry| %>
<div class="mb-2">
<span class="badge <%= color_class_for(entry) %>"><%= entry.entry_art.capitalize %></span>
<%= "#{entry.hours}h #{entry.minutes}min" %>
<%= link_to "✏️", edit_entry_path(entry), class: "btn btn-sm btn-outline-secondary ms-2" %>
</div>
<% end %>
<% else %>
<p class="text-muted small">Keine Einträge</p>
<% end %>
</div>
<%= link_to "+", new_entry_path(date: date), class: "btn btn-sm btn-success mt-1", onclick: "event.stopPropagation();" %>
</div>
<% end %>
</div>
<!-- Tagesmodal (wie im Monat) -->
<div class="modal fade" id="dayEntriesModal" tabindex="-1" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Einträge für <span id="modal-date-label"></span></h5>
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
</div>
<div class="modal-body" id="modal-day-entries"></div>
</div>
</div>
</div>
<script>
document.addEventListener("DOMContentLoaded", () => {
document.querySelectorAll(".day-cell").forEach(cell => {
cell.addEventListener("click", function () {
const date = this.dataset.date;
const label = this.dataset.label;
const entriesHtml = this.querySelector(".day-entries").innerHTML;
document.getElementById("modal-date-label").textContent = label;
document.getElementById("modal-day-entries").innerHTML = entriesHtml;
const modal = new bootstrap.Modal(document.getElementById("dayEntriesModal"));
modal.show();
});
});
});
</script>