-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0604ce1
commit 03e2950
Showing
3 changed files
with
48 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import app from 'flarum/forum/app'; | ||
import Component, { ComponentAttrs } from 'flarum/common/Component'; | ||
import Dropdown from 'flarum/common/components/Dropdown'; | ||
import Button from 'flarum/common/components/Button'; | ||
|
||
export interface SolvedFilterAttrs extends ComponentAttrs { | ||
selected: number; | ||
} | ||
|
||
export default class SolvedFilter extends Component<SolvedFilterAttrs> { | ||
view() { | ||
const { selected } = this.attrs; | ||
const options = ['all', 'solved', 'unsolved']; | ||
|
||
return Dropdown.component( | ||
{ | ||
buttonClassName: 'Button', | ||
label: app.translator.trans( | ||
`fof-best-answer.forum.filter.${options[selected] || Object.keys(options).map((key) => options[Number(key)])[0]}_label` | ||
), | ||
accessibleToggleLabel: app.translator.trans('fof-best-answer.forum.filter.accessible_label'), | ||
}, | ||
Object.keys(options).map((value) => { | ||
const label = options[Number(value)]; | ||
const active = (selected || Object.keys(options)[0]) === value; | ||
|
||
return Button.component( | ||
{ | ||
icon: active ? 'fas fa-check' : true, | ||
active: active, | ||
onclick: () => { | ||
app.discussions.bestAnswer = value; | ||
if (value === '0') { | ||
delete app.discussions.bestAnswer; | ||
} | ||
app.discussions.refresh(); | ||
}, | ||
}, | ||
app.translator.trans(`fof-best-answer.forum.filter.${label}_label`) | ||
); | ||
}) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters