Skip to content

Commit

Permalink
refactor objective status tooltip
Browse files Browse the repository at this point in the history
  • Loading branch information
kcinay055679 committed Oct 23, 2024
1 parent e1ee55a commit e0d85ea
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
[src]="'assets/icons/' + objective.state"
alt="The objectives state"
class="icon"
matTooltip="{{ getStateTooltip() + ' ' + formatObjectiveState(objective.state) }}"
matTooltip="{{ getStateTooltip(objective.state) }}"
matTooltipPosition="above"
/>
<h2 class="title fit-content">{{ objective.title }}</h2>
Expand Down
22 changes: 6 additions & 16 deletions frontend/src/app/components/objective/objective.component.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Component, Input, OnInit } from '@angular/core';
import { ObjectiveMin } from '../../shared/types/model/ObjectiveMin';
import { Router } from '@angular/router';
import { BehaviorSubject, map } from 'rxjs';
import { map, Subject } from 'rxjs';
import { RefreshDataService } from '../../services/refresh-data.service';
import { ObjectiveService } from '../../services/objective.service';
import { isObjectiveComplete, trackByFn } from '../../shared/common';
import { getStateByValue, isObjectiveComplete, trackByFn } from '../../shared/common';
import { KeyresultDialogComponent } from '../keyresult-dialog/keyresult-dialog.component';
import { TranslateService } from '@ngx-translate/core';
import { DialogService } from '../../services/dialog.service';
Expand All @@ -17,11 +17,9 @@ import { ObjectiveMenuActionsService, ObjectiveMenuEntry } from '../../services/
})
export class ObjectiveComponent implements OnInit {
@Input() isWritable!: boolean;
isComplete: boolean = false;
public objective$ = new BehaviorSubject<ObjectiveMin>({} as ObjectiveMin);
public objective$ = new Subject<ObjectiveMin>();
menuEntries = this.objective$.pipe(map((objective) => this.objectiveMenuActionsService.getMenu(objective)));
protected readonly trackByFn = trackByFn;
protected readonly console = console;
protected readonly isObjectiveComplete = isObjectiveComplete;

constructor(
Expand All @@ -39,17 +37,9 @@ export class ObjectiveComponent implements OnInit {

ngOnInit() {}

formatObjectiveState(state: string): string {
const lastIndex = state.lastIndexOf('-');
if (lastIndex !== -1) {
return state.substring(0, lastIndex).toUpperCase();
} else {
return state.toUpperCase();
}
}

getStateTooltip(): string {
return this.translate.instant('INFORMATION.OBJECTIVE_STATE_TOOLTIP');
getStateTooltip(stateString: string): string {
const state = getStateByValue(stateString);
return this.translate.instant('INFORMATION.OBJECTIVE_STATE_TOOLTIP', { state: state });
}

redirect(menuEntry: ObjectiveMenuEntry, objectiveMin: ObjectiveMin) {
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/app/shared/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,7 @@ export function hasFormFieldErrors(formGroup: FormGroup, field: string) {
return false;
}
}

export function getStateByValue(value: string): string {
return Object.keys(State).find((key) => State[key as keyof typeof State] === value) ?? '';
}
7 changes: 2 additions & 5 deletions frontend/src/assets/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@
"ordinal": "Ordinal"
},
"INFORMATION": {
"OBJECTIVE_STATE_TOOLTIP": "Der Status dieses Objectives ist",
"DELETE_TEAM": "Möchtest du dieses Team wirklich löschen? Zugehörige Objectives werden dadurch in allen Quartalen ebenfalls gelöscht!",
"DELETE_OBJECTIVE": "Möchtest du dieses Objective wirklich löschen? Zugehörige Key Results werden dadurch ebenfalls gelöscht!",
"DELETE_KEY_RESULT": "Möchtest du dieses Key Result wirklich löschen? Zugehörige Check-ins werden dadurch ebenfalls gelöscht!"
"OBJECTIVE_STATE_TOOLTIP": "Der Status dieses Objectives ist: {{state}}"
},
"CONFIRMATION": {
"DRAFT_CREATE": {
Expand Down Expand Up @@ -58,7 +55,7 @@
"TITLE": "Objective löschen",
"TEXT": "Möchtest du dieses Objective wirklich löschen? Zugehörige Key Results werden dadurch ebenfalls gelöscht!"
},
"KEYRESULT":{
"KEY_RESULT":{
"TITLE": "Key Result löschen\n",
"TEXT": "Möchtest du dieses Key Result wirklich löschen? Zugehörige Check-ins werden dadurch ebenfalls gelöscht!"
}
Expand Down

0 comments on commit e0d85ea

Please sign in to comment.