Improve view calculation config
This commit is contained in:
parent
88b2f423f7
commit
8be7f82ccb
|
@ -121,7 +121,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
const addCalc = () => {
|
const addCalc = () => {
|
||||||
calculations = [...calculations, {}]
|
calculations = [...calculations, { type: CalculationType.AVG }]
|
||||||
}
|
}
|
||||||
|
|
||||||
const deleteCalc = idx => {
|
const deleteCalc = idx => {
|
||||||
|
@ -188,20 +188,14 @@
|
||||||
size="M"
|
size="M"
|
||||||
onConfirm={save}
|
onConfirm={save}
|
||||||
>
|
>
|
||||||
{#if !calculations.length}
|
{#if calculations.length}
|
||||||
<div>
|
|
||||||
<ActionButton quiet icon="Add" on:click={addCalc}>
|
|
||||||
Add your first calculation
|
|
||||||
</ActionButton>
|
|
||||||
</div>
|
|
||||||
{:else}
|
|
||||||
<div class="calculations">
|
<div class="calculations">
|
||||||
{#each calculations as calc, idx}
|
{#each calculations as calc, idx}
|
||||||
<span>{idx === 0 ? "Calculate" : "and"} the</span>
|
<span>{idx === 0 ? "Calculate" : "and"} the</span>
|
||||||
<Select
|
<Select
|
||||||
options={getTypeOptions(calc, calculations)}
|
options={getTypeOptions(calc, calculations)}
|
||||||
bind:value={calc.type}
|
bind:value={calc.type}
|
||||||
placeholder="Function"
|
placeholder={false}
|
||||||
/>
|
/>
|
||||||
<span>of</span>
|
<span>of</span>
|
||||||
<Select
|
<Select
|
||||||
|
@ -211,7 +205,7 @@
|
||||||
/>
|
/>
|
||||||
<Icon
|
<Icon
|
||||||
hoverable
|
hoverable
|
||||||
name="Close"
|
name="Delete"
|
||||||
size="S"
|
size="S"
|
||||||
on:click={() => deleteCalc(idx)}
|
on:click={() => deleteCalc(idx)}
|
||||||
color="var(--spectrum-global-color-gray-700)"
|
color="var(--spectrum-global-color-gray-700)"
|
||||||
|
@ -226,22 +220,22 @@
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="buttons">
|
|
||||||
<ActionButton
|
|
||||||
quiet
|
|
||||||
icon="Add"
|
|
||||||
on:click={addCalc}
|
|
||||||
disabled={calculations.length >= 5}
|
|
||||||
>
|
|
||||||
Add calculation
|
|
||||||
</ActionButton>
|
|
||||||
</div>
|
|
||||||
<InfoDisplay
|
|
||||||
icon="Help"
|
|
||||||
quiet
|
|
||||||
body="Calculations only work with numeric columns and a maximum of 5 calculations can be added at once."
|
|
||||||
/>
|
|
||||||
{/if}
|
{/if}
|
||||||
|
<div class="buttons">
|
||||||
|
<ActionButton
|
||||||
|
quiet
|
||||||
|
icon="Add"
|
||||||
|
on:click={addCalc}
|
||||||
|
disabled={calculations.length >= 5}
|
||||||
|
>
|
||||||
|
Add calculation
|
||||||
|
</ActionButton>
|
||||||
|
</div>
|
||||||
|
<InfoDisplay
|
||||||
|
icon="Help"
|
||||||
|
quiet
|
||||||
|
body="Calculations only work with numeric columns and a maximum of 5 calculations can be added at once."
|
||||||
|
/>
|
||||||
</ModalContent>
|
</ModalContent>
|
||||||
</Modal>
|
</Modal>
|
||||||
|
|
||||||
|
|
|
@ -14,10 +14,6 @@ export function canBeDisplayColumn(column) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function canBeSortColumn(column) {
|
export function canBeSortColumn(column) {
|
||||||
if (!sharedCore.canBeSortColumn(column.type)) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
if (column.related) {
|
if (column.related) {
|
||||||
// If it's a related column (only available in the frontend), don't allow using it as display column
|
// If it's a related column (only available in the frontend), don't allow using it as display column
|
||||||
return false
|
return false
|
||||||
|
|
Loading…
Reference in New Issue