@@ -25,7 +25,6 @@ import { Button } from 'components/core/button';
2525import BulkActions from 'components/bulk-actions/bulk-actions' ;
2626import BulkMessages from 'components/bulk-actions/bulk-messages' ;
2727import { Link } from 'components/link' ;
28- import Content from 'components/core/content/content' ;
2928
3029// styles
3130import styles from './products.css' ;
@@ -41,7 +40,11 @@ type Props = {
4140 unlinkProduct : Function ,
4241 setExtraFilters : Function ,
4342 } ,
44- list : ?Object ,
43+ bulkActions : {
44+ exportByIds : Function ,
45+ } ,
46+ bulkExportAction : Function ,
47+ list : Object ,
4548 linkState : Object ,
4649 unlinkState : Object ,
4750}
@@ -61,14 +64,20 @@ class CatalogProducts extends Component {
6164
6265 componentDidMount ( ) {
6366 const { catalogId } = this . props . params ;
64-
67+
6568 this . props . actions . setExtraFilters ( [
6669 dsl . nestedTermFilter ( 'catalogs.id' , catalogId ) ,
6770 ] ) ;
68-
71+
6972 this . props . actions . fetch ( ) ;
7073 }
71-
74+
75+ get bulkActions ( ) : Array < any > {
76+ return [
77+ bulkExportBulkAction ( this . bulkExport , 'Products' ) ,
78+ ] ;
79+ }
80+
7281 get tableColumns ( ) : Columns {
7382 return [
7483 { field : 'productId' , text : 'ID' } ,
@@ -80,6 +89,27 @@ class CatalogProducts extends Component {
8089 ] ;
8190 }
8291
92+ bulkExport = ( allChecked : boolean , toggledIds : Array < number > ) => {
93+ const { exportByIds } = this . props . bulkActions ;
94+ const modalTitle = 'Products' ;
95+ const entity = 'products' ;
96+
97+ return renderExportModal ( this . tableColumns , entity , modalTitle , exportByIds , toggledIds ) ;
98+ } ;
99+
100+ renderBulkDetails = (context: string, id: number) => {
101+ const { list } = this . props ;
102+ const results = list . currentSearch ( ) . results . rows ;
103+ const filteredProduct = _ . filter ( results , ( product ) => product . id . toString ( ) === id ) [ 0 ] ;
104+ const productId = filteredProduct . productId ;
105+
106+ return (
107+ < span key = { id } >
108+ Product < Link to = "product-details" params = { { productId, context } } > { productId } </ Link >
109+ </ span >
110+ ) ;
111+ } ;
112+
83113 unlinkButton = ( children : any , row : Product ) => {
84114 const inProgress = this . props . unlinkState . inProgress
85115 && this . state . deletedProductId === row . productId ;
@@ -130,7 +160,7 @@ class CatalogProducts extends Component {
130160 }
131161
132162 addSearchFilters = ( filters : Array < SearchFilter > , initial : boolean = false ) => {
133- return this . props . actions . addSearchFilters ( filterArchived ( filters ) , initial )
163+ return this . props . actions . addSearchFilters ( filterArchived ( filters ) , initial ) ;
134164 } ;
135165
136166 render ( ) {
@@ -152,18 +182,34 @@ class CatalogProducts extends Component {
152182 addTitle = "Product"
153183 onAddClick = { this . openModal }
154184 />
155- < SelectableSearchList
156- exportEntity = "products"
157- exportTitle = "Products"
158- entity = "catalogs.products"
159- emptyMessage = "No products found."
160- list = { list }
161- renderRow = { this . renderRow }
162- tableColumns = { this . tableColumns }
163- searchOptions = { { singleSearch : true } }
164- searchActions = { searchActions }
165- predicate = { ( { id } ) => id }
185+ < BulkMessages
186+ bulkModule = "catalogs.bulk"
187+ storePath = "catalogs.bulk"
188+ module = "catalogs.details"
189+ entity = "product"
190+ renderDetail = { this . renderBulkDetails }
191+ />
192+ < BulkActions
193+ bulkModule = "catalogs.bulk"
194+ module = "catalogs.details"
195+ entity = "product"
196+ actions = { this . bulkActions }
197+ >
198+ < SelectableSearchList
199+ exportEntity = "products"
200+ exportTitle = "Products"
201+ bulkExport
202+ bulkExportAction = { this . props . bulkExportAction }
203+ entity = "catalogs.products"
204+ emptyMessage = "No products found."
205+ list = { list }
206+ renderRow = { this . renderRow }
207+ tableColumns = { this . tableColumns }
208+ searchOptions = { { singleSearch : true } }
209+ searchActions = { searchActions }
210+ predicate = { ( { id } ) => id }
166211 />
212+ </ BulkActions >
167213 < ProductsAddModal
168214 isVisible = { this . state . modalVisible }
169215 onCancel = { this . closeModal }
@@ -192,7 +238,7 @@ const mapDispatchToProps = (dispatch) => {
192238 linkProducts : bindActionCreators ( linkProducts , dispatch ) ,
193239 unlinkProduct : bindActionCreators ( unlinkProduct , dispatch ) ,
194240 } ,
195- bulkActionExport : bindActionCreators ( bulkExport , dispatch ) ,
241+ bulkExportAction : bindActionCreators ( bulkExport , dispatch ) ,
196242 bulkActions : bindActionCreators ( bulkActions , dispatch ) ,
197243 } ;
198244} ;
0 commit comments