From 7d2837490c12b8351169807a1877235691b4d729 Mon Sep 17 00:00:00 2001 From: Process-ing Date: Thu, 6 Feb 2025 15:56:19 +0000 Subject: [PATCH] Calculate course abbreviation when not provided --- .../lib/view/academic_path/courses_page.dart | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/packages/uni_app/lib/view/academic_path/courses_page.dart b/packages/uni_app/lib/view/academic_path/courses_page.dart index cd5c746fc..5318dd29f 100644 --- a/packages/uni_app/lib/view/academic_path/courses_page.dart +++ b/packages/uni_app/lib/view/academic_path/courses_page.dart @@ -45,6 +45,22 @@ class CoursesPageState extends State { return year; } + String _getCourseAbbreviation(Course course) { + if (course.abbreviation != null) { + return course.abbreviation!; + } + + if (course.name == null) { + return '???'; + } + + return course.name! + .replaceAll('Licenciatura', 'Licenciatura.') + .replaceAll('Mestrado', 'Mestrado.') + .replaceAll('Doutoramento', 'Doutoramento.') + .replaceAll(RegExp('[^A-Z.]'), ''); + } + @override Widget build(BuildContext context) { return Padding( @@ -60,7 +76,7 @@ class CoursesPageState extends State { child: CourseSelection( courseInfos: courses.map((course) { return CourseInfo( - abbreviation: course.abbreviation ?? '???', + abbreviation: _getCourseAbbreviation(course), enrollmentYear: course.firstEnrollment!, conclusionYear: _getConclusionYear(course), );