Skip to content

Commit

Permalink
create dedicated poll view route
Browse files Browse the repository at this point in the history
  • Loading branch information
imorland committed Feb 21, 2024
1 parent 812745a commit 05c18eb
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 6 deletions.
1 change: 1 addition & 0 deletions extend.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +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/composer', 'fof.polls.composer'),

(new Extend\Frontend('admin'))
Expand Down
2 changes: 1 addition & 1 deletion js/src/forum/addNavItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default function addNavItem() {
'fof-polls-list',
LinkButton.component(
{
href: app.route('fof_polls_list'),
href: app.route('fof.polls.list'),
icon: 'fas fa-poll',
},
app.translator.trans('fof-polls.forum.page.nav')
Expand Down
2 changes: 1 addition & 1 deletion js/src/forum/components/Poll/PollListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export default class PollListItem<CustomAttrs extends IPollListItemAttrs = IPoll

mainView(): Mithril.Children {
return (
<Link href={app.route('fof_polls_list', { id: this.poll.id() })} className="PollListItem-main">
<Link href={app.route('fof.polls.view', { id: this.poll.id() })} className="PollListItem-main">
<h2 className="PollListItem-title">{highlight(this.poll.question(), this.highlightRegExp)}</h2>
</Link>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ interface PollAttrs extends ComponentAttrs {
poll: PollModel;
}

export default class Poll extends Component<PollAttrs, PollState> {
export default class PollView extends Component<PollAttrs, PollState> {
oninit(vnode: Mithril.Vnode<ComponentAttrs, this>) {
super.oninit(vnode);
this.state = new PollState(this.attrs.poll);
Expand Down
2 changes: 1 addition & 1 deletion js/src/forum/components/PollsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import SelectDropdown from 'flarum/common/components/SelectDropdown';
import Acl from '../../common/Acl';
import LoadingIndicator from 'flarum/common/components/LoadingIndicator';
import PollModel from '../models/Poll';
import Poll from './Poll';
import Poll from './PollView';

export default class PollsPage extends Page<IPageAttrs, PollListState> {
loading: boolean = false;
Expand Down
4 changes: 3 additions & 1 deletion js/src/forum/extend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@ 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';
import ComposePollPage from './components/ComposePollPage';

export default [
new Extend.Routes() //
.add('fof_polls_list', '/polls', PollsPage)
.add('fof.polls.list', '/polls', PollsPage)
.add('fof.polls.view', '/polls/:id', PollView)
.add('fof_polls_compose', '/polls/composer', ComposePollPage),

new Extend.Store() //
Expand Down
2 changes: 1 addition & 1 deletion js/src/forum/utils/PollControls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default {

items.add(
'view',
<Link href={app.route('fof_polls_list', { id: poll.id() })}>{app.translator.trans('fof-polls.forum.poll_controls.view_label')}</Link>
<Link href={app.route('fof.polls.view', { id: poll.id() })}>{app.translator.trans('fof-polls.forum.poll_controls.view_label')}</Link>
);

return items;
Expand Down

0 comments on commit 05c18eb

Please sign in to comment.