@@ -5,11 +5,11 @@ import { Icons } from '@eqworks/lumen-labs'
55import modes from '../../constants/modes'
66import aggFunctions from '../../util/agg-functions'
77import { useStoreState , useStoreActions } from '../../store'
8- import CustomSelect from '../../components/custom-select'
98import PluralLinkedSelect from '../../components/plural-linked-select'
109import WidgetControlCard from '../shared/components/widget-control-card'
1110import { renderRow , renderSection } from './util'
1211import MutedBarrier from './muted-barrier'
12+ import CustomSelect from '../../components/custom-select'
1313
1414
1515const ValueControls = ( ) => {
@@ -19,20 +19,18 @@ const ValueControls = () => {
1919
2020 // common state
2121 const type = useStoreState ( ( state ) => state . type )
22- const columns = useStoreState ( ( state ) => state . columns )
2322 const group = useStoreState ( ( state ) => state . group )
2423 const domain = useStoreState ( ( state ) => state . domain )
2524 const valueKeys = useStoreState ( ( state ) => state . valueKeys )
2625 const dataHasVariance = useStoreState ( ( state ) => state . dataHasVariance )
2726 const dataSourceLoading = useStoreState ( ( state ) => state . ui . dataSourceLoading )
2827 const columnsAnalysis = useStoreState ( ( state ) => state . columnsAnalysis )
2928
30- const eligibleColumns = useMemo ( ( ) => columns
31- . map ( ( { name } ) => name )
32- . filter ( c => (
33- c !== domain . value
34- && columnsAnalysis [ c ] ?. isNumeric
35- ) ) , [ columns , columnsAnalysis , domain . value ] )
29+ const eligibleColumns = useMemo ( ( ) =>
30+ Object . fromEntries (
31+ Object . entries ( columnsAnalysis )
32+ . filter ( ( [ c , { isNumeric } ] ) => c !== domain . value && isNumeric )
33+ ) , [ columnsAnalysis , domain . value ] )
3634
3735 // UI state
3836 const mode = useStoreState ( ( state ) => state . ui . mode )
@@ -46,9 +44,10 @@ const ValueControls = () => {
4644 staticQuantity = { mode === modes . QL ? 3 : undefined }
4745 titles = { [ 'Column' , 'Operation' ] }
4846 values = { valueKeys }
47+ valueIcons = { Object . values ( eligibleColumns ) . map ( ( { Icon } ) => Icon ) }
4948 primaryKey = 'key'
5049 secondaryKey = 'agg'
51- data = { eligibleColumns }
50+ data = { Object . keys ( eligibleColumns ) }
5251 subData = { Object . keys ( aggFunctions ) }
5352 disableSubs = { ! dataHasVariance }
5453 disableSubMessage = "doesn't require aggregation."
@@ -71,7 +70,7 @@ const ValueControls = () => {
7170
7271 return (
7372 < MutedBarrier
74- mute = { ! dataSourceLoading && ( ! type || ! domain . value || ! eligibleColumns . length ) }
73+ mute = { ! dataSourceLoading && ( ! type || ! domain . value || ! Object . keys ( eligibleColumns ) ? .length ) }
7574 { ...! eligibleColumns . length && { message : 'Sorry, there are no eligible columns in this dataset.' } }
7675 >
7776 < WidgetControlCard
@@ -90,8 +89,9 @@ const ValueControls = () => {
9089 fullWidth
9190 multiSelect
9291 value = { valueKeys . map ( ( { key } ) => key ) }
93- data = { eligibleColumns }
92+ data = { Object . keys ( eligibleColumns ) }
9493 onSelect = { ( val ) => userUpdate ( { valueKeys : val . map ( v => ( { key : v } ) ) } ) }
94+ icons = { Object . values ( eligibleColumns ) . map ( ( { Icon } ) => Icon ) }
9595 />
9696 )
9797 )
0 commit comments