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

do not allow resizing all day events

Klaus Zanderscbf2f581dc48
diff --git a/frontend/src/stimulus/controllers/dynamic/my/time-tracking.controller.ts b/frontend/src/stimulus/controllers/dynamic/my/time-tracking.controller.ts
index 502b96f8938..6b893e8ebe6 100644
--- a/frontend/src/stimulus/controllers/dynamic/my/time-tracking.controller.ts
+++ b/frontend/src/stimulus/controllers/dynamic/my/time-tracking.controller.ts
@@ -110,12 +110,18 @@ export default class MyTimeTrackingController extends Controller {
);
},
eventResize: (info) => {
+ // it does not make sense to resize the events without start & end times
+ // we cannot only disable resize, because we want to be able to drag the events
+ // so we need to revert the event to its original size
+ if (info.event.allDay) {
+ info.revert();
+ return;
+ }
+
const startMoment = moment(info.event.startStr);
const endMoment = moment(info.event.endStr);
- const newEventHours = info.event.allDay
- ? (info.event.extendedProps.hours as number)
- : moment.duration(endMoment.diff(startMoment)).asHours();
+ const newEventHours = moment.duration(endMoment.diff(startMoment)).asHours();
info.event.setExtendedProp('hours', newEventHours);
@@ -132,12 +138,7 @@ export default class MyTimeTrackingController extends Controller {
// When dragging from all day into the calendar set the defaultTimedEventDuration to the hours of the event so
// that we display it correctly in the calendar. Will be reset in the drop event
if (info.event.allDay) {
- this.calendar.setOption(
- 'defaultTimedEventDuration',
- moment
- .duration(info.event.extendedProps.hours as number, 'hours')
- .asMilliseconds(),
- );
+ this.calendar.setOption('defaultTimedEventDuration', moment.duration(info.event.extendedProps.hours as number, 'hours').asMilliseconds());
}
},
@@ -168,10 +169,7 @@ export default class MyTimeTrackingController extends Controller {
);
}
- this.calendar.setOption(
- 'defaultTimedEventDuration',
- DEFAULT_TIMED_EVENT_DURATION,
- );
+ this.calendar.setOption('defaultTimedEventDuration', DEFAULT_TIMED_EVENT_DURATION);
},
eventClick: (info) => {
// check if we clicked on a link tag, if so exit early as we don't want to show the modal
@@ -184,15 +182,9 @@ export default class MyTimeTrackingController extends Controller {
{ method: 'GET' },
);
},
- viewDidMount: () => {
- setTimeout(() => this.addTotalFooter(), 100);
- },
- eventDidMount: () => {
- setTimeout(() => this.addTotalFooter(), 100);
- },
- eventChange: () => {
- setTimeout(() => this.addTotalFooter(), 100);
- },
+ viewDidMount: () => { setTimeout(() => this.addTotalFooter(), 100); },
+ eventDidMount: () => { setTimeout(() => this.addTotalFooter(), 100); },
+ eventChange: () => { setTimeout(() => this.addTotalFooter(), 100); },
});
this.calendar.render();
@@ -215,18 +207,22 @@ export default class MyTimeTrackingController extends Controller {
// Add footer dividier if it doesn't exist
if (calendarScrollGridWrapper.querySelector('.fc-timegrid-footer-divider') === null) {
- calendarScrollGridWrapper.insertAdjacentHTML('beforeend', '<tr role="presentation" class="fc-scrollgrid-section fc-timegrid-footer-divider"><td class="fc-timegrid-divider fc-cell-shaded"></td></tr>');
+ calendarScrollGridWrapper.insertAdjacentHTML(
+ 'beforeend',
+ '<tr role="presentation" class="fc-scrollgrid-section fc-timegrid-footer-divider"><td class="fc-timegrid-divider fc-cell-shaded"></td></tr>',
+ );
}
// Remove existing footer if it exists
const existingFooter = document.querySelector('.fc-timegrid-footer-totals');
- if (existingFooter) {
- existingFooter.remove();
- }
+ if (existingFooter) { existingFooter.remove(); }
+
const days:string[] = [];
- document.querySelectorAll('.fc-timegrid-cols .fc-day').forEach((dayElement) => {
- days.push(dayElement.getAttribute('data-date') as string);
- });
+ document
+ .querySelectorAll('.fc-timegrid-cols .fc-day')
+ .forEach((dayElement) => {
+ days.push(dayElement.getAttribute('data-date') as string);
+ });
calendarScrollGridWrapper.appendChild(this.buildHtmlFooter(days));
}
@@ -298,7 +294,9 @@ export default class MyTimeTrackingController extends Controller {
// Inner div in der zweiten Zelle erstellen
const syncInner = document.createElement('div');
syncInner.className = 'fc-scrollgrid-sync-inner';
- syncInner.textContent = this.displayDuration(this.calculateTotalHours(day));
+ syncInner.textContent = this.displayDuration(
+ this.calculateTotalHours(day),
+ );
footerCell.appendChild(syncInner);
tbodyTr.appendChild(footerCell);
});
@@ -330,14 +328,14 @@ export default class MyTimeTrackingController extends Controller {
start_time: startTime,
hours,
},
+ no_dialog: true,
}),
})
.then((response) => {
- if (response.ok) {
- void response.text().then((html) => {
- renderStreamMessage(html);
- });
- } else if (revertFunction) {
+ void response.text().then((html) => {
+ renderStreamMessage(html);
+ });
+ if (!response.ok && revertFunction) {
revertFunction();
}
})
diff --git a/modules/costs/app/controllers/time_entries_controller.rb b/modules/costs/app/controllers/time_entries_controller.rb
index dd83bf9c9ec..5462ad8c385 100644
--- a/modules/costs/app/controllers/time_entries_controller.rb
+++ b/modules/costs/app/controllers/time_entries_controller.rb
@@ -97,7 +97,7 @@ class TimeEntriesController < ApplicationController
end
end
- def update
+ def update # rubocop:disable Metrics/AbcSize
call = TimeEntries::UpdateService
.new(user: current_user, model: @time_entry)
.call(permitted_params.time_entries)
@@ -106,12 +106,15 @@ class TimeEntriesController < ApplicationController
if call.success?
render_success_flash_message_via_turbo_stream(message: t("notice_updated_successfully"))
+ elsif params[:no_dialog]
+ render_error_flash_message_via_turbo_stream(message: t("notice_update_failed",
+ errors: call.errors.full_messages.join(", ")))
else
form_component = TimeEntries::TimeEntryFormComponent.new(time_entry: @time_entry, **form_config_options)
update_via_turbo_stream(component: form_component, status: :bad_request)
end
- respond_with_turbo_streams
+ respond_with_turbo_streams(status: call.success? ? :ok : :bad_request)
end
def destroy
diff --git a/modules/costs/config/locales/en.yml b/modules/costs/config/locales/en.yml
index 7b0ee4e9718..7be9e5fe9f5 100644
--- a/modules/costs/config/locales/en.yml
+++ b/modules/costs/config/locales/en.yml
@@ -184,6 +184,8 @@ en:
notice_successful_lock: "Locked successfully."
notice_cost_logged_successfully: "Unit cost logged successfully."
notice_different_time_zones: "This user has a different time zone (%{tz}). Time will be logged using their time zone."
+ notice_updated_successfully: "Time entry updated successfully."
+ notice_update_failed: "Failed to update time entry. Errors: %{errors}"
permission_edit_cost_entries: "Edit booked unit costs"
permission_edit_own_cost_entries: "Edit own booked unit costs"