Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
nreese committed Mar 13, 2020
1 parent 8db2894 commit 9d6faa9
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 14 deletions.
21 changes: 12 additions & 9 deletions x-pack/legacy/plugins/maps/public/layers/blended_vector_layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,20 +92,23 @@ function getClusterStyleDescriptor(
return;
}

if (styleProperty.isDynamic() && styleProperty.isComplete()) {
if (styleProperty.isDynamic()) {
const options = (styleProperty as IDynamicStyleProperty).getOptions();
const field =
options && options.field && options.field.name
? {
...options.field,
name: clusterSource.getAggKey(
getAggType(styleProperty as IDynamicStyleProperty),
options.field.name
),
}
: undefined;
clusterStyleDescriptor.properties[styleName] = {
type: STYLE_TYPE.DYNAMIC,
options: {
...options,
field: {
...options.field,
name: clusterSource.getAggKey(
getAggType(styleProperty as IDynamicStyleProperty),
// @ts-ignore styleProperty.isComplete() check ensures options.field.name exists
options.field.name
),
},
field,
},
};
} else {
Expand Down
4 changes: 0 additions & 4 deletions x-pack/legacy/plugins/maps/public/layers/layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -342,10 +342,6 @@ export class AbstractLayer {
return [];
}

async getFields() {
return [];
}

syncVisibilityWithMb(mbMap, mbLayerId) {
mbMap.setLayoutProperty(mbLayerId, 'visibility', this.isVisible() ? 'visible' : 'none');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export class VectorStyleEditor extends Component {
};

//These are all fields (only used for text labeling)
const fields = await this.props.layer.getFields();
const fields = await this.props.layer.getStyleEditorFields();
const fieldPromises = fields.map(getFieldMeta);
const fieldsArrayAll = await Promise.all(fieldPromises);
if (!this._isMounted || _.isEqual(fieldsArrayAll, this.state.fields)) {
Expand Down
5 changes: 5 additions & 0 deletions x-pack/legacy/plugins/maps/public/layers/vector_layer.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { MapFilters, VectorLayerRequestMeta } from '../../common/data_request_de
import { ILayer } from './layer';
import { IJoin } from './joins/join';
import { IVectorStyle } from './styles/vector/vector_style';
import { IField } from './fields/field';

type VectorLayerArguments = {
source: IVectorSource;
Expand All @@ -20,6 +21,8 @@ type VectorLayerArguments = {
};

export interface IVectorLayer extends ILayer {
getFields(): Promise<IField[]>;
getStyleEditorFields(): Promise<IField[]>;
getValidJoins(): IJoin[];
}

Expand All @@ -34,6 +37,8 @@ export class VectorLayer extends AbstractLayer implements IVectorLayer {

constructor(options: VectorLayerArguments);

getFields(): Promise<IField[]>;
getStyleEditorFields(): Promise<IField[]>;
getValidJoins(): IJoin[];
_getSearchFilters(dataFilters: MapFilters): VectorLayerRequestMeta;
}
5 changes: 5 additions & 0 deletions x-pack/legacy/plugins/maps/public/layers/vector_layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,11 @@ export class VectorLayer extends AbstractLayer {
return [...sourceFields, ...this._getJoinFields()];
}

async getStyleEditorFields() {
const sourceFields = await this.getSourceForEditing().getFields();
return [...sourceFields, ...this._getJoinFields()];
}

getIndexPatternIds() {
const indexPatternIds = this.getSource().getIndexPatternIds();
this.getValidJoins().forEach(join => {
Expand Down

0 comments on commit 9d6faa9

Please sign in to comment.