diff --git a/src/app/group/group-routing.module.ts b/src/app/group/group-routing.module.ts
index e05f7fb..91e92f3 100644
--- a/src/app/group/group-routing.module.ts
+++ b/src/app/group/group-routing.module.ts
@@ -8,7 +8,7 @@ import { NewGroupComponent } from './components/new-group/new-group.component';
const routes: Routes = [
{ path: '', component: GroupMainComponent },
{ path: 'add-new', component: NewGroupComponent },
- { path: 'edit/:id', component: GroupEditComponent }
+ { path: 'edit/:groupId', component: GroupEditComponent }
];
@NgModule({
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 a594619..0995266 100644
--- a/src/app/subject/components/subject-edit/subject-edit.component.ts
+++ b/src/app/subject/components/subject-edit/subject-edit.component.ts
@@ -17,12 +17,14 @@ export class SubjectEditComponent implements OnInit {
subject: Subject;
subjectForm: FormGroup;
subjectId: number;
+ groupId: number;
constructor(private activatedRoute: ActivatedRoute,
private subjectService: SubjectService,
private router: Router) { }
ngOnInit(): void {
+ this.groupId = this.activatedRoute.snapshot.params['groupId'];
this.subject = this.createEmptySubject();
this.subjectForm = this.createSubjectForm();
this.subjectId = this.activatedRoute.snapshot.params.id;
@@ -37,6 +39,7 @@ export class SubjectEditComponent implements OnInit {
createEmptySubject(): Subject {
return {
id: null,
+ groupId: this.groupId,
name: '',
lectureTeacher: '',
labTeacher: '',
@@ -51,6 +54,7 @@ export class SubjectEditComponent implements OnInit {
createSubjectForm(): FormGroup {
return new FormGroup({
id: new FormControl(null),
+ groupId: new FormControl(this.groupId),
name: new FormControl('', Validators.required),
lectureTeacher: new FormControl(''),
labTeacher: new FormControl(''),
@@ -138,11 +142,11 @@ export class SubjectEditComponent implements OnInit {
onSubjectSave(): void {
if (this.subjectId) {
this.subjectService.update(this.subjectForm.value).subscribe(() => {
- this.router.navigateByUrl('/');
+ this.router.navigateByUrl('/group/edit/' + this.groupId);
});
} else {
this.subjectService.add(this.subjectForm.value).subscribe(() => {
- this.router.navigateByUrl('/');
+ this.router.navigateByUrl('/group/edit/' + this.groupId);
});
}
}
diff --git a/src/app/subject/components/subject-list/subject-list.component.html b/src/app/subject/components/subject-list/subject-list.component.html
index e0812d8..1bd4d5b 100644
--- a/src/app/subject/components/subject-list/subject-list.component.html
+++ b/src/app/subject/components/subject-list/subject-list.component.html
@@ -1,4 +1,4 @@
-
+
@@ -23,8 +23,8 @@
-
-
+
+
diff --git a/src/app/subject/components/subject-list/subject-list.component.ts b/src/app/subject/components/subject-list/subject-list.component.ts
index 51719e3..136787d 100644
--- a/src/app/subject/components/subject-list/subject-list.component.ts
+++ b/src/app/subject/components/subject-list/subject-list.component.ts
@@ -9,6 +9,8 @@ import { Subject } from '../../interfaces/subject.interface';
export class ListComponent implements OnInit {
@Input() subjects: Subject[];
+ @Input() userId: string;
+ @Input() adminId: string;
@Output() deleteRequest = new EventEmitter
();
@Output() deleteSubject = new EventEmitter();
@Output() addNewSubject = new EventEmitter();
diff --git a/src/app/subject/components/subject-main/subject-main.component.html b/src/app/subject/components/subject-main/subject-main.component.html
index e2936c4..9e49c68 100644
--- a/src/app/subject/components/subject-main/subject-main.component.html
+++ b/src/app/subject/components/subject-main/subject-main.component.html
@@ -1,16 +1,28 @@
-
-
-
-
-
-
+
+
+
+
+
+
0">
+
Subjects delete requests:
+
+
+
+
+
diff --git a/src/app/subject/components/subject-main/subject-main.component.scss b/src/app/subject/components/subject-main/subject-main.component.scss
index 0060a27..e69de29 100644
--- a/src/app/subject/components/subject-main/subject-main.component.scss
+++ b/src/app/subject/components/subject-main/subject-main.component.scss
@@ -1,3 +0,0 @@
-.lists-container {
- width: 80%;
-}
\ No newline at end of file
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 e03d8fd..931ffe5 100644
--- a/src/app/subject/components/subject-main/subject-main.component.ts
+++ b/src/app/subject/components/subject-main/subject-main.component.ts
@@ -14,6 +14,8 @@ import { Router } from '@angular/router';
export class SubjectMainComponent implements OnInit {
@Input() groupId: number;
+ @Input() adminId: string;
+ userId: string;
subjects$: Observable
;
subjectDeleteRequests$: Observable;
@@ -22,12 +24,13 @@ export class SubjectMainComponent implements OnInit {
private subjectDeleteRequestService: SubjectDeleteRequestService) { }
ngOnInit(): void {
- this.subjects$ = this.subjectService.getListByGroupId(Number(localStorage.getItem('userId')));
+ this.userId = localStorage.getItem('userId');
+ this.subjects$ = this.subjectService.getListByGroupId(Number(this.groupId));
this.subjectDeleteRequests$ = this.subjectDeleteRequestService.getListByGroupId(this.groupId);
}
onAddNewSubject(): void {
- this.router.navigateByUrl('/new-subject');
+ this.router.navigateByUrl('/subject/new-subject/' + this.groupId);
}
onApproveDeletion(deletionRequestId: number): void {
@@ -60,7 +63,7 @@ export class SubjectMainComponent implements OnInit {
}
onEditSubject(id: number): void {
- this.router.navigateByUrl(`/edit/${id}`);
+ this.router.navigateByUrl(`subject/edit/${id}/${this.groupId}`);
}
}
diff --git a/src/app/subject/interfaces/subject.interface.ts b/src/app/subject/interfaces/subject.interface.ts
index 9631b68..189adca 100644
--- a/src/app/subject/interfaces/subject.interface.ts
+++ b/src/app/subject/interfaces/subject.interface.ts
@@ -4,6 +4,7 @@ import { Comment } from './comment.interface';
export interface Subject {
id?: number;
+ groupId?: number;
name: string;
lectureTeacher: string;
labTeacher: string;
diff --git a/src/app/subject/subject-routing.module.ts b/src/app/subject/subject-routing.module.ts
index 1f4abf2..0f2afd0 100644
--- a/src/app/subject/subject-routing.module.ts
+++ b/src/app/subject/subject-routing.module.ts
@@ -6,8 +6,8 @@ import { SubjectEditComponent } from './components/subject-edit/subject-edit.com
const routes: Routes = [
{ path: '', component: SubjectMainComponent },
- { path: 'new-subject', component: SubjectEditComponent },
- { path: 'edit/:id', component: SubjectEditComponent }
+ { path: 'new-subject/:groupId', component: SubjectEditComponent },
+ { path: 'edit/:id/:groupId', component: SubjectEditComponent }
];
@NgModule({