fix: get triggers up to spec

This commit is contained in:
Taranto 2020-08-08 12:05:52 +01:00 committed by Josh Harvey
parent b07c0e180a
commit 0b28e7f98a
22 changed files with 347 additions and 95 deletions

View file

@ -47,6 +47,8 @@ const ETable = ({
setEditing,
stripeWhen,
disableRowEdit,
groupBy,
sortBy,
createText = 'Add override'
}) => {
const [editingId, setEditingId] = useState(null)
@ -102,6 +104,8 @@ const ETable = ({
const canAdd = !forceDisable && !editingId && !disableAdd && !adding
const showTable = adding || data.length !== 0
const innerData = sortBy ? R.sortWith(sortBy)(data) : data
const ctxValue = {
elements,
enableEdit,
@ -159,24 +163,33 @@ const ETable = ({
</Form>
</Formik>
)}
{data.map((it, idx) => (
<Formik
key={it.id ?? idx}
enableReinitialize
initialValues={it}
onReset={onReset}
validationSchema={validationSchema}
onSubmit={innerSave}>
<Form>
<ERow
editing={editingId === it.id}
disabled={
forceDisable || (editingId && editingId !== it.id)
}
/>
</Form>
</Formik>
))}
{innerData.map((it, idx) => {
const nextElement = innerData[idx + 1]
const isLastOfGroup =
groupBy &&
nextElement &&
nextElement[groupBy] !== it[groupBy]
return (
<Formik
key={it.id ?? idx}
enableReinitialize
initialValues={it}
onReset={onReset}
validationSchema={validationSchema}
onSubmit={innerSave}>
<Form>
<ERow
lastOfGroup={isLastOfGroup}
editing={editingId === it.id}
disabled={
forceDisable || (editingId && editingId !== it.id)
}
/>
</Form>
</Formik>
)
})}
</TBody>
</Table>
</>