feat: support manual course editing#667
Conversation
- Added `MANUALLY_ADDED_ROOM_ID` constant and `isManuallyAdded` getter to the `Course` model to replace hardcoded room ID. - Renamed `courseRoomIdcontroller` to `courseRoomNameController` for consistency.
- Updated `ManuallyAddCourseDialog` to support an `initialCourse` for editing existing entries. It might be renamed then. - Added `EditCourseEvent` and its stream listener to handle corse updates. - Extract some common logics in `ManuallyAddCourseDialog` into separate functions. # Conflicts: # lib/widget/dialogs/manually_add_course_dialog.dart
- Replace hardcoded `Constant.WeekDays` list with `DateFormat.E()`. - Move `kMonday` anchor from `TimeTable` to `Constant` for centralized access. - Update manual course dialogs and timetable to use the new method.
- Implement `Comparable` for `CourseTime` to support sorting by weekday and slot. - Support removing a `CourseTime` by both clicking a button or swiping horizontally
And implement deep copy.
There was a problem hiding this comment.
Pull request overview
Adds support for editing manually added courses from the timetable UI, including updating existing course fields and managing course meeting times, while improving weekday i18n formatting across the app.
Changes:
- Extend the manual course dialog to accept an
initialCoursefor editing, and support removing course times plus sorting/deduping after additions. - Add an edit action for manually added courses in the timetable page and wire it through an
EditCourseEvent. - Centralize weekday string formatting via
Constant.weekDay()and update relevant UI/data formatting to use it.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| lib/widget/dialogs/manually_add_course_dialog_sub.dart | Uses slot-count derived from timetable config and switches weekday label rendering to Constant.weekDay(). |
| lib/widget/dialogs/manually_add_course_dialog.dart | Supports editing via initialCourse, provides time tile removal UI, and attempts to sort/dedup added times. |
| lib/page/subpage_timetable.dart | Adds edit event/subscription and shows an edit button for manually added courses. |
| lib/model/time_table.dart | Adds Course.copyWith, Course.isManuallyAdded, and makes CourseTime comparable; updates weekday formatting usage. |
| lib/common/constant.dart | Introduces Constant.weekDay() (intl-based) and moves the “reference Monday” constant here. |
Comments suppressed due to low confidence (1)
lib/model/time_table.dart:355
CourseTimeis used inSetoperations (e.g.,toSet()for dedup) and is nowComparable, but it still lacksoperator==/hashCode. Without value equality (weekDay+slot), deduplication viaSet<CourseTime>will not work and may leave duplicate times. Implement==andhashCodeconsistent withcompareTo(and ideally keep it immutable).
class CourseTime implements Comparable<CourseTime> {
//Monday is 0, Morning lesson is 0
int weekDay, slot;
CourseTime(this.weekDay, this.slot);
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Reminder: It might be worth taking a look at Copilot's suggestions too. Even though I mentioned earlier that most of them aren't helpful, these specific ones actually seem to make sense. |
To correctly deduplicate slots of courses.
- Deleted `lib/widget/dialogs/manually_add_course_dialog_sub.dart`. - Appended the `AddCourseDialogSub` class and its state to `lib/widget/dialogs/manually_add_course_dialog.dart`.
Instead of new ID, remove the courses with the old ID. This ensures the courses with the old ID to be deleted even though the user modified the ID. By the way, when the ID is not unique, all matching courses are deleted, as this is the behaviour of the delete button.
There was a problem hiding this comment.
Pull request overview
Adds manual-course editing support in the timetable UI, including removing course times and improving weekday localization.
Changes:
- Extend the manual add course dialog to support editing an existing course and removing selected time entries.
- Add Course/CourseTime utilities (manual-course identifier,
copyWith,Comparable/equality) to enable deduplication + sorting of times. - Centralize weekday display via
Constant.weekDay()to improve i18n.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| lib/widget/dialogs/manually_add_course_dialog_sub.dart | Removes the standalone slot-selection sub-dialog (logic moved inline). |
| lib/widget/dialogs/manually_add_course_dialog.dart | Adds edit-mode support (initialCourse), dedup/sort on add, and UI to remove times. |
| lib/page/subpage_timetable.dart | Introduces edit event flow and surfaces edit action for manually-added courses. |
| lib/model/time_table.dart | Adds manual-course identifier helpers, Course.copyWith, and CourseTime ordering/equality. |
| lib/common/constant.dart | Adds localized weekday helper (weekDay) and moves weekday formatting dependency here. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Has GitHub upgraded the base model for their Copilot? 🤔 Those suggestions still look valid to me. Please take a look. |
And uninfy the `times` to be ungrowable.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
- Implemented validation in `ManuallyAddCourseDialog` to ensure course IDs are non-empty and unique among existing manual courses. - Refactored warning dialog logic into a helper method `_showWarningDialog`. - Added localization strings for empty and conflicting course ID provided.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| final availableWeeks = newCourse.availableWeeks; | ||
| if (availableWeeks != null) { | ||
| // Populate staged course times from the initial course, and drop the old | ||
| // ones. | ||
| widget.courseAvailableList.clear(); | ||
| widget.courseAvailableList.addAll(availableWeeks); | ||
| } |
| PlatformDialogAction( | ||
| child: Text(S.of(context).ok), | ||
| onPressed: () { |
|
Some confirmations:
Are these OK? |
That's okay to me. |
w568w
left a comment
There was a problem hiding this comment.
LGTM. Thanks for your contribution!
Close #666.