Skip to content

Commit

Permalink
fix poll compose
Browse files Browse the repository at this point in the history
  • Loading branch information
imorland committed Feb 21, 2024
1 parent cb6d8bc commit 4a96ad0
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 17 deletions.
2 changes: 1 addition & 1 deletion extend.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'))
Expand Down
4 changes: 2 additions & 2 deletions js/src/forum/components/ComposePollHero.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default class ComposePollHero extends Component<ComposePollHeroAttrs> {
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')}
</LinkButton>
Expand All @@ -31,7 +31,7 @@ export default class ComposePollHero extends Component<ComposePollHeroAttrs> {
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"
>
Expand Down
18 changes: 8 additions & 10 deletions js/src/forum/components/PollViewPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<PollModel>('poll', editId);

if (!this.poll) {
this.loading = true;
Expand All @@ -33,14 +33,12 @@ export default class PollViewPage extends Page {
return <LoadingIndicator />;
}

if (this.poll) {
return (
<div className="PollsPage">
<div className="container">
<PollView poll={this.poll} />
</div>
return (
<div className="PollsPage">
<div className="container">
<PollView poll={this.poll} />
</div>
);
}
</div>
);
}
}
2 changes: 1 addition & 1 deletion js/src/forum/components/PollsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,6 @@ export default class PollsPage extends Page<IPageAttrs, PollListState> {
return;
}

m.route.set(app.route('fof_polls_compose'));
m.route.set(app.route('fof.polls.compose'));
}
}
5 changes: 2 additions & 3 deletions js/src/forum/extend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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)
Expand Down

0 comments on commit 4a96ad0

Please sign in to comment.