mirror of
https://github.com/flarum/core.git
synced 2025-08-12 03:14:33 +02:00
update: forum/components/IndexPage.js
This commit is contained in:
committed by
Franz Liedke
parent
5f0dcc71ba
commit
8b891abb2b
@@ -19,8 +19,8 @@ import SelectDropdown from '../../common/components/SelectDropdown';
|
|||||||
export default class IndexPage extends Page {
|
export default class IndexPage extends Page {
|
||||||
static providesInitialSearch = true;
|
static providesInitialSearch = true;
|
||||||
|
|
||||||
init() {
|
oninit(vnode) {
|
||||||
super.init();
|
super.oninit(vnode);
|
||||||
|
|
||||||
// If the user is returning from a discussion page, then take note of which
|
// If the user is returning from a discussion page, then take note of which
|
||||||
// discussion they have just visited. After the view is rendered, we will
|
// discussion they have just visited. After the view is rendered, we will
|
||||||
@@ -64,7 +64,7 @@ export default class IndexPage extends Page {
|
|||||||
<ul className="IndexPage-toolbar-view">{listItems(this.viewItems().toArray())}</ul>
|
<ul className="IndexPage-toolbar-view">{listItems(this.viewItems().toArray())}</ul>
|
||||||
<ul className="IndexPage-toolbar-action">{listItems(this.actionItems().toArray())}</ul>
|
<ul className="IndexPage-toolbar-action">{listItems(this.actionItems().toArray())}</ul>
|
||||||
</div>
|
</div>
|
||||||
<DiscussionList state={app.discussions} />
|
{<DiscussionList state={app.discussions} />}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -139,25 +139,27 @@ export default class IndexPage extends Page {
|
|||||||
|
|
||||||
items.add(
|
items.add(
|
||||||
'newDiscussion',
|
'newDiscussion',
|
||||||
Button.component({
|
Button.component(
|
||||||
children: app.translator.trans(
|
{
|
||||||
canStartDiscussion ? 'core.forum.index.start_discussion_button' : 'core.forum.index.cannot_start_discussion_button'
|
icon: 'fas fa-edit',
|
||||||
),
|
className: 'Button Button--primary IndexPage-newDiscussion',
|
||||||
icon: 'fas fa-edit',
|
itemClassName: 'App-primaryControl',
|
||||||
className: 'Button Button--primary IndexPage-newDiscussion',
|
onclick: this.newDiscussionAction.bind(this),
|
||||||
itemClassName: 'App-primaryControl',
|
disabled: !canStartDiscussion,
|
||||||
onclick: this.newDiscussionAction.bind(this),
|
},
|
||||||
disabled: !canStartDiscussion,
|
app.translator.trans(canStartDiscussion ? 'core.forum.index.start_discussion_button' : 'core.forum.index.cannot_start_discussion_button')
|
||||||
})
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
items.add(
|
items.add(
|
||||||
'nav',
|
'nav',
|
||||||
SelectDropdown.component({
|
SelectDropdown.component(
|
||||||
children: this.navItems(this).toArray(),
|
{
|
||||||
buttonClassName: 'Button',
|
buttonClassName: 'Button',
|
||||||
className: 'App-titleControl',
|
className: 'App-titleControl',
|
||||||
})
|
},
|
||||||
|
this.navItems(this).toArray()
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
return items;
|
return items;
|
||||||
@@ -175,11 +177,13 @@ export default class IndexPage extends Page {
|
|||||||
|
|
||||||
items.add(
|
items.add(
|
||||||
'allDiscussions',
|
'allDiscussions',
|
||||||
LinkButton.component({
|
LinkButton.component(
|
||||||
href: app.route('index', params),
|
{
|
||||||
children: app.translator.trans('core.forum.index.all_discussions_link'),
|
href: app.route('index', params),
|
||||||
icon: 'far fa-comments',
|
icon: 'far fa-comments',
|
||||||
}),
|
},
|
||||||
|
app.translator.trans('core.forum.index.all_discussions_link')
|
||||||
|
),
|
||||||
100
|
100
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -204,21 +208,25 @@ export default class IndexPage extends Page {
|
|||||||
|
|
||||||
items.add(
|
items.add(
|
||||||
'sort',
|
'sort',
|
||||||
Dropdown.component({
|
Dropdown.component(
|
||||||
buttonClassName: 'Button',
|
{
|
||||||
label: sortOptions[app.search.params().sort] || Object.keys(sortMap).map((key) => sortOptions[key])[0],
|
buttonClassName: 'Button',
|
||||||
children: Object.keys(sortOptions).map((value) => {
|
label: sortOptions[app.search.params().sort] || Object.keys(sortMap).map((key) => sortOptions[key])[0],
|
||||||
|
},
|
||||||
|
Object.keys(sortOptions).map((value) => {
|
||||||
const label = sortOptions[value];
|
const label = sortOptions[value];
|
||||||
const active = (app.search.params().sort || Object.keys(sortMap)[0]) === value;
|
const active = (app.search.params().sort || Object.keys(sortMap)[0]) === value;
|
||||||
|
|
||||||
return Button.component({
|
return Button.component(
|
||||||
children: label,
|
{
|
||||||
icon: active ? 'fas fa-check' : true,
|
icon: active ? 'fas fa-check' : true,
|
||||||
onclick: app.search.changeSort.bind(app.search, value),
|
onclick: app.search.changeSort.bind(app.search, value),
|
||||||
active: active,
|
active: active,
|
||||||
});
|
},
|
||||||
}),
|
label
|
||||||
})
|
);
|
||||||
|
})
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
return items;
|
return items;
|
||||||
|
Reference in New Issue
Block a user