Skip to content

Commit ba43336

Browse files
Ticket #924 : FormAnchor can be a static link
1 parent 2c7ec76 commit ba43336

3 files changed

Lines changed: 63 additions & 6 deletions

File tree

formbuilder/FormBuilder/Components/FormElements/Anchor/FormAnchor.razor.cs

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using FormBuilder.Components.Drag;
22
using FormBuilder.Factories;
33
using FormBuilder.Helpers;
4+
using FormBuilder.Services;
45
using Microsoft.AspNetCore.Components;
56
using System.Text.Json.Nodes;
67

@@ -21,6 +22,7 @@ public string CssId
2122
}
2223
[Inject] private IWorkflowLinkActionFactory WorkflowLinkActionFactory { get; set; }
2324
[Inject] private IHtmlClassResolver htmlClassResolver { get; set; }
25+
[Inject] private IFormBuilderJsService formBuilderJsService { get; set; }
2426
public JsonNode InputData
2527
{
2628
get
@@ -48,10 +50,24 @@ public string AnchorClass
4850

4951
private async Task Navigate()
5052
{
51-
var linkExecution = Context.GetLinkExecutionFromElementAndCurrentStep(Value.Id);
52-
var link = Context.GetLinkDefinitionFromCurrentStep(Value.Id);
53-
if (linkExecution == null || link == null) return;
54-
var act = WorkflowLinkActionFactory.Build(link.ActionType);
55-
await act.Execute(link, linkExecution, Context);
53+
if(Value.IsStaticLink)
54+
{
55+
if(Value.OpenInNewTab)
56+
{
57+
await formBuilderJsService.Navigate(Value.Url);
58+
}
59+
else
60+
{
61+
await formBuilderJsService.NavigateForce(Value.Url);
62+
}
63+
}
64+
else
65+
{
66+
var linkExecution = Context.GetLinkExecutionFromElementAndCurrentStep(Value.Id);
67+
var link = Context.GetLinkDefinitionFromCurrentStep(Value.Id);
68+
if (linkExecution == null || link == null) return;
69+
var act = WorkflowLinkActionFactory.Build(link.ActionType);
70+
await act.Execute(link, linkExecution, Context);
71+
}
5672
}
5773
}

formbuilder/FormBuilder/Components/FormElements/Anchor/FormAnchorDialog.razor

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,25 @@
1313
<RadzenCheckBox @bind-Value="CopyRecord.ActAsButton" />
1414
<RadzenLabel>Act as a button ?</RadzenLabel>
1515
</div>
16+
<!-- Is static link -->
17+
<div>
18+
<RadzenCheckBox @bind-Value="CopyRecord.IsStaticLink" />
19+
<RadzenLabel>Is static link ?</RadzenLabel>
20+
</div>
21+
@if(CopyRecord.IsStaticLink)
22+
{
23+
24+
<!-- Url -->
25+
<div>
26+
<RadzenLabel Text="URL"></RadzenLabel>
27+
<RadzenTextBox @bind-Value="@CopyRecord.Url"></RadzenTextBox>
28+
</div>
29+
<!-- Open in new tab -->
30+
<div>
31+
<RadzenCheckBox @bind-Value="CopyRecord.OpenInNewTab" />
32+
<RadzenLabel>Open in new tab ?</RadzenLabel>
33+
</div>
34+
}
1635
</RadzenStack>
1736
</RadzenTabsItem>
1837
<RadzenTabsItem Text="Label">
@@ -43,6 +62,9 @@
4362
Record.ActAsButton = CopyRecord.ActAsButton;
4463
Record.Transformations = CopyRecord.Transformations;
4564
Record.Labels = CopyRecord.Labels;
65+
Record.IsStaticLink = CopyRecord.IsStaticLink;
66+
Record.Url = CopyRecord.Url;
67+
Record.OpenInNewTab = CopyRecord.OpenInNewTab;
4668
dialogService.Close();
4769
}
4870
}

formbuilder/FormBuilder/Components/FormElements/Anchor/FormAnchorRecord.cs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,26 @@ namespace FormBuilder.Components.FormElements.Anchor;
66
public class FormAnchorRecord : BaseFormFieldRecord
77
{
88
public override string Type => FormAnchorDefinition.TYPE;
9-
public bool ActAsButton { get; set; } = false;
9+
10+
public bool ActAsButton
11+
{
12+
get; set;
13+
} = false;
14+
15+
public bool IsStaticLink
16+
{
17+
get; set;
18+
} = false;
19+
20+
public string Url
21+
{
22+
get; set;
23+
}
24+
25+
public bool OpenInNewTab
26+
{
27+
get; set;
28+
} = false;
1029

1130
public override void Apply(JsonNode node)
1231
{

0 commit comments

Comments
 (0)