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
76ba859a
Commit
76ba859a
authored
8 years ago
by
Lewis Liu
Browse files
Options
Downloads
Patches
Plain Diff
Updated custom select component to allow for immediate updates
parent
7126c999
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/components/Select.jsx
+19
-4
19 additions, 4 deletions
frontend/src/metabase/components/Select.jsx
frontend/src/metabase/reference/components/Field.jsx
+2
-0
2 additions, 0 deletions
frontend/src/metabase/reference/components/Field.jsx
with
21 additions
and
4 deletions
frontend/src/metabase/components/Select.jsx
+
19
−
4
View file @
76ba859a
...
...
@@ -5,8 +5,16 @@ import Icon from "metabase/components/Icon.jsx";
import
PopoverWithTrigger
from
"
metabase/components/PopoverWithTrigger.jsx
"
;
export
default
class
Select
extends
Component
{
constructor
(
props
,
context
)
{
super
(
props
,
context
);
this
.
state
=
{
value
:
null
};
}
static
propTypes
=
{
value
:
PropTypes
.
any
,
updateImmediately
:
PropTypes
.
bool
,
options
:
PropTypes
.
array
.
isRequired
,
placeholder
:
PropTypes
.
string
,
onChange
:
PropTypes
.
func
,
...
...
@@ -26,10 +34,14 @@ export default class Select extends Component {
}
render
()
{
var
selectedName
=
this
.
props
.
value
?
this
.
props
.
optionNameFn
(
this
.
props
.
value
)
:
this
.
props
.
placeholder
;
const
value
=
this
.
props
.
updateImmediately
?
this
.
state
.
value
||
this
.
props
.
value
:
this
.
props
.
value
;
var
selectedName
=
value
?
this
.
props
.
optionNameFn
(
value
)
:
this
.
props
.
placeholder
;
var
triggerElement
=
(
<
div
className
=
{
"
flex align-center
"
+
(
!
this
.
props
.
value
?
"
text-grey-3
"
:
""
)
}
>
<
div
className
=
{
"
flex align-center
"
+
(
!
value
?
"
text-grey-3
"
:
""
)
}
>
<
span
className
=
"mr1"
>
{
selectedName
}
</
span
>
<
Icon
className
=
"flex-align-right"
name
=
"chevrondown"
width
=
"10"
height
=
"10"
/>
</
div
>
...
...
@@ -45,12 +57,15 @@ export default class Select extends Component {
var
columns
=
[
{
selectedItem
:
this
.
props
.
value
,
selectedItem
:
this
.
state
.
value
||
value
,
sections
:
sections
,
itemTitleFn
:
this
.
props
.
optionNameFn
,
itemDescriptionFn
:
(
item
)
=>
item
.
description
,
itemSelectFn
:
(
item
)
=>
{
this
.
props
.
onChange
(
this
.
props
.
optionValueFn
(
item
))
this
.
props
.
onChange
(
this
.
props
.
optionValueFn
(
item
));
if
(
this
.
props
.
updateImmediately
)
{
this
.
setState
({
value
:
this
.
props
.
optionValueFn
(
item
)});
}
this
.
toggle
();
}
}
...
...
This diff is collapsed.
Click to expand it.
frontend/src/metabase/reference/components/Field.jsx
+
2
−
0
View file @
76ba859a
...
...
@@ -18,6 +18,7 @@ import pure from "recompose/pure";
const
Field
=
({
field
,
specialTypeId
,
url
,
icon
,
isEditing
,
...
...
@@ -56,6 +57,7 @@ const Field = ({
true
)
}
updateImmediately
=
{
true
}
onChange
=
{
(
type
)
=>
formField
.
special_type
.
onChange
(
type
.
id
)
}
/>
:
<
span
>
...
...
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