diff --git a/webui/src/components/widgets/Table.svelte b/webui/src/components/widgets/Table.svelte index b2c708d..ce6604f 100644 --- a/webui/src/components/widgets/Table.svelte +++ b/webui/src/components/widgets/Table.svelte @@ -21,10 +21,13 @@ export let editable = false; // Display - $: columns = columns || "attribute, value"; - $: showEntity = columns.includes("entity"); - $: showAttribute = columns.includes("attribute"); - $: showValue = columns.includes("value"); + $: displayColumns = (columns || "attribute, value") + .split(",") + .map((c) => c.trim()); + + const ENTITY_COL = "entity"; + const ATTR_COL = "attribute"; + const VALUE_COL = "value"; // Editing let newEntryAttribute = ""; @@ -199,6 +202,12 @@ IS: "Type", }; + const COLUMN_LABELS: { [key: string]: string } = { + entity: "Entity", + attribute: "Attribute", + value: "Value", + }; + const VALUE_FORMATTERS: { [key: string]: (val: string | number) => string } = { FILE_MTIME: (val) => @@ -227,17 +236,11 @@
{/if} - {#if showEntity} - | Entity | - {/if} - {#if showAttribute} -Attribute | - {/if} - {#if showValue} -Value | - {/if} + {#each displayColumns as column} +{COLUMN_LABELS[column] || ATTRIBUTE_LABELS[column] || column} | + {/each} {/if} @@ -267,66 +264,65 @@ /> {/if} - - {#if showEntity} -
- |
- {/if}
-
- {#if showAttribute}
-
- |
- {/if}
-
- {#if showValue}
-
-
- |
+ {:else if column == ATTR_COL}
+
+ |
+ {:else if column == VALUE_COL}
+
+ |
- {/if}
+ {:else}
+ ? | + {/if} + {/each} {/each} @@ -335,12 +331,12 @@
|
- {#if showAttribute}
+ {#if displayColumns.includes(ATTR_COL)}
|
{/if}
- {#if showValue}
+ {#if displayColumns.includes(VALUE_COL)}
|
@@ -377,11 +373,11 @@
}
}
- .attr-action-col {
+ .action-col {
width: 1.5em;
}
- .attr-col {
+ .attribute-col {
width: 33%;
}
}
---|