diff --git a/extend.php b/extend.php index 29148236..292c1ff3 100755 --- a/extend.php +++ b/extend.php @@ -21,7 +21,6 @@ use Flarum\Post\Post; use Flarum\Settings\Event\Saved as SettingsSaved; use FoF\Polls\Api\Controllers; -use FoF\Polls\Api\Serializers\PollSerializer; return [ (new Extend\Frontend('forum')) @@ -57,7 +56,7 @@ ->attributes(Api\AddDiscussionAttributes::class), (new Extend\ApiSerializer(PostSerializer::class)) - ->hasMany('polls', PollSerializer::class) + ->hasMany('polls', Api\Serializers\PollSerializer::class) ->attributes(Api\AddPostAttributes::class), (new Extend\ApiSerializer(ForumSerializer::class)) diff --git a/js/src/common/models/Poll.tsx b/js/src/common/models/Poll.tsx deleted file mode 100644 index 79d88072..00000000 --- a/js/src/common/models/Poll.tsx +++ /dev/null @@ -1,55 +0,0 @@ -import app from 'flarum/forum/app'; -import Model from 'flarum/common/Model'; -import User from 'flarum/common/Model'; -import computed from 'flarum/common/utils/computed'; - -export default class Poll extends Model { - title() { - return Model.attribute('title').call(this); - } - slug() { - return Model.attribute('slug').call(this); - } - - createdAt() { - return Model.attribute('createdAt', Model.transformDate).call(this); - } - user() { - return Model.hasOne('user').call(this); - } - - voteCount() { - return Model.attribute('voteCount').call(this); - } - - // TODO: These two don't make sense as of now - isUnread() { - return computed('unreadCount', (unreadCount) => !!unreadCount).call(this); - } - isRead() { - return computed('unreadCount', (unreadCount) => !!(app.session.user && !unreadCount)).call(this); - } - - hiddenAt() { - return Model.attribute('hiddenAt', Model.transformDate).call(this); - } - hiddenUser() { - return Model.hasOne('hiddenUser').call(this); - } - isHidden() { - return computed('hiddenAt', (hiddenAt) => !!hiddenAt).call(this); - } - - canVote() { - return Model.attribute('canVote').call(this); - } - canRename() { - return Model.attribute('canRename').call(this); - } - canHide() { - return Model.attribute('canHide').call(this); - } - canDelete() { - return Model.attribute('canDelete').call(this); - } -} diff --git a/js/src/forum/addNavItem.ts b/js/src/forum/addNavItem.ts index 56e7b0ad..da75df08 100644 --- a/js/src/forum/addNavItem.ts +++ b/js/src/forum/addNavItem.ts @@ -6,7 +6,7 @@ import LinkButton from 'flarum/common/components/LinkButton'; export default function addNavItem() { extend(IndexPage.prototype, 'navItems', (items) => { items.add( - 'fof-polls-directory', + 'fof-polls-list', LinkButton.component( { href: app.route('fof_polls_list'), diff --git a/js/src/forum/extend.ts b/js/src/forum/extend.ts index 427dfd04..0e191782 100644 --- a/js/src/forum/extend.ts +++ b/js/src/forum/extend.ts @@ -9,7 +9,9 @@ import PollsPage from './components/PollsPage'; import ComposePollPage from './components/ComposePollPage'; export default [ - new Extend.Routes().add('fof_polls_list', '/polls', PollsPage).add('fof_polls_compose', '/polls/composer', ComposePollPage), + new Extend.Routes() // + .add('fof_polls_list', '/polls', PollsPage) + .add('fof_polls_compose', '/polls/composer', ComposePollPage), new Extend.Store() // .add('polls', Poll)