4
11
Fork
You've already forked tomato
1

Edit page for trackers #184

Open
edwardloveall wants to merge 1 commit from el-edit-tracker into main
pull from: el-edit-tracker
merge into: rootable:main
rootable:main
rootable:el-tracker-receipts
rootable:el-exclude-tracker-site-receipt
rootable:el-trackers
rootable:el-occurrence-view
rootable:el-fix-shift-filter-time-zone
rootable:bb-reports

While this is mostly straight forward, I had to wrangle deleting shifts in the
form on an already existing tracker. If you set _destroy: true on a nested
attribute, it will be destroyed, but only after the parent model is saved.
That's not great for a form that's being edited but not yet saved.

So instead, I replaced the <button> with a checkbox styled to look like a
button. The label is hidden visually but still there for screen readers. If the
checkbox is checked, css hides the whole field! This works with the css :has
selector. So now the nested object persists on the form so it can be eventually
removed, or reverted when canceled, but appears removed for the user when
editing.

To make it not show up on the form, you have to:

  • assign_attributes to the already persisted model after fetching in the
    controller
  • check in nested form to see if the object it marked_for_destruction?. If it
    is, hide everything but the checkbox holding the _destroy attribute.
    assign_attributes converts the _destroy params into mark_for_destruction
    calls on the model.

Screen Shot 2026年07月08日 at 16.42.44-fullpage

While this is mostly straight forward, I had to wrangle deleting shifts in the form on an already existing tracker. If you set `_destroy: true` on a nested attribute, it will be destroyed, but only after the parent model is saved. That's not great for a form that's being edited but not yet saved. So instead, I replaced the `<button>` with a checkbox styled to look like a button. The label is hidden visually but still there for screen readers. If the checkbox is checked, css hides the whole field! This works with the css `:has` selector. So now the nested object persists on the form so it can be eventually removed, or reverted when canceled, but _appears_ removed for the user when editing. To make it not show up on the form, you have to: - `assign_attributes` to the already persisted model after fetching in the controller - check in nested form to see if the object it `marked_for_destruction?`. If it is, hide everything but the checkbox holding the `_destroy` attribute. `assign_attributes` converts the `_destroy` params into `mark_for_destruction` calls on the model. ![Screen Shot 2026年07月08日 at 16.42.44-fullpage](/attachments/a017d78f-06f6-4982-9d8d-a004c83b4513)
Edit page for trackers
Some checks failed
ci/woodpecker/pr/ci Pipeline failed
01fc7d4a75
While this is mostly straight forward, I had to wrangle deleting shifts in the
form on an already existing tracker. If you set `_destroy: true` on a nested
attribute, it will be destroyed, but only after the parent model is saved.
That's not great for a form that's being edited but not yet saved.
So instead, I replaced the `<button>` with a checkbox styled to look like a
button. The label is hidden visually but still there for screen readers. If the
checkbox is checked, css hides the whole field! This works with the css `:has`
selector. So now the nested object persists on the form so it can be eventually
removed, or reverted when canceled, but _appears_ removed for the user when
editing.
To make it not show up on the form, you have to:
- `assign_attributes` to the already persisted model after fetching in the
 controller
- check in nested form to see if the object it `marked_for_destruction?`. If it
 is, hide everything but the checkbox holding the `_destroy` attribute.
 `assign_attributes` converts the `_destroy` params into `mark_for_destruction`
 calls on the model.
edwardloveall changed target branch from el-tracker-totals to main 2026年07月09日 15:11:39 +02:00
edwardloveall force-pushed el-edit-tracker from 01fc7d4a75
Some checks failed
ci/woodpecker/pr/ci Pipeline failed
to d1f193fc17
All checks were successful
ci/woodpecker/pr/ci Pipeline was successful
2026年07月09日 15:13:47 +02:00
Compare
edwardloveall force-pushed el-edit-tracker from d1f193fc17
All checks were successful
ci/woodpecker/pr/ci Pipeline was successful
to 10a9736780
Some checks failed
ci/woodpecker/pr/ci Pipeline failed
2026年07月09日 20:22:14 +02:00
Compare
edwardloveall force-pushed el-edit-tracker from 10a9736780
Some checks failed
ci/woodpecker/pr/ci Pipeline failed
to 292aa13370
All checks were successful
ci/woodpecker/pr/ci Pipeline was successful
2026年07月13日 20:01:38 +02:00
Compare
All checks were successful
ci/woodpecker/pr/ci Pipeline was successful
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin el-edit-tracker:el-edit-tracker
git switch el-edit-tracker

Merge

Merge the changes and update on Forgejo.
git switch main
git merge --no-ff el-edit-tracker
git switch el-edit-tracker
git rebase main
git switch main
git merge --ff-only el-edit-tracker
git switch el-edit-tracker
git rebase main
git switch main
git merge --no-ff el-edit-tracker
git switch main
git merge --squash el-edit-tracker
git switch main
git merge --ff-only el-edit-tracker
git switch main
git merge el-edit-tracker
git push origin main
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
1 participant
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!184
Reference in a new issue
rootable/tomato
No description provided.
Delete branch "el-edit-tracker"

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?