-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
More features & breaking v2 changes (#74)
* Move voters button next to heading & fix no permission error after poll ends * Create endpoint for new poll to add to existing post (refs #67, #16) * Drop 'newPollVote' websocket message (fixes #38) * Remove deprecated single vote API endpoint * Drop ReFlar/polls database compatibility * Rename 'canSeeVotes' to 'canseeVoters' * Don't show if post is hidden unless revealing content, adjust some styling * Add visibility scoping to polls, prohibit actions if user cannot view post * Reduce quirkiness with poll option tooltips & disable voting while voting * Move 'canStartPolls' global attribute to ForumSerializer * Don't check for existence of post when poll is created during post creation * Fix check for being able to start poll in non-existing post * Fix frontend not allowing clearing existing poll's end date * Separate edit permission into own polls & polls in own posts
- Loading branch information
1 parent
1d54e7d
commit 533b54b
Showing
33 changed files
with
592 additions
and
606 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import app from 'flarum/forum/app'; | ||
|
||
import { extend } from 'flarum/common/extend'; | ||
import PostControls from 'flarum/forum/utils/PostControls'; | ||
import CreatePollModal from './components/CreatePollModal'; | ||
import Button from 'flarum/common/components/Button'; | ||
|
||
export default () => { | ||
const createPoll = (post) => | ||
app.modal.show(CreatePollModal, { | ||
onsubmit: (data) => | ||
app.store | ||
.createRecord('polls') | ||
.save( | ||
{ | ||
...data, | ||
relationships: { | ||
post, | ||
}, | ||
}, | ||
{ | ||
data: { | ||
include: 'options,myVotes,myVotes.option', | ||
}, | ||
} | ||
) | ||
.then((poll) => { | ||
post.rawRelationship('polls')?.push?.({ type: 'polls', id: poll.id() }); | ||
|
||
return poll; | ||
}), | ||
}); | ||
|
||
extend(PostControls, 'moderationControls', function (items, post) { | ||
if (!post.isHidden() && post.canStartPoll()) { | ||
items.add( | ||
'addPoll', | ||
<Button icon="fas fa-poll" onclick={createPoll.bind(this, post)}> | ||
{app.translator.trans('fof-polls.forum.moderation.add')} | ||
</Button> | ||
); | ||
} | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.