From 41742e7138ead91479f62e9ddabac81bc56e7e98 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Mon, 12 Apr 2021 16:14:24 +0100 Subject: [PATCH] Use BBUI spectrum table in standard components --- packages/bbui/src/Table/CellRenderer.svelte | 2 +- packages/bbui/src/Table/StringRenderer.svelte | 1 - packages/bbui/src/Table/Table.svelte | 29 +- .../src/table/AttachmentRenderer.svelte | 39 --- .../src/table/BooleanRenderer.svelte | 38 --- .../src/table/CellRenderer.svelte | 27 -- .../src/table/DateTimeRenderer.svelte | 13 - .../src/table/RelationshipRenderer.svelte | 20 -- .../src/table/SlotRenderer.svelte | 11 + .../src/table/StringRenderer.svelte | 13 - .../src/table/Table.svelte | 283 +++--------------- 11 files changed, 76 insertions(+), 400 deletions(-) delete mode 100644 packages/standard-components/src/table/AttachmentRenderer.svelte delete mode 100644 packages/standard-components/src/table/BooleanRenderer.svelte delete mode 100644 packages/standard-components/src/table/CellRenderer.svelte delete mode 100644 packages/standard-components/src/table/DateTimeRenderer.svelte delete mode 100644 packages/standard-components/src/table/RelationshipRenderer.svelte create mode 100644 packages/standard-components/src/table/SlotRenderer.svelte delete mode 100644 packages/standard-components/src/table/StringRenderer.svelte diff --git a/packages/bbui/src/Table/CellRenderer.svelte b/packages/bbui/src/Table/CellRenderer.svelte index 89f7e8716d..d0323487e1 100644 --- a/packages/bbui/src/Table/CellRenderer.svelte +++ b/packages/bbui/src/Table/CellRenderer.svelte @@ -26,7 +26,7 @@ $: renderer = customRenderer?.component ?? typeMap[type] -{#if renderer && value != null && value !== ''} +{#if renderer && (customRenderer || (value != null && value !== ''))} diff --git a/packages/bbui/src/Table/StringRenderer.svelte b/packages/bbui/src/Table/StringRenderer.svelte index ae95297dfc..2756839616 100644 --- a/packages/bbui/src/Table/StringRenderer.svelte +++ b/packages/bbui/src/Table/StringRenderer.svelte @@ -3,7 +3,6 @@
{value}
- diff --git a/packages/standard-components/src/table/BooleanRenderer.svelte b/packages/standard-components/src/table/BooleanRenderer.svelte deleted file mode 100644 index a71e28cb91..0000000000 --- a/packages/standard-components/src/table/BooleanRenderer.svelte +++ /dev/null @@ -1,38 +0,0 @@ - - - - - diff --git a/packages/standard-components/src/table/CellRenderer.svelte b/packages/standard-components/src/table/CellRenderer.svelte deleted file mode 100644 index 0c14ec2aa5..0000000000 --- a/packages/standard-components/src/table/CellRenderer.svelte +++ /dev/null @@ -1,27 +0,0 @@ - - -{#if value != null && value !== ''} - {#if plainTypes.includes(type)} - - {:else if type === 'boolean'} - - {:else if type === 'datetime'} - - {:else if type === 'link'} - - {:else if type === 'attachment'} - - {/if} -{/if} diff --git a/packages/standard-components/src/table/DateTimeRenderer.svelte b/packages/standard-components/src/table/DateTimeRenderer.svelte deleted file mode 100644 index 169adab163..0000000000 --- a/packages/standard-components/src/table/DateTimeRenderer.svelte +++ /dev/null @@ -1,13 +0,0 @@ - - -
{dayjs(value).format('MMMM D YYYY, HH:mm')}
- - diff --git a/packages/standard-components/src/table/RelationshipRenderer.svelte b/packages/standard-components/src/table/RelationshipRenderer.svelte deleted file mode 100644 index 6c04000fa7..0000000000 --- a/packages/standard-components/src/table/RelationshipRenderer.svelte +++ /dev/null @@ -1,20 +0,0 @@ - - -{#each relationships as relationship} - {#if relationship?.primaryDisplay} - - {relationship.primaryDisplay} - - {/if} -{/each} -{#if leftover} -
+{leftover} more
-{/if} diff --git a/packages/standard-components/src/table/SlotRenderer.svelte b/packages/standard-components/src/table/SlotRenderer.svelte new file mode 100644 index 0000000000..dc24f4249c --- /dev/null +++ b/packages/standard-components/src/table/SlotRenderer.svelte @@ -0,0 +1,11 @@ + + + + + diff --git a/packages/standard-components/src/table/StringRenderer.svelte b/packages/standard-components/src/table/StringRenderer.svelte deleted file mode 100644 index 2756839616..0000000000 --- a/packages/standard-components/src/table/StringRenderer.svelte +++ /dev/null @@ -1,13 +0,0 @@ - - -
{value}
- - diff --git a/packages/standard-components/src/table/Table.svelte b/packages/standard-components/src/table/Table.svelte index 8065b520e9..b213c3c397 100644 --- a/packages/standard-components/src/table/Table.svelte +++ b/packages/standard-components/src/table/Table.svelte @@ -1,8 +1,8 @@ -{#if !loaded} -
-{:else} -
-
-
- - - - {#if $component.children} - - {/if} - {#each fields as field} - - {/each} - - - - {#each sortedRows as row, idx} - lastVisibleRow}> - {#if idx >= firstVisibleRow && idx <= lastVisibleRow} - {#if $component.children} - - {/if} - {#each fields as field} - - {/each} - {/if} - - {/each} - -
-
-
sortBy(field)}> -
-
{schema[field]?.name}
- -
-
-
- - - -
-
-
- -
-
-
-
-
-{/if} - - +
+ + +
+