// This fixes a bunch of bugs within the voting functionality, let's go back to it when we look at bugs.
Problem
- After voting on a wish, there's no easy way to remove your vote or modify the comment (T399500)
- If a comment contains unbalanced wikitext, it can break display of the entire voting section (T404000)
- Users don't know that they need to go to a /Votes page to modify or remove votes, and even if they do, the syntax is not very straightforward to work with.
Proposal
Let's do like we've done for entity pages and treat the /Votes page as a pseudo-structured page managed only by the backend (or those with the manually-edit-wishlist user right).
We already have the ArgumentExtractor class that can turn wikitext using our parser functions into structured data. The only piece missing for this work for voting is to iterate over the /Votes page and feed each line into the ArgumentExtractor.
Doing this will solve the three problems above, since we can validate that the wikitext has no unbalanced tags or template syntax, and we'll be able to easily change or remove an existing vote.
We tie all this together in a new API module, ApiWishlistVote (or whatever), that works like the other ApiWishlistEntityBase subclasses by internally making an action=edit request. Then we can prevent manual editing of the /Votes page altogether.
Finally, the voting Vue app would need to be changed to use our API instead of editing the /Votes page directly. Also, the responsibility of purging the entity page can be moved to the backend, cleaning up the code a bit in the Vue app.
Drawbacks
- We possibly won't be able to allow for comments anymore, at least not easily.
- We don't want a situation where a DiscussionTools comment breaks things, and users have to ask a Community Wishlist manager to fix it.
- … ?
Acceptance criteria
- A new action=wishlistvote endpoint should be available that takes an entity (i.e. W1, FA4), a comment, and an action (either add or remove). QA efforts can be done solely using the voting button; There is no need to test the API directly.
- After placing a vote on a wish or focus area, a message like "You've already voted" should be shown, with buttons to edit the comment or remove the vote
- Any updates to the /Votes page via the voting button and dialog should be visible immediately (i.e. you shouldn't have to manually run action=purge on the page)
- An error should be shown when attempting to submit a vote with unbalanced wikitext (Example: This is my comment }}, or stray pipes like This | is my comment)