Hide add row FAB when selecting rows
This commit is contained in:
parent
9991fd9558
commit
ed9065aae3
|
@ -5,9 +5,10 @@
|
||||||
import { Grid } from "@budibase/frontend-core"
|
import { Grid } from "@budibase/frontend-core"
|
||||||
|
|
||||||
export let table
|
export let table
|
||||||
export let allowAddRows
|
export let allowAddRows = true
|
||||||
export let allowEditRows
|
export let allowEditRows = true
|
||||||
export let allowDeleteRows
|
export let allowDeleteRows = true
|
||||||
|
export let stripeRows = false
|
||||||
|
|
||||||
const component = getContext("component")
|
const component = getContext("component")
|
||||||
const { styleable, API, builderStore } = getContext("sdk")
|
const { styleable, API, builderStore } = getContext("sdk")
|
||||||
|
@ -23,6 +24,7 @@
|
||||||
{allowAddRows}
|
{allowAddRows}
|
||||||
{allowEditRows}
|
{allowEditRows}
|
||||||
{allowDeleteRows}
|
{allowDeleteRows}
|
||||||
|
{stripeRows}
|
||||||
showControls={false}
|
showControls={false}
|
||||||
allowExpandRows={false}
|
allowExpandRows={false}
|
||||||
allowSchemaChanges={false}
|
allowSchemaChanges={false}
|
||||||
|
|
|
@ -6,15 +6,9 @@
|
||||||
|
|
||||||
let modal
|
let modal
|
||||||
|
|
||||||
$: selectedRowCount = Object.values($selectedRows).filter(x => !!x).length
|
$: selectedRowCount = Object.values($selectedRows).length
|
||||||
$: rowsToDelete = Object.entries($selectedRows)
|
$: rowsToDelete = Object.entries($selectedRows)
|
||||||
.map(entry => {
|
.map(entry => $rows.find(x => x._id === entry[0]))
|
||||||
if (entry[1] === true) {
|
|
||||||
return $rows.find(x => x._id === entry[0])
|
|
||||||
} else {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.filter(x => x != null)
|
.filter(x => x != null)
|
||||||
|
|
||||||
// Deletion callback when confirmed
|
// Deletion callback when confirmed
|
||||||
|
|
|
@ -57,6 +57,7 @@
|
||||||
allowEditRows,
|
allowEditRows,
|
||||||
allowDeleteRows,
|
allowDeleteRows,
|
||||||
stripeRows,
|
stripeRows,
|
||||||
|
showControls,
|
||||||
})
|
})
|
||||||
|
|
||||||
// Build up context
|
// Build up context
|
||||||
|
@ -91,6 +92,7 @@
|
||||||
allowEditRows,
|
allowEditRows,
|
||||||
allowDeleteRows,
|
allowDeleteRows,
|
||||||
stripeRows,
|
stripeRows,
|
||||||
|
showControls,
|
||||||
})
|
})
|
||||||
|
|
||||||
// Set context for children to consume
|
// Set context for children to consume
|
||||||
|
|
|
@ -26,6 +26,8 @@
|
||||||
maxScrollTop,
|
maxScrollTop,
|
||||||
rowVerticalInversionIndex,
|
rowVerticalInversionIndex,
|
||||||
columnHorizontalInversionIndex,
|
columnHorizontalInversionIndex,
|
||||||
|
config,
|
||||||
|
selectedRows,
|
||||||
} = getContext("grid")
|
} = getContext("grid")
|
||||||
|
|
||||||
let visible = false
|
let visible = false
|
||||||
|
@ -37,6 +39,7 @@
|
||||||
$: width = GutterWidth + ($stickyColumn?.width || 0)
|
$: width = GutterWidth + ($stickyColumn?.width || 0)
|
||||||
$: $tableId, (visible = false)
|
$: $tableId, (visible = false)
|
||||||
$: invertY = shouldInvertY(offset, $rowVerticalInversionIndex, $renderedRows)
|
$: invertY = shouldInvertY(offset, $rowVerticalInversionIndex, $renderedRows)
|
||||||
|
$: selectedRowCount = Object.values($selectedRows).length
|
||||||
|
|
||||||
const shouldInvertY = (offset, inversionIndex, rows) => {
|
const shouldInvertY = (offset, inversionIndex, rows) => {
|
||||||
if (offset === 0) {
|
if (offset === 0) {
|
||||||
|
@ -142,7 +145,7 @@
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<!-- New row FAB -->
|
<!-- New row FAB -->
|
||||||
{#if !visible}
|
{#if !visible && !$config.showControls && !selectedRowCount}
|
||||||
<div
|
<div
|
||||||
class="new-row-fab"
|
class="new-row-fab"
|
||||||
on:click={() => dispatch("add-row-inline")}
|
on:click={() => dispatch("add-row-inline")}
|
||||||
|
@ -243,7 +246,7 @@
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: var(--default-row-height);
|
top: var(--default-row-height);
|
||||||
left: calc(var(--gutter-width) / 2);
|
left: calc(var(--gutter-width) / 2);
|
||||||
transform: translateX(8px) translateY(-50%);
|
transform: translateX(6px) translateY(-50%);
|
||||||
background: var(--cell-background);
|
background: var(--cell-background);
|
||||||
padding: 4px;
|
padding: 4px;
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
} = getContext("grid")
|
} = getContext("grid")
|
||||||
|
|
||||||
$: rowCount = $rows.length
|
$: rowCount = $rows.length
|
||||||
$: selectedRowCount = Object.values($selectedRows).filter(x => !!x).length
|
$: selectedRowCount = Object.values($selectedRows).length
|
||||||
$: width = GutterWidth + ($stickyColumn?.width || 0)
|
$: width = GutterWidth + ($stickyColumn?.width || 0)
|
||||||
|
|
||||||
const selectAll = () => {
|
const selectAll = () => {
|
||||||
|
|
Loading…
Reference in New Issue