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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
allow resize & drag/drop
Klaus Zanders4ce972039263
diff --git a/frontend/src/stimulus/controllers/dynamic/my/time-tracking.controller.ts b/frontend/src/stimulus/controllers/dynamic/my/time-tracking.controller.tsindex 79fa5215496..892af3b9f2d 100644--- a/frontend/src/stimulus/controllers/dynamic/my/time-tracking.controller.ts+++ b/frontend/src/stimulus/controllers/dynamic/my/time-tracking.controller.ts@@ -54,6 +54,8 @@ export default class MyTimeTrackingController extends Controller {contentHeight: 780,aspectRatio: 3,selectable: this.canCreateValue,+ editable: this.canEditValue,+ eventResizableFromStart: true,allDayContent: I18n.t('js.myTimeTracking.noSpecificTime'),eventClassNames(arg) {return [@@ -63,8 +65,9 @@ export default class MyTimeTrackingController extends Controller {];},eventDidMount(info) {+ console.log(info.event);//eslint-disable-next-line- info.el.innerHTML = info.event.extendedProps.customEventView;+ // info.el.innerHTML = info.event.extendedProps.customEventView;},select: (info) => {let dialogParams = 'onlyMe=true';@@ -80,6 +83,38 @@ export default class MyTimeTrackingController extends Controller {{ method: 'GET' },);},+ eventResize: (info) => {+ let dialogParams = 'onlyMe=true';++ if (info.event.allDay) {+ dialogParams = `${dialogParams}&date=${info.event.startStr}&removeTime=true`;+ } else {+ dialogParams = `${dialogParams}&startTime=${info.event.start?.toISOString()}&endTime=${info.event.end?.toISOString()}`;+ }++ void this.turboRequests.request(+ `${this.pathHelper.timeEntryEditDialog(info.event.id)}?${dialogParams}`,+ { method: 'GET' },+ );++ info.revert(); // revert back to old position, when modal succeeds, we reload anyways+ },+ eventDrop: (info) => {+ let dialogParams = 'onlyMe=true';++ if (info.event.allDay) {+ dialogParams = `${dialogParams}&date=${info.event.startStr}&removeTime=true`;+ } else {+ dialogParams = `${dialogParams}&startTime=${info.event.start?.toISOString()}&endTime=${info.event.end?.toISOString()}`;+ }++ void this.turboRequests.request(+ `${this.pathHelper.timeEntryEditDialog(info.event.id)}?${dialogParams}`,+ { method: 'GET' },+ );++ info.revert(); // revert back to old position, when modal succeeds, we reload anyways+ },});this.calendar.render();diff --git a/lib/full_calendar/event.rb b/lib/full_calendar/event.rbindex 897d4a7c5de..1d56c563109 100644--- a/lib/full_calendar/event.rb+++ b/lib/full_calendar/event.rb@@ -41,7 +41,6 @@ module FullCalendarattribute :title, :stringattribute :url, :stringattribute :class_names, array: true, default: []- attribute :editable, :boolean, default: falsedef as_json{@@ -53,7 +52,6 @@ module FullCalendar"title" => title,"url" => url,"classNames" => class_names,- "editable" => editable,"customEventView" => rendered_event_content}.compact_blank.as_jsonenddiff --git a/modules/costs/app/controllers/time_entries_controller.rb b/modules/costs/app/controllers/time_entries_controller.rbindex f7375086437..4ec3067a90c 100644--- a/modules/costs/app/controllers/time_entries_controller.rb+++ b/modules/costs/app/controllers/time_entries_controller.rb@@ -49,7 +49,31 @@ class TimeEntriesController < ApplicationController@show_user = show_user_input_in_dialog@limit_to_project_id = @project&.id- @time_entry.spent_on ||= params[:date].presence || Time.zone.today+ @time_entry.time_zone = User.current.time_zone.name++ # TODO: Move this into a service++ if params[:date].present?+ @time_entry.spent_on = params[:date]+ elsif params[:startTime].present? && params[:endTime].present?+ parsed_start_time = DateTime.parse(params[:startTime]).in_time_zone(User.current.time_zone)+ parsed_end_time = DateTime.parse(params[:endTime]).in_time_zone(User.current.time_zone)++ @time_entry.spent_on = parsed_start_time.to_date++ # full day events have the same start and end time+ puts "****", parsed_start_time, parsed_end_time, (parsed_start_time != parsed_end_time), "****"+ if parsed_start_time != parsed_end_time+ @time_entry.start_time = (parsed_start_time.hour * 60) + parsed_start_time.min+ @time_entry.hours = ((parsed_end_time - parsed_start_time) / 1.hour).round(2)+ end+ else+ @time_entry.spent_on ||= Time.zone.today+ end++ if params[:removeTime] == "true"+ @time_entry.start_time = nil+ endenddef user_tz_captiondiff --git a/modules/costs/app/views/my/time_tracking/_calendar.html.erb b/modules/costs/app/views/my/time_tracking/_calendar.html.erbindex e6fe6c3d031..e24f9f6666b 100644--- a/modules/costs/app/views/my/time_tracking/_calendar.html.erb+++ b/modules/costs/app/views/my/time_tracking/_calendar.html.erb@@ -3,23 +3,49 @@data-application-target="dynamic"data-my--time-tracking-mode-value="<%= local_assigns[:mode] %>"data-my--time-tracking-time-entries-value="<%= time_entries_json %>"- data-my--time-tracking-initial-date-value="<%= current_day %>">-<%= render(Primer::OpenProject::SubHeader.new) do |component|- component.with_text do- "#{current_day.beginning_of_week.day}-#{current_day.end_of_week.day}. #{current_day.strftime('%B %Y')}"- end+ data-my--time-tracking-initial-date-value="<%= current_day %>"+ data-my--time-tracking-can-create-value="<%= User.current.allowed_in_any_project?(:log_own_time) %>"+ data-my--time-tracking-can-edit-value="<%= User.current.allowed_in_any_project?(:edit_own_time_entries) %>">+ <%= render(Primer::OpenProject::SubHeader.new) do |component|+ component.with_text do+ "#{current_day.beginning_of_week.day}-#{current_day.end_of_week.day}. #{current_day.strftime('%B %Y')}"+ end- component.with_action_component do- render(Primer::Beta::ButtonGroup.new) do |group|- group.with_button(icon: "arrow-left", aria: { label: "Previous week" }, tag: :a, href: my_time_tracking_week_path(date: current_day - 1.week))- group.with_button(icon: "arrow-right", aria: { label: "Next week" }, tag: :a, href: my_time_tracking_week_path(date: current_day + 1.week))+ component.with_action_component do+ render(Primer::Beta::ButtonGroup.new) do |group|+ group.with_button(+ icon: "arrow-left",+ aria: {+ label: "Previous week"+ },+ tag: :a,+ href: my_time_tracking_week_path(date: current_day - 1.week)+ )+ group.with_button(+ icon: "arrow-right",+ aria: {+ label: "Next week"+ },+ tag: :a,+ href: my_time_tracking_week_path(date: current_day + 1.week)+ )+ endend- end- component.with_action_button(tag: :a, href: my_time_tracking_week_path(date: Time.zone.today)) { "Today" }+ component.with_action_button(+ tag: :a,+ href: my_time_tracking_week_path(date: Time.zone.today)+ ) { "Today" }- component.with_action_button(scheme: :primary, data: { "turbo-stream" => true }, tag: :a, href: dialog_time_entries_path(onlyMe: true)) { "Log Time" }- end %>+ component.with_action_button(+ scheme: :primary,+ data: {+ "turbo-stream" => true+ },+ tag: :a,+ href: dialog_time_entries_path(onlyMe: true)+ ) { "Log Time" }+ end %>-<div data-my--time-tracking-target="calendar"></div>+ <div data-my--time-tracking-target="calendar"></div></div>diff --git a/modules/costs/lib/full_calendar/time_entry_event.rb b/modules/costs/lib/full_calendar/time_entry_event.rbindex 13b465d82d0..16ecd454726 100644--- a/modules/costs/lib/full_calendar/time_entry_event.rb+++ b/modules/costs/lib/full_calendar/time_entry_event.rb@@ -49,6 +49,7 @@ module FullCalendardef as_json(*)super.merge(+ hours: time_entry.hours,statusId: time_entry.work_package.status_id)end