@@ -25,7 +25,6 @@ import { Button } from 'components/core/button';
25
25
import BulkActions from 'components/bulk-actions/bulk-actions' ;
26
26
import BulkMessages from 'components/bulk-actions/bulk-messages' ;
27
27
import { Link } from 'components/link' ;
28
- import Content from 'components/core/content/content' ;
29
28
30
29
// styles
31
30
import styles from './products.css' ;
@@ -41,7 +40,11 @@ type Props = {
41
40
unlinkProduct : Function ,
42
41
setExtraFilters : Function ,
43
42
} ,
44
- list : ?Object ,
43
+ bulkActions : {
44
+ exportByIds : Function ,
45
+ } ,
46
+ bulkExportAction : Function ,
47
+ list : Object ,
45
48
linkState : Object ,
46
49
unlinkState : Object ,
47
50
}
@@ -61,14 +64,20 @@ class CatalogProducts extends Component {
61
64
62
65
componentDidMount ( ) {
63
66
const { catalogId } = this . props . params ;
64
-
67
+
65
68
this . props . actions . setExtraFilters ( [
66
69
dsl . nestedTermFilter ( 'catalogs.id' , catalogId ) ,
67
70
] ) ;
68
-
71
+
69
72
this . props . actions . fetch ( ) ;
70
73
}
71
-
74
+
75
+ get bulkActions ( ) : Array < any > {
76
+ return [
77
+ bulkExportBulkAction ( this . bulkExport , 'Products' ) ,
78
+ ] ;
79
+ }
80
+
72
81
get tableColumns ( ) : Columns {
73
82
return [
74
83
{ field : 'productId' , text : 'ID' } ,
@@ -80,6 +89,27 @@ class CatalogProducts extends Component {
80
89
] ;
81
90
}
82
91
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
+
83
113
unlinkButton = ( children : any , row : Product ) => {
84
114
const inProgress = this . props . unlinkState . inProgress
85
115
&& this . state . deletedProductId === row . productId ;
@@ -130,7 +160,7 @@ class CatalogProducts extends Component {
130
160
}
131
161
132
162
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 ) ;
134
164
} ;
135
165
136
166
render ( ) {
@@ -152,18 +182,34 @@ class CatalogProducts extends Component {
152
182
addTitle = "Product"
153
183
onAddClick = { this . openModal }
154
184
/>
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 }
166
211
/>
212
+ </ BulkActions >
167
213
< ProductsAddModal
168
214
isVisible = { this . state . modalVisible }
169
215
onCancel = { this . closeModal }
@@ -192,7 +238,7 @@ const mapDispatchToProps = (dispatch) => {
192
238
linkProducts : bindActionCreators ( linkProducts , dispatch ) ,
193
239
unlinkProduct : bindActionCreators ( unlinkProduct , dispatch ) ,
194
240
} ,
195
- bulkActionExport : bindActionCreators ( bulkExport , dispatch ) ,
241
+ bulkExportAction : bindActionCreators ( bulkExport , dispatch ) ,
196
242
bulkActions : bindActionCreators ( bulkActions , dispatch ) ,
197
243
} ;
198
244
} ;
0 commit comments