From 0c2f63c57a0c3465d5a5b1a26604b1493a70e473 Mon Sep 17 00:00:00 2001 From: JakubWalkowiak Date: Tue, 29 Dec 2020 22:56:35 +0100 Subject: [PATCH] fixed problems with groups --- .../group-candidates.component.html | 2 +- .../group-edit/group-edit.component.html | 41 ++++++++++++------- .../group-edit/group-edit.component.scss | 7 ++++ .../group-edit/group-edit.component.ts | 8 ++-- .../group-list/group-list.component.html | 2 +- .../group-users/group-users.component.html | 2 +- src/app/group/group-routing.module.ts | 2 +- .../subject-edit/subject-edit.component.ts | 8 +++- .../subject-list/subject-list.component.html | 6 +-- .../subject-list/subject-list.component.ts | 2 + .../subject-main/subject-main.component.html | 40 +++++++++++------- .../subject-main/subject-main.component.scss | 3 -- .../subject-main/subject-main.component.ts | 9 ++-- .../subject/interfaces/subject.interface.ts | 1 + src/app/subject/subject-routing.module.ts | 4 +- 15 files changed, 87 insertions(+), 50 deletions(-) diff --git a/src/app/group/components/group-candidates/group-candidates.component.html b/src/app/group/components/group-candidates/group-candidates.component.html index f7240a0..e6f2369 100644 --- a/src/app/group/components/group-candidates/group-candidates.component.html +++ b/src/app/group/components/group-candidates/group-candidates.component.html @@ -1,4 +1,4 @@ -
+
diff --git a/src/app/group/components/group-edit/group-edit.component.html b/src/app/group/components/group-edit/group-edit.component.html index b7b3cdb..8058aa2 100644 --- a/src/app/group/components/group-edit/group-edit.component.html +++ b/src/app/group/components/group-edit/group-edit.component.html @@ -1,20 +1,31 @@ -
-
- - -
-
-
- Name: {{ group.name }} +
+
+
+ +
-
- Year: {{ group.year }} +
+

Group info:

+
+ Name: {{ group.name }} +
+
+ Year: {{ group.year }} +
+
+ Admin: {{ group.admin.fullName }} ({{group.admin.userName}}) +
-
- Admin: {{ group.admin.fullName }} ({{group.admin.userName}}) +
+ +
+
+

Users:

+ +
+
+

Group candidates:

+
- - -
diff --git a/src/app/group/components/group-edit/group-edit.component.scss b/src/app/group/components/group-edit/group-edit.component.scss index e69de29..cdf8ba6 100644 --- a/src/app/group/components/group-edit/group-edit.component.scss +++ b/src/app/group/components/group-edit/group-edit.component.scss @@ -0,0 +1,7 @@ +h3 { + font-weight: 500; +} + +.edit-group-wrapper { + width: 80%; +} \ No newline at end of file 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 97da66b..358ebec 100644 --- a/src/app/group/components/group-edit/group-edit.component.ts +++ b/src/app/group/components/group-edit/group-edit.component.ts @@ -1,4 +1,4 @@ -import { ActivatedRouteSnapshot, Router } from '@angular/router'; +import { Router, ActivatedRoute } from '@angular/router'; import { GroupService } from './../../services/group.service'; import { Component, OnInit } from '@angular/core'; import { Group } from '../../interfaces/group.interface'; @@ -16,12 +16,12 @@ export class GroupEditComponent implements OnInit { groupId: number; constructor(private groupService: GroupService, - private activatedRouteSnapshot: ActivatedRouteSnapshot, - private router: Router) { } + private activatedRoute: ActivatedRoute, + private router: Router) { } ngOnInit(): void { this.userId = localStorage.getItem('userId'); - this.groupId = this.activatedRouteSnapshot.params['groupId']; + this.groupId = this.activatedRoute.snapshot.params['groupId']; this.group$ = this.groupService.getGroup(this.groupId); } diff --git a/src/app/group/components/group-list/group-list.component.html b/src/app/group/components/group-list/group-list.component.html index 71872f8..b2a6901 100644 --- a/src/app/group/components/group-list/group-list.component.html +++ b/src/app/group/components/group-list/group-list.component.html @@ -1,4 +1,4 @@ -
+
diff --git a/src/app/group/components/group-users/group-users.component.html b/src/app/group/components/group-users/group-users.component.html index 09b8ffe..1eba419 100644 --- a/src/app/group/components/group-users/group-users.component.html +++ b/src/app/group/components/group-users/group-users.component.html @@ -1,4 +1,4 @@ -
+
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 @@ -
-
- - - - +
+
+
+

Subjects:

+ + +
+
+
+
+

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({