mirror of
https://github.com/flarum/core.git
synced 2025-05-11 01:45:29 +02:00
Clicking on an index nav item should always refresh the discussion list
This commit is contained in:
parent
10acb839cf
commit
8cba7ad3f2
10
js/forum/src/components/index-nav-item.js
Normal file
10
js/forum/src/components/index-nav-item.js
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import NavItem from 'flarum/components/nav-item'
|
||||||
|
|
||||||
|
export default class IndexNavItem extends NavItem {
|
||||||
|
static props(props) {
|
||||||
|
props.onclick = props.onclick || function() {
|
||||||
|
app.cache.discussionList = null;
|
||||||
|
m.redraw.strategy('none');
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@ -12,7 +12,7 @@ import DiscussionPage from 'flarum/components/discussion-page';
|
|||||||
|
|
||||||
import SelectInput from 'flarum/components/select-input';
|
import SelectInput from 'flarum/components/select-input';
|
||||||
import ActionButton from 'flarum/components/action-button';
|
import ActionButton from 'flarum/components/action-button';
|
||||||
import NavItem from 'flarum/components/nav-item';
|
import IndexNavItem from 'flarum/components/index-nav-item';
|
||||||
import LoadingIndicator from 'flarum/components/loading-indicator';
|
import LoadingIndicator from 'flarum/components/loading-indicator';
|
||||||
import DropdownSelect from 'flarum/components/dropdown-select';
|
import DropdownSelect from 'flarum/components/dropdown-select';
|
||||||
|
|
||||||
@ -204,7 +204,7 @@ export default class IndexPage extends Component {
|
|||||||
var params = {sort: m.route.param('sort')};
|
var params = {sort: m.route.param('sort')};
|
||||||
|
|
||||||
items.add('allDiscussions',
|
items.add('allDiscussions',
|
||||||
NavItem.component({
|
IndexNavItem.component({
|
||||||
href: app.route('index', params),
|
href: app.route('index', params),
|
||||||
label: 'All Discussions',
|
label: 'All Discussions',
|
||||||
icon: 'comments-o'
|
icon: 'comments-o'
|
||||||
|
@ -32,7 +32,7 @@ export default class Component {
|
|||||||
static component(props) {
|
static component(props) {
|
||||||
props = props || {};
|
props = props || {};
|
||||||
if (this.props) {
|
if (this.props) {
|
||||||
props = this.props(props);
|
this.props(props);
|
||||||
}
|
}
|
||||||
var view = function(component) {
|
var view = function(component) {
|
||||||
component.props = props;
|
component.props = props;
|
||||||
|
@ -4,7 +4,11 @@ import icon from 'flarum/helpers/icon'
|
|||||||
export default class NavItem extends Component {
|
export default class NavItem extends Component {
|
||||||
view() {
|
view() {
|
||||||
var active = this.constructor.active(this.props);
|
var active = this.constructor.active(this.props);
|
||||||
return m('li'+(active ? '.active' : ''), m('a', {href: this.props.href, config: m.route}, [
|
return m('li'+(active ? '.active' : ''), m('a', {
|
||||||
|
href: this.props.href,
|
||||||
|
onclick: this.props.onclick,
|
||||||
|
config: m.route
|
||||||
|
}, [
|
||||||
icon(this.props.icon+' icon'),
|
icon(this.props.icon+' icon'),
|
||||||
this.props.label, ' ',
|
this.props.label, ' ',
|
||||||
this.props.badge ? m('span.count', this.props.badge) : ''
|
this.props.badge ? m('span.count', this.props.badge) : ''
|
||||||
|
Loading…
x
Reference in New Issue
Block a user