Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Merge branch 'dev' into implementation/61533-extend-data-model-to-allow-logging-time-on-other-resources

Klaus Zanders0571f4beea36
diff --cc modules/costs/app/controllers/my/time_tracking_controller.rb
index 4ac0ddd43f7,659f501ac12..fb988f43e21
--- a/modules/costs/app/controllers/my/time_tracking_controller.rb
+++ b/modules/costs/app/controllers/my/time_tracking_controller.rb
@@@ -123,9 -123,9 +123,9 @@@ module M
def load_time_entries(time_scope)
@time_entries = TimeEntry
- .includes(:project, :activity, { work_package: :status })
+ .preload(:project, :activity, :entity)
.where(project_id: Project.visible.select(:id))
- .where(user: User.current, spent_on: time_scope, ongoing: false)
+ .where(user: User.current, spent_on: time_scope)
.order(:spent_on, :start_time, :hours)
end
diff --cc modules/costs/lib/full_calendar/time_entry_event.rb
index 266c03c4f77,406ad0aebe5..3dabdcc2ff8
--- a/modules/costs/lib/full_calendar/time_entry_event.rb
+++ b/modules/costs/lib/full_calendar/time_entry_event.rb
@@@ -34,27 -34,45 +34,45 @@@ module FullCalenda
class << self
def from_time_entry(time_entry)
+ starts_at, ends_at = start_and_end_time_from_time_entry(time_entry)
+
event = new(
id: time_entry.id,
- starts_at: time_entry.start_timestamp || time_entry.spent_on,
- ends_at: time_entry.end_timestamp || time_entry.spent_on,
- all_day: time_entry.start_time.blank?,
+ starts_at: starts_at,
+ ends_at: ends_at,
+ all_day: !time_entry.ongoing? && time_entry.start_time.blank?,
- title: "#{time_entry.project.name}: ##{time_entry.work_package.id} #{time_entry.work_package.subject}"
+ title: "#{time_entry.project.name}: ##{time_entry.entity.id} #{time_entry.entity.subject}"
)
event.time_entry = time_entry
event
end
+
+ def start_and_end_time_from_time_entry(time_entry)
+ if time_entry.ongoing?
+ [
+ time_entry.created_at.in_time_zone(time_entry.time_zone),
+ Time.current.in_time_zone(time_entry.time_zone)
+ ]
+ else
+ [
+ time_entry.start_timestamp || time_entry.spent_on,
+ time_entry.end_timestamp || time_entry.spent_on
+ ]
+ end
+ end
end
- def additional_attributes
+ def additional_attributes # rubocop:disable Metrics/AbcSize
{
- hours: time_entry.hours,
+ durationEditable: time_entry.start_time.present?,
+ hours: time_entry.hours_for_calculation,
- typeId: time_entry.work_package.type_id,
- workPackageId: time_entry.work_package.id,
- workPackageSubject: time_entry.work_package.subject,
+ typeId: time_entry.entity.type_id,
+ workPackageId: time_entry.entity.id,
+ workPackageSubject: time_entry.entity.subject,
projectId: time_entry.project.id,
- projectName: time_entry.project.name
+ projectName: time_entry.project.name,
+ ongoing: time_entry.ongoing?
}
end
end