From 6525f1d19c28fe3a6ee59d6e327375f548a83248 Mon Sep 17 00:00:00 2001 From: Tim Purdum Date: Wed, 2 Aug 2023 08:16:28 -0500 Subject: [PATCH 1/4] fix popup actions --- src/dymaptic.GeoBlazor.Core/Scripts/jsBuilder.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/dymaptic.GeoBlazor.Core/Scripts/jsBuilder.ts b/src/dymaptic.GeoBlazor.Core/Scripts/jsBuilder.ts index 1a793a0c..8298551b 100644 --- a/src/dymaptic.GeoBlazor.Core/Scripts/jsBuilder.ts +++ b/src/dymaptic.GeoBlazor.Core/Scripts/jsBuilder.ts @@ -110,6 +110,7 @@ import ComboBoxInput from "@arcgis/core/form/elements/inputs/ComboBoxInput"; import RadioButtonsInput from "@arcgis/core/form/elements/inputs/RadioButtonsInput"; import SwitchInput from "@arcgis/core/form/elements/inputs/SwitchInput"; import Domain from "@arcgis/core/layers/support/Domain"; +import * as reactiveUtils from "@arcgis/core/core/reactiveUtils"; export function buildJsSpatialReference(dotNetSpatialReference: DotNetSpatialReference): SpatialReference { @@ -260,9 +261,12 @@ export function buildJsPopupTemplate(popupTemplateObject: DotNetPopupTemplate, v if (hasValue(templateTriggerActionHandler)) { templateTriggerActionHandler.remove(); } - templateTriggerActionHandler = view.popup.on("trigger-action", async (event: PopupTriggerActionEvent) => { - await popupTemplateObject.dotNetPopupTemplateReference.invokeMethodAsync("OnTriggerAction", event.action.id); - }); + reactiveUtils.once(() => view.popup.on !== undefined) + .then(() => { + templateTriggerActionHandler = view.popup.on("trigger-action", async (event: PopupTriggerActionEvent) => { + await popupTemplateObject.dotNetPopupTemplateReference.invokeMethodAsync("OnTriggerAction", event.action.id); + }); + }) } catch (error) { console.debug(error); @@ -727,9 +731,9 @@ export function buildJsQuery(dotNetQuery: DotNetQuery): Query { where: dotNetQuery.where ?? "1=1", spatialRelationship: dotNetQuery.spatialRelationship as any ?? "intersects", distance: dotNetQuery.distance ?? undefined, - units: dotNetQuery.units as any ?? null, + units: dotNetQuery.units as any ?? undefined, returnGeometry: dotNetQuery.returnGeometry ?? false, - outFields: dotNetQuery.outFields ?? null, + outFields: dotNetQuery.outFields ?? undefined, orderByFields: dotNetQuery.orderByFields ?? undefined, outStatistics: dotNetQuery.outStatistics ?? undefined, groupByFieldsForStatistics: dotNetQuery.groupByFieldsForStatistics ?? undefined, @@ -748,7 +752,7 @@ export function buildJsQuery(dotNetQuery: DotNetQuery): Query { having: dotNetQuery.having ?? undefined, historicMoment: dotNetQuery.historicMoment ?? undefined, maxRecordCountFactor: dotNetQuery.maxRecordCountFactor ?? 1, - text: dotNetQuery.text ?? null, + text: dotNetQuery.text ?? undefined, parameterValues: dotNetQuery.parameterValues ?? undefined, quantizationParameters: dotNetQuery.quantizationParameters ?? undefined, rangeValues: dotNetQuery.rangeValues ?? undefined, From 010ca640942b5c77272757832f7d6172ae193134 Mon Sep 17 00:00:00 2001 From: Tim Purdum Date: Wed, 2 Aug 2023 08:46:51 -0500 Subject: [PATCH 2/4] update version for beta build, fix assetCopy (PS defaults changed again?!?) --- src/dymaptic.GeoBlazor.Core.sln | 6 ------ src/dymaptic.GeoBlazor.Core/assetCopy.ps1 | 2 +- src/dymaptic.GeoBlazor.Core/dymaptic.GeoBlazor.Core.csproj | 5 ++--- src/dymaptic.GeoBlazor.Core/package-lock.json | 4 ++-- src/dymaptic.GeoBlazor.Core/package.json | 2 +- 5 files changed, 6 insertions(+), 13 deletions(-) diff --git a/src/dymaptic.GeoBlazor.Core.sln b/src/dymaptic.GeoBlazor.Core.sln index 19be7992..c0163b98 100644 --- a/src/dymaptic.GeoBlazor.Core.sln +++ b/src/dymaptic.GeoBlazor.Core.sln @@ -24,8 +24,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "dymaptic.GeoBlazor.Core.Sam EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "dymaptic.GeoBlazor.Core.Sample.ServerOAuth", "..\samples\dymaptic.GeoBlazor.Core.Sample.ServerOAuth\dymaptic.GeoBlazor.Core.Sample.ServerOAuth.csproj", "{3DED106E-5ED1-4506-87CA-50C40465D6A1}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "dymaptic.GeoBlazor.Core.Test.Blazor", "..\tests\dymaptic.GeoBlazor.Core.Test.Blazor\dymaptic.GeoBlazor.Core.Test.Blazor.csproj", "{FACB8396-34A0-4BB0-98B0-463BC26BE349}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "dymaptic.GeoBlazor.Core.Test.Blazor.Server", "..\test\dymaptic.GeoBlazor.Core.Test.Blazor.Server\dymaptic.GeoBlazor.Core.Test.Blazor.Server.csproj", "{915558F0-1755-42D9-81EC-805774ECEB42}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "dymaptic.GeoBlazor.Core.Test.Blazor.Shared", "..\test\dymaptic.GeoBlazor.Core.Test.Blazor.Shared\dymaptic.GeoBlazor.Core.Test.Blazor.Shared.csproj", "{41CD66DB-1487-4F37-B2C6-3DB569116E89}" @@ -72,10 +70,6 @@ Global {3DED106E-5ED1-4506-87CA-50C40465D6A1}.Debug|Any CPU.Build.0 = Debug|Any CPU {3DED106E-5ED1-4506-87CA-50C40465D6A1}.Release|Any CPU.ActiveCfg = Release|Any CPU {3DED106E-5ED1-4506-87CA-50C40465D6A1}.Release|Any CPU.Build.0 = Release|Any CPU - {FACB8396-34A0-4BB0-98B0-463BC26BE349}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {FACB8396-34A0-4BB0-98B0-463BC26BE349}.Debug|Any CPU.Build.0 = Debug|Any CPU - {FACB8396-34A0-4BB0-98B0-463BC26BE349}.Release|Any CPU.ActiveCfg = Release|Any CPU - {FACB8396-34A0-4BB0-98B0-463BC26BE349}.Release|Any CPU.Build.0 = Release|Any CPU {915558F0-1755-42D9-81EC-805774ECEB42}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {915558F0-1755-42D9-81EC-805774ECEB42}.Debug|Any CPU.Build.0 = Debug|Any CPU {915558F0-1755-42D9-81EC-805774ECEB42}.Release|Any CPU.ActiveCfg = Release|Any CPU diff --git a/src/dymaptic.GeoBlazor.Core/assetCopy.ps1 b/src/dymaptic.GeoBlazor.Core/assetCopy.ps1 index 6096d4ab..0d20d60d 100644 --- a/src/dymaptic.GeoBlazor.Core/assetCopy.ps1 +++ b/src/dymaptic.GeoBlazor.Core/assetCopy.ps1 @@ -1,4 +1,4 @@ -$SourceFiles = "./node_modules/@arcgis/core/assets/*" +$SourceFiles = "./node_modules/@arcgis/core/assets" $OutputDir = "./wwwroot/assets" $packageJson = (Get-Content "package.json" -Raw) | ConvertFrom-Json # read the version from package.json diff --git a/src/dymaptic.GeoBlazor.Core/dymaptic.GeoBlazor.Core.csproj b/src/dymaptic.GeoBlazor.Core/dymaptic.GeoBlazor.Core.csproj index 465f9736..c94288f2 100644 --- a/src/dymaptic.GeoBlazor.Core/dymaptic.GeoBlazor.Core.csproj +++ b/src/dymaptic.GeoBlazor.Core/dymaptic.GeoBlazor.Core.csproj @@ -9,8 +9,8 @@ GeoBlazor MIT - 2.2.1 - 2.2.1 + 2.3.0-beta-1 + 2.3.0-beta-1 Tim Purdum, Christopher Moravec, Mara Stoica, Tim Rawson dymaptic ©2023 by dymaptic @@ -68,7 +68,6 @@ - diff --git a/src/dymaptic.GeoBlazor.Core/package-lock.json b/src/dymaptic.GeoBlazor.Core/package-lock.json index c266056a..ac31d674 100644 --- a/src/dymaptic.GeoBlazor.Core/package-lock.json +++ b/src/dymaptic.GeoBlazor.Core/package-lock.json @@ -1,12 +1,12 @@ { "name": "dymaptic.GeoBlazor.Core", - "version": "2.2.1", + "version": "2.3.0-beta-1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "dymaptic.GeoBlazor.Core", - "version": "2.2.1", + "version": "2.3.0-beta-1", "license": "ISC", "dependencies": { "@arcgis/core": "^4.27.6", diff --git a/src/dymaptic.GeoBlazor.Core/package.json b/src/dymaptic.GeoBlazor.Core/package.json index 818eca9e..8cada501 100644 --- a/src/dymaptic.GeoBlazor.Core/package.json +++ b/src/dymaptic.GeoBlazor.Core/package.json @@ -1,6 +1,6 @@ { "name": "dymaptic.GeoBlazor.Core", - "version": "2.2.1", + "version": "2.3.0-beta-1", "description": "https://www.geoblazor.com", "main": "arcGisInterop.js", "scripts": { From 817a9d80d2cbfeae12f5a8f8d019c7f27a45bc7f Mon Sep 17 00:00:00 2001 From: Tim Purdum Date: Wed, 2 Aug 2023 16:14:58 -0500 Subject: [PATCH 3/4] working on test, broken --- .../Components/PopupTests.razor | 43 +++++++++++++++++++ .../wwwroot/testRunner.js | 10 +++++ 2 files changed, 53 insertions(+) create mode 100644 test/dymaptic.GeoBlazor.Core.Test.Blazor.Shared/Components/PopupTests.razor diff --git a/test/dymaptic.GeoBlazor.Core.Test.Blazor.Shared/Components/PopupTests.razor b/test/dymaptic.GeoBlazor.Core.Test.Blazor.Shared/Components/PopupTests.razor new file mode 100644 index 00000000..7ca2d721 --- /dev/null +++ b/test/dymaptic.GeoBlazor.Core.Test.Blazor.Shared/Components/PopupTests.razor @@ -0,0 +1,43 @@ +@inherits TestRunnerBase + +@{ + base.BuildRenderTree(__builder); +} + +@code { + + [TestMethod] + public async Task TestCanActivatePopupAction() + { + bool callbackCalled = false; + CreateViewRenderedHandler(async () => + { + await AssertJavaScript("assertPopupCallback"); + Assert.IsTrue(callbackCalled); + }); + + Task MeasureThis() + { + callbackCalled = true; + return Task.CompletedTask; + } + + AddMapRenderFragment( + @ + + + + + + + + + ); + + await WaitForMapToRender(); + + } +} \ No newline at end of file diff --git a/test/dymaptic.GeoBlazor.Core.Test.Blazor.Shared/wwwroot/testRunner.js b/test/dymaptic.GeoBlazor.Core.Test.Blazor.Shared/wwwroot/testRunner.js index c7be631b..a6217cc9 100644 --- a/test/dymaptic.GeoBlazor.Core.Test.Blazor.Shared/wwwroot/testRunner.js +++ b/test/dymaptic.GeoBlazor.Core.Test.Blazor.Shared/wwwroot/testRunner.js @@ -33,4 +33,14 @@ export function assertKmlLayerExists(viewId) { export function testThrow() { throw new Error("Test throw"); +} + +export async function assertPopupCallback(viewId, layerId) { + let view = arcGisObjectRefs[viewId]; + let layer = view.map.layers.items[0]; + let featureSet = await layer.queryFeatures(); + view.popup.open({ + features: [ featureSet.features[0] ] + }); + view.popup.triggerAction(0); } \ No newline at end of file From 0b1ef680b0a97f5a7f781fdd933e68028023ba6f Mon Sep 17 00:00:00 2001 From: Tim Purdum Date: Thu, 3 Aug 2023 09:05:06 -0500 Subject: [PATCH 4/4] Added unit test, comment --- src/dymaptic.GeoBlazor.Core/Scripts/jsBuilder.ts | 2 ++ .../wwwroot/testRunner.js | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/dymaptic.GeoBlazor.Core/Scripts/jsBuilder.ts b/src/dymaptic.GeoBlazor.Core/Scripts/jsBuilder.ts index 8298551b..4403429f 100644 --- a/src/dymaptic.GeoBlazor.Core/Scripts/jsBuilder.ts +++ b/src/dymaptic.GeoBlazor.Core/Scripts/jsBuilder.ts @@ -261,6 +261,8 @@ export function buildJsPopupTemplate(popupTemplateObject: DotNetPopupTemplate, v if (hasValue(templateTriggerActionHandler)) { templateTriggerActionHandler.remove(); } + + // we need to wait for the popup to be initialized before we can add the trigger-action handler reactiveUtils.once(() => view.popup.on !== undefined) .then(() => { templateTriggerActionHandler = view.popup.on("trigger-action", async (event: PopupTriggerActionEvent) => { diff --git a/test/dymaptic.GeoBlazor.Core.Test.Blazor.Shared/wwwroot/testRunner.js b/test/dymaptic.GeoBlazor.Core.Test.Blazor.Shared/wwwroot/testRunner.js index a6217cc9..af2326f4 100644 --- a/test/dymaptic.GeoBlazor.Core.Test.Blazor.Shared/wwwroot/testRunner.js +++ b/test/dymaptic.GeoBlazor.Core.Test.Blazor.Shared/wwwroot/testRunner.js @@ -42,5 +42,10 @@ export async function assertPopupCallback(viewId, layerId) { view.popup.open({ features: [ featureSet.features[0] ] }); - view.popup.triggerAction(0); + let button = null; + while (button === null) { + await new Promise(resolve => setTimeout(resolve, 100)); + button = document.querySelector('[title="Measure Length"]'); + } + button.click(); } \ No newline at end of file