allow users to remove a calculation
This commit is contained in:
parent
5565bd2124
commit
3dac1e2a78
|
@ -9,12 +9,14 @@
|
||||||
export let view = {}
|
export let view = {}
|
||||||
|
|
||||||
let data = []
|
let data = []
|
||||||
|
let loading = false
|
||||||
|
|
||||||
$: name = view.name
|
$: name = view.name
|
||||||
|
|
||||||
// Fetch rows for specified view
|
// Fetch rows for specified view
|
||||||
$: {
|
$: {
|
||||||
if (!name.startsWith("all_")) {
|
if (!name.startsWith("all_")) {
|
||||||
|
loading = true
|
||||||
fetchViewData(name, view.field, view.groupBy, view.calculation)
|
fetchViewData(name, view.field, view.groupBy, view.calculation)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,10 +33,11 @@
|
||||||
const QUERY_VIEW_URL = `/api/views/${name}?${params}`
|
const QUERY_VIEW_URL = `/api/views/${name}?${params}`
|
||||||
const response = await api.get(QUERY_VIEW_URL)
|
const response = await api.get(QUERY_VIEW_URL)
|
||||||
data = await response.json()
|
data = await response.json()
|
||||||
|
loading = false
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Table title={decodeURI(name)} schema={view.schema} {data}>
|
<Table title={decodeURI(name)} schema={view.schema} {data} {loading}>
|
||||||
<FilterButton {view} />
|
<FilterButton {view} />
|
||||||
<CalculateButton {view} />
|
<CalculateButton {view} />
|
||||||
{#if view.calculation}
|
{#if view.calculation}
|
||||||
|
|
|
@ -9,7 +9,11 @@
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div bind:this={anchor}>
|
<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" />
|
<Icon name="calculate" />
|
||||||
Calculate
|
Calculate
|
||||||
</TextButton>
|
</TextButton>
|
||||||
|
|
|
@ -34,7 +34,6 @@
|
||||||
)
|
)
|
||||||
|
|
||||||
function saveView() {
|
function saveView() {
|
||||||
if (!view.calculation) view.calculation = "stats"
|
|
||||||
backendUiStore.actions.views.save(view)
|
backendUiStore.actions.views.save(view)
|
||||||
notifier.success(`View ${view.name} saved.`)
|
notifier.success(`View ${view.name} saved.`)
|
||||||
onClosed()
|
onClosed()
|
||||||
|
|
|
@ -109,7 +109,7 @@ function viewTemplate({ field, tableId, groupBy, filters = [], calculation }) {
|
||||||
|
|
||||||
const emitExpression = parseEmitExpression(field, groupBy)
|
const emitExpression = parseEmitExpression(field, groupBy)
|
||||||
|
|
||||||
const reduction = field ? { reduce: `_${calculation}` } : {}
|
const reduction = field && calculation ? { reduce: `_${calculation}` } : {}
|
||||||
|
|
||||||
let schema = null
|
let schema = null
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue