From 19a38feb60408a8c1a7a036eb24d73f47d9a321b Mon Sep 17 00:00:00 2001 From: Tim Purdum Date: Fri, 14 Jul 2023 17:40:16 -0400 Subject: [PATCH] Extra fixes for Pro widgets --- .../Components/Widgets/Widget.cs | 13 +++++++++++++ .../Scripts/arcGisJsInterop.ts | 8 ++++++++ .../Scripts/jsBuilder.ts | 19 ++++++++++++------- .../dymaptic.GeoBlazor.Core.csproj | 4 ++-- 4 files changed, 35 insertions(+), 9 deletions(-) diff --git a/src/dymaptic.GeoBlazor.Core/Components/Widgets/Widget.cs b/src/dymaptic.GeoBlazor.Core/Components/Widgets/Widget.cs index 86715397..03a14d7c 100644 --- a/src/dymaptic.GeoBlazor.Core/Components/Widgets/Widget.cs +++ b/src/dymaptic.GeoBlazor.Core/Components/Widgets/Widget.cs @@ -41,6 +41,19 @@ public abstract class Widget : MapComponent /// [JsonPropertyName("type")] public abstract string WidgetType { get; } + + /// + /// Icon which represents the widget. It is typically used when the widget is controlled by another one (e.g. in the Expand widget). + /// Default Value:null + /// + [Parameter] + public string? Icon { get; set; } + + /// + /// The unique ID assigned to the widget when the widget is created. If not set by the developer, it will default to the container ID, or if that is not present then it will be automatically generated. + /// + [Parameter] + public string? WidgetId { get; set; } /// /// DotNet Object Reference to the widget diff --git a/src/dymaptic.GeoBlazor.Core/Scripts/arcGisJsInterop.ts b/src/dymaptic.GeoBlazor.Core/Scripts/arcGisJsInterop.ts index 8adfb850..7daf4a75 100644 --- a/src/dymaptic.GeoBlazor.Core/Scripts/arcGisJsInterop.ts +++ b/src/dymaptic.GeoBlazor.Core/Scripts/arcGisJsInterop.ts @@ -1757,6 +1757,14 @@ async function createWidget(widget: any, viewId: string): Promise default: return null; } + + if (hasValue(widget.icon)) { + newWidget.icon = widget.icon; + } + + if (hasValue(widget.widgetId)) { + newWidget.id = widget.widgetId; + } arcGisObjectRefs[widget.id] = newWidget; dotNetRefs[widget.id] = widget.dotNetComponentReference; diff --git a/src/dymaptic.GeoBlazor.Core/Scripts/jsBuilder.ts b/src/dymaptic.GeoBlazor.Core/Scripts/jsBuilder.ts index a6c42a3c..dcc8b306 100644 --- a/src/dymaptic.GeoBlazor.Core/Scripts/jsBuilder.ts +++ b/src/dymaptic.GeoBlazor.Core/Scripts/jsBuilder.ts @@ -244,15 +244,20 @@ export function buildJsPopupTemplate(popupTemplateObject: DotNetPopupTemplate, v if (viewId !== null) { let view = arcGisObjectRefs[viewId] as View; if (hasValue(view)) { - if (hasValue(triggerActionHandler)) { - triggerActionHandler.remove(); + try { + if (hasValue(triggerActionHandler)) { + triggerActionHandler.remove(); + } + if (hasValue(templateTriggerActionHandler)) { + templateTriggerActionHandler.remove(); + } + templateTriggerActionHandler = view.popup.on("trigger-action", async (event: PopupTriggerActionEvent) => { + await popupTemplateObject.dotNetPopupTemplateReference.invokeMethodAsync("OnTriggerAction", event.action.id); + }); } - if (hasValue(templateTriggerActionHandler)) { - templateTriggerActionHandler.remove(); + catch (error) { + console.debug(error); } - templateTriggerActionHandler = view.popup.on("trigger-action", async (event: PopupTriggerActionEvent) => { - await popupTemplateObject.dotNetPopupTemplateReference.invokeMethodAsync("OnTriggerAction", event.action.id); - }); } } diff --git a/src/dymaptic.GeoBlazor.Core/dymaptic.GeoBlazor.Core.csproj b/src/dymaptic.GeoBlazor.Core/dymaptic.GeoBlazor.Core.csproj index abb58948..465f9736 100644 --- a/src/dymaptic.GeoBlazor.Core/dymaptic.GeoBlazor.Core.csproj +++ b/src/dymaptic.GeoBlazor.Core/dymaptic.GeoBlazor.Core.csproj @@ -78,12 +78,12 @@ - + - +