diff --git a/backend/src/models/course.model.ts b/backend/src/models/course.model.ts
index 39d7fd5..2d38e8c 100644
--- a/backend/src/models/course.model.ts
+++ b/backend/src/models/course.model.ts
@@ -1,4 +1,4 @@
-import { Entity, model, property, belongsTo, hasMany } from '@loopback/repository';
+import { belongsTo, Entity, hasMany, model, property } from '@loopback/repository';
import { Subject } from './subject.model';
import { User } from './user.model';
import { CourseUser } from './course-user.model';
@@ -19,6 +19,12 @@ export class Course extends Entity {
})
semester: string;
+ @property({
+ type: 'string',
+ required: true,
+ })
+ alias: string;
+
@belongsTo(() => Subject)
subjectId: number;
diff --git a/frontend/src/app/app.component.html b/frontend/src/app/app.component.html
index c9de255..cdf9e56 100644
--- a/frontend/src/app/app.component.html
+++ b/frontend/src/app/app.component.html
@@ -35,7 +35,7 @@
-
+
diff --git a/frontend/src/app/app.component.ts b/frontend/src/app/app.component.ts
index 291dc10..92280e6 100644
--- a/frontend/src/app/app.component.ts
+++ b/frontend/src/app/app.component.ts
@@ -31,6 +31,8 @@ export class AppComponent implements OnInit {
pageTitle: string;
+ private activeRouteTitle: string;
+
constructor(private breakpointObserver: BreakpointObserver, public loginService: LoginService, private api: ApiService,
private router: Router, private login: LoginService, private activeRoute: ActivatedRoute,
private title: Title) {
@@ -102,7 +104,11 @@ export class AppComponent implements OnInit {
this.pageTitle = 'Szakdolgozat';
return this.title.setTitle('Szakdolgozat');
}
- let pageTitle = routeParts.reverse().map(part => part.title).reduce((partA, partI) => `${partA} > ${partI}`);
+ const titleParts = routeParts.reverse().map(part => part.title);
+ if (this.activeRouteTitle) {
+ titleParts[titleParts.length - 1] = this.activeRouteTitle;
+ }
+ let pageTitle = titleParts.reduce((partA, partI) => `${partA} > ${partI}`);
this.pageTitle = pageTitle;
pageTitle += ` | Szakdolgozat`;
this.title.setTitle(pageTitle);
@@ -117,7 +123,24 @@ export class AppComponent implements OnInit {
getMenuItems(): MenuItem[] {
return this.menu.filter(item => item.requiredRole === 'admin' ? this.login.user?.isAdmin : true); // TODO: Roles
}
+
+ routeActivated($event: any): void {
+ if (this.isCustomTitleComponent($event)) {
+ this.activeRouteTitle = $event.getPageTitle();
+ } else {
+ this.activeRouteTitle = null;
+ }
+ }
+
+ isCustomTitleComponent(obj: any): obj is CustomTitleComponent {
+ return obj?.getPageTitle instanceof Function;
+ }
+
}
type MenuItem = { path: string, requiredRole: UserRole | 'admin', title?: string };
type RouteSegment = { title: string, url: string };
+
+export interface CustomTitleComponent {
+ getPageTitle(): string;
+}
diff --git a/frontend/src/app/model/course.model.ts b/frontend/src/app/model/course.model.ts
index 269cf15..b2ab546 100644
--- a/frontend/src/app/model/course.model.ts
+++ b/frontend/src/app/model/course.model.ts
@@ -3,4 +3,5 @@ import { Model } from './model';
export class Course extends Model {
semester: string;
subjectId: number;
+ alias: string;
}
diff --git a/frontend/src/app/shared-components/list/list.component.ts b/frontend/src/app/shared-components/list/list.component.ts
index b5b1803..5be2137 100644
--- a/frontend/src/app/shared-components/list/list.component.ts
+++ b/frontend/src/app/shared-components/list/list.component.ts
@@ -37,10 +37,11 @@ export class ListComponent implements OnInit {
async getItems(limit: number, page: number): Promise {
try {
this.loading = true;
- const total = await this.api.requestItemCount(this.apiPath);
+ if (!this.paginationData.total) {
+ this.paginationData.total = await this.api.requestItemCount(this.apiPath);
+ }
this.paginationData.page = page;
this.paginationData.limit = limit;
- this.paginationData.total = total;
this.items = await this.api.requestPage(this.apiPath, limit, page);
} finally {
this.loading = false;
@@ -53,6 +54,6 @@ export class ListComponent implements OnInit {
}
async newItem(): Promise {
- await this.router.navigate([this.router.url, 'new']);
+ await this.router.navigate([this.router.url, 'new']);
}
}
diff --git a/frontend/src/app/subjects/subject-edit/courses/course-edit/course-edit.component.html b/frontend/src/app/subjects/subject-edit/courses/course-edit/course-edit.component.html
index b508328..08f66e1 100644
--- a/frontend/src/app/subjects/subject-edit/courses/course-edit/course-edit.component.html
+++ b/frontend/src/app/subjects/subject-edit/courses/course-edit/course-edit.component.html
@@ -1,3 +1,4 @@
diff --git a/frontend/src/app/subjects/subject-edit/courses/course-list/course-list.component.html b/frontend/src/app/subjects/subject-edit/courses/course-list/course-list.component.html
index 31f7da6..a21996c 100644
--- a/frontend/src/app/subjects/subject-edit/courses/course-list/course-list.component.html
+++ b/frontend/src/app/subjects/subject-edit/courses/course-list/course-list.component.html
@@ -1,3 +1,4 @@
-
diff --git a/frontend/src/app/subjects/subject-edit/courses/course-list/course-list.component.ts b/frontend/src/app/subjects/subject-edit/courses/course-list/course-list.component.ts
index cd620a1..7cf0f43 100644
--- a/frontend/src/app/subjects/subject-edit/courses/course-list/course-list.component.ts
+++ b/frontend/src/app/subjects/subject-edit/courses/course-list/course-list.component.ts
@@ -1,15 +1,18 @@
-import { Component, OnInit } from '@angular/core';
+import { Component, OnInit, ViewChild } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { Course } from '../../../../model/course.model';
+import { ListComponent } from '../../../../shared-components/list/list.component';
+import { CustomTitleComponent } from '../../../../app.component';
@Component({
selector: 'app-courses',
templateUrl: './course-list.component.html',
styleUrls: ['./course-list.component.css']
})
-export class CourseListComponent implements OnInit {
+export class CourseListComponent implements OnInit, CustomTitleComponent {
subjectId: string;
itemType = Course;
+ @ViewChild('list') list: ListComponent;
constructor(route: ActivatedRoute) {
this.subjectId = route.snapshot.params.subjectId;
@@ -18,4 +21,7 @@ export class CourseListComponent implements OnInit {
ngOnInit(): void {
}
+ getPageTitle(): string {
+ return 'Custom title'; //TODO
+ }
}
diff --git a/frontend/src/app/subjects/subjects.module.ts b/frontend/src/app/subjects/subjects.module.ts
index 13e51ec..0694244 100644
--- a/frontend/src/app/subjects/subjects.module.ts
+++ b/frontend/src/app/subjects/subjects.module.ts
@@ -12,7 +12,7 @@ const routes: Routes = [
{path: '', component: SubjectListComponent, data: {title: 'Tárgyak'} as RouteData},
{path: ':id', component: SubjectEditComponent, data: {title: 'Szerkesztés'}},
{
- path: ':subjectId/courses', children: [
+ path: ':subjectId/courses', data: {title: 'Kurzusok'}, children: [
{path: ':id', component: CourseEditComponent, data: {title: 'Szerkesztés'} as RouteData},
{path: '', component: CourseListComponent, data: {title: 'Kurzusok'}}
]
diff --git a/frontend/tslint.json b/frontend/tslint.json
index 277c8eb..48ca035 100644
--- a/frontend/tslint.json
+++ b/frontend/tslint.json
@@ -70,7 +70,8 @@
],
"semicolon": {
"options": [
- "always"
+ "always",
+ "ignore-bound-class-methods"
]
},
"space-before-function-paren": {