Revert field changes

This commit is contained in:
Mel O'Hagan 2022-06-07 15:14:53 +01:00
parent 12ced8cba7
commit 543d2521e6
1 changed files with 24 additions and 20 deletions

View File

@ -132,7 +132,7 @@
style += " auto" style += " auto"
} }
fields?.forEach(field => { fields?.forEach(field => {
const fieldSchema = schema[field.name] const fieldSchema = schema[field]
if (fieldSchema.width) { if (fieldSchema.width) {
style += ` ${fieldSchema.width}` style += ` ${fieldSchema.width}`
} else { } else {
@ -204,6 +204,7 @@
return nameA < nameB ? a : b return nameA < nameB ? a : b
}) })
.concat(autoColumns) .concat(autoColumns)
.map(column => column.name)
} }
const editColumn = (e, field) => { const editColumn = (e, field) => {
@ -299,19 +300,19 @@
{#each fields as field} {#each fields as field}
<div <div
class="spectrum-Table-headCell" class="spectrum-Table-headCell"
class:spectrum-Table-headCell--alignCenter={schema[field.name] class:spectrum-Table-headCell--alignCenter={schema[field]
.align === "Center"} .align === "Center"}
class:spectrum-Table-headCell--alignRight={schema[field.name] class:spectrum-Table-headCell--alignRight={schema[field].align ===
.align === "Right"} "Right"}
class:is-sortable={schema[field.name].sortable !== false} class:is-sortable={schema[field].sortable !== false}
class:is-sorted-desc={sortColumn === field.name && class:is-sorted-desc={sortColumn === field &&
sortOrder === "Descending"} sortOrder === "Descending"}
class:is-sorted-asc={sortColumn === field.name && class:is-sorted-asc={sortColumn === field &&
sortOrder === "Ascending"} sortOrder === "Ascending"}
on:click={() => sortBy(schema[field.name])} on:click={() => sortBy(schema[field])}
> >
<div class="title">{getDisplayName(schema[field.name])}</div> <div class="title">{getDisplayName(schema[field])}</div>
{#if schema[field.name]?.autocolumn} {#if schema[field]?.autocolumn}
<svg <svg
class="spectrum-Icon spectrum-Table-autoIcon" class="spectrum-Icon spectrum-Table-autoIcon"
focusable="false" focusable="false"
@ -319,7 +320,7 @@
<use xlink:href="#spectrum-icon-18-MagicWand" /> <use xlink:href="#spectrum-icon-18-MagicWand" />
</svg> </svg>
{/if} {/if}
{#if sortColumn === field.name} {#if sortColumn === field}
<svg <svg
class="spectrum-Icon spectrum-UIIcon-ArrowDown100 spectrum-Table-sortedIcon" class="spectrum-Icon spectrum-UIIcon-ArrowDown100 spectrum-Table-sortedIcon"
focusable="false" focusable="false"
@ -328,11 +329,11 @@
<use xlink:href="#spectrum-css-icon-Arrow100" /> <use xlink:href="#spectrum-css-icon-Arrow100" />
</svg> </svg>
{/if} {/if}
{#if allowEditColumns && schema[field.name]?.editable !== false} {#if allowEditColumns && schema[field]?.editable !== false}
<svg <svg
class="spectrum-Icon spectrum-Table-editIcon" class="spectrum-Icon spectrum-Table-editIcon"
focusable="false" focusable="false"
on:click={e => editColumn(e, field.name)} on:click={e => editColumn(e, field)}
> >
<use xlink:href="#spectrum-icon-18-Edit" /> <use xlink:href="#spectrum-icon-18-Edit" />
</svg> </svg>
@ -342,7 +343,7 @@
</div> </div>
{/if} {/if}
{#if sortedRows?.length} {#if sortedRows?.length}
{#each sortedRows as row} {#each sortedRows as row, idx}
<div class="spectrum-Table-row"> <div class="spectrum-Table-row">
{#if showEditColumn} {#if showEditColumn}
<div <div
@ -366,12 +367,15 @@
{#each fields as field} {#each fields as field}
<div <div
class="spectrum-Table-cell" class="spectrum-Table-cell"
class:spectrum-Table-cell--divider={!!schema[field.name] class:spectrum-Table-cell--divider={!!schema[field].divider}
.divider} style={cellStyles[field]}
style={cellStyles[field.name]}
on:click={() => { on:click={() => {
if (!field.preventSelectRow) { if (!field.startsWith("custom-")) {
dispatch("click", row) dispatch("click", row)
}
}}
on:click={() => {
if (!field.startsWith("custom-")) {
toggleSelectRow(row) toggleSelectRow(row)
} }
}} }}
@ -379,8 +383,8 @@
<CellRenderer <CellRenderer
{customRenderers} {customRenderers}
{row} {row}
schema={schema[field.name]} schema={schema[field]}
value={deepGet(row, field.name)} value={deepGet(row, field)}
on:clickrelationship on:clickrelationship
> >
<slot /> <slot />