milestone dans tableau issue
This commit is contained in:
@@ -7,6 +7,7 @@ import { marked } from 'marked';
|
||||
import { IssueEntity, IssuesStore } from '../issues.store';
|
||||
import { IssueComments } from '../issue-comments/issue-comments';
|
||||
import { handleImagePaste, insertAtSelection } from '../paste-image.util';
|
||||
import { MilestoneEntity, MilestonesStore } from '../../milestones/milestones.store';
|
||||
|
||||
@Component({
|
||||
selector: 'app-issue-detail',
|
||||
@@ -18,11 +19,13 @@ export class IssueDetail {
|
||||
private readonly route = inject(ActivatedRoute);
|
||||
private readonly router = inject(Router);
|
||||
private readonly issuesStore = inject(IssuesStore);
|
||||
private readonly milestonesStore = inject(MilestonesStore);
|
||||
private readonly sanitizer = inject(DomSanitizer);
|
||||
protected readonly isNewIssueRoute = this.route.snapshot.routeConfig?.path === 'issues/new';
|
||||
|
||||
protected issue: IssueEntity = this.buildIssue();
|
||||
protected readonly issues = this.issuesStore.issues;
|
||||
protected readonly milestones = this.milestonesStore.milestones;
|
||||
protected moreMenuOpen = false;
|
||||
protected statusMenuOpen = false;
|
||||
|
||||
@@ -30,6 +33,7 @@ export class IssueDetail {
|
||||
const idParam = this.route.snapshot.paramMap.get('id');
|
||||
const safeId = Number(idParam ?? 0);
|
||||
|
||||
this.milestonesStore.load();
|
||||
this.issuesStore.load().then(() => {
|
||||
if (safeId) {
|
||||
const found = this.issuesStore.getById(safeId);
|
||||
@@ -280,6 +284,37 @@ export class IssueDetail {
|
||||
}
|
||||
}
|
||||
|
||||
protected get currentMilestone(): MilestoneEntity | undefined {
|
||||
return this.milestones().find((m) => m.issueIds.includes(this.issue.id));
|
||||
}
|
||||
|
||||
protected get currentMilestoneId(): number | null {
|
||||
return this.currentMilestone?.id ?? null;
|
||||
}
|
||||
|
||||
protected async onMilestoneChange(newMilestoneId: number | null): Promise<void> {
|
||||
if (this.isNewIssueRoute) return;
|
||||
const previous = this.currentMilestone;
|
||||
if (previous) {
|
||||
await this.milestonesStore.upsert({
|
||||
...previous,
|
||||
issueIds: previous.issueIds.filter((id) => id !== this.issue.id),
|
||||
});
|
||||
}
|
||||
if (newMilestoneId !== null) {
|
||||
const target = this.milestones().find((m) => m.id === newMilestoneId);
|
||||
if (target) {
|
||||
await this.milestonesStore.upsert({ ...target, issueIds: [...target.issueIds, this.issue.id] });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected navigateToMilestone(): void {
|
||||
if (this.currentMilestoneId !== null) {
|
||||
this.router.navigate(['/milestones', this.currentMilestoneId]);
|
||||
}
|
||||
}
|
||||
|
||||
protected async saveIssue(explicit = false): Promise<void> {
|
||||
if (this.isNewIssueRoute && !explicit) return;
|
||||
if (!this.issue.name.trim()) return;
|
||||
|
||||
Reference in New Issue
Block a user