Skip to content

Conversation

FionaDL
Copy link
Member

@FionaDL FionaDL commented Oct 7, 2025

#30

This PR adds a modal to update the puzzles from the admin table. Before if there was a small mistake in a puzzle it was impossible to update it and it was usually rejected. Now the team that is looking over puzzles will be able to update them as well. I only allowed this to happen in the pending table so that we don't edit them in other tables once they have been approved, rejected, or archived. In my opinion it would be better for them to be moved back to the pending table if they need to be edited. Let me know if you disagree.

QA:

Click edit button on a puzzle and make sure you can edit all the fields, and that they are updated. make sure you can close to modal if you decide not to edit.

@@ -0,0 +1,11 @@
import { Controller } from "@hotwired/stimulus"

export default class extends Controller {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Closing the modal happens here.

Copy link
Member

@JuanVqz JuanVqz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not reviewing your PR just a small comment; feel free to skip it, though.

Copy link
Member

@JuanVqz JuanVqz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It depends on point of view, but the Puzzle model does not have at least one validation, meaning updating a record and removing all the content is valid. I'd say you need to add at least validates :question, presence: true this way you should show an error when trying to save it blank.

@JuanVqz JuanVqz mentioned this pull request Oct 8, 2025
@JuanVqz
Copy link
Member

JuanVqz commented Oct 8, 2025

It depends on point of view, but the Puzzle model does not have at least one validation, meaning updating a record and removing all the content is valid. I'd say you need to add at least validates :question, presence: true this way you should show an error when trying to save it blank.

I worked on it here #40, so this is out of the scope for this PR.

Copy link
Member

@JuanVqz JuanVqz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved in case you don't want to extract the raw table, which i think it adds value because in the future we may forget about updating the raw in both places.

Great Job! TIL: how turbo-frames works (still learning tho)

@FionaDL FionaDL requested a review from JuanVqz October 8, 2025 18:22
Remove unnecessary dataset action check in modal close method. Update
modal overlay to use click event for closing, ensuring consistent modal
dismissal behavior.

def update
@puzzle = Puzzle.find(params[:id])
if @puzzle.update(puzzle_params)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[non-blocking/question]

Do we need to respond to json and html requests?
Is it possible to make an html/json request using the UI?

@fbuys fbuys merged commit 2101f5a into main Oct 8, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants