Skip to content

Commit

Permalink
Allow setting button settings per layer
Browse files Browse the repository at this point in the history
  • Loading branch information
MattiasSp committed Sep 27, 2024
1 parent 786447a commit 2be6b64
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/infowindow_exporthandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ function createToaster(status, exportOptions, message) {

function createExportButtons(
obj,
buttonPerLayer,
requestMethodPerLayer,
urlParametersPerLayer,
attributesToSendToExportPerLayer,
Expand All @@ -320,9 +321,11 @@ function createExportButtons(
exportOptions,
responseHandler
) {
const roundButton = obj.button.roundButton || false;
const buttonText = obj.button.buttonText || defaultText;
const url = obj.url;
const buttonText = obj.button?.buttonText || buttonPerLayer?.buttonText || defaultText;
const roundButton = obj.button?.roundButton ?? buttonPerLayer?.roundButton ?? false;
const roundButtonIcon = obj.button?.roundButtonIcon || buttonPerLayer?.roundButtonIcon || defaultIcon;
const roundButtonTooltipText = obj.button?.roundButtonTooltipText || buttonPerLayer?.roundButtonTooltipText || defaultText;
const requestMethod = obj.requestMethod || requestMethodPerLayer || 'POST_JSON';
const urlParameters = obj.urlParameters || urlParametersPerLayer;
const attributesToSendToExport = obj.attributesToSendToExport || attributesToSendToExportPerLayer;
Expand All @@ -335,8 +338,8 @@ function createExportButtons(
}
const exportBtn = roundButton
? createCustomExportButton(
obj.button.roundButtonIcon || defaultIcon,
obj.button.roundButtonTooltipText || defaultText
roundButtonIcon,
roundButtonTooltipText
)
: createExportButton(buttonText);
const btn = exportBtn.querySelector('button');
Expand Down Expand Up @@ -400,6 +403,7 @@ export function createSubexportComponent({ selectionGroup, viewer, exportOptions
}
if (layerSpecificExportOptions) {
const exportUrls = layerSpecificExportOptions.exportUrls || [];
const buttonPerLayer = layerSpecificExportOptions.button;
const requestMethodPerLayer = layerSpecificExportOptions.requestMethod;
const urlParametersPerLayer = layerSpecificExportOptions.urlParameters;
const attributesToSendToExportPerLayer = layerSpecificExportOptions.attributesToSendToExport;
Expand All @@ -410,6 +414,7 @@ export function createSubexportComponent({ selectionGroup, viewer, exportOptions
.forEach((obj) => {
const button = createExportButtons(
obj,
buttonPerLayer,
requestMethodPerLayer,
urlParametersPerLayer,
attributesToSendToExportPerLayer,
Expand Down

0 comments on commit 2be6b64

Please sign in to comment.