Skip to content

Commit

Permalink
feat: make it possible to modify the poll title and subtitle from 3rd…
Browse files Browse the repository at this point in the history
… party extensions (#98)

* feat: make it possible to modify the poll title and subtitle from 3rd party extensions

* export additional components
  • Loading branch information
imorland authored Oct 7, 2024
1 parent 58cdf7a commit 7181a69
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
25 changes: 15 additions & 10 deletions js/src/forum/components/Poll/PollListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,21 +115,26 @@ export default class PollListItem<CustomAttrs extends IPollListItemAttrs = IPoll
mainView(): Mithril.Children {
return (
<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>
{this.poll.subtitle() && <p className="PollListItem-subtitle helpText">{this.poll.subtitle()}</p>}
<h2 className="PollListItem-title">{highlight(this.pollQuestion(this.poll), this.highlightRegExp)}</h2>
{this.poll.subtitle() && <p className="PollListItem-subtitle helpText">{this.pollSubtitle(this.poll)}</p>}
<ul className="PollListItem-info">{listItems(this.infoItems().toArray())}</ul>
</Link>
);
}

// infoView() {
// return (
// <div>
// {this.poll.subtitle() && <p className="PollListItem-subtitle helpText">{this.poll.subtitle()}</p>}
// <ul className="PollListItem-info">{listItems(this.infoItems().toArray())}</ul>
// </div>
// );
// }
/**
* Allow extensions to revise the question string.
*/
pollQuestion(poll: Poll): string {
return poll.question();
}

/**
* Allow extensions to revise the subtitle string.
*/
pollSubtitle(poll: Poll): string | null {
return poll.subtitle();
}

oncreate(vnode: Mithril.VnodeDOM<CustomAttrs, this>) {
super.oncreate(vnode);
Expand Down
4 changes: 4 additions & 0 deletions js/src/forum/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import { AbstractPollPage } from './AbstractPollPage';
import PollTitle from './Poll/PollTitle';
import PollSubtitle from './Poll/PollSubtitle';
import PollImage from './Poll/PollImage';
import PollListItem from './Poll/PollListItem';
import PollList from './Poll/PollList';

export const components = {
CreatePollModal,
Expand All @@ -40,4 +42,6 @@ export const components = {
PollTitle,
PollSubtitle,
PollImage,
PollListItem,
PollList,
};

0 comments on commit 7181a69

Please sign in to comment.