1
0
Fork 0
mirror of synced 2024-07-11 01:06:04 +12:00

Update tables to use button actions rather than link settings

This commit is contained in:
Andrew Kingston 2022-11-14 15:47:14 +00:00
parent aa81e0451a
commit 8b941df5ff
5 changed files with 36 additions and 38 deletions

View file

@ -64,7 +64,7 @@
transition: color var(--spectrum-global-animation-duration-100, 130ms);
}
svg.hoverable:hover {
color: var(--spectrum-alias-icon-color-selected-hover);
color: var(--spectrum-alias-icon-color-selected-hover) !important;
cursor: pointer;
}

View file

@ -3786,29 +3786,13 @@
"info": "Row selection is only compatible with internal or SQL tables"
},
{
"type": "boolean",
"label": "Link table rows",
"key": "linkRows"
},
{
"type": "boolean",
"label": "Open link screens in modal",
"key": "linkPeek"
},
{
"type": "url",
"label": "Link screen",
"key": "linkURL"
},
{
"section": true,
"name": "Advanced",
"settings": [
"type": "event",
"label": "On row click",
"key": "onClick",
"context": [
{
"type": "field",
"label": "ID column for linking (appended to URL)",
"key": "linkColumn",
"placeholder": "Default"
"label": "Clicked row",
"key": "row"
}
]
}

View file

@ -249,7 +249,12 @@
</div>
<div id="side-panel-container" class:open={$sidePanelStore.open}>
<div class="side-panel-header">
<Icon name="Close" hoverable on:click={sidePanelStore.actions.close} />
<Icon
color="var(--spectrum-global-color-gray-600)"
name="RailRightClose"
hoverable
on:click={sidePanelStore.actions.close}
/>
</div>
</div>
</div>
@ -345,7 +350,7 @@
margin-right: -410px;
display: flex;
flex-direction: column;
gap: var(--spacing-xl);
gap: 30px;
overflow-y: auto;
border-left: 1px solid var(--spectrum-global-color-gray-300);
}

View file

@ -46,6 +46,7 @@
<style>
.side-panel {
flex: 1 1 auto;
display: flex;
flex-direction: column;
justify-content: flex-start;

View file

@ -11,12 +11,15 @@
export let rowCount
export let quiet
export let size
export let allowSelectRows
export let compact
export let onClick
// Legacy settings, still supported for old apps
export let linkRows
export let linkURL
export let linkColumn
export let linkPeek
export let allowSelectRows
export let compact
const component = getContext("component")
const { styleable, getAction, ActionTypes, routeStore, rowSelectionStore } =
@ -28,7 +31,9 @@
component: SlotRenderer,
},
]
let selectedRows = []
$: hasChildren = $component.children
$: loading = dataProvider?.loading ?? false
$: data = dataProvider?.rows || []
@ -40,7 +45,6 @@
ActionTypes.SetDataProviderSorting
)
$: table = dataProvider?.datasource?.type === "table"
$: {
rowSelectionStore.actions.updateSelection(
$component.id,
@ -118,17 +122,21 @@
})
}
const onClick = e => {
if (!linkRows || !linkURL) {
return
const handleClick = e => {
if (onClick) {
onClick({ row: e.detail })
}
const col = linkColumn || "_id"
const id = e.detail?.[col]
if (!id) {
return
// Handle legacy settings
else if (linkRows && linkURL) {
const col = linkColumn || "_id"
const id = e.detail?.[col]
if (!id) {
return
}
const split = linkURL.split("/:")
routeStore.actions.navigate(`${split[0]}/${id}`, linkPeek)
}
const split = linkURL.split("/:")
routeStore.actions.navigate(`${split[0]}/${id}`, linkPeek)
}
onDestroy(() => {
@ -153,7 +161,7 @@
disableSorting
autoSortColumns={!columns?.length}
on:sort={onSort}
on:click={onClick}
on:click={handleClick}
>
<slot />
</Table>