Skip to content

Commit bd71f32

Browse files
authored
Merge pull request #86 from felix-mu/85-bug-datalinks-update-to-undefined-if-a-data-layer-does-not-include-the-field-name
fix: add toggle for data layers to configure if the layer is used in data links Closes #85
2 parents c02dc2c + f2de22e commit bd71f32

File tree

3 files changed

+36
-2
lines changed

3 files changed

+36
-2
lines changed

src/GeomapPanel.tsx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,31 @@ export class GeomapPanel extends Component<Props, State> {
149149

150150
let dataFrame: DataFrame = event.payload.data!;
151151
let rowIndex: number = event.payload.rowIndex!;
152+
153+
// Return if either dataframe or rowIndex are undefined
154+
if (dataFrame === undefined || rowIndex === undefined) {
155+
return;
156+
}
157+
158+
// Get options for data layer with refIf of dataframes and check if the data layer is configured for datalinks
159+
const dataLayer = this.props.options.layers.find((el) => {
160+
try {
161+
return el.query!.options === dataFrame.refId;
162+
} catch (error) {
163+
return false;
164+
}
165+
})
166+
167+
if (!dataLayer) {
168+
return;
169+
}
170+
171+
// By default 'enabledForDataLinks' is considered to be true, even though it might not be defined.
172+
// I.e. the value must be explicitely set to false to be excluded
173+
if (dataLayer.enabledForDataLinks !== undefined && dataLayer.enabledForDataLinks === false) {
174+
return;
175+
}
176+
152177
// let proxyObject = getFieldDisplayValuesProxy({
153178
// frame: this.state.ttip!.data!,
154179
// rowIndex: this.state.ttip!.rowIndex!

src/editor/LayerEditor.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,13 @@ export const LayerEditor: FC<LayerEditorProps> = ({ options, onChange, data, fil
228228
settings: {},
229229
defaultValue: true
230230
});
231+
builder.addBooleanSwitch({
232+
path: 'enabledForDataLinks',
233+
name: 'Toggle to include the data layer for data links',
234+
description: 'If toggled the layer is used to interpolate the data links URL.',
235+
settings: {},
236+
defaultValue: true
237+
});
231238
}
232239

233240
if (layer.registerOptionsUI) {
@@ -255,7 +262,8 @@ export const LayerEditor: FC<LayerEditorProps> = ({ options, onChange, data, fil
255262
options: {
256263
...options,
257264
opacity: options?.opacity === undefined && layer.showOpacity ? 1.0 : options?.opacity,
258-
visible: options?.visible === undefined ? true : options?.visible
265+
visible: options?.visible === undefined ? true : options?.visible,
266+
enabledForDataLinks: options?.enabledForDataLinks === undefined ? true : options?.enabledForDataLinks,
259267
}
260268
};
261269

src/extension.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ export interface ExtendMapLayerOptions<TConfig = any> {
5050
displayProperties?: string[];
5151
titleField?: string;
5252
timeField?: string;
53-
visible?: boolean
53+
visible?: boolean;
54+
enabledForDataLinks?: boolean;
5455
}
5556

5657
export interface ExtendMapLayerRegistryItem<TConfig = ExtendMapLayerOptions> extends RegistryItemWithOptions {

0 commit comments

Comments
 (0)