diff --git a/extend.php b/extend.php index 1282d5d4..394b0172 100755 --- a/extend.php +++ b/extend.php @@ -27,7 +27,7 @@ ->js(__DIR__.'/js/dist/forum.js') ->css(__DIR__.'/resources/less/forum.less') ->route('/polls', 'fof_polls_directory', Content\PollsDirectory::class) - //->route('/polls/{id}', 'fof.poll.view') + ->route('/polls/view/{id}', 'fof.poll.view') ->route('/polls/composer', 'fof.polls.composer'), (new Extend\Frontend('admin')) diff --git a/js/src/forum/components/ComposePollHero.tsx b/js/src/forum/components/ComposePollHero.tsx index f60d47af..7a36cda5 100644 --- a/js/src/forum/components/ComposePollHero.tsx +++ b/js/src/forum/components/ComposePollHero.tsx @@ -22,7 +22,7 @@ export default class ComposePollHero extends Component { icon="far fa-edit" className="Button Button--secondary IndexPage-newDiscussion GoodiesManagerLink" itemClassName="App-primaryControl" - href={app.route('fof_polls_list')} + href={app.route('fof.polls.list')} > {app.translator.trans('fof-polls.forum.compose.polls_manager')} @@ -31,7 +31,7 @@ export default class ComposePollHero extends Component { icon="far fa-arrow-up-right-from-square" className="Button Button--secondary IndexPage-newDiscussion GoodiePreviewLink" itemClassName="App-primaryControl" - href={app.route('fof_polls_list', { id: poll.id() })} + href={app.route('fof.polls.list', { id: poll.id() })} external={true} target="_blank" > diff --git a/js/src/forum/components/PollViewPage.tsx b/js/src/forum/components/PollViewPage.tsx index acff8a7e..54afd2d1 100644 --- a/js/src/forum/components/PollViewPage.tsx +++ b/js/src/forum/components/PollViewPage.tsx @@ -7,14 +7,14 @@ import LoadingIndicator from 'flarum/common/components/LoadingIndicator'; import PollView from './PollView'; export default class PollViewPage extends Page { - poll: PollModel | null = null; + poll: PollModel | null | undefined = null; loading: boolean = false; oninit(vnode: Mithril.Vnode) { super.oninit(vnode); const editId = m.route.param('id'); - this.poll = app.store.getById('poll', editId) as PollModel; + this.poll = app.store.getById('poll', editId); if (!this.poll) { this.loading = true; @@ -33,14 +33,12 @@ export default class PollViewPage extends Page { return ; } - if (this.poll) { - return ( -
-
- -
+ return ( +
+
+
- ); - } +
+ ); } } diff --git a/js/src/forum/components/PollsPage.tsx b/js/src/forum/components/PollsPage.tsx index 82dee5ab..ec64e371 100644 --- a/js/src/forum/components/PollsPage.tsx +++ b/js/src/forum/components/PollsPage.tsx @@ -139,6 +139,6 @@ export default class PollsPage extends Page { return; } - m.route.set(app.route('fof_polls_compose')); + m.route.set(app.route('fof.polls.compose')); } } diff --git a/js/src/forum/extend.ts b/js/src/forum/extend.ts index 9442fe09..5d7e98d1 100644 --- a/js/src/forum/extend.ts +++ b/js/src/forum/extend.ts @@ -3,7 +3,6 @@ import Post from 'flarum/common/models/Post'; import Forum from 'flarum/common/models/Forum'; import Discussion from 'flarum/common/models/Discussion'; import Poll from './models/Poll'; -import PollView from './components/PollView'; import PollOption from './models/PollOption'; import PollVote from './models/PollVote'; import PollsPage from './components/PollsPage'; @@ -13,8 +12,8 @@ import PollViewPage from './components/PollViewPage'; export default [ new Extend.Routes() // .add('fof.polls.list', '/polls', PollsPage) - .add('fof.polls.view', '/polls/:id', PollViewPage) - .add('fof_polls_compose', '/polls/composer', ComposePollPage), + .add('fof.polls.view', '/polls/view/:id', PollViewPage) + .add('fof.polls.compose', '/polls/composer', ComposePollPage), new Extend.Store() // .add('polls', Poll)