Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Metabase
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Engineering Digital Service
Metabase
Commits
6b2edde4
Unverified
Commit
6b2edde4
authored
7 years ago
by
Tom Robinson
Browse files
Options
Downloads
Patches
Plain Diff
Port aggregation and breakout widgets (temporary wrapper components for now)
parent
8ce73892
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
frontend/src/metabase-lib/lib/Query.js
+4
-1
4 additions, 1 deletion
frontend/src/metabase-lib/lib/Query.js
frontend/src/metabase/query_builder/components/GuiQueryEditor.jsx
+34
-15
34 additions, 15 deletions
.../src/metabase/query_builder/components/GuiQueryEditor.jsx
with
38 additions
and
16 deletions
frontend/src/metabase-lib/lib/Query.js
+
4
−
1
View file @
6b2edde4
...
...
@@ -95,6 +95,9 @@ export default class Query {
canAddAggregation
():
boolean
{
return
false
;
}
canRemoveAggregation
():
boolean
{
return
this
.
aggregations
().
length
>
1
;
}
isBareRows
():
boolean
{
return
Q
.
isBareRows
(
this
.
query
());
...
...
@@ -139,7 +142,7 @@ export default class Query {
);
}
canAddBreakout
():
boolean
{
return
false
;
return
this
.
breakoutableDimensions
().
count
>
0
;
}
addBreakout
(
breakout
:
Breakout
)
{
...
...
This diff is collapsed.
Click to expand it.
frontend/src/metabase/query_builder/components/GuiQueryEditor.jsx
+
34
−
15
View file @
6b2edde4
...
...
@@ -4,8 +4,8 @@ import React, { Component } from "react";
import
PropTypes
from
"
prop-types
"
;
import
ReactDOM
from
"
react-dom
"
;
import
AggregationWidget
from
'
./AggregationWidget.jsx
'
;
import
BreakoutWidget
from
'
./BreakoutWidget.jsx
'
;
import
AggregationWidget
_LEGACY
from
'
./AggregationWidget.jsx
'
;
import
BreakoutWidget
_LEGACY
from
'
./BreakoutWidget.jsx
'
;
import
DataSelector
from
'
./DataSelector.jsx
'
;
import
ExtendedOptions
from
"
./ExtendedOptions.jsx
"
;
import
FilterList
from
'
./filters/FilterList.jsx
'
;
...
...
@@ -42,6 +42,8 @@ type Props = {
databases
:
DatabaseMetadata
[],
tables
:
TableMetadata
[],
supportMultipleAggregations
?:
boolean
,
setDatabaseFn
:
(
id
:
DatabaseId
)
=>
void
,
setSourceTableFn
:
(
id
:
TableId
)
=>
void
,
setDatasetQuery
:
(
datasetQuery
:
DatasetQuery
)
=>
void
,
...
...
@@ -184,8 +186,6 @@ export default class GuiQueryEditor extends Component {
aggregations
.
push
([
"
rows
"
]);
}
const
canRemoveAggregation
=
aggregations
.
length
>
1
;
// Placeholder aggregation for showing the add button
if
(
supportMultipleAggregations
&&
!
query
.
isBareRows
())
{
// $FlowFixMe
...
...
@@ -197,11 +197,10 @@ export default class GuiQueryEditor extends Component {
aggregationList
.
push
(
<
AggregationWidget
key
=
{
"
agg
"
+
index
}
index
=
{
index
}
aggregation
=
{
aggregation
}
tableMetadata
=
{
query
.
tableMetadata
()
}
customFields
=
{
query
.
expressions
()
}
updateAggregation
=
{
(
aggregation
)
=>
query
.
updateAggregation
(
index
,
aggregation
).
update
(
setDatasetQuery
)
}
removeAggregation
=
{
canRemoveAggregation
?
(()
=>
query
.
removeAggregation
(
index
).
update
(
setDatasetQuery
))
:
null
}
query
=
{
query
}
updateQuery
=
{
setDatasetQuery
}
addButton
=
{
this
.
renderAdd
(
null
)
}
/>
);
...
...
@@ -237,8 +236,8 @@ export default class GuiQueryEditor extends Component {
if
(
enabled
&&
tableMetadata
)
{
const
breakouts
=
query
.
breakouts
();
const
dimensions
=
query
.
breakoutableDimensions
();
if
(
dimensions
.
count
>
0
&&
(
breakouts
.
length
===
0
||
breakouts
[
breakouts
.
length
-
1
]
!=
null
)
)
{
// Placeholder breakout for showing the add button
if
(
query
.
canAddBreakout
()
&&
breakouts
.
length
===
0
)
{
// $FlowFixMe
breakouts
.
push
(
null
);
}
...
...
@@ -254,11 +253,10 @@ export default class GuiQueryEditor extends Component {
<
BreakoutWidget
key
=
{
"
breakout
"
+
i
}
className
=
"View-section-breakout SelectionModule p1"
fieldOptions
=
{
query
.
breakoutableDimensions
(
breakout
)
}
customFieldOptions
=
{
query
.
expressions
()
}
tableMetadata
=
{
tableMetadata
}
field
=
{
breakout
}
setField
=
{
(
field
)
=>
query
.
updateBreakout
(
i
,
field
).
update
(
setDatasetQuery
)
}
index
=
{
i
}
breakout
=
{
breakout
}
query
=
{
query
}
updateQuery
=
{
setDatasetQuery
}
addButton
=
{
this
.
renderAdd
(
i
===
0
?
"
Add a grouping
"
:
null
)
}
/>
);
...
...
@@ -391,3 +389,24 @@ export default class GuiQueryEditor extends Component {
);
}
}
const
AggregationWidget
=
({
index
,
aggregation
,
query
,
updateQuery
,
addButton
})
=>
<
AggregationWidget_LEGACY
aggregation
=
{
aggregation
}
tableMetadata
=
{
query
.
tableMetadata
()
}
customFields
=
{
query
.
expressions
()
}
updateAggregation
=
{
(
aggregation
)
=>
query
.
updateAggregation
(
index
,
aggregation
).
update
(
updateQuery
)
}
removeAggregation
=
{
query
.
canRemoveAggregation
()
?
(()
=>
query
.
removeAggregation
(
index
).
update
(
updateQuery
))
:
null
}
addButton
=
{
addButton
}
/>
const
BreakoutWidget
=
({
className
,
index
,
breakout
,
query
,
updateQuery
,
addButton
})
=>
<
BreakoutWidget_LEGACY
className
=
{
className
}
field
=
{
breakout
}
fieldOptions
=
{
query
.
breakoutableDimensions
(
breakout
)
}
customFieldOptions
=
{
query
.
expressions
()
}
tableMetadata
=
{
query
.
tableMetadata
()
}
setField
=
{
(
field
)
=>
query
.
updateBreakout
(
index
,
field
).
update
(
updateQuery
)
}
addButton
=
{
addButton
}
/>
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment