5
11
Fork
You've already forked tomato
1

Ensure event tasks show up in order #139

Merged
edwardloveall merged 1 commit from el-edit-task-order into main 2026年04月13日 20:43:22 +02:00

Tasks were appearing out of order. On the shift occurrence show page the tasks are listed by calling occurrence.tasks.each which sorts them by event_tasks.order. That's good! But when editing, the tasks were listed with Task.where(id: event_params.fetch(:task_ids, []) + @occurrence.task_ids). Because not all the tasks are saved in the database, we can't take the event_tasks.order into account.

To solve this is a bit complex, but what we do is:

  • If there are no task_id in the params, use what's in the database, in event_tasks.order. But if there are task_id in the params, we can use the tasks there as they represent all the tasks we want on the event in the correct order.
  • When fetching the tasks for the edit page, we use rails' in_order_of method to ensure they are sorted.
  • Because they are saved in that order the show page will order them correctly.
Tasks were appearing out of order. On the shift occurrence show page the tasks are listed by calling `occurrence.tasks.each` which sorts them by `event_tasks.order`. That's good! But when editing, the tasks _were_ listed with `Task.where(id: event_params.fetch(:task_ids, []) + @occurrence.task_ids)`. Because not all the tasks are saved in the database, we can't take the `event_tasks.order` into account. To solve this is a bit complex, but what we do is: - If there are no `task_id` in the params, use what's in the database, in `event_tasks.order`. But if there are `task_id` in the params, we can use the tasks there as they represent all the tasks we want on the event in the correct order. - When fetching the tasks for the edit page, we use rails' `in_order_of` method to ensure they are sorted. - Because they are saved in that order the show page will order them correctly.
edwardloveall force-pushed el-edit-task-order from d052796fd4
Some checks are pending
ci/woodpecker/pr/ci Pipeline is pending
to fd4ad24178
Some checks failed
ci/woodpecker/pr/ci Pipeline failed
2026年04月13日 16:08:35 +02:00
Compare
edwardloveall changed target branch from el-event-cleanup to main 2026年04月13日 16:10:41 +02:00
edwardloveall force-pushed el-edit-task-order from fd4ad24178
Some checks failed
ci/woodpecker/pr/ci Pipeline failed
to f59ac3e70e
All checks were successful
ci/woodpecker/pr/ci Pipeline was successful
2026年04月13日 20:34:53 +02:00
Compare
edwardloveall deleted branch el-edit-task-order 2026年04月13日 20:43:22 +02:00
Sign in to join this conversation.
No reviewers
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
rootable/tomato!139
Reference in a new issue
rootable/tomato
No description provided.
Delete branch "el-edit-task-order"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?