1
0
Fork 0
mirror of synced 2024-07-06 15:00:49 +12:00

Hide add row FAB when selecting rows

This commit is contained in:
Andrew Kingston 2023-06-14 09:10:09 +01:00
parent 9991fd9558
commit ed9065aae3
5 changed files with 15 additions and 14 deletions

View file

@ -5,9 +5,10 @@
import { Grid } from "@budibase/frontend-core"
export let table
export let allowAddRows
export let allowEditRows
export let allowDeleteRows
export let allowAddRows = true
export let allowEditRows = true
export let allowDeleteRows = true
export let stripeRows = false
const component = getContext("component")
const { styleable, API, builderStore } = getContext("sdk")
@ -23,6 +24,7 @@
{allowAddRows}
{allowEditRows}
{allowDeleteRows}
{stripeRows}
showControls={false}
allowExpandRows={false}
allowSchemaChanges={false}

View file

@ -6,15 +6,9 @@
let modal
$: selectedRowCount = Object.values($selectedRows).filter(x => !!x).length
$: selectedRowCount = Object.values($selectedRows).length
$: rowsToDelete = Object.entries($selectedRows)
.map(entry => {
if (entry[1] === true) {
return $rows.find(x => x._id === entry[0])
} else {
return null
}
})
.map(entry => $rows.find(x => x._id === entry[0]))
.filter(x => x != null)
// Deletion callback when confirmed

View file

@ -57,6 +57,7 @@
allowEditRows,
allowDeleteRows,
stripeRows,
showControls,
})
// Build up context
@ -91,6 +92,7 @@
allowEditRows,
allowDeleteRows,
stripeRows,
showControls,
})
// Set context for children to consume

View file

@ -26,6 +26,8 @@
maxScrollTop,
rowVerticalInversionIndex,
columnHorizontalInversionIndex,
config,
selectedRows,
} = getContext("grid")
let visible = false
@ -37,6 +39,7 @@
$: width = GutterWidth + ($stickyColumn?.width || 0)
$: $tableId, (visible = false)
$: invertY = shouldInvertY(offset, $rowVerticalInversionIndex, $renderedRows)
$: selectedRowCount = Object.values($selectedRows).length
const shouldInvertY = (offset, inversionIndex, rows) => {
if (offset === 0) {
@ -142,7 +145,7 @@
</script>
<!-- New row FAB -->
{#if !visible}
{#if !visible && !$config.showControls && !selectedRowCount}
<div
class="new-row-fab"
on:click={() => dispatch("add-row-inline")}
@ -243,7 +246,7 @@
position: absolute;
top: var(--default-row-height);
left: calc(var(--gutter-width) / 2);
transform: translateX(8px) translateY(-50%);
transform: translateX(6px) translateY(-50%);
background: var(--cell-background);
padding: 4px;
border-radius: 50%;

View file

@ -26,7 +26,7 @@
} = getContext("grid")
$: rowCount = $rows.length
$: selectedRowCount = Object.values($selectedRows).filter(x => !!x).length
$: selectedRowCount = Object.values($selectedRows).length
$: width = GutterWidth + ($stickyColumn?.width || 0)
const selectAll = () => {