From 67faa701ced40fc1b86b99e09627e05f181114c7 Mon Sep 17 00:00:00 2001 From: Aino Tani Date: Mon, 25 Nov 2024 11:00:25 +0000 Subject: [PATCH 1/2] Preparatory education for an upper secondary qualification TUVA (#1140) --- package-lock.json | 2 +- package.json | 2 +- .../manage-materials.component.ts | 2 +- src/app/admin/model/educational-level.ts | 13 +- src/app/admin/model/notification.ts | 1 - src/app/admin/services/admin.service.ts | 4 +- src/app/admin/services/koodisto.service.ts | 39 +++-- src/app/components/search/search.component.ts | 41 +++-- .../components/taglist/taglist.component.ts | 4 +- src/app/constants/educational-level-keys.ts | 2 + src/app/constants/koodisto-sources.ts | 2 + src/app/models/alignment-objects.ts | 2 + src/app/models/collections/collection-form.ts | 16 +- src/app/models/collections/collection.ts | 16 +- src/app/models/educational-material-form.ts | 2 + src/app/models/educational-material.ts | 2 + src/app/models/koodisto/educational-level.ts | 13 +- src/app/services/collection.service.ts | 32 +++- src/app/services/koodisto.service.ts | 53 ++++-- src/app/services/material.service.ts | 80 +++++---- ...ion-educational-details-tab.component.html | 63 +++++++ ...ction-educational-details-tab.component.ts | 52 +++++- .../collection-preview-tab.component.html | 22 +++ .../collection-preview-tab.component.ts | 18 +- .../collection-view.component.html | 21 +++ ...cational-material-edit-form.component.html | 2 +- ...ducational-material-edit-form.component.ts | 7 +- .../edit-educational-details.component.html | 62 +++++++ .../edit-educational-details.component.ts | 60 ++++++- .../edit-preview/edit-preview.component.html | 14 ++ .../edit-preview/edit-preview.component.ts | 12 ++ .../educational-material-view.component.html | 30 +++- .../educational-material-view.component.ts | 4 +- .../educational-resource-form.component.ts | 2 +- .../based-on-details.component.ts | 4 +- .../basic-details/basic-details.component.ts | 2 +- .../educational-details.component.html | 163 ++++++------------ .../educational-details.component.ts | 88 ++++++++-- .../extended-details.component.ts | 15 +- .../tabs/files/files.component.ts | 4 +- .../tabs/license/license.component.ts | 17 +- .../tabs/preview/preview.component.html | 14 ++ .../tabs/preview/preview.component.ts | 24 +-- src/assets/i18n/en.json | 46 +++-- src/assets/i18n/fi.json | 46 +++-- src/assets/i18n/sv.json | 46 +++-- tsconfig.json | 72 +++----- 47 files changed, 861 insertions(+), 377 deletions(-) diff --git a/package-lock.json b/package-lock.json index bd9dd3c10..e408465dc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "aoe-web-frontend", - "version": "6.2.22", + "version": "6.4.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 7985d4a34..185f110c2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "aoe-web-frontend", - "version": "6.2.22", + "version": "6.4.0", "description": "Client SPA for the Library of Open Educational Resources", "author": "CSC - IT Center for Science Ltd.", "contributors": [ diff --git a/src/app/admin/manage-materials-view/manage-materials.component.ts b/src/app/admin/manage-materials-view/manage-materials.component.ts index 2d0b1bb52..c3592bf32 100644 --- a/src/app/admin/manage-materials-view/manage-materials.component.ts +++ b/src/app/admin/manage-materials-view/manage-materials.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core'; +import { Component } from '@angular/core'; @Component({ selector: 'app-manage-materials', diff --git a/src/app/admin/model/educational-level.ts b/src/app/admin/model/educational-level.ts index 2fde45af7..2ce44aaa0 100644 --- a/src/app/admin/model/educational-level.ts +++ b/src/app/admin/model/educational-level.ts @@ -1,10 +1,11 @@ export interface EducationalLevel { key: string; value: string; - children: [ - { - key: string; - value: string; - }, - ]; + children: EducationalLevelChild[]; +} + +export interface EducationalLevelChild { + key: string; + value: string; + disabled?: boolean; } diff --git a/src/app/admin/model/notification.ts b/src/app/admin/model/notification.ts index c44d99f28..cd37d5cb1 100644 --- a/src/app/admin/model/notification.ts +++ b/src/app/admin/model/notification.ts @@ -1,4 +1,3 @@ -import { NotificationType } from '@admin/model/enumeration/NotificationType'; import { SafeHtml } from '@angular/platform-browser'; export interface Notification { diff --git a/src/app/admin/services/admin.service.ts b/src/app/admin/services/admin.service.ts index d238938c9..a4c700baf 100644 --- a/src/app/admin/services/admin.service.ts +++ b/src/app/admin/services/admin.service.ts @@ -1,7 +1,7 @@ import { Injectable } from '@angular/core'; -import { HttpClient, HttpErrorResponse, HttpResponse } from '@angular/common/http'; +import { HttpClient, HttpErrorResponse } from '@angular/common/http'; import { Observable, Subject, throwError } from 'rxjs'; -import { environment } from '../../../environments/environment'; +import { environment } from '@environments/environment'; import { catchError } from 'rxjs/operators'; import { AoeUser, diff --git a/src/app/admin/services/koodisto.service.ts b/src/app/admin/services/koodisto.service.ts index 0e507ff37..3a4fb6ebc 100644 --- a/src/app/admin/services/koodisto.service.ts +++ b/src/app/admin/services/koodisto.service.ts @@ -4,10 +4,10 @@ import { HttpClient, HttpErrorResponse, HttpHeaders } from '@angular/common/http import { BehaviorSubject, Observable, of, Subject, throwError } from 'rxjs'; import { TranslateService } from '@ngx-translate/core'; -import { EducationalLevel, EducationalSubject } from '../model'; -import { environment } from '../../../environments/environment'; +import { EducationalLevel, EducationalSubject, EducationalLevelChild } from '@admin/model'; +import { environment } from '@environments/environment'; import { Organization } from '@admin/model/organization'; -import { catchError, filter, map, tap } from 'rxjs/operators'; +import { catchError, map, tap } from 'rxjs/operators'; @Injectable({ providedIn: 'root', @@ -21,18 +21,21 @@ export class KoodistoService { 'Content-Type': 'application/json', }), }; - private educationalLevelsBehaviorSubject: BehaviorSubject = new BehaviorSubject< - EducationalLevel[] + private educationalLevelsBehaviorSubject: BehaviorSubject = new BehaviorSubject< + EducationalLevel[] | null >(null); - private educationalSubjectsBehaviorSubject: BehaviorSubject = new BehaviorSubject< - EducationalSubject[] + private educationalSubjectsBehaviorSubject: BehaviorSubject = new BehaviorSubject< + EducationalSubject[] | null + >(null); + private organizationsBehaviorSubject: BehaviorSubject = new BehaviorSubject< + Organization[] | null >(null); - private organizationsBehaviorSubject: BehaviorSubject = new BehaviorSubject(null); - public educationalLevels$: Observable = this.educationalLevelsBehaviorSubject.asObservable(); - public educationalSubjects$: Observable = + public educationalLevels$: Observable = + this.educationalLevelsBehaviorSubject.asObservable(); + public educationalSubjects$: Observable = this.educationalSubjectsBehaviorSubject.asObservable(); - public organizations$: Observable = this.organizationsBehaviorSubject.asObservable(); + public organizations$: Observable = this.organizationsBehaviorSubject.asObservable(); constructor(private http: HttpClient, private translate: TranslateService) { this.lang = this.translate.currentLang; @@ -42,7 +45,7 @@ export class KoodistoService { switch (error.status) { case 404: subject$.next([]); - break; + return throwError('Resource not found; please try again later.'); default: console.error(error); return throwError('Something bad happened; please try again later.'); @@ -56,7 +59,17 @@ export class KoodistoService { map((educationalLevels: EducationalLevel[]) => educationalLevels.filter((educationalLevel: EducationalLevel): boolean => educationalLevel !== null), ), - tap((educationalLevels: EducationalLevel[]) => this.educationalLevelsBehaviorSubject.next(educationalLevels)), + tap((educationalLevels: EducationalLevel[]) => + this.educationalLevelsBehaviorSubject.next( + educationalLevels.map((level: EducationalLevel) => ({ + ...level, + children: level.children.map((child: EducationalLevelChild) => ({ + ...child, + disabled: false, + })), + })), + ), + ), catchError((err: any) => of(err)), ); } diff --git a/src/app/components/search/search.component.ts b/src/app/components/search/search.component.ts index e5137bde8..ed359539c 100644 --- a/src/app/components/search/search.component.ts +++ b/src/app/components/search/search.component.ts @@ -4,10 +4,9 @@ import { Router } from '@angular/router'; import { TranslateService } from '@ngx-translate/core'; import { ToastrService } from 'ngx-toastr'; import { Subscription } from 'rxjs'; -import { environment } from '../../../environments/environment'; -import { textInputValidator } from './../../shared/shared.module'; +import { environment } from '@environments/environment'; +import { textInputValidator } from '@shared/shared.module'; import { KoodistoService } from '@services/koodisto.service'; -import { SearchService } from '@services/search.service'; import { SubjectFilter } from '@models/koodisto/subject-filter'; import { SearchParams } from '@models/search/search-params'; import { EducationalLevel } from '@models/koodisto/educational-level'; @@ -22,17 +21,16 @@ import { validatorParams } from '@constants/validator-params'; styleUrls: ['./search.component.scss'], }) export class SearchComponent implements OnInit, OnDestroy { - searchForm: FormGroup; - educationalLevelSubscription: Subscription; - educationalLevels: EducationalLevel[]; - educationalSubjectSubscription: Subscription; - educationalSubjects: SubjectFilter[]; - learningResourceTypeSubscription: Subscription; - learningResourceTypes: LearningResourceType[]; + searchForm: FormGroup = new FormGroup({}); + educationalLevelSubscription = new Subscription(); + educationalLevels: EducationalLevel[] = []; + educationalSubjectSubscription = new Subscription(); + educationalSubjects: SubjectFilter[] = []; + learningResourceTypeSubscription = new Subscription(); + learningResourceTypes: LearningResourceType[] = []; resultsPerPage = 15; constructor( - private searchSvc: SearchService, private fb: FormBuilder, private router: Router, private koodistoProxySvc: KoodistoService, @@ -56,7 +54,7 @@ export class SearchComponent implements OnInit, OnDestroy { }), }); - this.educationalLevelSubscription = this.koodistoProxySvc.educationalLevels$.subscribe( + this.educationalLevelSubscription = this.koodistoProxySvc.educationalLevelsEnabled$.subscribe( (levels: EducationalLevel[]) => { this.educationalLevels = levels; }, @@ -106,7 +104,9 @@ export class SearchComponent implements OnInit, OnDestroy { educationLevelChange(): void { if (this.educationalLevelsCtrl.value.length > 0) { - const educationLevelKeys = this.educationalLevelsCtrl.value?.map((level) => level.key); + const educationLevelKeys = this.educationalLevelsCtrl.value?.map( + (level: Record) => level.key, + ); this.educationalSubjects = this.educationalSubjects.filter((subject: SubjectFilter) => educationLevelKeys.includes(subject.key), @@ -119,7 +119,7 @@ export class SearchComponent implements OnInit, OnDestroy { setUsedFilters(): void { const usedFilters: UsedFilter[] = []; - this.educationalLevelsCtrl.value?.forEach((level) => { + this.educationalLevelsCtrl.value?.forEach((level: Record) => { usedFilters.push({ key: level.key, value: level.value, @@ -127,7 +127,7 @@ export class SearchComponent implements OnInit, OnDestroy { }); }); - this.educationalSubjectsCtrl.value?.forEach((subject) => { + this.educationalSubjectsCtrl.value?.forEach((subject: Record) => { usedFilters.push({ key: subject.key.toString(), value: subject.value, @@ -135,7 +135,7 @@ export class SearchComponent implements OnInit, OnDestroy { }); }); - this.learningResourceTypesCtrl.value?.forEach((type) => { + this.learningResourceTypesCtrl.value?.forEach((type: Record) => { usedFilters.push({ key: type.key, value: type.value, @@ -170,10 +170,13 @@ export class SearchComponent implements OnInit, OnDestroy { }; searchParams.keywords = this.keywordsCtrl.value; - searchParams.filters.educationalLevels = this.educationalLevelsCtrl.value?.map((level) => level.key) ?? []; + searchParams.filters.educationalLevels = + this.educationalLevelsCtrl.value?.map((level: Record) => level.key) ?? []; searchParams.filters.educationalSubjects = - this.educationalSubjectsCtrl.value?.map((subject) => subject.key.toString()) ?? []; - searchParams.filters.learningResourceTypes = this.learningResourceTypesCtrl.value?.map((type) => type.key) ?? []; + this.educationalSubjectsCtrl.value?.map((subject: Record) => subject.key.toString()) ?? + []; + searchParams.filters.learningResourceTypes = + this.learningResourceTypesCtrl.value?.map((type: Record) => type.key) ?? []; searchParams.sort = sortOptions.relevance.value; searchParams.from = 0; searchParams.size = this.resultsPerPage; diff --git a/src/app/components/taglist/taglist.component.ts b/src/app/components/taglist/taglist.component.ts index d0eee9722..e0dfbb52b 100644 --- a/src/app/components/taglist/taglist.component.ts +++ b/src/app/components/taglist/taglist.component.ts @@ -1,6 +1,6 @@ -import { ChangeDetectionStrategy, Component, Input } from '@angular/core'; +import { Component, Input } from '@angular/core'; import { SearchParams } from '@models/search/search-params'; -import { environment } from '../../../environments/environment'; +import { environment } from '@environments/environment'; import { Router } from '@angular/router'; import { UsedFilter } from '@models/search/used-filter'; diff --git a/src/app/constants/educational-level-keys.ts b/src/app/constants/educational-level-keys.ts index e9d36de7f..4104241cb 100644 --- a/src/app/constants/educational-level-keys.ts +++ b/src/app/constants/educational-level-keys.ts @@ -9,6 +9,7 @@ export const educationalLevelKeys = { 'a2a70a14-b150-4f37-9e20-2bbb71731807', '14fe3b08-8516-4999-946b-96eb90c2d563', ], + preparatoryEducation: ['64a427b5-3a25-43e4-b976-ccf3f0539b95'], upperSecondary: ['94f79e1e-10e6-483d-b651-27521f94f7bf', 'fd362a80-9662-48b8-acd1-d8cef520530c'], vocational: [ '010c6689-5021-4d8e-8c02-68a27cc5a87b', @@ -19,6 +20,7 @@ export const educationalLevelKeys = { 'bc25d0e7-3c68-49a1-9329-239dae01fab7', '087dd008-16db-46e7-b0ee-5cd76c64e990', '67900499-2356-45a4-b830-3021e73398bc', + '427511b0-7071-46f9-a946-3c4c18d4223c', ], higherEducation: [ 'e5a48ada-3de0-4246-9b8f-32d4ff68e22f', diff --git a/src/app/constants/koodisto-sources.ts b/src/app/constants/koodisto-sources.ts index 6143f1db5..29006710a 100644 --- a/src/app/constants/koodisto-sources.ts +++ b/src/app/constants/koodisto-sources.ts @@ -6,6 +6,8 @@ export const koodistoSources = { basicStudySubjects: 'basicStudySubjects', basicStudyObjectives: 'basicStudyObjectives', basicStudyContents: 'basicStudyContents', + preparatoryEducationSubjects: 'preparatoryEducationSubjects', + preparatoryEducationObjectives: 'preparatoryEducationObjectives', upperSecondarySubjects: 'upperSecondarySchoolSubjects', upperSecondaryObjectives: 'upperSecondarySchoolObjectives', upperSecondarySubjectsOld: 'upperSecondarySchoolSubjectsOld', diff --git a/src/app/models/alignment-objects.ts b/src/app/models/alignment-objects.ts index 3831b9c15..3ec8156de 100644 --- a/src/app/models/alignment-objects.ts +++ b/src/app/models/alignment-objects.ts @@ -8,6 +8,8 @@ export interface AlignmentObjects { basicStudySubjects: AlignmentObjectExtended[]; basicStudyObjectives: AlignmentObjectExtended[]; basicStudyContents: AlignmentObjectExtended[]; + preparatoryEducationSubjects: AlignmentObjectExtended[]; + preparatoryEducationObjectives: AlignmentObjectExtended[]; upperSecondarySchoolSubjectsOld: AlignmentObjectExtended[]; upperSecondarySchoolCoursesOld: AlignmentObjectExtended[]; upperSecondarySchoolObjectives: AlignmentObjectExtended[]; diff --git a/src/app/models/collections/collection-form.ts b/src/app/models/collections/collection-form.ts index 3fee2cbca..8dd8a22c8 100644 --- a/src/app/models/collections/collection-form.ts +++ b/src/app/models/collections/collection-form.ts @@ -48,35 +48,37 @@ export interface CollectionForm { ]; earlyChildhoodEducationSubjects: AlignmentObjectExtended[]; earlyChildhoodEducationObjectives: AlignmentObjectExtended[]; - earlyChildhoodEducationFramework: string; + earlyChildhoodEducationFramework?: string; prePrimaryEducationSubjects: AlignmentObjectExtended[]; prePrimaryEducationObjectives: AlignmentObjectExtended[]; - prePrimaryEducationFramework: string; + prePrimaryEducationFramework?: string; basicStudySubjects: AlignmentObjectExtended[]; basicStudyObjectives: AlignmentObjectExtended[]; basicStudyContents: AlignmentObjectExtended[]; - basicStudyFramework: string; + basicStudyFramework?: string; + preparatoryEducationSubjects: AlignmentObjectExtended[]; + preparatoryEducationObjectives: AlignmentObjectExtended[]; currentUpperSecondarySchoolSelected: boolean; newUpperSecondarySchoolSelected: boolean; upperSecondarySchoolSubjectsOld: AlignmentObjectExtended[]; upperSecondarySchoolCoursesOld: AlignmentObjectExtended[]; upperSecondarySchoolObjectives: AlignmentObjectExtended[]; - upperSecondarySchoolFramework: string; + upperSecondarySchoolFramework?: string; upperSecondarySchoolSubjectsNew: AlignmentObjectExtended[]; upperSecondarySchoolModulesNew: AlignmentObjectExtended[]; upperSecondarySchoolObjectivesNew: AlignmentObjectExtended[]; upperSecondarySchoolContentsNew: AlignmentObjectExtended[]; - newUpperSecondarySchoolFramework: string; + newUpperSecondarySchoolFramework?: string; vocationalDegrees: AlignmentObjectExtended[]; vocationalUnits: AlignmentObjectExtended[]; subjectOfCommonUnit: AlignmentObjectExtended[]; vocationalRequirements: AlignmentObjectExtended[]; - vocationalEducationFramework: string; + vocationalEducationFramework?: string; selfMotivatedEducationSubjects: AlignmentObjectExtended[]; selfMotivatedEducationObjectives: AlignmentObjectExtended[]; scienceBranches: AlignmentObjectExtended[]; scienceBranchObjectives: AlignmentObjectExtended[]; - higherEducationFramework: string; + higherEducationFramework?: string; // materials materials: CollectionFormMaterial[]; materialsAndHeadings: CollectionFormMaterialAndHeading[]; diff --git a/src/app/models/collections/collection.ts b/src/app/models/collections/collection.ts index bdd390824..e51a218ca 100644 --- a/src/app/models/collections/collection.ts +++ b/src/app/models/collections/collection.ts @@ -88,33 +88,35 @@ export interface Collection { ]; earlyChildhoodEducationSubjects: AlignmentObjectExtended[]; earlyChildhoodEducationObjectives: AlignmentObjectExtended[]; - earlyChildhoodEducationFramework: string; + earlyChildhoodEducationFramework?: string; prePrimaryEducationSubjects: AlignmentObjectExtended[]; prePrimaryEducationObjectives: AlignmentObjectExtended[]; - prePrimaryEducationFramework: string; + prePrimaryEducationFramework?: string; basicStudySubjects: AlignmentObjectExtended[]; basicStudyObjectives: AlignmentObjectExtended[]; basicStudyContents: AlignmentObjectExtended[]; - basicStudyFramework: string; + basicStudyFramework?: string; + preparatoryEducationSubjects?: AlignmentObjectExtended[]; + preparatoryEducationObjectives?: AlignmentObjectExtended[]; upperSecondarySchoolSubjectsOld: AlignmentObjectExtended[]; upperSecondarySchoolCoursesOld: AlignmentObjectExtended[]; upperSecondarySchoolObjectives: AlignmentObjectExtended[]; - upperSecondarySchoolFramework: string; + upperSecondarySchoolFramework?: string; upperSecondarySchoolSubjectsNew: AlignmentObjectExtended[]; upperSecondarySchoolModulesNew: AlignmentObjectExtended[]; upperSecondarySchoolObjectivesNew: AlignmentObjectExtended[]; upperSecondarySchoolContentsNew: AlignmentObjectExtended[]; - newUpperSecondarySchoolFramework: string; + newUpperSecondarySchoolFramework?: string; vocationalDegrees: AlignmentObjectExtended[]; vocationalUnits: AlignmentObjectExtended[]; subjectOfCommonUnit: AlignmentObjectExtended[]; vocationalRequirements: AlignmentObjectExtended[]; - vocationalEducationFramework: string; + vocationalEducationFramework?: string; selfMotivatedEducationSubjects: AlignmentObjectExtended[]; selfMotivatedEducationObjectives: AlignmentObjectExtended[]; scienceBranches: AlignmentObjectExtended[]; scienceBranchObjectives: AlignmentObjectExtended[]; - higherEducationFramework: string; + higherEducationFramework?: string; authors: string[]; thumbnail: string; } diff --git a/src/app/models/educational-material-form.ts b/src/app/models/educational-material-form.ts index 86274d067..bffe17679 100644 --- a/src/app/models/educational-material-form.ts +++ b/src/app/models/educational-material-form.ts @@ -79,6 +79,8 @@ export interface EducationalMaterialForm { basicStudyObjectives?: AlignmentObjectExtended[]; basicStudyContents?: AlignmentObjectExtended[]; basicStudyFramework?: string; + preparatoryEducationSubjects?: AlignmentObjectExtended[]; + preparatoryEducationObjectives?: AlignmentObjectExtended[]; upperSecondarySchoolSubjectsOld?: AlignmentObjectExtended[]; upperSecondarySchoolCoursesOld?: AlignmentObjectExtended[]; suitsAllUpperSecondarySubjects?: boolean; diff --git a/src/app/models/educational-material.ts b/src/app/models/educational-material.ts index 264e29084..b065e121d 100644 --- a/src/app/models/educational-material.ts +++ b/src/app/models/educational-material.ts @@ -72,6 +72,8 @@ export interface EducationalMaterial { basicStudyObjectives: AlignmentObjectExtended[]; basicStudyContents: AlignmentObjectExtended[]; suitsAllBasicStudySubjects: boolean; + preparatoryEducationSubjects?: AlignmentObjectExtended[]; + preparatoryEducationObjectives?: AlignmentObjectExtended[]; upperSecondarySchoolSubjectsOld: AlignmentObjectExtended[]; upperSecondarySchoolFrameworks: string[]; upperSecondarySchoolCoursesOld: AlignmentObjectExtended[]; diff --git a/src/app/models/koodisto/educational-level.ts b/src/app/models/koodisto/educational-level.ts index 2fde45af7..2ce44aaa0 100644 --- a/src/app/models/koodisto/educational-level.ts +++ b/src/app/models/koodisto/educational-level.ts @@ -1,10 +1,11 @@ export interface EducationalLevel { key: string; value: string; - children: [ - { - key: string; - value: string; - }, - ]; + children: EducationalLevelChild[]; +} + +export interface EducationalLevelChild { + key: string; + value: string; + disabled?: boolean; } diff --git a/src/app/services/collection.service.ts b/src/app/services/collection.service.ts index c76d4b519..324547543 100644 --- a/src/app/services/collection.service.ts +++ b/src/app/services/collection.service.ts @@ -2,7 +2,7 @@ import { Injectable } from '@angular/core'; import { HttpClient, HttpErrorResponse, HttpEvent, HttpEventType, HttpHeaders } from '@angular/common/http'; import { Observable, Subject, throwError } from 'rxjs'; import { catchError, map } from 'rxjs/operators'; -import { environment } from '../../environments/environment'; +import { environment } from '@environments/environment'; import { koodistoSources } from '@constants/koodisto-sources'; import { CreateCollectionPost } from '@models/collections/create-collection-post'; import { CreateCollectionResponse } from '@models/collections/create-collection-response'; @@ -188,6 +188,8 @@ export class CollectionService { basicStudyObjectives: alignmentObjects.basicStudyObjectives, basicStudyContents: alignmentObjects.basicStudyContents, basicStudyFramework: alignmentObjects.basicStudySubjects[0]?.educationalFramework, + preparatoryEducationSubjects: alignmentObjects.preparatoryEducationSubjects, + preparatoryEducationObjectives: alignmentObjects.preparatoryEducationObjectives, upperSecondarySchoolSubjectsOld: alignmentObjects.upperSecondarySchoolSubjectsOld, upperSecondarySchoolCoursesOld: alignmentObjects.upperSecondarySchoolCoursesOld, upperSecondarySchoolObjectives: alignmentObjects.upperSecondarySchoolObjectives, @@ -298,6 +300,8 @@ export class CollectionService { basicStudyObjectives: alignmentObjects.basicStudyObjectives, basicStudyContents: alignmentObjects.basicStudyContents, basicStudyFramework: alignmentObjects.basicStudySubjects[0]?.educationalFramework, + preparatoryEducationSubjects: alignmentObjects.preparatoryEducationSubjects, + preparatoryEducationObjectives: alignmentObjects.preparatoryEducationObjectives, currentUpperSecondarySchoolSelected: alignmentObjects.upperSecondarySchoolSubjectsOld.length > 0, newUpperSecondarySchoolSelected: alignmentObjects.upperSecondarySchoolSubjectsNew.length > 0, upperSecondarySchoolSubjectsOld: alignmentObjects.upperSecondarySchoolSubjectsOld, @@ -359,8 +363,12 @@ export class CollectionService { map((event: HttpEvent) => { switch (event.type) { case HttpEventType.UploadProgress: - const progress = Math.round((100 * event.loaded) / event.total); - return { status: 'progress', message: progress }; + if (event.total) { + const progress = Math.round((100 * event.loaded) / event.total); + return { status: 'progress', message: progress }; + } else { + return { status: 'progress', message: 'Calculating...' }; + } case HttpEventType.Response: return { status: 'completed', message: event.body }; @@ -401,11 +409,11 @@ export class CollectionService { /** * Extracts different alignment objects from object array. - * @param alignmentObjects + * @param {any} alignmentObjects * @returns {AlignmentObjects} Alignment objects * @private */ - private extractAlignmentObjects(alignmentObjects): AlignmentObjects { + private extractAlignmentObjects(alignmentObjects: any): AlignmentObjects { const earlyChildhoodEducationSubjects: AlignmentObjectExtended[] = []; const earlyChildhoodEducationObjectives: AlignmentObjectExtended[] = []; const prePrimaryEducationSubjects: AlignmentObjectExtended[] = []; @@ -413,6 +421,8 @@ export class CollectionService { const basicStudySubjects: AlignmentObjectExtended[] = []; const basicStudyObjectives: AlignmentObjectExtended[] = []; const basicStudyContents: AlignmentObjectExtended[] = []; + const preparatoryEducationSubjects: AlignmentObjectExtended[] = []; + const preparatoryEducationObjectives: AlignmentObjectExtended[] = []; const upperSecondarySchoolSubjectsOld: AlignmentObjectExtended[] = []; const upperSecondarySchoolCoursesOld: AlignmentObjectExtended[] = []; const upperSecondarySchoolObjectives: AlignmentObjectExtended[] = []; @@ -431,7 +441,7 @@ export class CollectionService { alignmentObjects .map( - (aObject): AlignmentObjectExtended => ({ + (aObject: any): AlignmentObjectExtended => ({ alignmentType: aObject.alignmenttype, educationalFramework: aObject.educationalframework, key: aObject.objectkey, @@ -470,6 +480,14 @@ export class CollectionService { basicStudyContents.push(aObject); break; + case koodistoSources.preparatoryEducationSubjects: + preparatoryEducationSubjects.push(aObject); + break; + + case koodistoSources.preparatoryEducationObjectives: + preparatoryEducationObjectives.push(aObject); + break; + case koodistoSources.upperSecondarySubjectsOld: upperSecondarySchoolSubjectsOld.push(aObject); break; @@ -548,6 +566,8 @@ export class CollectionService { basicStudySubjects, basicStudyObjectives, basicStudyContents, + preparatoryEducationSubjects, + preparatoryEducationObjectives, upperSecondarySchoolSubjectsOld, upperSecondarySchoolCoursesOld, upperSecondarySchoolObjectives, diff --git a/src/app/services/koodisto.service.ts b/src/app/services/koodisto.service.ts index a70be157a..54dd89bf9 100644 --- a/src/app/services/koodisto.service.ts +++ b/src/app/services/koodisto.service.ts @@ -8,12 +8,12 @@ import { Language } from '@models/koodisto/language'; import { LearningResourceType } from '@models/koodisto/learning-resource-type'; import { EducationalRole } from '@models/koodisto/educational-role'; import { EducationalUse } from '@models/koodisto/educational-use'; -import { EducationalLevel } from '@models/koodisto/educational-level'; +import { EducationalLevel, EducationalLevelChild } from '@models/koodisto/educational-level'; import { AlignmentObjectExtended } from '@models/alignment-object-extended'; import { AccessibilityFeature } from '@models/koodisto/accessibility-feature'; import { AccessibilityHazard } from '@models/koodisto/accessibility-hazard'; import { License } from '@models/koodisto/license'; -import { environment } from '../../environments/environment'; +import { environment } from '@environments/environment'; import { SubjectFilter } from '@models/koodisto/subject-filter'; import { catchError, map } from 'rxjs/operators'; import { EducationalSubject } from '@models/koodisto/educational-subject'; @@ -34,10 +34,12 @@ export class KoodistoService { public educationalRoles$ = new Subject(); public educationalUses$ = new Subject(); public educationalLevels$ = new Subject(); + public educationalLevelsEnabled$ = new Subject(); public basicStudySubjects$ = new Subject(); public basicStudyObjectives$ = new Subject(); public basicStudyContents$ = new Subject(); - public upperSecondarySchoolSubjects$ = new Subject(); + public preparatorySubjects$ = new Subject(); + public preparatoryObjectives$ = new Subject(); public upperSecondarySchoolSubjectsOld$ = new Subject(); public upperSecondarySchoolCoursesOld$ = new Subject(); public upperSecondarySchoolSubjectsNew$ = new Subject(); @@ -58,10 +60,10 @@ export class KoodistoService { public educationalSubject$ = new Subject(); private languagesBehaviorSubject: BehaviorSubject = new BehaviorSubject([]); - private licenses$$: BehaviorSubject = new BehaviorSubject(null); + private licenses$$: BehaviorSubject = new BehaviorSubject(null); public languages$: Observable = this.languagesBehaviorSubject.asObservable(); - public licenses$: Observable = this.licenses$$.asObservable(); + public licenses$: Observable = this.licenses$$.asObservable(); constructor(private http: HttpClient, private translate: TranslateService) { this.lang = this.translate.currentLang; @@ -71,7 +73,7 @@ export class KoodistoService { switch (error.status) { case 404: subject$.next([]); - break; + return throwError('Resource not found; please try again later.'); default: console.error(error); return throwError('Something bad happened; please try again later.'); @@ -142,6 +144,15 @@ export class KoodistoService { this.http.get(`${this.apiUri}/koulutusasteet/${lang}`, this.httpOptions).subscribe( (educationalLevels: EducationalLevel[]) => { this.educationalLevels$.next(educationalLevels); + this.educationalLevelsEnabled$.next( + educationalLevels.map((level: EducationalLevel) => ({ + ...level, + children: level.children.map((child: EducationalLevelChild) => ({ + ...child, + disabled: false, + })), + })), + ); }, (error: HttpErrorResponse) => this.handleError(error, this.educationalLevels$), ); @@ -192,19 +203,35 @@ export class KoodistoService { } /** - * Updates upper secondary school subjects. + * Updates preparatory education subjects. */ - updateUpperSecondarySchoolSubjects(): void { + updatePreparatorySubjects(): void { const lang = this.translate.currentLang; - - this.http.get(`${this.apiUri}/lukionkurssit/${lang}`, this.httpOptions).subscribe( - (upperSecondarySchoolSubjects: AlignmentObjectExtended[]) => { - this.upperSecondarySchoolSubjects$.next(upperSecondarySchoolSubjects); + this.http.get(`${this.apiUri}/tuva-oppiaineet/${lang}`, this.httpOptions).subscribe( + (preparatorySubjects: AlignmentObjectExtended[]) => { + this.preparatorySubjects$.next(preparatorySubjects); }, - (error: HttpErrorResponse) => this.handleError(error, this.upperSecondarySchoolSubjects$), + (error: HttpErrorResponse) => this.handleError(error, this.preparatorySubjects$), ); } + /** + * Updates preparatory education objectives. + * @param {string} ids + */ + updatePreparatoryObjectives(ids: string): void { + const lang = this.translate.currentLang; + + this.http + .get(`${this.apiUri}/tuva-tavoitteet/${ids}/${lang}`, this.httpOptions) + .subscribe( + (preparatoryObjectives: AlignmentObjectExtended[]) => { + this.preparatoryObjectives$.next(preparatoryObjectives); + }, + (error: HttpErrorResponse) => this.handleError(error, this.preparatoryObjectives$), + ); + } + /** * Updates upper secondary school subjects (old). */ diff --git a/src/app/services/material.service.ts b/src/app/services/material.service.ts index 3cb47b84c..5649b74b9 100644 --- a/src/app/services/material.service.ts +++ b/src/app/services/material.service.ts @@ -1,23 +1,11 @@ import { Injectable } from '@angular/core'; import { HttpClient, HttpErrorResponse, HttpEvent, HttpEventType, HttpHeaders } from '@angular/common/http'; -import { - catchError, - concatMap, - delay, - map, - mergeMap, - retryWhen, - take, - takeLast, - tap, - timeout, - toArray, -} from 'rxjs/operators'; -import { BehaviorSubject, EMPTY, from, NEVER, Observable, of, Subject, throwError } from 'rxjs'; +import { catchError, concatMap, delay, map, mergeMap, retryWhen, take, takeLast, tap, toArray } from 'rxjs/operators'; +import { BehaviorSubject, EMPTY, from, Observable, of, Subject, throwError } from 'rxjs'; import { TranslateService } from '@ngx-translate/core'; -import { environment } from '../../environments/environment'; -import { deduplicate, getUniqueFrameworks } from '../shared/shared.module'; +import { environment } from '@environments/environment'; +import { deduplicate, getUniqueFrameworks } from '@shared/shared.module'; import { EducationalMaterial } from '@models/educational-material'; import { UploadMessage } from '@models/upload-message'; import { EducationalMaterialCard } from '@models/educational-material-card'; @@ -39,19 +27,19 @@ import { koodistoSources } from '@constants/koodisto-sources'; export class MaterialService { private educationalMaterialEditForm$$: BehaviorSubject = new BehaviorSubject(null); - private educationalMaterialID$$: BehaviorSubject = new BehaviorSubject(null); - private uploadedFiles$$: BehaviorSubject = new BehaviorSubject(null); + private educationalMaterialID$$: BehaviorSubject = new BehaviorSubject(null); + private uploadedFiles$$: BehaviorSubject = new BehaviorSubject(null); private uploadResponses$$: BehaviorSubject = new BehaviorSubject([]); public lang: string = this.translate.currentLang; public material$$: Subject = new Subject(); - public uploadedFiles$: Observable = this.uploadedFiles$$.asObservable(); + public uploadedFiles$: Observable = this.uploadedFiles$$.asObservable(); public uploadResponses$: Observable = this.uploadResponses$$.asObservable(); public educationalMaterialEditForm$: Observable = this.educationalMaterialEditForm$$.asObservable(); public educationalMaterialID$: Observable = this.educationalMaterialID$$ .asObservable() - .pipe(map((id: string) => +id)); + .pipe(map((id: string | null) => (id !== null ? +id : 0))); public publishedUserMaterials$$: Subject = new Subject(); public unpublishedUserMaterials$$: Subject = new Subject(); @@ -85,7 +73,7 @@ export class MaterialService { this.educationalMaterialEditForm$$.next(educationalMaterialForm); } - getEducationalMaterialID(): string { + getEducationalMaterialID(): string | null { return this.educationalMaterialID$$.getValue(); } @@ -93,7 +81,7 @@ export class MaterialService { this.educationalMaterialID$$.next(id); } - getUploadedFiles(): UploadedFile[] { + getUploadedFiles(): UploadedFile[] | null { return this.uploadedFiles$$.getValue(); } @@ -454,6 +442,14 @@ export class MaterialService { alignmentObject.source === koodistoSources.basicStudyContents, ), suitsAllBasicStudySubjects: material.suitsAllBasicStudySubjects, + preparatoryEducationSubjects: alignmentObjects.filter( + (alignmentObject: AlignmentObjectExtended): boolean => + alignmentObject.source === koodistoSources.preparatoryEducationSubjects, + ), + preparatoryEducationObjectives: alignmentObjects.filter( + (alignmentObject: AlignmentObjectExtended): boolean => + alignmentObject.source === koodistoSources.preparatoryEducationObjectives, + ), upperSecondarySchoolSubjectsOld: upperSecondarySchoolSubjectsOld, upperSecondarySchoolFrameworks: getUniqueFrameworks(upperSecondarySchoolSubjectsOld), upperSecondarySchoolCoursesOld: alignmentObjects.filter( @@ -676,7 +672,7 @@ export class MaterialService { * @param educationalMaterialID * @returns {Observable} Upload message */ - uploadImage(base64Image: string, educationalMaterialID?: number | string): Observable { + uploadImage(base64Image: string, educationalMaterialID?: number | string | null): Observable { const body: UploadImageBody = { base64image: base64Image }; educationalMaterialID = educationalMaterialID ?? this.educationalMaterialID$$.getValue() ?? null; if (educationalMaterialID) { @@ -693,8 +689,12 @@ export class MaterialService { map((event: HttpEvent) => { switch (event.type) { case HttpEventType.UploadProgress: - const progress = Math.round((100 * event.loaded) / event.total); - return { status: 'progress', message: progress }; + if (event.total) { + const progress = Math.round((100 * event.loaded) / event.total); + return { status: 'progress', message: progress }; + } else { + return { status: 'progress', message: 'Calculating...' }; + } case HttpEventType.Response: return { status: 'completed', message: event.body }; default: @@ -1009,6 +1009,25 @@ export class MaterialService { basicStudySubjects.length > 0 && basicStudySubjects[0].educationalFramework ? basicStudySubjects[0].educationalFramework : null, + preparatoryEducationSubjects: educationalMaterial.educationalAlignment + .filter((alignment) => alignment.source === koodistoSources.preparatoryEducationSubjects) + .map((alignment) => ({ + key: alignment.objectkey, + source: alignment.source, + alignmentType: alignment.alignmenttype, + targetName: alignment.targetname, + targetUrl: alignment.targeturl, + })), + preparatoryEducationObjectives: educationalMaterial.educationalAlignment + .filter((alignment) => alignment.source === koodistoSources.preparatoryEducationObjectives) + .map((alignment) => ({ + key: alignment.objectkey, + source: alignment.source, + alignmentType: alignment.alignmenttype, + educationalFramework: alignment.educationalframework, + targetName: alignment.targetname, + targetUrl: alignment.targeturl, + })), upperSecondarySchoolSubjectsOld: upperSecondarySubjectsOld, upperSecondarySchoolCoursesOld: upperSecondaryCoursesOld, suitsAllUpperSecondarySubjects: educationalMaterial.suitsAllUpperSecondarySubjects, @@ -1242,11 +1261,12 @@ export class MaterialService { map((event: HttpEvent) => { switch (event.type) { case HttpEventType.UploadProgress: - const progress = Math.round((100 * event.loaded) / event.total); - return { - status: 'progress', - message: progress, - }; + if (event.total) { + const progress = Math.round((100 * event.loaded) / event.total); + return { status: 'progress', message: progress }; + } else { + return { status: 'progress', message: 'Calculating...' }; + } case HttpEventType.Response: return { status: 'completed', diff --git a/src/app/views/collection-form/collection-educational-details-tab/collection-educational-details-tab.component.html b/src/app/views/collection-form/collection-educational-details-tab/collection-educational-details-tab.component.html index 459967ba3..505f0b086 100644 --- a/src/app/views/collection-form/collection-educational-details-tab/collection-educational-details-tab.component.html +++ b/src/app/views/collection-form/collection-educational-details-tab/collection-educational-details-tab.component.html @@ -9,6 +9,7 @@

{{ "forms.collection.educational.title" | translate }}

[multiple]="true" [closeOnSelect]="false" bindLabel="value" + id="educationalLevels" groupBy="children" labelForId="educationalLevels" formControlName="educationalLevels" @@ -32,6 +33,7 @@

{{ "forms.collection.educational.headings.early" | translate }}

[multiple]="true" [addTag]="addEarlyChildhoodEducationSubject" bindLabel="targetName" + id="earlyChildhoodEducationSubjects" labelForId="earlyChildhoodEducationSubjects" formControlName="earlyChildhoodEducationSubjects"> @@ -47,6 +49,7 @@

{{ "forms.collection.educational.headings.early" | translate }}

[multiple]="true" [addTag]="addEarlyChildhoodEducationObjective" bindLabel="targetName" + id="earlyChildhoodEducationObjectives" labelForId="earlyChildhoodEducationObjectives" formControlName="earlyChildhoodEducationObjectives"> @@ -101,6 +104,7 @@

{{ "forms.collection.educational.headings.prePrimary" | translate }}

[multiple]="true" [addTag]="addPrePrimaryEducationSubject" bindLabel="targetName" + id="prePrimaryEducationSubjects" labelForId="prePrimaryEducationSubjects" formControlName="prePrimaryEducationSubjects"> @@ -116,6 +120,7 @@

{{ "forms.collection.educational.headings.prePrimary" | translate }}

[multiple]="true" [addTag]="addPrePrimaryEducationObjective" bindLabel="targetName" + id="prePrimaryEducationObjectives" labelForId="prePrimaryEducationObjectives" formControlName="prePrimaryEducationObjectives"> @@ -169,6 +174,7 @@

{{ "forms.collection.educational.headings.basic" | translate }}

[closeOnSelect]="false" bindLabel="targetName" groupBy="children" + id="basicStudySubjects" labelForId="basicStudySubjects" formControlName="basicStudySubjects" (change)="basicStudySubjectsChange($event)"> @@ -189,6 +195,7 @@

{{ "forms.collection.educational.headings.basic" | translate }}

[multiple]="true" [closeOnSelect]="false" bindLabel="targetName" + id="basicStudyObjectives" groupBy="parent" labelForId="basicStudyObjectives" formControlName="basicStudyObjectives"> @@ -208,6 +215,7 @@

{{ "forms.collection.educational.headings.basic" | translate }}

[multiple]="true" [closeOnSelect]="false" bindLabel="targetName" + id="basicStudyContents" groupBy="parent" labelForId="basicStudyContents" formControlName="basicStudyContents"> @@ -254,6 +262,46 @@

{{ "forms.collection.educational.headings.basic" | translate }}

+ + +

{{ "forms.collection.educational.headings.preparatory" | translate }}

+ +
+ + + +
+ + +
+ + + +
+
+
+ +

{{ "forms.collection.educational.headings.upperSecondary" | translate }}

@@ -310,6 +358,7 @@

{{ "forms.collection.educational.upperSecondarySchoolSelection.current" | tr [multiple]="true" [closeOnSelect]="false" bindLabel="targetName" + id="upperSecondarySchoolSubjectsOld" groupBy="parent" labelForId="upperSecondarySchoolSubjectsOld" formControlName="upperSecondarySchoolSubjectsOld" @@ -332,6 +381,7 @@

{{ "forms.collection.educational.upperSecondarySchoolSelection.current" | tr [multiple]="true" [closeOnSelect]="false" bindLabel="targetName" + id="upperSecondarySchoolCoursesOld" groupBy="parent" labelForId="upperSecondarySchoolCoursesOld" formControlName="upperSecondarySchoolCoursesOld"> @@ -349,6 +399,7 @@

{{ "forms.collection.educational.upperSecondarySchoolSelection.current" | tr [multiple]="true" [addTag]="addUpperSecondarySchoolObjective" bindLabel="targetName" + id="upperSecondarySchoolObjectives" labelForId="upperSecondarySchoolObjectives" formControlName="upperSecondarySchoolObjectives"> @@ -403,6 +454,7 @@

{{ "forms.collection.educational.upperSecondarySchoolSelection.new" | transl [multiple]="true" [closeOnSelect]="false" bindLabel="targetName" + id="upperSecondarySchoolSubjectsNew" groupBy="parent" labelForId="upperSecondarySchoolSubjectsNew" formControlName="upperSecondarySchoolSubjectsNew" @@ -423,6 +475,7 @@

{{ "forms.collection.educational.upperSecondarySchoolSelection.new" | transl [multiple]="true" [closeOnSelect]="false" bindLabel="targetName" + id="upperSecondarySchoolModulesNew" groupBy="parent" labelForId="upperSecondarySchoolModulesNew" formControlName="upperSecondarySchoolModulesNew" @@ -440,6 +493,7 @@

{{ "forms.collection.educational.upperSecondarySchoolSelection.new" | transl [multiple]="true" [closeOnSelect]="false" bindLabel="targetName" + id="upperSecondarySchoolObjectivesNew" groupBy="parent" labelForId="upperSecondarySchoolObjectivesNew" formControlName="upperSecondarySchoolObjectivesNew"> @@ -456,6 +510,7 @@

{{ "forms.collection.educational.upperSecondarySchoolSelection.new" | transl [multiple]="true" [closeOnSelect]="false" bindLabel="targetName" + id="upperSecondarySchoolContentsNew" groupBy="parent" labelForId="upperSecondarySchoolContentsNew" formControlName="upperSecondarySchoolContentsNew"> @@ -477,6 +532,7 @@

{{ "forms.collection.educational.headings.vocational" | translate }}

[multiple]="true" [closeOnSelect]="false" bindLabel="targetName" + id="vocationalDegrees" labelForId="vocationalDegrees" formControlName="vocationalDegrees" (change)="vocationalDegreesChange($event)"> @@ -493,6 +549,7 @@

{{ "forms.collection.educational.headings.vocational" | translate }}

[multiple]="true" [closeOnSelect]="false" bindLabel="targetName" + id="vocationalCommonUnits" groupBy="children" labelForId="vocationalCommonUnits" formControlName="subjectOfCommonUnit"> @@ -510,6 +567,7 @@

{{ "forms.collection.educational.headings.vocational" | translate }}

[multiple]="true" [closeOnSelect]="false" bindLabel="targetName" + id="vocationalUnits" groupBy="parent" labelForId="vocationalUnits" formControlName="vocationalUnits" @@ -528,6 +586,7 @@

{{ "forms.collection.educational.headings.vocational" | translate }}

[closeOnSelect]="false" [addTag]="addVocationalEducationObjective" bindLabel="targetName" + id="vocationalRequirements" groupBy="parent" labelForId="vocationalRequirements" formControlName="vocationalRequirements"> @@ -584,6 +643,7 @@

{{ "forms.collection.educational.headings.selfMotivated" | translate }}

[multiple]="true" [addTag]="addSelfMotivatedEducationSubject" bindLabel="targetName" + id="selfMotivatedEducationSubjects" labelForId="selfMotivatedEducationSubjects" formControlName="selfMotivatedEducationSubjects"> @@ -599,6 +659,7 @@

{{ "forms.collection.educational.headings.selfMotivated" | translate }}

[multiple]="true" [addTag]="addSelfMotivatedEducationObjective" bindLabel="targetName" + id="selfMotivatedEducationObjectives" labelForId="selfMotivatedEducationObjectives" formControlName="selfMotivatedEducationObjectives"> @@ -619,6 +680,7 @@

{{ "forms.collection.educational.headings.higher" | translate }}

[selectableGroup]="true" [selectableGroupAsModel]="false" bindLabel="targetName" + id="scienceBranches" groupBy="children" labelForId="scienceBranches" formControlName="scienceBranches"> @@ -638,6 +700,7 @@

{{ "forms.collection.educational.headings.higher" | translate }}

[multiple]="true" [addTag]="addScienceBranchObjectives" bindLabel="targetName" + id="scienceBranchObjectives" labelForId="scienceBranchObjectives" formControlName="scienceBranchObjectives"> diff --git a/src/app/views/collection-form/collection-educational-details-tab/collection-educational-details-tab.component.ts b/src/app/views/collection-form/collection-educational-details-tab/collection-educational-details-tab.component.ts index 1e254a53e..bb64b8a4e 100644 --- a/src/app/views/collection-form/collection-educational-details-tab/collection-educational-details-tab.component.ts +++ b/src/app/views/collection-form/collection-educational-details-tab/collection-educational-details-tab.component.ts @@ -4,7 +4,7 @@ import { Router } from '@angular/router'; import { Title } from '@angular/platform-browser'; import { LangChangeEvent, TranslateService } from '@ngx-translate/core'; import { Subscription } from 'rxjs'; -import { environment } from '../../../../environments/environment'; +import { environment } from '@environments/environment'; import { addEarlyChildhoodEducationSubject, addEarlyChildhoodEducationObjective, @@ -45,6 +45,10 @@ export class CollectionEducationalDetailsTabComponent implements OnInit, OnDestr basicStudyObjectives: AlignmentObjectExtended[]; basicStudyContentSubscription: Subscription; basicStudyContents: AlignmentObjectExtended[]; + preparatoryEducationSubjectsSubscription: Subscription; + preparatoryEducationSubjects: AlignmentObjectExtended[]; + preparatoryEducationObjectivesSubscription: Subscription; + preparatoryEducationObjectives: AlignmentObjectExtended[]; upperSecondarySchoolSubjectOldSubscription: Subscription; upperSecondarySchoolSubjectsOld: AlignmentObjectExtended[]; upperSecondarySchoolCourseOldSubscription: Subscription; @@ -71,6 +75,8 @@ export class CollectionEducationalDetailsTabComponent implements OnInit, OnDestr hasPrePrimaryEducation = false; hasBasicStudies = false; hasBasicStudySubjects = false; + hasPreparatoryEducation = false; + hasPreparatoryEducationSubjects = false; hasUpperSecondarySchool = false; hasUpperSecondarySchoolSubjectsOld = false; hasUpperSecondarySchoolSubjectsNew = false; @@ -133,6 +139,8 @@ export class CollectionEducationalDetailsTabComponent implements OnInit, OnDestr Validators.maxLength(validatorParams.educationalFramework.maxLength), textInputValidator(), ]), + preparatoryEducationSubjects: this.fb.control(null), + preparatoryEducationObjectives: this.fb.control(null), currentUpperSecondarySchoolSelected: this.fb.control(false), newUpperSecondarySchoolSelected: this.fb.control(false), upperSecondarySchoolSubjectsOld: this.fb.control(null), @@ -212,6 +220,25 @@ export class CollectionEducationalDetailsTabComponent implements OnInit, OnDestr }, ); + // preparatory subjects + this.preparatoryEducationSubjectsSubscription = this.koodistoService.preparatorySubjects$.subscribe( + (subjects: AlignmentObjectExtended[]) => { + this.preparatoryEducationSubjects = subjects; + }, + ); + this.koodistoService.updatePreparatorySubjects(); + + if (this.preparatoryEducationSubjectsCtrl.value.length > 0) { + this.preparatoryEducationSubjectsChange(this.preparatoryEducationSubjectsCtrl.value); + } + + // preparatory objectives + this.preparatoryEducationObjectivesSubscription = this.koodistoService.preparatoryObjectives$.subscribe( + (objectives: AlignmentObjectExtended[]) => { + this.preparatoryEducationObjectives = objectives; + }, + ); + // upper secondary school subjects (old) this.upperSecondarySchoolSubjectOldSubscription = this.koodistoService.upperSecondarySchoolSubjectsOld$.subscribe( (subjects: AlignmentObjectExtended[]) => { @@ -328,6 +355,8 @@ export class CollectionEducationalDetailsTabComponent implements OnInit, OnDestr this.educationalLevelSubscription.unsubscribe(); this.basicStudySubjectSubscription.unsubscribe(); + this.preparatoryEducationSubjectsSubscription.unsubscribe(); + this.preparatoryEducationObjectivesSubscription.unsubscribe(); this.basicStudyObjectiveSubscription.unsubscribe(); this.basicStudyContentSubscription.unsubscribe(); this.upperSecondarySchoolSubjectOldSubscription.unsubscribe(); @@ -378,6 +407,10 @@ export class CollectionEducationalDetailsTabComponent implements OnInit, OnDestr return this.form.get('basicStudyFramework') as FormControl; } + get preparatoryEducationSubjectsCtrl(): FormControl { + return this.form.get('preparatoryEducationSubjects') as FormControl; + } + get currentUpperSecondarySchoolSelected(): FormControl { return this.form.get('currentUpperSecondarySchoolSelected') as FormControl; } @@ -452,6 +485,9 @@ export class CollectionEducationalDetailsTabComponent implements OnInit, OnDestr this.hasBasicStudySubjects = false; } + this.hasPreparatoryEducation = + value.filter((e: any) => educationalLevelKeys.preparatoryEducation.includes(e.key)).length > 0; + this.hasUpperSecondarySchool = value.filter((level: EducationalLevel) => educationalLevelKeys.upperSecondary.includes(level.key)).length > 0; @@ -481,6 +517,15 @@ export class CollectionEducationalDetailsTabComponent implements OnInit, OnDestr } } + preparatoryEducationSubjectsChange(value: AlignmentObjectExtended[]): void { + this.hasPreparatoryEducationSubjects = value.length > 0; + + if (this.hasPreparatoryEducationSubjects) { + const ids = value.map((degree: AlignmentObjectExtended) => degree.key).join(','); + this.koodistoService.updatePreparatoryObjectives(ids); + } + } + /** * Runs on upper secondary school subject (old) change. Sets hasUpperSecondarySchoolSubjectsOld boolean * value. Updates upper secondary school courses based on selected subjects. @@ -595,6 +640,11 @@ export class CollectionEducationalDetailsTabComponent implements OnInit, OnDestr this.basicStudyFrameworkCtrl.setValue(null); } + if (!this.hasPreparatoryEducation) { + this.preparatoryEducationSubjectsCtrl.setValue([]); + this.form.get('preparatoryEducationObjectives').setValue([]); + } + if (!this.hasBasicStudySubjects) { this.form.get('basicStudyObjectives').setValue([]); this.form.get('basicStudyContents').setValue([]); diff --git a/src/app/views/collection-form/collection-preview-tab/collection-preview-tab.component.html b/src/app/views/collection-form/collection-preview-tab/collection-preview-tab.component.html index 2d12f7417..daacfdb49 100644 --- a/src/app/views/collection-form/collection-preview-tab/collection-preview-tab.component.html +++ b/src/app/views/collection-form/collection-preview-tab/collection-preview-tab.component.html @@ -247,6 +247,28 @@

{{ "forms.collection.preview.headings.educational" | translate }}

+ +
{{ "forms.collection.educational.preparatoryEducationSubjects.label" | translate }}
+ +
+ + {{ subject.targetName }}{{ isLast ? "" : ", " }} + +
+
+ + + +
{{ "forms.collection.educational.preparatoryEducationObjectives.label" | translate }}
+ +
+ + {{ objective.targetName }}{{ isLast ? "" : ", " }} + +
+
+ +
{{ "forms.collection.educational.upperSecondarySchoolSubjects.label" | translate }}
diff --git a/src/app/views/collection-form/collection-preview-tab/collection-preview-tab.component.ts b/src/app/views/collection-form/collection-preview-tab/collection-preview-tab.component.ts index af6d24189..42d6f44e6 100644 --- a/src/app/views/collection-form/collection-preview-tab/collection-preview-tab.component.ts +++ b/src/app/views/collection-form/collection-preview-tab/collection-preview-tab.component.ts @@ -4,7 +4,7 @@ import { FormBuilder, FormGroup, Validators } from '@angular/forms'; import { LangChangeEvent, TranslateService } from '@ngx-translate/core'; import { Router } from '@angular/router'; import { Title } from '@angular/platform-browser'; -import { environment } from '../../../../environments/environment'; +import { environment } from '@environments/environment'; import { UpdateCollectionPut, UpdateCollectionPutHeading, @@ -193,6 +193,20 @@ export class CollectionPreviewTabComponent implements OnInit { delete this.previewCollection.basicStudyContents; delete this.previewCollection.basicStudyFramework; + //preparatory education + this.previewCollection.preparatoryEducationSubjects.forEach((subject: AlignmentObjectExtended) => { + alignmentObjects.push({ + ...subject, + }); + }); + + this.previewCollection.preparatoryEducationObjectives.forEach((objective: AlignmentObjectExtended) => { + alignmentObjects.push({ ...objective }); + }); + + delete this.previewCollection.preparatoryEducationSubjects; + delete this.previewCollection.preparatoryEducationObjectives; + // upper secondary school this.previewCollection.upperSecondarySchoolSubjectsOld.forEach((subject: AlignmentObjectExtended) => { alignmentObjects.push({ @@ -352,6 +366,6 @@ export class CollectionPreviewTabComponent implements OnInit { * Redirects user to previous tab. */ previous(): void { - this.router.navigate(['/kokoelma', this.collectionId, 'muokkaa', this.tabId - 1]); + this.router.navigate(['/kokoelma', this.collectionId, 'muokkaa', this.tabId - 1]).then(); } } diff --git a/src/app/views/collection-view/collection-view.component.html b/src/app/views/collection-view/collection-view.component.html index c65904faa..566444e39 100644 --- a/src/app/views/collection-view/collection-view.component.html +++ b/src/app/views/collection-view/collection-view.component.html @@ -262,6 +262,27 @@

{{ collection.name }}

+ + + + + + + {{ "forms.editEducationalResource.title" | translate }} -
diff --git a/src/app/views/educational-material-edit-form/educational-material-edit-form.component.ts b/src/app/views/educational-material-edit-form/educational-material-edit-form.component.ts index c661aa506..2bc5d95fb 100644 --- a/src/app/views/educational-material-edit-form/educational-material-edit-form.component.ts +++ b/src/app/views/educational-material-edit-form/educational-material-edit-form.component.ts @@ -61,9 +61,8 @@ export class EducationalMaterialEditFormComponent implements OnInit, OnDestroy { ngOnInit(): void { this.koodistoService.updateLicenses().subscribe(); - const educationalMaterialID: string = this.route.snapshot.paramMap.get('materialId'); - this.educationalMaterialID = +educationalMaterialID; - this.materialService.setEducationalMaterialID(educationalMaterialID); + this.educationalMaterialID = +this.route.snapshot.paramMap.get('materialId'); + this.materialService.setEducationalMaterialID(this.educationalMaterialID.toString()); this.subscriptionUpdateUploadedFiles = this.materialService .updateUploadedFiles(this.educationalMaterialID) .subscribe({ @@ -97,7 +96,7 @@ export class EducationalMaterialEditFormComponent implements OnInit, OnDestroy { this.subscriptionRoute = this.route.paramMap.subscribe((params: Params): void => { this.tabId = +params.get('tabId'); if (!this.tabId) { - void this.router.navigate(['/muokkaa-oppimateriaalia', educationalMaterialID, 1]); + void this.router.navigate(['/muokkaa-oppimateriaalia', this.educationalMaterialID, 1]); } }); this.subscriptionLanguageChange = this.translate.onLangChange.subscribe((event: LangChangeEvent): void => { diff --git a/src/app/views/educational-material-edit-form/tabs/edit-educational-details/edit-educational-details.component.html b/src/app/views/educational-material-edit-form/tabs/edit-educational-details/edit-educational-details.component.html index 248d37b54..bb10d19cb 100644 --- a/src/app/views/educational-material-edit-form/tabs/edit-educational-details/edit-educational-details.component.html +++ b/src/app/views/educational-material-edit-form/tabs/edit-educational-details/edit-educational-details.component.html @@ -396,6 +396,63 @@

{{ "forms.educationalResource.educationalDetails.basicEducation.title" | tra + + +
+

{{ "forms.educationalResource.educationalDetails.preparatoryEducation.title" | translate }}

+ + + + + + +
+ +
+ + + + + +
+
+
+ +

{{ "forms.educationalResource.educationalDetails.upperSecondarySchoolEducation.title" | translate }}

@@ -452,6 +509,7 @@

[multiple]="true" [closeOnSelect]="false" bindLabel="targetName" + id="upperSecondarySchoolSubjectsOld" groupBy="parent" labelForId="upperSecondarySchoolSubjectsOld" formControlName="upperSecondarySchoolSubjectsOld" @@ -474,6 +532,7 @@

[multiple]="true" [closeOnSelect]="false" bindLabel="targetName" + id="upperSecondarySchoolCoursesOld" groupBy="parent" labelForId="upperSecondarySchoolCoursesOld" formControlName="upperSecondarySchoolCoursesOld"> @@ -707,6 +766,7 @@

{{ "forms.educationalResource.educationalDetails.vocationalEducation.title" [multiple]="true" [closeOnSelect]="false" bindLabel="targetName" + id="furtherVocationalQualifications" labelForId="furtherVocationalQualifications" formControlName="furtherVocationalQualifications" (change)="vocationalDegreesChange()"> @@ -724,6 +784,7 @@

{{ "forms.educationalResource.educationalDetails.vocationalEducation.title" [multiple]="true" [closeOnSelect]="false" bindLabel="targetName" + id="specialistVocationalQualifications" labelForId="specialistVocationalQualifications" formControlName="specialistVocationalQualifications" (change)="vocationalDegreesChange()"> @@ -800,6 +861,7 @@

{{ "forms.educationalResource.educationalDetails.vocationalEducation.title" [closeOnSelect]="false" [addTag]="addVocationalEducationObjective" bindLabel="targetName" + id="vocationalRequirements" groupBy="parent" labelForId="vocationalRequirements" formControlName="vocationalRequirements"> diff --git a/src/app/views/educational-material-edit-form/tabs/edit-educational-details/edit-educational-details.component.ts b/src/app/views/educational-material-edit-form/tabs/edit-educational-details/edit-educational-details.component.ts index 9d5f066f1..ba101e1de 100644 --- a/src/app/views/educational-material-edit-form/tabs/edit-educational-details/edit-educational-details.component.ts +++ b/src/app/views/educational-material-edit-form/tabs/edit-educational-details/edit-educational-details.component.ts @@ -15,7 +15,7 @@ import { addUpperSecondarySchoolObjective, addVocationalEducationObjective, textInputValidator, -} from '../../../../shared/shared.module'; +} from '@shared/shared.module'; import { KoodistoService } from '@services/koodisto.service'; import { educationalLevelKeys } from '@constants/educational-level-keys'; import { validatorParams } from '@constants/validator-params'; @@ -43,6 +43,10 @@ export class EditEducationalDetailsComponent implements OnInit, OnDestroy { basicStudyObjectives: AlignmentObjectExtended[]; basicStudyContentSubscription: Subscription; basicStudyContents: AlignmentObjectExtended[]; + preparatoryEducationSubjectSubscription: Subscription; + preparatorySubjects: AlignmentObjectExtended[]; + preparatoryEducationObjectiveSubscription: Subscription; + preparatoryObjectives: AlignmentObjectExtended[]; upperSecondarySchoolSubjectOldSubscription: Subscription; upperSecondarySchoolSubjectsOld: AlignmentObjectExtended[]; upperSecondarySchoolCourseOldSubscription: Subscription; @@ -73,6 +77,8 @@ export class EditEducationalDetailsComponent implements OnInit, OnDestroy { hasPrePrimaryEducation = false; hasBasicStudies = false; hasBasicStudySubjects = false; + hasPreparatoryEducation = false; + hasPreparatoryEducationSubjects = false; hasUpperSecondarySchool = false; hasUpperSecondarySchoolSubjectsOld = false; hasUpperSecondarySchoolSubjectsNew = false; @@ -80,7 +86,6 @@ export class EditEducationalDetailsComponent implements OnInit, OnDestroy { hasVocationalEducation = false; hasVocationalDegrees = false; hasVocationalUnits = false; - hasVocationalCommonUnits = false; hasSelfMotivatedEducation = false; hasHigherEducation = false; addEarlyChildhoodEducationSubject = addEarlyChildhoodEducationSubject; @@ -130,6 +135,8 @@ export class EditEducationalDetailsComponent implements OnInit, OnDestroy { Validators.maxLength(validatorParams.educationalFramework.maxLength), textInputValidator(), ]), + preparatoryEducationSubjects: this.fb.control(null), + preparatoryEducationObjectives: this.fb.control(null), currentUpperSecondarySchoolSelected: this.fb.control(false), newUpperSecondarySchoolSelected: this.fb.control(false), upperSecondarySchoolSubjectsOld: this.fb.control(null), @@ -176,6 +183,7 @@ export class EditEducationalDetailsComponent implements OnInit, OnDestroy { this.setTitle(); this.koodistoService.updateEducationalLevels(); this.koodistoService.updateBasicStudySubjects(); + this.koodistoService.updatePreparatorySubjects(); this.koodistoService.updateUpperSecondarySchoolSubjectsOld(); this.koodistoService.updateUpperSecondarySchoolSubjectsNew(); this.koodistoService.updateVocationalDegrees(); @@ -195,6 +203,9 @@ export class EditEducationalDetailsComponent implements OnInit, OnDestroy { if (this.basicStudySubjectsCtrl.value && this.basicStudySubjectsCtrl.value.length > 0) { this.basicStudySubjectsChange(this.basicStudySubjectsCtrl.value); } + if (this.preparatoryEducationSubjectsCtrl.value?.length > 0) { + this.preparatoryEducationSubjectsChange(this.preparatoryEducationSubjectsCtrl.value); + } if ( this.upperSecondarySchoolSubjectsOldCtrl.value?.length > 0 || this.upperSecondarySchoolCoursesOldCtrl.value?.length > 0 @@ -251,6 +262,20 @@ export class EditEducationalDetailsComponent implements OnInit, OnDestroy { }, ); + //preparatory education + this.preparatoryEducationSubjectSubscription = this.koodistoService.preparatorySubjects$.subscribe( + (subjects: AlignmentObjectExtended[]) => { + this.preparatorySubjects = subjects; + }, + ); + this.koodistoService.updatePreparatorySubjects(); + + this.preparatoryEducationObjectiveSubscription = this.koodistoService.preparatoryObjectives$.subscribe( + (ojective: AlignmentObjectExtended[]) => { + this.preparatoryObjectives = ojective; + }, + ); + // upper secondary school subjects (old) this.upperSecondarySchoolSubjectOldSubscription = this.koodistoService.upperSecondarySchoolSubjectsOld$.subscribe( (subjects: AlignmentObjectExtended[]) => { @@ -358,6 +383,8 @@ export class EditEducationalDetailsComponent implements OnInit, OnDestroy { this.basicStudySubjectSubscription.unsubscribe(); this.basicStudyObjectiveSubscription.unsubscribe(); this.basicStudyContentSubscription.unsubscribe(); + this.preparatoryEducationSubjectSubscription.unsubscribe(); + this.preparatoryEducationObjectiveSubscription.unsubscribe(); this.upperSecondarySchoolSubjectOldSubscription.unsubscribe(); this.upperSecondarySchoolCourseOldSubscription.unsubscribe(); this.upperSecondarySchoolSubjectNewSubscription.unsubscribe(); @@ -403,6 +430,10 @@ export class EditEducationalDetailsComponent implements OnInit, OnDestroy { return this.form.get('basicStudyFramework') as FormControl; } + get preparatoryEducationSubjectsCtrl(): FormControl { + return this.form.get('preparatoryEducationSubjects') as FormControl; + } + get currentUpperSecondarySchoolSelected(): FormControl { return this.form.get('currentUpperSecondarySchoolSelected') as FormControl; } @@ -431,10 +462,6 @@ export class EditEducationalDetailsComponent implements OnInit, OnDestroy { return this.form.get('upperSecondarySchoolModulesNew') as FormControl; } - get newUpperSecondarySchoolFrameworkCtrl(): FormControl { - return this.form.get('newUpperSecondarySchoolFramework') as FormControl; - } - get vocationalDegreesCtrl(): FormControl { return this.form.get('vocationalDegrees') as FormControl; } @@ -483,6 +510,9 @@ export class EditEducationalDetailsComponent implements OnInit, OnDestroy { this.hasBasicStudySubjects = false; } + this.hasPreparatoryEducation = + value.filter((e: any) => educationalLevelKeys.preparatoryEducation.includes(e.key)).length > 0; + this.hasUpperSecondarySchool = value.filter((e: any) => educationalLevelKeys.upperSecondary.includes(e.key)).length > 0; @@ -510,6 +540,20 @@ export class EditEducationalDetailsComponent implements OnInit, OnDestroy { } } + /** + * Runs on preparatory education subjects change. Sets hasPreparatoryEducationSubjects boolean value. + * Updates preparatory education objectives based on selected subjects. + * @param value + */ + preparatoryEducationSubjectsChange(value: AlignmentObjectExtended[]): void { + this.hasPreparatoryEducationSubjects = value.length > 0; + + if (this.hasPreparatoryEducationSubjects) { + const ids = value.map((degree: AlignmentObjectExtended) => degree.key).join(','); + this.koodistoService.updatePreparatoryObjectives(ids); + } + } + /** * Runs on upper secondary school subject (old) change. Sets hasUpperSecondarySchoolSubjectsOld boolean * value. Updates upper secondary school courses based on selected subjects. @@ -629,6 +673,10 @@ export class EditEducationalDetailsComponent implements OnInit, OnDestroy { changedMaterial.basicStudyContents = this.form.get('basicStudyContents').value; changedMaterial.basicStudyFramework = this.form.get('basicStudyFramework').value; + // preparatory education + changedMaterial.preparatoryEducationSubjects = this.form.get('preparatoryEducationSubjects').value; + changedMaterial.preparatoryEducationObjectives = this.form.get('preparatoryEducationObjectives').value; + // upper secondary school changedMaterial.upperSecondarySchoolSubjectsOld = this.upperSecondarySchoolSubjectsOldCtrl.value; changedMaterial.upperSecondarySchoolCoursesOld = this.upperSecondarySchoolCoursesOldCtrl.value; diff --git a/src/app/views/educational-material-edit-form/tabs/edit-preview/edit-preview.component.html b/src/app/views/educational-material-edit-form/tabs/edit-preview/edit-preview.component.html index 7f66ca854..c73b8fc1f 100644 --- a/src/app/views/educational-material-edit-form/tabs/edit-preview/edit-preview.component.html +++ b/src/app/views/educational-material-edit-form/tabs/edit-preview/edit-preview.component.html @@ -355,6 +355,20 @@

{{ "forms.educationalResource.nav.educationalDetails" | translate }}

[title]="'forms.educationalResource.educationalDetails.basicEducation.inputs.framework.label' | translate" [item]="previewMaterial.basicStudyFramework"> + + + + + + { + alignmentObjects.push(subject); + }); + delete this.previewMaterial.preparatoryEducationSubjects; + + this.previewMaterial.preparatoryEducationObjectives.forEach((objective: AlignmentObjectExtended) => { + alignmentObjects.push(objective); + }); + delete this.previewMaterial.preparatoryEducationObjectives; + // higher education this.previewMaterial.branchesOfScience.forEach((branch: AlignmentObjectExtended) => { branch.educationalFramework = this.previewMaterial.higherEducationFramework; diff --git a/src/app/views/educational-material-view/educational-material-view.component.html b/src/app/views/educational-material-view/educational-material-view.component.html index cd66b1a69..537bd4c3b 100644 --- a/src/app/views/educational-material-view/educational-material-view.component.html +++ b/src/app/views/educational-material-view/educational-material-view.component.html @@ -97,6 +97,7 @@

{{ materialName }}

{{ type.value }} @@ -565,6 +566,29 @@

{{ "demo.educationalMaterial.license" | translate }}

+ + + + +
- + + -->
- -

{{ "forms.educationalResource.educationalDetails.upperSecondarySchoolEducation.title" | translate }}

- - - + +
+ + + + + +
+
+
+ + +

{{ "forms.educationalResource.educationalDetails.upperSecondarySchoolEducation.title" | translate }}

+

{{ "forms.educationalResource.educationalDetails.upperSecondarySchoolEducation.selection.current" | translate }} @@ -507,81 +528,9 @@

labelForId="upperSecondarySchoolObjectives" formControlName="upperSecondarySchoolObjectives"> - - - -