diff --git a/src/app/group/components/group-edit/group-edit.component.ts b/src/app/group/components/group-edit/group-edit.component.ts index e14e518..0692ddf 100644 --- a/src/app/group/components/group-edit/group-edit.component.ts +++ b/src/app/group/components/group-edit/group-edit.component.ts @@ -25,7 +25,7 @@ export class GroupEditComponent implements OnInit { ngOnInit(): void { this.currentUserId = localStorage.getItem('userId'); - this.groupId = this.activatedRoute.snapshot.params['groupId']; + this.groupId = this.activatedRoute.snapshot.params.groupId; this.group$ = this.groupService.getGroup(this.groupId); this.groupCandidates$ = this.groupCandidateService.getList(this.groupId); } diff --git a/src/app/subject/components/subject-edit/subject-edit.component.html b/src/app/subject/components/subject-edit/subject-edit.component.html index 2db178a..7203485 100644 --- a/src/app/subject/components/subject-edit/subject-edit.component.html +++ b/src/app/subject/components/subject-edit/subject-edit.component.html @@ -1,3 +1,8 @@ +
+
+

Subject is edited by another user

+
+
@@ -87,5 +92,8 @@
+
+ +
diff --git a/src/app/subject/components/subject-edit/subject-edit.component.scss b/src/app/subject/components/subject-edit/subject-edit.component.scss index bbc38e4..8ddd9ee 100644 --- a/src/app/subject/components/subject-edit/subject-edit.component.scss +++ b/src/app/subject/components/subject-edit/subject-edit.component.scss @@ -2,4 +2,8 @@ .subject-form { width: 80%; } +} + +.edit-warning { + width: 80%; } \ No newline at end of file diff --git a/src/app/subject/components/subject-edit/subject-edit.component.ts b/src/app/subject/components/subject-edit/subject-edit.component.ts index 5a026ed..beeace0 100644 --- a/src/app/subject/components/subject-edit/subject-edit.component.ts +++ b/src/app/subject/components/subject-edit/subject-edit.component.ts @@ -27,7 +27,7 @@ export class SubjectEditComponent implements OnInit { private router: Router) { } ngOnInit(): void { - this.groupId = this.activatedRoute.snapshot.params['groupId']; + this.groupId = this.activatedRoute.snapshot.params.groupId; this.subject = this.createEmptySubject(); this.subjectForm = this.createSubjectForm(); this.subjectId = this.activatedRoute.snapshot.params.id; @@ -43,6 +43,16 @@ export class SubjectEditComponent implements OnInit { } } + backToGroup(): void { + if (this.editable) { + this.subjectService.unlock(this.subjectId).subscribe(() => { + this.router.navigateByUrl('/group/edit/' + this.groupId); + }); + } else { + this.router.navigateByUrl('/group/edit/' + this.groupId); + } + } + createEmptySubject(): Subject { return { id: null, diff --git a/src/app/subject/components/subject-main/subject-main.component.ts b/src/app/subject/components/subject-main/subject-main.component.ts index 46386ff..0b2019c 100644 --- a/src/app/subject/components/subject-main/subject-main.component.ts +++ b/src/app/subject/components/subject-main/subject-main.component.ts @@ -63,7 +63,7 @@ export class SubjectMainComponent implements OnInit { } onEditSubject(id: number): void { - this.router.navigateByUrl(`subject/edit/${id}/${this.userId}`); + this.router.navigateByUrl(`subject/edit/${this.groupId}/${id}`); } onUnlockSubject(id: number): void { diff --git a/src/app/subject/subject-routing.module.ts b/src/app/subject/subject-routing.module.ts index fc138fc..b01bd81 100644 --- a/src/app/subject/subject-routing.module.ts +++ b/src/app/subject/subject-routing.module.ts @@ -12,7 +12,7 @@ const routes: Routes = [ children: [ { path: '', component: SubjectMainComponent }, { path: 'new-subject/:groupId', component: SubjectEditComponent }, - { path: 'edit/:id/:groupId', component: SubjectEditComponent } + { path: 'edit/:groupId/:id', component: SubjectEditComponent } ] } ];