Skip to content

Commit

Permalink
refactor dialog header
Browse files Browse the repository at this point in the history
  • Loading branch information
kcinay055679 committed Oct 22, 2024
1 parent 5ad70e4 commit 7758312
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 28 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<section mat-dialog-title>
<app-dialog-header *ngIf="!this.checkIn.id" [dialogTitle]="'Check-in erfassen'"></app-dialog-header>
<app-dialog-header *ngIf="this.checkIn.id" [dialogTitle]="'Check-in bearbeiten'"></app-dialog-header>
<app-dialog-header [dialogTitle]="getDialogTitle()"></app-dialog-header>
</section>

<mat-dialog-content>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,8 @@ export class CheckInFormComponent implements OnInit {
actions[index] = { ...actions[index], isChecked: event.checked };
this.dialogForm.patchValue({ actionList: actions });
}

getDialogTitle(): string {
return this.checkIn.id ? 'Check-in bearbeiten' : 'Check-in erfassen';
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
<section mat-dialog-title>
<app-dialog-header
[dialogTitle]="data.keyResult ? 'Key Result bearbeiten' : 'Key Result erfassen'"
></app-dialog-header>
</section>
<app-dialog-header mat-dialog-title [dialogTitle]="getDialogTitle()"></app-dialog-header>

<mat-dialog-content>
<div class="d-flex flex-column scroll-shadows">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,8 @@ export class KeyresultDialogComponent {
(typeof this.keyResultForm.value.owner === 'string' || !this.keyResultForm.value.owner)
);
}

getDialogTitle(): string {
return this.data.keyResult ? 'Key Result bearbeiten' : 'Key Result erfassen';
}
}
Original file line number Diff line number Diff line change
@@ -1,23 +1,7 @@
<section mat-dialog-title>
<div *ngIf="this.data.action == 'duplicate'">
<app-dialog-header
[dialogTitle]="'Objective von ' + (this.currentTeam | async)?.name + ' duplizieren'"
></app-dialog-header>
</div>
<div *ngIf="this.data.action == 'releaseBacklog'">
<app-dialog-header [dialogTitle]="'Objective veröffentlichen'"></app-dialog-header>
</div>
<div *ngIf="this.data.action != 'duplicate'">
<app-dialog-header
*ngIf="!data.objective.objectiveId"
[dialogTitle]="'Objective für ' + (this.currentTeam | async)?.name + ' erfassen'"
></app-dialog-header>
<app-dialog-header
*ngIf="data.objective.objectiveId && this.data.action != 'releaseBacklog'"
[dialogTitle]="'Objective von ' + (this.currentTeam | async)?.name + ' bearbeiten'"
></app-dialog-header>
</div>
</section>
<app-dialog-header
mat-dialog-title
[dialogTitle]="getDialogTitle((this.currentTeam | async)?.name || '')"
></app-dialog-header>

<mat-dialog-content>
<form [formGroup]="objectiveForm">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,5 +216,25 @@ export class ObjectiveFormComponent implements OnInit, OnDestroy {
return GJ_REGEX_PATTERN.test(label);
}

getDialogTitle(teamName: string): string {
if (this.data.action === 'duplicate') {
return `Objective von ${teamName} duplizieren`;
}

if (this.data.action === 'releaseBacklog') {
return 'Objective veröffentlichen';
}

if (!this.data.objective.objectiveId) {
return `Objective für ${teamName} erfassen`;
}

if (this.data.objective.objectiveId && this.data.action !== 'releaseBacklog') {
return `Objective von ${teamName} bearbeiten`;
}

return '';
}

protected readonly getQuarterLabel = getQuarterLabel;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<app-dialog-header mat-dialog-title [dialogTitle]="data ? 'Team bearbeiten' : 'Team erfassen'"></app-dialog-header>
<app-dialog-header mat-dialog-title [dialogTitle]="getDialogTitle()"></app-dialog-header>

<mat-dialog-content>
<form [formGroup]="teamForm" class="okr-dialog-form">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,8 @@ export class AddEditTeamDialog implements OnInit {
getErrorMessage(error: string, field: string, firstNumber: number | null, secondNumber: number | null): string {
return field + this.translate.instant('DIALOG_ERRORS.' + error).format(firstNumber, secondNumber);
}

getDialogTitle(): string {
return this.data ? 'Team bearbeiten' : 'Team erfassen';
}
}

0 comments on commit 7758312

Please sign in to comment.