Modification ajoute de dépendence

This commit is contained in:
2026-05-23 08:50:03 +02:00
parent eeb648addd
commit b3f25369be
3 changed files with 124 additions and 41 deletions
+34 -21
View File
@@ -18,6 +18,8 @@ export class IssueDetail {
protected issue: IssueEntity = this.buildIssue();
protected readonly issues = this.issuesStore.issues;
protected moreMenuOpen = false;
protected showAddDependency = false;
protected selectedCandidateId: number | null = null;
protected readonly statusOptions: IssueEntity['status'][] = [
'draft',
@@ -39,10 +41,38 @@ export class IssueDetail {
return this.issue.dependsOnIds;
}
protected set dependencyIds(value: number[]) {
this.issue.dependsOnIds = Array.isArray(value)
? value.filter((dependencyId): dependencyId is number => typeof dependencyId === 'number')
: [];
protected get availableCandidates(): IssueEntity[] {
return this.issues().filter(
(issue) => issue.id !== this.issue.id && !this.issue.dependsOnIds.includes(issue.id),
);
}
protected resolveDependency(id: number): IssueEntity | undefined {
return this.issues().find((issue) => issue.id === id);
}
protected openAddDependency(): void {
this.selectedCandidateId = null;
this.showAddDependency = true;
}
protected cancelAddDependency(): void {
this.showAddDependency = false;
this.selectedCandidateId = null;
}
protected confirmAddDependency(): void {
if (this.selectedCandidateId !== null) {
this.issue.dependsOnIds = [...this.issue.dependsOnIds, this.selectedCandidateId];
this.saveIssue();
}
this.showAddDependency = false;
this.selectedCandidateId = null;
}
protected removeDependency(id: number): void {
this.issue.dependsOnIds = this.issue.dependsOnIds.filter((depId) => depId !== id);
this.saveIssue();
}
protected get estimatedTimeValue(): number | null {
@@ -102,23 +132,6 @@ export class IssueDetail {
this.moreMenuOpen = false;
}
protected resolveDependencyLabels(issueIds: number[]): string {
if (issueIds.length === 0) {
return '-';
}
return issueIds
.map((issueId) => this.issues().find((issue) => issue.id === issueId))
.filter((issue): issue is IssueEntity => Boolean(issue))
.map((issue) => `#${issue.id} - ${issue.name || 'Sans nom'}`)
.join(', ');
}
protected get dependencyCandidates(): IssueEntity[] {
return this.issues().filter((issue) => issue.id !== this.issue.id);
}
private buildIssue(): IssueEntity {
const idParam = this.route.snapshot.paramMap.get('id');
const draftId = this.route.snapshot.queryParamMap.get('draftId');