Skip to content

Commit

Permalink
[Maps] use style-prop methods to determine state (#55607) (#55749)
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasneirynck committed Jan 24, 2020
1 parent 95a62d1 commit 6943bca
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@ import { RENDER_AS } from './render_as';
import { CreateSourceEditor } from './create_source_editor';
import { UpdateSourceEditor } from './update_source_editor';
import { GRID_RESOLUTION } from '../../grid_resolution';
import { SOURCE_DATA_ID_ORIGIN, ES_GEO_GRID, COUNT_PROP_NAME } from '../../../../common/constants';
import {
SOURCE_DATA_ID_ORIGIN,
ES_GEO_GRID,
COUNT_PROP_NAME,
COLOR_MAP_TYPE,
} from '../../../../common/constants';
import { i18n } from '@kbn/i18n';
import { getDataSourceLabel } from '../../../../common/i18n_getters';
import { AbstractESAggSource } from '../es_agg_source';
Expand Down Expand Up @@ -251,6 +256,7 @@ export class ESGeoGridSource extends AbstractESAggSource {
origin: SOURCE_DATA_ID_ORIGIN,
},
color: COLOR_GRADIENTS[0].value,
type: COLOR_MAP_TYPE.ORDINAL,
},
},
[VECTOR_STYLES.LINE_COLOR]: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export function DynamicColorForm({
return null;
}

if (styleOptions.type === COLOR_MAP_TYPE.ORDINAL) {
if (styleProperty.isOrdinal()) {
return (
<ColorMapSelect
colorMapOptions={COLOR_GRADIENTS}
Expand Down Expand Up @@ -95,7 +95,7 @@ export function DynamicColorForm({
<EuiFlexItem>
<FieldSelect
fields={fields}
selectedFieldName={_.get(styleOptions, 'field.name')}
selectedFieldName={styleProperty.getFieldName()}
onChange={onFieldChange}
compressed
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
* you may not use this file except in compliance with the Elastic License.
*/

import _ from 'lodash';
import React from 'react';
import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui';
import { FieldSelect } from '../field_select';
Expand All @@ -27,7 +26,7 @@ export function DynamicLabelForm({
<EuiFlexItem>
<FieldSelect
fields={fields}
selectedFieldName={_.get(styleOptions, 'field.name')}
selectedFieldName={styleProperty.getFieldName()}
onChange={onFieldChange}
compressed
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
* you may not use this file except in compliance with the Elastic License.
*/

import _ from 'lodash';
import React from 'react';
import { FieldSelect } from '../field_select';
import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui';
Expand All @@ -30,7 +29,7 @@ export function DynamicOrientationForm({
<EuiFlexItem>
<FieldSelect
fields={fields}
selectedFieldName={_.get(styleOptions, 'field.name')}
selectedFieldName={styleProperty.getFieldName()}
onChange={onFieldChange}
compressed
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
* you may not use this file except in compliance with the Elastic License.
*/

import _ from 'lodash';
import React, { Fragment } from 'react';
import { FieldSelect } from '../field_select';
import { SizeRangeSelector } from './size_range_selector';
Expand Down Expand Up @@ -50,7 +49,7 @@ export function DynamicSizeForm({
<EuiFlexItem>
<FieldSelect
fields={fields}
selectedFieldName={_.get(styleOptions, 'field.name')}
selectedFieldName={styleProperty.getFieldName()}
onChange={onFieldChange}
compressed
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ export class DynamicStyleProperty extends AbstractStyleProperty {
return this._field;
}

getFieldName() {
return this._field ? this._field.getName() : '';
}

getComputedFieldName() {
if (!this.isComplete()) {
return null;
Expand Down

0 comments on commit 6943bca

Please sign in to comment.