Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug/616-enable-disable-buttons #656

Merged
merged 3 commits into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions frontend/src/app/objective/objective.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
/>
<header class="title col-10 ps-2">{{ objective.title }}</header>
<button
#menuButton
*ngIf="isWritable"
class="icon-button three-dot-menu"
[matMenuTriggerFor]="objectiveMenu"
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/app/objective/objective.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ChangeDetectionStrategy, Component, Input, OnInit } from '@angular/core';
import { ChangeDetectionStrategy, Component, ElementRef, Input, OnInit, ViewChild } from '@angular/core';
import { MenuEntry } from '../shared/types/menu-entry';
import { ObjectiveMin } from '../shared/types/model/ObjectiveMin';
import { Router } from '@angular/router';
Expand Down Expand Up @@ -29,6 +29,7 @@ export class ObjectiveComponent implements OnInit {
menuEntries: MenuEntry[] = [];
isComplete: boolean = false;
protected readonly trackByFn = trackByFn;
@ViewChild('menuButton') private menuButton!: ElementRef;

constructor(
private matDialog: MatDialog,
Expand Down Expand Up @@ -160,6 +161,7 @@ export class ObjectiveComponent implements OnInit {
maxWidth: dialogConfig.maxWidth,
});
matDialogRef.afterClosed().subscribe((result) => {
this.menuButton.nativeElement.focus();
if (result) {
this.handleDialogResult(menuEntry, result);
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/app/team/team.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
>
<app-objective-column
id="objective-column"
*ngFor="let objective of OVEntity.objectives; trackBy: trackByFn"
*ngFor="let objective of OVEntity.objectives; trackBy: trackByObjectiveId"
[objective]="objective"
[isWritable]="OVEntity.team.writable"
class="col-xs-12 col-md-4 p-0 column-width"
Expand Down
17 changes: 10 additions & 7 deletions frontend/src/app/team/team.component.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
import { ChangeDetectionStrategy, Component, Input, TrackByFunction } from '@angular/core';
import { OverviewEntity } from '../shared/types/model/OverviewEntity';
import { MatDialog } from '@angular/material/dialog';
import { ObjectiveFormComponent } from '../shared/dialog/objective-dialog/objective-form.component';
import { BehaviorSubject, ReplaySubject } from 'rxjs';
import { RefreshDataService } from '../shared/services/refresh-data.service';
import { Objective } from '../shared/types/model/Objective';
import { isMobileDevice, optionalReplaceWithNulls, trackByFn } from '../shared/common';
import { isMobileDevice, optionalReplaceWithNulls } from '../shared/common';
import { TeamManagementComponent } from '../shared/dialog/team-management/team-management.component';
import { TeamMin } from '../shared/types/model/TeamMin';
import { KeyresultDialogComponent } from '../shared/dialog/keyresult-dialog/keyresult-dialog.component';
import { ActivatedRoute, Router } from '@angular/router';
import { CloseState } from '../shared/types/enums/CloseState';
import { ObjectiveMin } from '../shared/types/model/ObjectiveMin';

@Component({
selector: 'app-team',
Expand All @@ -20,7 +21,7 @@ import { CloseState } from '../shared/types/enums/CloseState';
})
export class TeamComponent {
private overviewEntity$ = new BehaviorSubject<OverviewEntity>({} as OverviewEntity);
protected readonly trackByFn = trackByFn;
trackByObjectiveId: TrackByFunction<ObjectiveMin> = (index, objective) => objective.id;

@Input()
hasAdminAccess!: ReplaySubject<boolean>;
Expand Down Expand Up @@ -129,10 +130,12 @@ export class TeamComponent {
},
});
dialog.afterClosed().subscribe((result) => {
if (result.state == CloseState.DELETED) {
this.removeTeam(result.id).then(() => this.refreshDataService.markDataRefresh());
} else {
this.refreshDataService.markDataRefresh();
if (result) {
if (result.state == CloseState.DELETED) {
this.removeTeam(result.id).then(() => this.refreshDataService.markDataRefresh());
} else {
this.refreshDataService.markDataRefresh();
}
}
});
}
Expand Down
Loading