Browse Source

add minus break

main
Christoph Marzell 4 weeks ago
parent
commit
d0ba2c091c
  1. 4
      app/controllers/entries_controller.rb
  2. 8
      app/views/entries/index.html.erb

4
app/controllers/entries_controller.rb

@ -74,7 +74,9 @@ class EntriesController < ApplicationController
#@entry = current_user.entries.where(end_time: nil).order(start_time: :desc).first
if @entry
@entry.end_time = Time.current
@entry.lunch_break_minutes = params[:lunch_break_minutes].to_i
@entry.lunch_break_minutes = 30 if ActiveModel::Type::Boolean.new.cast(params[:lunch_break])
total_minutes = @entry.total_minutes_including_break
@entry.hours = total_minutes / 60

8
app/views/entries/index.html.erb

@ -111,7 +111,13 @@
Dauer: <span id="live-timer">Berechne …</span>
</div>
<div>
<%= button_to '⏹️ Stoppen', stop_timer_entry_path(@running_entry), method: :post, class: "btn btn-danger" %>
<%= form_with url: stop_timer_entry_path(@running_entry), method: :post, local: true do |f| %>
<div class="form-check mb-2">
<%= f.check_box :lunch_break, class: 'form-check-input', id: 'lunch_break' %>
<%= f.label :lunch_break, '30 Min Mittagspause abziehen', class: 'form-check-label' %>
</div>
<%= f.submit '⏹️ Stoppen', class: "btn btn-danger" %>
<% end %>
</div>
</div>
<% end %>

Loading…
Cancel
Save