Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions app/helpers/time_regs_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ def weekdays_of_week(date, exclude: nil)
(0..4).map { |i| start_of_week + i.days }.reject { |d| d == exclude }
end

def rest_of_weekdays(date)
end_of_work_week = date.beginning_of_week + 4.days # Friday
return [] if date > end_of_work_week # If after Friday, no remaining days

((date + 1.day)..end_of_work_week).to_a
end

def minutes_by_day_of_week(date, user)
start_of_week = date.beginning_of_week
end_of_week = date.end_of_week
Expand Down
2 changes: 1 addition & 1 deletion app/views/time_regs/_time_reg.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
class: "gap-x-2",
dropdown_items: [
{ label: t("common.copy_to_next_day"), path: time_reg_copies_path(time_reg, date: time_reg.date_worked + 1.day), method: :post },
{ label: t("common.copy_to_week"), path: time_reg_copies_path(time_reg, dates: weekdays_of_week(time_reg.date_worked, exclude: time_reg.date_worked)), method: :post },
{ label: t("common.copy_to_week"), path: time_reg_copies_path(time_reg, dates: rest_of_weekdays(time_reg.date_worked)), method: :post },
{ label: t("common.copy_to_next_week"), path: time_reg_copies_path(time_reg, dates: weekdays_of_week(time_reg.date_worked + 1.week)), method: :post }
]
) do %>
Expand Down
2 changes: 1 addition & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ en:
week: "Week"
copy_to_today: "Copy to today"
copy_to_next_day: "Copy to <b>next day</b>"
copy_to_week: "Copy to all of <b>week</b>"
copy_to_week: "Copy through rest of <b>week</b>"
copy_to_next_week: "Copy to all of <b>next week</b>"
unable_to_proceed: "Unable to proceed"
organization_name: "Organization name"
Expand Down
2 changes: 1 addition & 1 deletion config/locales/nb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ nb:
week: "Uke"
copy_to_today: "Kopier til i dag"
copy_to_next_day: "Kopier til <b>neste dag</b>"
copy_to_week: "Kopier til hele <b>uken</b>"
copy_to_week: "Kopier til resten av <b>uken</b>"
copy_to_next_week: "Kopier til hele <b>neste uke</b>"
unable_to_proceed: "Kan ikke fortsette"
organization_name: "Organisasjonsnavn"
Expand Down