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
Dynamically add timer so it doesn't show up in the table
Oliver Günther966e74d012da
diff --git a/frontend/src/app/shared/components/op-context-menu/wp-context-menu/wp-single-context-menu.ts b/frontend/src/app/shared/components/op-context-menu/wp-context-menu/wp-single-context-menu.tsindex f1125bede6b..fff4740da6f 100644--- a/frontend/src/app/shared/components/op-context-menu/wp-context-menu/wp-single-context-menu.ts+++ b/frontend/src/app/shared/components/op-context-menu/wp-context-menu/wp-single-context-menu.ts@@ -23,6 +23,7 @@ import { TurboRequestsService } from 'core-app/core/turbo/turbo-requests.serviceimport { ApiV3Service } from 'core-app/core/apiv3/api-v3.service';import { TimeEntryTimerService } from 'core-app/shared/components/time_entries/services/time-entry-timer.service';import { TimeEntryResource } from 'core-app/features/hal/resources/time-entry-resource';+import { action } from 'ts-action';@Directive({// eslint-disable-next-line @angular-eslint/directive-selector@@ -128,7 +129,7 @@ export class WorkPackageSingleContextMenuDirective extends OpContextMenuTriggerreturn position;}- private activeForWorkPackage(entry:TimeEntryResource | null):boolean {+ private activeForWorkPackage(entry:TimeEntryResource|null):boolean {return !!entry && entry.entity.href === this.workPackage.href;}@@ -136,7 +137,7 @@ export class WorkPackageSingleContextMenuDirective extends OpContextMenuTriggerreturn Object.prototype.hasOwnProperty.call(this.workPackage, 'logTime');}- private getTimerAction():string | null {+ private getTimerAction():string {if (this.activeForWorkPackage(this.currentTimer)) {return 'stop_timer';} else {@@ -147,8 +148,8 @@ export class WorkPackageSingleContextMenuDirective extends OpContextMenuTriggerprivate getPermittedActions(authorization:WorkPackageAuthorization) {let actions:WorkPackageAction[] = authorization.permittedActionsWithLinks(PERMITTED_CONTEXT_MENU_ACTIONS);- // Reduce the available actions on timers- actions = this.reduceTimerAction(actions);+ // Add the available actions on timers+ actions = this.addTimerAction(actions);// Splice plugin actions onto the core actions_.each(this.getPermittedPluginActions(authorization), (action:WorkPackageAction) => {@@ -159,21 +160,18 @@ export class WorkPackageSingleContextMenuDirective extends OpContextMenuTriggerreturn actions;}- private reduceTimerAction(actions:WorkPackageAction[]) {- const requiredTimerAction = this.getTimerAction();- return actions.filter((action) => {- // Show one action- if (action.key === requiredTimerAction) {- return true;- }+ private addTimerAction(actions:WorkPackageAction[]) {+ const key = this.getTimerAction();+ const action = {+ key,+ icon: 'icon-time-tracking-start',+ link: 'logTime',+ };- // Hide the other- if (action.key === 'start_timer' || action.key === 'stop_timer') {- return false;- }+ const timeIndex = actions.findIndex((action) => action.key === 'log_time');+ actions.splice(timeIndex + 1, 0, action);- return true;- });+ return actions;}private getPermittedPluginActions(authorization:WorkPackageAuthorization) {diff --git a/frontend/src/app/shared/components/op-context-menu/wp-context-menu/wp-static-context-menu-actions.ts b/frontend/src/app/shared/components/op-context-menu/wp-context-menu/wp-static-context-menu-actions.tsindex 0f13427b71c..7fac1519492 100644--- a/frontend/src/app/shared/components/op-context-menu/wp-context-menu/wp-static-context-menu-actions.ts+++ b/frontend/src/app/shared/components/op-context-menu/wp-context-menu/wp-static-context-menu-actions.ts@@ -12,16 +12,6 @@ export const PERMITTED_CONTEXT_MENU_ACTIONS:WorkPackageAction[] = [key: 'log_time',link: 'logTime',},- {- key: 'start_timer',- icon: 'icon-time-tracking-start',- link: 'logTime'- },- {- key: 'stop_timer',- icon: 'icon-time-tracking-stop',- link: 'logTime'- },{key: 'change_project',icon: 'icon-move',