fixed errors
This commit is contained in:
parent
83d84ee5fd
commit
24be14bef5
@ -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);
|
||||
}
|
||||
|
@ -1,3 +1,8 @@
|
||||
<div class="d-flex justify-content-center">
|
||||
<div *ngIf="!editable" class="edit-warning">
|
||||
<p class="text-danger">Subject is edited by another user</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="subject-form-container d-flex justify-content-center">
|
||||
<form [formGroup]="subjectForm" class="subject-form d-flex flex-column mt-5">
|
||||
<mat-form-field>
|
||||
@ -87,5 +92,8 @@
|
||||
<div class="mt-4">
|
||||
<button [disabled]="!editable" (click)="onSubjectSave()" class="btn btn-primary">Save</button>
|
||||
</div>
|
||||
<div class="mt-4">
|
||||
<button (click)="backToGroup()" class="btn btn-primary">Back to group</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
@ -3,3 +3,7 @@
|
||||
width: 80%;
|
||||
}
|
||||
}
|
||||
|
||||
.edit-warning {
|
||||
width: 80%;
|
||||
}
|
@ -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,
|
||||
|
@ -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 {
|
||||
|
@ -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 }
|
||||
]
|
||||
}
|
||||
];
|
||||
|
Loading…
Reference in New Issue
Block a user