auth
This commit is contained in:
@@ -25,6 +25,16 @@ export class IssueDetail {
|
||||
protected moreMenuOpen = false;
|
||||
|
||||
constructor() {
|
||||
const idParam = this.route.snapshot.paramMap.get('id');
|
||||
const safeId = Number(idParam ?? 0);
|
||||
|
||||
this.issuesStore.load().then(() => {
|
||||
if (safeId) {
|
||||
const found = this.issuesStore.getById(safeId);
|
||||
if (found) this.issue = { ...found };
|
||||
}
|
||||
});
|
||||
|
||||
this.route.paramMap.pipe(takeUntilDestroyed()).subscribe((params) => {
|
||||
const id = Number(params.get('id'));
|
||||
if (!id || isNaN(id)) return;
|
||||
@@ -38,6 +48,7 @@ export class IssueDetail {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected showAddDependency = false;
|
||||
protected selectedCandidateId: number | null = null;
|
||||
protected editingDescription = false;
|
||||
@@ -86,18 +97,18 @@ export class IssueDetail {
|
||||
this.selectedCandidateId = null;
|
||||
}
|
||||
|
||||
protected confirmAddDependency(): void {
|
||||
protected async confirmAddDependency(): Promise<void> {
|
||||
if (this.selectedCandidateId !== null) {
|
||||
this.issue.dependsOnIds = [...this.issue.dependsOnIds, this.selectedCandidateId];
|
||||
this.saveIssue();
|
||||
await this.saveIssue();
|
||||
}
|
||||
this.showAddDependency = false;
|
||||
this.selectedCandidateId = null;
|
||||
}
|
||||
|
||||
protected removeDependency(id: number): void {
|
||||
protected async removeDependency(id: number): Promise<void> {
|
||||
this.issue.dependsOnIds = this.issue.dependsOnIds.filter((depId) => depId !== id);
|
||||
this.saveIssue();
|
||||
await this.saveIssue();
|
||||
}
|
||||
|
||||
protected get estimatedTimeValue(): number | null {
|
||||
@@ -146,11 +157,11 @@ export class IssueDetail {
|
||||
this.newIssueName = '';
|
||||
}
|
||||
|
||||
protected confirmCreateInEpic(): void {
|
||||
protected async confirmCreateInEpic(): Promise<void> {
|
||||
const name = this.newIssueName.trim();
|
||||
if (!name) return;
|
||||
this.issuesStore.upsert({
|
||||
id: this.issuesStore.getNextId(),
|
||||
await this.issuesStore.upsert({
|
||||
id: 0,
|
||||
type: 'Story',
|
||||
assignee: '',
|
||||
epic: this.issue.name,
|
||||
@@ -178,11 +189,11 @@ export class IssueDetail {
|
||||
this.selectedEpicCandidateId = null;
|
||||
}
|
||||
|
||||
protected confirmAddToEpic(): void {
|
||||
protected async confirmAddToEpic(): Promise<void> {
|
||||
if (this.selectedEpicCandidateId !== null) {
|
||||
const target = this.issues().find((i) => i.id === this.selectedEpicCandidateId);
|
||||
if (target) {
|
||||
this.issuesStore.upsert({ ...target, epic: this.issue.name });
|
||||
await this.issuesStore.upsert({ ...target, epic: this.issue.name });
|
||||
}
|
||||
}
|
||||
this.showAddToEpic = false;
|
||||
@@ -229,12 +240,13 @@ export class IssueDetail {
|
||||
}
|
||||
}
|
||||
|
||||
protected saveIssue(explicit = false): void {
|
||||
protected async saveIssue(explicit = false): Promise<void> {
|
||||
if (this.isNewIssueRoute && !explicit) return;
|
||||
if (!this.issue.name.trim()) return;
|
||||
this.issuesStore.upsert(this.issue);
|
||||
const saved = await this.issuesStore.upsert(this.issue);
|
||||
this.issue = { ...saved };
|
||||
if (this.isNewIssueRoute) {
|
||||
this.router.navigate(['/issues', this.issue.id]);
|
||||
this.router.navigate(['/issues', saved.id]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -242,14 +254,15 @@ export class IssueDetail {
|
||||
this.router.navigate(['/issues']);
|
||||
}
|
||||
|
||||
protected deleteIssue(): void {
|
||||
this.issuesStore.deleteById(this.issue.id);
|
||||
protected async deleteIssue(): Promise<void> {
|
||||
await this.issuesStore.deleteById(this.issue.id);
|
||||
this.router.navigate(['/issues']);
|
||||
}
|
||||
|
||||
protected updateStatus(status: IssueEntity['status']): void {
|
||||
protected async updateStatus(status: IssueEntity['status']): Promise<void> {
|
||||
this.issue.status = status;
|
||||
this.issuesStore.upsert(this.issue);
|
||||
const saved = await this.issuesStore.upsert(this.issue);
|
||||
this.issue = { ...saved };
|
||||
}
|
||||
|
||||
protected toggleMoreMenu(): void {
|
||||
@@ -262,15 +275,11 @@ export class IssueDetail {
|
||||
|
||||
private buildIssue(): IssueEntity {
|
||||
const idParam = this.route.snapshot.paramMap.get('id');
|
||||
const draftId = this.route.snapshot.queryParamMap.get('draftId');
|
||||
const isNewIssueRoute = this.route.snapshot.routeConfig?.path === 'issues/new';
|
||||
|
||||
const resolvedId = Number(idParam ?? draftId ?? 0);
|
||||
const safeId = Number.isNaN(resolvedId) ? 0 : resolvedId;
|
||||
|
||||
if (isNewIssueRoute) {
|
||||
return {
|
||||
id: safeId,
|
||||
id: 0,
|
||||
type: 'Story',
|
||||
assignee: '',
|
||||
epic: '',
|
||||
@@ -286,6 +295,7 @@ export class IssueDetail {
|
||||
};
|
||||
}
|
||||
|
||||
const safeId = Number(idParam ?? 0);
|
||||
const existingIssue = this.issuesStore.getById(safeId);
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user