Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extra fixes for Pro widgets #198

Merged
merged 1 commit into from
Jul 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -1757,6 +1757,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