Updated group sorting in frontend
• Updated: - group sorting in frontend
This commit is contained in:
@@ -32,15 +32,17 @@ const mapStateToProps = (state) => ({
|
||||
})
|
||||
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
onOpenSortingOptions(targetRef) {
|
||||
onOpenSortingOptions(targetRef, options) {
|
||||
dispatch(openPopover(POPOVER_GROUP_TIMELINE_SORT_OPTIONS, {
|
||||
targetRef,
|
||||
options,
|
||||
position: 'bottom',
|
||||
}))
|
||||
},
|
||||
onOpenSortingTopOptions(targetRef) {
|
||||
onOpenSortingTopOptions(targetRef, options) {
|
||||
dispatch(openPopover(POPOVER_GROUP_TIMELINE_SORT_TOP_OPTIONS, {
|
||||
targetRef,
|
||||
options,
|
||||
position: 'bottom',
|
||||
}))
|
||||
},
|
||||
@@ -53,23 +55,31 @@ class GroupSortBlock extends PureComponent {
|
||||
|
||||
static propTypes = {
|
||||
intl: PropTypes.object.isRequired,
|
||||
sortByValue: PropTypes.string.isRequired,
|
||||
groupId: PropTypes.string,
|
||||
collectionType: PropTypes.string,
|
||||
sortByValue: PropTypes.string.isRequired,
|
||||
sortByTopValue: PropTypes.string,
|
||||
onOpenSortingOptions: PropTypes.func.isRequired,
|
||||
onOpenSortingTopOptions: PropTypes.func,
|
||||
}
|
||||
|
||||
handleOnClickValue = (btn) => {
|
||||
this.props.onOpenSortingOptions(btn)
|
||||
this.props.onOpenSortingOptions(btn, {
|
||||
groupId: this.props.groupId,
|
||||
collectionType: this.props.collectionType,
|
||||
})
|
||||
}
|
||||
|
||||
handleOnClickSubValue = (btn) => {
|
||||
this.props.onOpenSortingTopOptions(btn)
|
||||
this.props.onOpenSortingTopOptions(btn, {
|
||||
groupId: this.props.groupId,
|
||||
collectionType: this.props.collectionType,
|
||||
})
|
||||
}
|
||||
|
||||
render() {
|
||||
const {
|
||||
intl,
|
||||
intl,
|
||||
sortByValue,
|
||||
sortByTopValue,
|
||||
} = this.props
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { defineMessages, injectIntl } from 'react-intl'
|
||||
import isObject from 'lodash.isobject'
|
||||
import { closePopover } from '../../actions/popover'
|
||||
import { setGroupTimelineSort } from '../../actions/groups'
|
||||
import {
|
||||
@@ -23,8 +24,8 @@ const mapStateToProps = (state) => ({
|
||||
})
|
||||
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
onSort(sort) {
|
||||
dispatch(setGroupTimelineSort(sort))
|
||||
onSort(sort, options) {
|
||||
dispatch(setGroupTimelineSort(sort, options))
|
||||
dispatch(closePopover())
|
||||
},
|
||||
onClosePopover: () => dispatch(closePopover()),
|
||||
@@ -41,10 +42,11 @@ class GroupTimelineSortOptionsPopover extends PureComponent {
|
||||
isXS: PropTypes.bool,
|
||||
onClosePopover: PropTypes.func.isRequired,
|
||||
onSort: PropTypes.func.isRequired,
|
||||
options: PropTypes.object.isRequired,
|
||||
}
|
||||
|
||||
handleOnClick = (type) => {
|
||||
this.props.onSort(type)
|
||||
this.props.onSort(type, this.props.options)
|
||||
}
|
||||
|
||||
handleOnClosePopover = () => {
|
||||
@@ -56,8 +58,11 @@ class GroupTimelineSortOptionsPopover extends PureComponent {
|
||||
sorting,
|
||||
intl,
|
||||
isXS,
|
||||
options,
|
||||
} = this.props
|
||||
|
||||
const isFeaturedTimeline = isObject(options) && options.collectionType === 'featured'
|
||||
|
||||
const items = [
|
||||
{
|
||||
hideArrow: true,
|
||||
@@ -65,22 +70,25 @@ class GroupTimelineSortOptionsPopover extends PureComponent {
|
||||
title: intl.formatMessage(messages.topTitle),
|
||||
subtitle: intl.formatMessage(messages.topSubtitle),
|
||||
onClick: () => this.handleOnClick(GROUP_TIMELINE_SORTING_TYPE_TOP),
|
||||
},
|
||||
{
|
||||
}
|
||||
]
|
||||
|
||||
if (!isFeaturedTimeline) {
|
||||
items.push({
|
||||
hideArrow: true,
|
||||
isActive: sorting === GROUP_TIMELINE_SORTING_TYPE_NEWEST,
|
||||
title: intl.formatMessage(messages.newTitle),
|
||||
subtitle: intl.formatMessage(messages.newSubtitle),
|
||||
onClick: () => this.handleOnClick(GROUP_TIMELINE_SORTING_TYPE_NEWEST),
|
||||
},
|
||||
{
|
||||
})
|
||||
items.push({
|
||||
hideArrow: true,
|
||||
isActive: sorting === GROUP_TIMELINE_SORTING_TYPE_RECENT_ACTIVITY,
|
||||
title: intl.formatMessage(messages.recentTitle),
|
||||
subtitle: intl.formatMessage(messages.recentSubtitle),
|
||||
onClick: () => this.handleOnClick(GROUP_TIMELINE_SORTING_TYPE_RECENT_ACTIVITY),
|
||||
},
|
||||
]
|
||||
})
|
||||
}
|
||||
|
||||
return (
|
||||
<PopoverLayout
|
||||
|
||||
@@ -24,8 +24,8 @@ const mapStateToProps = (state) => ({
|
||||
})
|
||||
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
onSort(sort) {
|
||||
dispatch(setGroupTimelineTopSort(sort))
|
||||
onSort(sort, options) {
|
||||
dispatch(setGroupTimelineTopSort(sort, options))
|
||||
dispatch(closePopover())
|
||||
},
|
||||
onClosePopover: () => dispatch(closePopover()),
|
||||
@@ -42,10 +42,11 @@ class GroupTimelineSortTopOptionsPopover extends PureComponent {
|
||||
isXS: PropTypes.bool,
|
||||
onClosePopover: PropTypes.func.isRequired,
|
||||
onSort: PropTypes.func.isRequired,
|
||||
options: PropTypes.object.isRequired,
|
||||
}
|
||||
|
||||
handleOnClick = (type) => {
|
||||
this.props.onSort(type)
|
||||
this.props.onSort(type, this.props.options)
|
||||
}
|
||||
|
||||
handleOnClosePopover = () => {
|
||||
|
||||
Reference in New Issue
Block a user