feat(frontend): gebruikersvriendelijkere foutmeldingen voor foutieve leerpaden
This commit is contained in:
		
							parent
							
								
									ac933df57b
								
							
						
					
					
						commit
						759282f1c6
					
				
					 7 changed files with 22 additions and 8 deletions
				
			
		|  | @ -27,7 +27,7 @@ | ||||||
|     <div v-if="isError"> |     <div v-if="isError"> | ||||||
|         <v-empty-state |         <v-empty-state | ||||||
|             icon="mdi-alert-circle-outline" |             icon="mdi-alert-circle-outline" | ||||||
|             :text="errorMessage" |             :text="t(errorMessage)" | ||||||
|             :title="t('error_title')" |             :title="t('error_title')" | ||||||
|         ></v-empty-state> |         ></v-empty-state> | ||||||
|     </div> |     </div> | ||||||
|  |  | ||||||
|  | @ -1,7 +1,7 @@ | ||||||
| import { BaseController } from "@/controllers/base-controller.ts"; | import { BaseController } from "@/controllers/base-controller.ts"; | ||||||
| import type { Language } from "@/data-objects/language.ts"; | import type { Language } from "@/data-objects/language.ts"; | ||||||
| import { LearningPath } from "@/data-objects/learning-paths/learning-path"; | import { LearningPath } from "@/data-objects/learning-paths/learning-path"; | ||||||
| import { single } from "@/utils/response-assertions.ts"; | import { NotFoundException } from "@/exception/not-found-exception"; | ||||||
| import type { LearningPath as LearningPathDTO } from "@dwengo-1/common/interfaces/learning-content"; | import type { LearningPath as LearningPathDTO } from "@dwengo-1/common/interfaces/learning-content"; | ||||||
| 
 | 
 | ||||||
| export class LearningPathController extends BaseController { | export class LearningPathController extends BaseController { | ||||||
|  | @ -24,7 +24,10 @@ export class LearningPathController extends BaseController { | ||||||
|             assignmentNo: forGroup?.assignmentNo, |             assignmentNo: forGroup?.assignmentNo, | ||||||
|             classId: forGroup?.classId, |             classId: forGroup?.classId, | ||||||
|         }); |         }); | ||||||
|         return LearningPath.fromDTO(single(dtos)); |         if (dtos.length === 0) { | ||||||
|  |             throw new NotFoundException('learningPathNotFound') | ||||||
|  |         } | ||||||
|  |         return LearningPath.fromDTO(dtos[0]); | ||||||
|     } |     } | ||||||
|     async getAllByTheme(theme: string): Promise<LearningPath[]> { |     async getAllByTheme(theme: string): Promise<LearningPath[]> { | ||||||
|         const dtos = await this.get<LearningPathDTO[]>("/", { theme }); |         const dtos = await this.get<LearningPathDTO[]>("/", { theme }); | ||||||
|  |  | ||||||
|  | @ -93,7 +93,10 @@ export class LearningPath { | ||||||
|         const startNodeDtos = dto.nodes.filter((it) => it.start_node === true); |         const startNodeDtos = dto.nodes.filter((it) => it.start_node === true); | ||||||
|         if (startNodeDtos.length < 1) { |         if (startNodeDtos.length < 1) { | ||||||
|             // The learning path has no starting node -> use the first node.
 |             // The learning path has no starting node -> use the first node.
 | ||||||
|             return dto.nodes[0]; |             if (dto.nodes.length > 0) { | ||||||
|  |                 return dto.nodes[0]; | ||||||
|  |             } | ||||||
|  |             throw new Error("emptyLearningPath"); | ||||||
|         } // The learning path has 1 or more starting nodes -> use the first start node.
 |         } // The learning path has 1 or more starting nodes -> use the first start node.
 | ||||||
|         return startNodeDtos[0]; |         return startNodeDtos[0]; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  | @ -160,5 +160,7 @@ | ||||||
|     "learningPathCantModifyId": "Der HRUID oder die Sprache eines Lernpfads kann nicht geändert werden.", |     "learningPathCantModifyId": "Der HRUID oder die Sprache eines Lernpfads kann nicht geändert werden.", | ||||||
|     "error": "Fehler", |     "error": "Fehler", | ||||||
|     "ownLearningContentTitle": "Eigene Lerninhalte", |     "ownLearningContentTitle": "Eigene Lerninhalte", | ||||||
|     "ownLearningContentDescription": "Erstellen und verwalten Sie eigene Lernobjekte und Lernpfade. Nur für fortgeschrittene Nutzer." |     "ownLearningContentDescription": "Erstellen und verwalten Sie eigene Lernobjekte und Lernpfade. Nur für fortgeschrittene Nutzer.", | ||||||
|  |     "learningPathNotFound": "Dieser Lernpfad konnte nicht gefunden werden.", | ||||||
|  |     "emptyLearningPath": "Dieser Lernpfad enthält keine Lernobjekte." | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -160,5 +160,7 @@ | ||||||
|     "learningPathCantModifyId": "The HRUID or language of a learning path cannot be modified.", |     "learningPathCantModifyId": "The HRUID or language of a learning path cannot be modified.", | ||||||
|     "error": "Error", |     "error": "Error", | ||||||
|     "ownLearningContentTitle": "Own learning content", |     "ownLearningContentTitle": "Own learning content", | ||||||
|     "ownLearningContentDescription": "Create and administrate your own learning objects and learning paths. For advanced users only." |     "ownLearningContentDescription": "Create and administrate your own learning objects and learning paths. For advanced users only.", | ||||||
|  |     "learningPathNotFound": "This learning path could not be found.", | ||||||
|  |     "emptyLearningPath": "This learning path does not contain any learning objects." | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -161,5 +161,7 @@ | ||||||
|     "learningPathCantModifyId": "Le HRUID ou la langue d’un parcours ne peuvent pas être modifiés.", |     "learningPathCantModifyId": "Le HRUID ou la langue d’un parcours ne peuvent pas être modifiés.", | ||||||
|     "error": "Erreur", |     "error": "Erreur", | ||||||
|     "ownLearningContentTitle": "Contenu d’apprentissage personnel", |     "ownLearningContentTitle": "Contenu d’apprentissage personnel", | ||||||
|     "ownLearningContentDescription": "Créez et gérez vos propres objets et parcours d’apprentissage. Réservé aux utilisateurs avancés." |     "ownLearningContentDescription": "Créez et gérez vos propres objets et parcours d’apprentissage. Réservé aux utilisateurs avancés.", | ||||||
|  |     "learningPathNotFound": "Ce parcours d'apprentissage est introuvable.", | ||||||
|  |     "emptyLearningPath": "Ce parcours d'apprentissage ne contient aucun objet d'apprentissage." | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -160,5 +160,7 @@ | ||||||
|     "learningPathCantModifyId": "De HRUID of taal van een leerpad kan niet worden gewijzigd.", |     "learningPathCantModifyId": "De HRUID of taal van een leerpad kan niet worden gewijzigd.", | ||||||
|     "error": "Fout", |     "error": "Fout", | ||||||
|     "ownLearningContentTitle": "Eigen leerinhoud", |     "ownLearningContentTitle": "Eigen leerinhoud", | ||||||
|     "ownLearningContentDescription": "Maak en beheer je eigen leerobjecten en leerpads. Alleen voor gevorderde gebruikers." |     "ownLearningContentDescription": "Maak en beheer je eigen leerobjecten en leerpads. Alleen voor gevorderde gebruikers.", | ||||||
|  |     "learningPathNotFound": "Dit leerpad kon niet gevonden worden.", | ||||||
|  |     "emptyLearningPath": "Dit leerpad bevat geen leerobjecten." | ||||||
| } | } | ||||||
|  |  | ||||||
		Reference in a new issue
	
	 Gerald Schmittinger
						Gerald Schmittinger