@onehat/ui 0.3.246 → 0.3.248
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
CHANGED
|
@@ -488,6 +488,7 @@ function GridComponent(props) {
|
|
|
488
488
|
rowDragProps.isDropTarget = true;
|
|
489
489
|
rowDragProps.dropTargetAccept = dropTargetAccept;
|
|
490
490
|
rowDragProps.onDrop = (droppedItem) => {
|
|
491
|
+
// NOTE: item is sometimes getting destroyed, but it still as the id, so you can still use it
|
|
491
492
|
onRowDrop(item, droppedItem); // item is what it was dropped on; droppedItem is the dragSourceItem defined above
|
|
492
493
|
};
|
|
493
494
|
}
|
|
@@ -982,6 +983,9 @@ function GridComponent(props) {
|
|
|
982
983
|
{...flatListProps}
|
|
983
984
|
/>
|
|
984
985
|
|
|
986
|
+
if (CURRENT_MODE === UI_MODE_WEB) {
|
|
987
|
+
grid = <ScrollView horizontal={false}>{grid}</ScrollView>; // fix scrolling bug on nested FlatLists
|
|
988
|
+
} else
|
|
985
989
|
if (CURRENT_MODE === UI_MODE_REACT_NATIVE) {
|
|
986
990
|
grid = <ScrollView flex={1} w="100%">{grid}</ScrollView>
|
|
987
991
|
}
|
|
@@ -112,6 +112,22 @@ export default function withSelection(WrappedComponent) {
|
|
|
112
112
|
secondarySetSelection([]);
|
|
113
113
|
}
|
|
114
114
|
},
|
|
115
|
+
secondaryRefreshSelection = () => {
|
|
116
|
+
// When Repository reloads, the entities get destroyed.
|
|
117
|
+
// Loop through these destroyed entities and see if new ones exist with same ids.
|
|
118
|
+
// If so, select these new ones.
|
|
119
|
+
// That way, after a load event, we'll keep the same selection, if possible.
|
|
120
|
+
const
|
|
121
|
+
newSelection = [],
|
|
122
|
+
ids = _.map(secondaryLocalSelection, (item) => item.id);
|
|
123
|
+
_.each(ids, (id) => {
|
|
124
|
+
const found = SecondaryRepository.getById(id);
|
|
125
|
+
if (found) {
|
|
126
|
+
newSelection.push(found);
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
secondarySetSelection(newSelection);
|
|
130
|
+
},
|
|
115
131
|
getMaxMinSelectionIndices = () => {
|
|
116
132
|
let items,
|
|
117
133
|
currentlySelectedRowIndices = [];
|
|
@@ -283,6 +299,15 @@ export default function withSelection(WrappedComponent) {
|
|
|
283
299
|
}
|
|
284
300
|
};
|
|
285
301
|
|
|
302
|
+
if (SecondaryRepository) {
|
|
303
|
+
useEffect(() => {
|
|
304
|
+
SecondaryRepository.on('load', secondaryRefreshSelection);
|
|
305
|
+
return () => {
|
|
306
|
+
SecondaryRepository.off('load', secondaryRefreshSelection);
|
|
307
|
+
};
|
|
308
|
+
}, []);
|
|
309
|
+
}
|
|
310
|
+
|
|
286
311
|
useEffect(() => {
|
|
287
312
|
|
|
288
313
|
(async () => {
|
|
@@ -110,6 +110,22 @@ export default function withSelection(WrappedComponent) {
|
|
|
110
110
|
deselectAll = () => {
|
|
111
111
|
setSelection([]);
|
|
112
112
|
},
|
|
113
|
+
refreshSelection = () => {
|
|
114
|
+
// When Repository reloads, the entities get destroyed.
|
|
115
|
+
// Loop through these destroyed entities and see if new ones exist with same ids.
|
|
116
|
+
// If so, select these new ones.
|
|
117
|
+
// That way, after a load event, we'll keep the same selection, if possible.
|
|
118
|
+
const
|
|
119
|
+
newSelection = [],
|
|
120
|
+
ids = _.map(localSelection.current, (item) => item.id);
|
|
121
|
+
_.each(ids, (id) => {
|
|
122
|
+
const found = Repository.getById(id);
|
|
123
|
+
if (found) {
|
|
124
|
+
newSelection.push(found);
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
setSelection(newSelection);
|
|
128
|
+
},
|
|
113
129
|
getMaxMinSelectionIndices = () => {
|
|
114
130
|
let items,
|
|
115
131
|
currentlySelectedRowIndices = [];
|
|
@@ -283,10 +299,9 @@ export default function withSelection(WrappedComponent) {
|
|
|
283
299
|
|
|
284
300
|
if (Repository) {
|
|
285
301
|
useEffect(() => {
|
|
286
|
-
|
|
287
|
-
Repository.on('load', deselectAll);
|
|
302
|
+
Repository.on('load', refreshSelection);
|
|
288
303
|
return () => {
|
|
289
|
-
Repository.off('load',
|
|
304
|
+
Repository.off('load', refreshSelection);
|
|
290
305
|
};
|
|
291
306
|
}, []);
|
|
292
307
|
}
|