Skip to content
This repository was archived by the owner on Nov 22, 2022. It is now read-only.

Commit 45b60cb

Browse files
Enable grid repeat
1 parent 6eee692 commit 45b60cb

File tree

1 file changed

+12
-13
lines changed
  • packages/builder/src/components/ComponentOptions/components/Content/Loop/Grid

1 file changed

+12
-13
lines changed

packages/builder/src/components/ComponentOptions/components/Content/Loop/Grid/footer.js

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,17 @@ const exportGrid = (data, columns) => {
2727
)
2828
}
2929

30-
export default ({ columns, data }) => {
30+
export default ({ addItem, columns }) => {
3131
const [dropdownOpen, setDropdownOpen] = useState(false)
3232
//const factorialModal = createRef()
33-
const { addRow, overwriteAll } = useArrayContext()
33+
const { dispatch, overwriteAll } = useArrayContext()
34+
const data = []
3435

3536
return (
3637
<tfoot>
3738
<tr>
3839
<td />
39-
<td colSpan={ columns.length }>
40+
<td colSpan={ columns }>
4041
{ /*
4142
<FactorialModal ref={ factorialModal } />
4243
*/ }
@@ -50,10 +51,8 @@ export default ({ columns, data }) => {
5051
block size="sm"
5152
outline color="muted"
5253
className="hover-target"
53-
onClick={ () => addRow() }
54-
onMouseUp={
55-
e => e.target.blur()
56-
}
54+
onClick={ () => addItem(Array(columns).fill('')) }
55+
onMouseUp={ e => e.target.blur() }
5756
style={{
5857
paddingLeft: '32px', // 6px standard + 24px toggle width
5958
}}
@@ -85,10 +84,10 @@ export default ({ columns, data }) => {
8584
onClick={ () => {
8685
const n = window.prompt('How many times?')
8786
if (n) {
88-
overwriteAll(
89-
data.flatMap(r => range(n).map(() => r)),
87+
dispatch((rows, columns) => [
88+
rows.flatMap(r => range(n).map(() => r)),
9089
columns,
91-
)
90+
])
9291
}
9392
} }
9493
>
@@ -98,10 +97,10 @@ export default ({ columns, data }) => {
9897
onClick={ () => {
9998
const n = window.prompt('How many times?')
10099
if (n) {
101-
overwriteAll(
102-
range(n).flatMap(() => data),
100+
dispatch((rows, columns) => [
101+
range(n).flatMap(() => rows),
103102
columns,
104-
)
103+
])
105104
}
106105
} }
107106
>

0 commit comments

Comments
 (0)