Skip to content

Commit

Permalink
Show stats in dropdown
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffreyATW committed May 1, 2016
1 parent 89a4fd4 commit fe22bb8
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 9 deletions.
36 changes: 27 additions & 9 deletions src/components/RestaurantDropdown/RestaurantDropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import withStyles from 'isomorphic-style-loader/lib/withStyles';
import s from './RestaurantDropdown.scss';

const RestaurantDropdown = ({
id,
restaurant,
listUiItem,
decision,
showMapAndInfoWindow,
Expand All @@ -15,36 +15,46 @@ const RestaurantDropdown = ({
}) => {
let editButton;
if (!listUiItem.isEditingName) {
editButton = <MenuItem onSelect={showEditNameForm} key={`restaurantDropdown_${id}_editName`}>Edit name</MenuItem>;
editButton = (
<MenuItem onSelect={showEditNameForm} key={`restaurantDropdown_${restaurant.id}_editName`}>
Edit name
</MenuItem>
);
}

let decideButton;
if (decision !== null && decision.restaurant_id === id) {
if (decision !== null && decision.restaurant_id === restaurant.id) {
decideButton = (
<MenuItem
onSelect={removeDecision}
key={`restaurantDropdown_${id}_removeDecision`}
key={`restaurantDropdown_${restaurant.id}_removeDecision`}
>
Remove decision
</MenuItem>
);
} else {
decideButton = <MenuItem onSelect={decide} key={`restaurantDropdown_${id}_decide`}>Mark as decision</MenuItem>;
decideButton = (
<MenuItem onSelect={decide} key={`restaurantDropdown_${restaurant.id}_decide`}>
Mark as decision
</MenuItem>
);
}

const menuItems = [
<MenuItem onSelect={showMapAndInfoWindow} key={`restaurantDropdown_${id}_showMap`}>Reveal on map</MenuItem>,
<MenuItem onSelect={showMapAndInfoWindow} key={`restaurantDropdown_${restaurant.id}_showMap`}>
Reveal on map
</MenuItem>,
editButton,
decideButton,
<MenuItem onSelect={deleteRestaurant} key={`restaurantDropdown_${id}_delete`}>Delete</MenuItem>
<MenuItem onSelect={deleteRestaurant} key={`restaurantDropdown_${restaurant.id}_delete`}>Delete</MenuItem>
];

const DropdownToggle = Dropdown.Toggle;
const DropdownMenu = Dropdown.Menu;

return (
<Dropdown
id={`restaurantDropdown_${id}`}
id={`restaurantDropdown_${restaurant.id}`}
title=""
bsRole="toggle"
pullRight
Expand All @@ -55,13 +65,21 @@ const RestaurantDropdown = ({
</DropdownToggle>
<DropdownMenu bsRole="menu" className={s.menu}>
{menuItems}
<MenuItem divider />
<MenuItem header>Last 4 weeks:</MenuItem>
<li className={s.stat}>
{restaurant.all_vote_count} vote{parseInt(restaurant.all_vote_count, 10) === 1 ? '' : 's'}
</li>
<li className={s.stat}>
{restaurant.all_decision_count} decision{parseInt(restaurant.all_decision_count, 10) === 1 ? '' : 's'}
</li>
</DropdownMenu>
</Dropdown>
);
};

RestaurantDropdown.propTypes = {
id: PropTypes.number.isRequired,
restaurant: PropTypes.object.isRequired,
listUiItem: PropTypes.object.isRequired,
decision: PropTypes.object,
showMapAndInfoWindow: PropTypes.func.isRequired,
Expand Down
5 changes: 5 additions & 0 deletions src/components/RestaurantDropdown/RestaurantDropdown.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,8 @@
.menu {
border: $default-border;
}

.stat {
line-height: 1.42857143;
padding: 3px 20px;
}

0 comments on commit fe22bb8

Please sign in to comment.