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

use specific work package apis and call turbo action to replace activities

Klaus Zandersdff3b97ff52b
diff --git a/frontend/src/app/core/path-helper/path-helper.service.ts b/frontend/src/app/core/path-helper/path-helper.service.ts
index 90f816d4c06..25bb5c7e860 100644
--- a/frontend/src/app/core/path-helper/path-helper.service.ts
+++ b/frontend/src/app/core/path-helper/path-helper.service.ts
@@ -334,7 +334,7 @@ export class PathHelperService {
return `${this.staticBase}/time_entries/users/${userId}/tz_caption`;
}
- public timeEntriesWorkPackageActicity(workPackageId:string) {
+ public timeEntriesWorkPackageActivity(workPackageId:string) {
return `${this.staticBase}/time_entries/work_packages/${workPackageId}/time_entry_activities`;
}
diff --git a/frontend/src/stimulus/controllers/dynamic/time-entry.controller.ts b/frontend/src/stimulus/controllers/dynamic/time-entry.controller.ts
index bbb2364a966..3f77f5325c0 100644
--- a/frontend/src/stimulus/controllers/dynamic/time-entry.controller.ts
+++ b/frontend/src/stimulus/controllers/dynamic/time-entry.controller.ts
@@ -29,7 +29,10 @@
*/
import { Controller } from '@hotwired/stimulus';
-import { parseChronicDuration, outputChronicDuration } from 'core-app/shared/helpers/chronic_duration';
+import {
+ parseChronicDuration,
+ outputChronicDuration,
+} from 'core-app/shared/helpers/chronic_duration';
import { TurboRequestsService } from 'core-app/core/turbo/turbo-requests.service';
import { PathHelperService } from 'core-app/core/path-helper/path-helper.service';
@@ -53,8 +56,18 @@ export default class TimeEntryController extends Controller {
userChanged(event:InputEvent) {
const userId = (event.currentTarget as HTMLInputElement).value;
+ void this.turboRequests.request(
+ this.pathHelper.timeEntriesUserTimezoneCaption(userId),
+ { method: 'GET' },
+ );
+ }
- void this.turboRequests.request(this.pathHelper.timeEntriesUserTimezoneCaption(userId), { method: 'GET' });
+ workPackageChanged(event:InputEvent) {
+ const workPackageId = (event.currentTarget as HTMLInputElement).value;
+ void this.turboRequests.request(
+ this.pathHelper.timeEntriesWorkPackageActivity(workPackageId),
+ { method: 'GET' },
+ );
}
timeInputChanged(event:InputEvent) {
@@ -76,9 +89,15 @@ export default class TimeEntryController extends Controller {
// We calculate the hours field if:
// - We have start & end time and no hours
// - We have start & end time and we have triggered the change from the end time field
- if (startTimeInMinutes && endTimeInMinutes && (hoursInMinutes === 0 || initiatedBy === this.endTimeInputTarget)) {
+ if (
+ startTimeInMinutes
+ && endTimeInMinutes
+ && (hoursInMinutes === 0 || initiatedBy === this.endTimeInputTarget)
+ ) {
hoursInMinutes = endTimeInMinutes - startTimeInMinutes;
- if (hoursInMinutes <= 0) { hoursInMinutes += 24 * 60; }
+ if (hoursInMinutes <= 0) {
+ hoursInMinutes += 24 * 60;
+ }
const formattedHours = outputChronicDuration(hoursInMinutes * 60, { format: 'hours_only' }) || '';
this.hoursInputTarget.value = formattedHours;
@@ -97,7 +116,10 @@ export default class TimeEntryController extends Controller {
hoursChanged() {
// Parse input through our chronic duration parser and then reformat as hours that can be nicely parsed on the
// backend
- const hours = parseChronicDuration(this.hoursInputTarget.value, { defaultUnit: 'hours', ignoreSecondsWhenColonSeperated: true });
+ const hours = parseChronicDuration(this.hoursInputTarget.value, {
+ defaultUnit: 'hours',
+ ignoreSecondsWhenColonSeperated: true,
+ });
this.hoursInputTarget.value = outputChronicDuration(hours, { format: 'hours_only' }) || '';
this.datesChanged(this.hoursInputTarget);
diff --git a/modules/costs/app/components/time_entries/work_package_form.rb b/modules/costs/app/components/time_entries/work_package_form.rb
index ee840affc25..5ef4b1059f4 100644
--- a/modules/costs/app/components/time_entries/work_package_form.rb
+++ b/modules/costs/app/components/time_entries/work_package_form.rb
@@ -35,14 +35,24 @@ module TimeEntries
label: TimeEntry.human_attribute_name(:work_package),
required: true,
autocomplete_options: {
+ hiddenFieldAction: "change->time-entry#workPackageChanged",
focusDirectly: false,
append_to: "#time-entry-dialog",
+ url: work_package_completer_url,
filters: work_package_completer_filters
}
end
private
+ def work_package_completer_url
+ if model.persisted?
+ ::API::V3::Utilities::PathHelper::ApiV3Path.time_entries_available_work_packages_on_edit(model.id)
+ else
+ ::API::V3::Utilities::PathHelper::ApiV3Path.time_entries_available_work_packages_on_create
+ end
+ end
+
def work_package_completer_filters
filters = []