-
Notifications
You must be signed in to change notification settings - Fork 136
Fix: Inline validation for empty and duplicate tags in Tag Editor #519
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -17,6 +17,9 @@ class DetailRouteController extends GetxController { | |||||
| var onEdit = false.obs; | ||||||
| var isReadOnly = false.obs; | ||||||
|
|
||||||
| // Track whether user explicitly selected a start date | ||||||
| bool startEdited = false; | ||||||
|
|
||||||
| @override | ||||||
| void onInit() { | ||||||
| super.onInit(); | ||||||
|
|
@@ -50,13 +53,19 @@ class DetailRouteController extends GetxController { | |||||
| } | ||||||
|
|
||||||
| if (name == 'start') { | ||||||
| debugPrint('Start Value Changed to $newValue'); | ||||||
| startEdited = true; // MARK AS USER-SELECTED | ||||||
| startValue.value = newValue; | ||||||
| } | ||||||
| initValues(); | ||||||
| } | ||||||
|
|
||||||
| Future<void> saveChanges() async { | ||||||
| // If start was never edited AND backend auto-generated it (start == entry) | ||||||
| if (!startEdited && | ||||||
| modify.original.start != null && | ||||||
| modify.original.start!.isAtSameMomentAs(modify.original.entry)) { | ||||||
| modify.set('start', null); // remove auto start | ||||||
| } | ||||||
| var now = DateTime.now().toUtc(); | ||||||
| modify.save(modified: () => now); | ||||||
| onEdit.value = false; | ||||||
|
|
@@ -106,7 +115,20 @@ class DetailRouteController extends GetxController { | |||||
| statusValue.value = modify.draft.status; | ||||||
| entryValue.value = modify.draft.entry; | ||||||
| modifiedValue.value = modify.draft.modified; | ||||||
| startValue.value ??= null; | ||||||
| final originalStart = modify.original.start; | ||||||
| final originalEntry = modify.original.entry; | ||||||
|
|
||||||
| final backendAutoStart = (originalStart != null && | ||||||
| originalStart.isAtSameMomentAs(originalEntry)); | ||||||
|
|
||||||
| // START DATE LOGIC (THE FIX) | ||||||
| if (startEdited) { | ||||||
| startValue.value = modify.draft.start; | ||||||
| } else if (backendAutoStart) { | ||||||
| startValue.value = null; // Do not show backend auto start | ||||||
|
||||||
| startValue.value = null; // Do not show backend auto start | |
| startValue.value = null; // Hide backend-generated start date (start == entry) from UI |
Copilot
AI
Dec 9, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The comment "Existing meaningful start" could be clearer. Consider: "Show user-set or pre-existing start date (not auto-generated)" to better distinguish this case from the other branches.
| startValue.value = modify.draft.start; // Existing meaningful start | |
| startValue.value = modify.draft.start; // Show user-set or pre-existing start date (not auto-generated) |
Copilot
AI
Dec 9, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] This code style change from an if-else block to a ternary-like expression should be reverted or explained. The original code was more readable with explicit if-else blocks. If this change is intentional for consistency with project style, it should be in a separate commit focused on code style improvements, not bundled with functional changes.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -234,10 +234,17 @@ class TagsRouteState extends State<TagsRoute> { | |
| color: tColors.primaryTextColor, | ||
| ), | ||
| validator: (value) { | ||
| if (value != null) { | ||
| if (value.isNotEmpty && value.contains(" ")) { | ||
| return "Tags cannot contain spaces"; | ||
| } | ||
| if (value == null || value.trim().isEmpty) { | ||
| return "Please enter a tag"; | ||
| } | ||
| final tag = value.trim(); | ||
|
Comment on lines
+237
to
+240
|
||
| if (tag.contains(" ")) { | ||
| return "Tags cannot contain spaces"; | ||
| } | ||
| final currentTags = | ||
| draftTags?.build().toList() ?? <String>[]; | ||
| if (currentTags.contains(tag)) { | ||
| return "Tag already exists"; | ||
| } | ||
| return null; | ||
|
Comment on lines
236
to
249
|
||
| }, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The inline comment "remove auto start" is redundant given the self-documenting nature of the code (
modify.set('start', null)). The larger block comment above (lines 63-66) already explains the intent. Consider removing this inline comment to reduce noise.