allow users to remove a calculation
This commit is contained in:
parent
5565bd2124
commit
3dac1e2a78
|
@ -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}
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -34,7 +34,6 @@
|
|||
)
|
||||
|
||||
function saveView() {
|
||||
if (!view.calculation) view.calculation = "stats"
|
||||
backendUiStore.actions.views.save(view)
|
||||
notifier.success(`View ${view.name} saved.`)
|
||||
onClosed()
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue