Skip to content

Commit

Permalink
Merge pull request #198 from dymaptic/feature/193_extra_fixes
Browse files Browse the repository at this point in the history
Extra fixes for Pro widgets
  • Loading branch information
TimPurdum authored Jul 18, 2023
2 parents cc3cdb7 + 19a38fe commit dbffbb6
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 9 deletions.
13 changes: 13 additions & 0 deletions src/dymaptic.GeoBlazor.Core/Components/Widgets/Widget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,19 @@ public abstract class Widget : MapComponent
/// </summary>
[JsonPropertyName("type")]
public abstract string WidgetType { get; }

/// <summary>
/// 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
/// </summary>
[Parameter]
public string? Icon { get; set; }

/// <summary>
/// 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.
/// </summary>
[Parameter]
public string? WidgetId { get; set; }

/// <summary>
/// DotNet Object Reference to the widget
Expand Down
8 changes: 8 additions & 0 deletions src/dymaptic.GeoBlazor.Core/Scripts/arcGisJsInterop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1758,6 +1758,14 @@ async function createWidget(widget: any, viewId: string): Promise<Widget | null>
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;
Expand Down
19 changes: 12 additions & 7 deletions src/dymaptic.GeoBlazor.Core/Scripts/jsBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/dymaptic.GeoBlazor.Core/dymaptic.GeoBlazor.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,12 @@
<Exec Command="npm install" />
</Target>

<Target Name="Copy Assets Debug" AfterTargets="NPM Install" Condition="$(Configuration) == 'DEBUG' AND $(TargetFrameworks.StartsWith($(TargetFramework))) AND '$(OptOutFromCoreEsBuild)' != 'true'">
<Target Name="Copy Assets Debug" AfterTargets="PreBuildEvent" Condition="$(Configuration) == 'DEBUG' AND $(TargetFrameworks.StartsWith($(TargetFramework)))">
<Message Importance="high" Text="Copying Asset files" />
<ExecAsync FilePath="pwsh" Arguments="./assetCopy.ps1" />
</Target>

<Target Name="Copy Assets Release" AfterTargets="NPM Install" Condition="$(Configuration) == 'RELEASE' AND $(TargetFrameworks.StartsWith($(TargetFramework)))">
<Target Name="Copy Assets Release" AfterTargets="PreBuildEvent" Condition="$(Configuration) == 'RELEASE' AND $(TargetFrameworks.StartsWith($(TargetFramework)))">
<Message Importance="high" Text="Copying Asset files" />
<Exec Command="pwsh ./assetCopy.ps1" />
</Target>
Expand Down

0 comments on commit dbffbb6

Please sign in to comment.