1
0
Fork 0
mirror of synced 2024-10-03 19:43:32 +13:00

allow users to remove a calculation

This commit is contained in:
Martin McKeaveney 2020-10-15 15:02:22 +01:00
parent 5565bd2124
commit 3dac1e2a78
4 changed files with 10 additions and 4 deletions

View file

@ -9,12 +9,14 @@
export let view = {}
let data = []
let loading = false
$: name = view.name
// Fetch rows for specified view
$: {
if (!name.startsWith("all_")) {
loading = true
fetchViewData(name, view.field, view.groupBy, view.calculation)
}
}
@ -31,10 +33,11 @@
const QUERY_VIEW_URL = `/api/views/${name}?${params}`
const response = await api.get(QUERY_VIEW_URL)
data = await response.json()
loading = false
}
</script>
<Table title={decodeURI(name)} schema={view.schema} {data}>
<Table title={decodeURI(name)} schema={view.schema} {data} {loading}>
<FilterButton {view} />
<CalculateButton {view} />
{#if view.calculation}

View file

@ -9,7 +9,11 @@
</script>
<div bind:this={anchor}>
<TextButton text small on:click={dropdown.show} active={!!view.field}>
<TextButton
text
small
on:click={dropdown.show}
active={view.field && view.calculation}>
<Icon name="calculate" />
Calculate
</TextButton>

View file

@ -34,7 +34,6 @@
)
function saveView() {
if (!view.calculation) view.calculation = "stats"
backendUiStore.actions.views.save(view)
notifier.success(`View ${view.name} saved.`)
onClosed()

View file

@ -109,7 +109,7 @@ function viewTemplate({ field, tableId, groupBy, filters = [], calculation }) {
const emitExpression = parseEmitExpression(field, groupBy)
const reduction = field ? { reduce: `_${calculation}` } : {}
const reduction = field && calculation ? { reduce: `_${calculation}` } : {}
let schema = null