Skip to content

Commit aca2280

Browse files
Brano5PTKu
andauthored
Dialogs implementations (#188)
* WIP - initial Dialogs Implementations * Working on AlertDialogs --------- Co-authored-by: Peter Kurhajec <[email protected]>
1 parent 4831b05 commit aca2280

File tree

9 files changed

+143
-31
lines changed

9 files changed

+143
-31
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using AXSharp.Connector;
2+
using System;
3+
4+
namespace AXSharp.Abstractions.Dialogs.ActionDialog
5+
{
6+
public interface IsDialog : ITwinObject
7+
{
8+
string DialogId { get; set; }
9+
void Initialize(Action dialogAction);
10+
11+
}
12+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
using AXSharp.Abstractions.Dialogs.AlertDialog;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using System.Timers;
6+
7+
namespace AXSharp.Abstractions.Dialogs.AlertDialog
8+
{
9+
public class AlertDialogServiceBase : IAlertDialogService
10+
{
11+
public event EventHandler AlertDialogChanged;
12+
13+
public void AddToast(string type, string title, string message, int time)
14+
{
15+
throw new NotImplementedException();
16+
}
17+
18+
public void AddAlertDialog(string type, string title, string message, int time)
19+
{
20+
throw new NotImplementedException();
21+
}
22+
23+
public void AddAlertDialog(IAlertDialog toast)
24+
{
25+
throw new NotImplementedException();
26+
}
27+
28+
public List<IAlertDialog> GetAlertDialogs()
29+
{
30+
throw new NotImplementedException();
31+
}
32+
33+
public void RemoveAlertDialog(IAlertDialog toast)
34+
{
35+
throw new NotImplementedException();
36+
}
37+
38+
public void RemoveAllAlertDialogs()
39+
{
40+
throw new NotImplementedException();
41+
}
42+
}
43+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System;
2+
3+
namespace AXSharp.Abstractions.Dialogs.AlertDialog
4+
{
5+
public interface IAlertDialog
6+
{
7+
public Guid Id { get; set; }
8+
public string Type { get; set; }
9+
public string Title { get; set; }
10+
public string Message { get; set; }
11+
public DateTimeOffset TimeToBurn { get; set; }
12+
public DateTimeOffset Posted { get; set; }
13+
}
14+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using System;
2+
using System.Collections.Generic;
3+
4+
5+
namespace AXSharp.Abstractions.Dialogs.AlertDialog
6+
{
7+
public interface IAlertDialogService
8+
{
9+
public event EventHandler? AlertDialogChanged;
10+
public void AddAlertDialog(string type, string title, string message, int time);
11+
public void AddAlertDialog(IAlertDialog toast);
12+
public List<IAlertDialog> GetAlertDialogs();
13+
public void RemoveAlertDialog(IAlertDialog toast);
14+
public void RemoveAllAlertDialogs();
15+
}
16+
}

src/AXSharp.blazor/src/AXSharp.Presentation.Blazor.Controls/AXSharp.Presentation.Blazor.Controls.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@
8787
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
8888
</PackageReference>
8989
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="6.0.10" />
90+
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client.Core" Version="7.0.5" />
91+
<PackageReference Include="Microsoft.AspNetCore.SignalR.Core" Version="1.1.0" />
9092
</ItemGroup>
9193

9294
<ItemGroup>

src/AXSharp.blazor/src/AXSharp.Presentation.Blazor.Controls/RenderableContent/RenderableComponentBase.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
using AXSharp.Presentation.Blazor.Interfaces;
1717
using AXSharp.Connector.ValueTypes.Online;
1818
using System.Xml.Linq;
19+
using AXSharp.Abstractions.Dialogs.AlertDialog;
1920

2021
namespace AXSharp.Presentation.Blazor.Controls.RenderableContent
2122
{
@@ -26,6 +27,10 @@ public partial class RenderableComponentBase : ComponentBase, IRenderableCompone
2627
{
2728
[Parameter] public int PollingInterval { get; set; }
2829

30+
[CascadingParameter]
31+
public IAlertDialogService AlertDialogService { get; set; }
32+
33+
2934
///<inheritdoc/>
3035
public virtual void Dispose()
3136
{

src/AXSharp.blazor/src/AXSharp.Presentation.Blazor.Controls/RenderableContent/RenderableContentControl.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
using System.Reflection;
2121
using System.ComponentModel;
2222
using AXSharp.Connector.ValueTypes;
23+
using AXSharp.Abstractions.Dialogs.AlertDialog;
2324

2425
namespace AXSharp.Presentation.Blazor.Controls.RenderableContent
2526
{
@@ -84,6 +85,20 @@ public string Presentation
8485
private Type _groupContainer { get; set; }
8586
public Type MainLayoutType { get; set; }
8687

88+
89+
private IAlertDialogService _alertDialogService;
90+
91+
[Parameter]
92+
public IAlertDialogService AlertDialogService {
93+
get
94+
{
95+
if(_alertDialogService == null)
96+
_alertDialogService = new AlertDialogServiceBase();
97+
return _alertDialogService;
98+
}
99+
set => _alertDialogService = value;
100+
}
101+
87102
private ITwinElement _context { get; set; }
88103
protected override void OnInitialized()
89104
{

src/AXSharp.blazor/src/AXSharp.Presentation.Blazor.Controls/RenderableContent/RenderableContentControl.razor

Lines changed: 34 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
@*This class is view part of RenderableContentControl. It contains UI generation pipeline.*@
22

3-
@*Call rendering method over context object*@
3+
@*Call rendering method over context object*@
4+
<CascadingValue Value="@AlertDialogService">
45
<div name="@_context.Symbol.Replace(".","-")" class="@Class">
56
@RenderComponent(_context)
67
</div>
8+
</CascadingValue>
79

810

911

@@ -24,17 +26,18 @@
2426
var component = ViewLocatorBuilder(twinType, twin, Presentation);
2527
if (component != null)
2628
{
27-
@CreateComplexComponent(twin, component);
29+
@CreateComplexComponent(twin, component)
30+
;
2831
}
2932
else
3033
{
3134
var groupName = String.IsNullOrEmpty(twin.AttributeName) ? twin.GetSymbolTail() : twin.AttributeName;
3235
//otherwise render children and set MainLayout
33-
<GroupContainerAttributeSetter GroupType="_groupContainer" GroupName="@groupName">
34-
<MainLayoutSetter LayoutType="@MainLayoutType" GroupBoxName="@groupName" LayoutClass="@LayoutClass">
35-
@RenderChildren(twin, MainLayoutType)
36-
</MainLayoutSetter>
37-
</GroupContainerAttributeSetter>
36+
<GroupContainerAttributeSetter GroupType="_groupContainer" GroupName="@groupName">
37+
<MainLayoutSetter LayoutType="@MainLayoutType" GroupBoxName="@groupName" LayoutClass="@LayoutClass">
38+
@RenderChildren(twin, MainLayoutType)
39+
</MainLayoutSetter>
40+
</GroupContainerAttributeSetter>
3841
}
3942
};
4043

@@ -62,13 +65,13 @@
6265
@Generator(child, parentLayout)
6366
}
6467
else
65-
{
68+
{
6669
var name = String.IsNullOrEmpty(child.AttributeName) ? child.GetSymbolTail() : child.AttributeName;
6770
//otherwise is value tag or has mainLayout set, add children layout and continue
6871
<ChildrenLayoutPropSetter ChildName="@name"
69-
ChildrenLayout="@parentLayout"
70-
ChildContent="@Generator(child,null)"
71-
Class="@LayoutChildrenClass"/>
72+
ChildrenLayout="@parentLayout"
73+
ChildContent="@Generator(child,null)"
74+
Class="@LayoutChildrenClass" />
7275
}
7376
canEnumerate = enumerator.MoveNext();
7477
}
@@ -79,11 +82,11 @@
7982
var groupContainer = TryLoadGroupTypeFromProperty(child);
8083

8184
<GroupLayoutSetter ParentLayout="@parentLayout"
82-
GroupLayout="@groupLayout"
83-
GroupContainer="@groupContainer"
84-
GroupName="@group.GroupName"
85-
LayoutClass="@LayoutClass">
86-
@RenderGroup(group, groupLayout)
85+
GroupLayout="@groupLayout"
86+
GroupContainer="@groupContainer"
87+
GroupName="@group.GroupName"
88+
LayoutClass="@LayoutClass">
89+
@RenderGroup(group, groupLayout)
8790
</GroupLayoutSetter>
8891

8992
}
@@ -96,27 +99,27 @@
9699
{
97100
foreach (var child in group.GroupElements)
98101
{
99-
102+
100103
//if child is complex, we can again call recursively and generate it's groups
101104
if (child is ITwinObject complex)
102105
{
103106
@Generator(complex, group.GroupLayout)
104107
}
105108
else
106109
{
107-
var name = String.IsNullOrEmpty(child.AttributeName) ? child.GetSymbolTail() : child.AttributeName;
108-
<ChildrenLayoutPropSetter ChildName="@name"
109-
ChildrenLayout="@groupLayout"
110-
ChildContent="@Generator(child, groupLayout)"
111-
Class="@LayoutChildrenClass" />
110+
var name = String.IsNullOrEmpty(child.AttributeName) ? child.GetSymbolTail() : child.AttributeName;
111+
<ChildrenLayoutPropSetter ChildName="@name"
112+
ChildrenLayout="@groupLayout"
113+
ChildContent="@Generator(child, groupLayout)"
114+
Class="@LayoutChildrenClass" />
112115
}
113116
}
114117

115118
};
116-
119+
117120
private RenderFragment Generator(ITwinElement kid, Type layout) => __builder =>
118121
{
119-
122+
120123
if (IsEnumerator(kid))
121124
{
122125
var enumDiscriminatorAttribute = AttributesHandler.GetEnumeratorDiscriminatorAttribute(kid);
@@ -138,23 +141,23 @@
138141
private RenderFragment GenerateComplex(ITwinObject twin, Type layout) => __builder =>
139142
{
140143
Type mainLayout = null;
141-
144+
142145
var component = ViewLocatorBuilder(twin.GetType(), twin, Presentation);
143146
if (component != null)
144147
{
145148
var name = String.IsNullOrEmpty(twin.AttributeName) ? twin.GetSymbolTail() : twin.AttributeName;
146149
<ChildrenLayoutPropSetter ChildName="@name"
147-
ChildrenLayout="layout"
148-
ChildContent="@CreateComplexComponent(twin, component)"
149-
Class="@LayoutChildrenClass" />
150+
ChildrenLayout="layout"
151+
ChildContent="@CreateComplexComponent(twin, component)"
152+
Class="@LayoutChildrenClass" />
150153
}
151154
else
152155
{
153-
if(TryLoadLayoutTypeFromProperty(twin) == null)
156+
if (TryLoadLayoutTypeFromProperty(twin) == null)
154157
{
155158
mainLayout = TryLoadLayoutType(twin);
156159
}
157-
160+
158161
<ArrayBorderSetter IsArray="@CheckForArray(twin)" Name="@twin.GetSymbolTail()">
159162
@if (mainLayout != null)
160163
{
@@ -191,7 +194,7 @@
191194
var enumKidType = kid.GetType()?.BaseType ?? kid.GetType();
192195
var component = ViewEnumLocatorBuilder(enumKidType, presentationType);
193196
@CreateEnumComponent(enumDiscriminatorAttribute, kid, component)
194-
};
197+
};
195198

196199
private RenderFragment GenerateValueTag(ITwinElement element) => __builder =>
197200
{

src/AXSharp.blazor/src/AXSharp.Presentation.Blazor.Controls/RenderableContent/RenderableViewModelComponentBase.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ namespace AXSharp.Presentation.Blazor.Controls.RenderableContent
3030

3131
private TwinContainerObject _twinContainer;
3232

33+
34+
3335
[Parameter]
3436
public TwinContainerObject TwinContainer
3537
{

0 commit comments

Comments
 (0)