Skip to content

Commit

Permalink
Merge pull request #5395 from reactioncommerce/feat-5366-show-filter-…
Browse files Browse the repository at this point in the history
…count

Feat #5366 show filter count
  • Loading branch information
machikoyasuda authored Aug 1, 2019
2 parents e534568 + 3642884 commit 82069f4
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function ProductTable({ onCreateProduct }) {
onClick={onCreateProduct}
variant="contained"
>
{i18next.t("admin.createProduct") || "Create Product"}
{i18next.t("admin.createProduct") || "Create product"}
</Button>
</Grid>
<Grid item sm={12}>
Expand Down
4 changes: 3 additions & 1 deletion imports/plugins/included/product-admin/server/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@
"duplicate": "Duplicate",
"duplicateTitle": "Duplicate {{count}} product?",
"duplicateTitle_plural": "Duplicate {{count}} products?",
"duplicateMessage": "Duplicate selected products and their variants."
"duplicateMessage": "Duplicate selected products and their variants.",
"filteredProducts": "Filtered products",
"selectedCount": "{{count}} selected"
}
},
"products": "Products",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,24 @@ import TablePagination from "@material-ui/core/TablePagination";
import TableRow from "@material-ui/core/TableRow";
import ChevronDownIcon from "mdi-material-ui/ChevronDown";
import ConfirmDialog from "@reactioncommerce/catalyst/ConfirmDialog";
import Typography from "@material-ui/core/Typography";
import withStyles from "@material-ui/core/styles/withStyles";


const styles = (theme) => ({
filterCountContainer: {
paddingLeft: theme.spacing(2),
paddingTop: theme.spacing(3)
},
filterCountText: {
paddingLeft: theme.spacing(2),
fontWeight: theme.typography.fontWeightRegular
}
});

class ProductGrid extends Component {
static propTypes = {
classes: PropTypes.object,
onArchiveProducts: PropTypes.func,
onChangePage: PropTypes.func,
onChangeRowsPerPage: PropTypes.func,
Expand Down Expand Up @@ -81,6 +95,26 @@ class ProductGrid extends Component {
}
}

renderFilteredCount() {
const { selectedProductIds, classes } = this.props;
const count = selectedProductIds.length;
const filterByProductIds = Session.get("filterByProductIds");

if (filterByProductIds) {
return (
<div className={classes.filterCountContainer}>
<Typography variant="h4" display="inline">
{i18next.t("admin.productTable.bulkActions.filteredProducts")}
</Typography>
<Typography variant="h5" display="inline" className={classes.filterCountText}>
{i18next.t("admin.productTable.bulkActions.selectedCount", { count })}
</Typography>
</div>
);
}
return "";
}

renderProductGridItems() {
const { productMediaById, products } = this.props;

Expand Down Expand Up @@ -222,6 +256,7 @@ class ProductGrid extends Component {

return (
<Card>
{this.renderFilteredCount()}
{this.renderToolbar()}
<CardContent>
<Table>
Expand Down Expand Up @@ -263,4 +298,4 @@ class ProductGrid extends Component {
}
}

export default ProductGrid;
export default withStyles(styles)(ProductGrid);

0 comments on commit 82069f4

Please sign in to comment.