goblin-gadgets 4.0.26 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/widgets/list/widget.js +24 -8
package/package.json
CHANGED
package/widgets/list/widget.js
CHANGED
|
@@ -3,6 +3,7 @@ import React from 'react';
|
|
|
3
3
|
import Widget from 'goblin-laboratory/widgets/widget';
|
|
4
4
|
import ReactList from 'react-list';
|
|
5
5
|
import throttle from 'lodash/throttle';
|
|
6
|
+
import CheckboxNC from '../checkbox-nc/widget.js';
|
|
6
7
|
|
|
7
8
|
class List extends Widget {
|
|
8
9
|
constructor() {
|
|
@@ -113,19 +114,32 @@ class List extends Widget {
|
|
|
113
114
|
this.doAs('list', 'fetch', {range});
|
|
114
115
|
}
|
|
115
116
|
|
|
117
|
+
select = (index) => {
|
|
118
|
+
this.doFor(this.props.id, 'toggle-select', {rowId: index});
|
|
119
|
+
};
|
|
120
|
+
|
|
116
121
|
renderItem(index) {
|
|
117
122
|
setTimeout(this._fetch, 0);
|
|
118
123
|
|
|
119
124
|
const Item = this.props.renderItem;
|
|
125
|
+
const enableSelection = this.props.enableSelection;
|
|
126
|
+
const select = () => this.select(index);
|
|
120
127
|
return (
|
|
121
|
-
<
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
128
|
+
<div style={{display: 'flex'}} key={index}>
|
|
129
|
+
{enableSelection ? (
|
|
130
|
+
<CheckboxNC
|
|
131
|
+
checked={this.props.selected.get(index, false)}
|
|
132
|
+
onChange={select}
|
|
133
|
+
/>
|
|
134
|
+
) : null}
|
|
135
|
+
<Item
|
|
136
|
+
index={index}
|
|
137
|
+
listId={this.props.id}
|
|
138
|
+
itemId={`${index}-item`}
|
|
139
|
+
busyHeight={this._height}
|
|
140
|
+
data={this.props.data}
|
|
141
|
+
/>
|
|
142
|
+
</div>
|
|
129
143
|
);
|
|
130
144
|
}
|
|
131
145
|
|
|
@@ -207,5 +221,7 @@ export default Widget.connect((state, props) => {
|
|
|
207
221
|
contentIndex: state.get(`backend.${props.id}.options.contentIndex`),
|
|
208
222
|
entityId: state.get(`backend.${props.id}.options.entityId`),
|
|
209
223
|
path: state.get(`backend.${props.id}.options.path`),
|
|
224
|
+
enableSelection: state.get(`backend.${props.id}.enableSelection`),
|
|
225
|
+
selected: state.get(`backend.${props.id}.selected`),
|
|
210
226
|
};
|
|
211
227
|
})(List);
|