diff --git a/src/CSharp/Blazor/EasyMicroservices.UI.TemplateGenerator.Blazor/EasyMicroservices.UI.TemplateGenerator.Blazor.csproj b/src/CSharp/Blazor/EasyMicroservices.UI.TemplateGenerator.Blazor/EasyMicroservices.UI.TemplateGenerator.Blazor.csproj index 3abcc23..976a657 100644 --- a/src/CSharp/Blazor/EasyMicroservices.UI.TemplateGenerator.Blazor/EasyMicroservices.UI.TemplateGenerator.Blazor.csproj +++ b/src/CSharp/Blazor/EasyMicroservices.UI.TemplateGenerator.Blazor/EasyMicroservices.UI.TemplateGenerator.Blazor.csproj @@ -4,7 +4,7 @@ net6.0;net7.0;net8.0 EasyMicroservices true - 0.0.0.34 + 0.0.0.35 TemplateGenerator UI compoents. EasyMicroservices@gmail.com component,microcomponent,ui,core,templategenerator,generator,template,form,formgenerator diff --git a/src/CSharp/Blazor/EasyMicroservices.UI.TemplateGenerator.Blazor/Pages/Generators/Components/CardFormItem.razor b/src/CSharp/Blazor/EasyMicroservices.UI.TemplateGenerator.Blazor/Pages/Generators/Components/CardFormItem.razor index 9a04acf..8b0682b 100644 --- a/src/CSharp/Blazor/EasyMicroservices.UI.TemplateGenerator.Blazor/Pages/Generators/Components/CardFormItem.razor +++ b/src/CSharp/Blazor/EasyMicroservices.UI.TemplateGenerator.Blazor/Pages/Generators/Components/CardFormItem.razor @@ -9,7 +9,7 @@ @implements IParentComponent - + @code { @@ -34,6 +34,9 @@ protected override void OnAfterRender(bool firstRender) { base.OnAfterRender(firstRender); + if (Parent != null && viewModel.FormItem != null) + ComponentPool.SetParent(Parent, this, viewModel.FormItem); + if (viewModel.FormItem != null && Control != null) { Control.Parent = this; diff --git a/src/CSharp/Blazor/EasyMicroservices.UI.TemplateGenerator.Blazor/Pages/Generators/Components/HorizontalStackFormItem.razor b/src/CSharp/Blazor/EasyMicroservices.UI.TemplateGenerator.Blazor/Pages/Generators/Components/HorizontalStackFormItem.razor index 5fb4f0c..b6c80c1 100644 --- a/src/CSharp/Blazor/EasyMicroservices.UI.TemplateGenerator.Blazor/Pages/Generators/Components/HorizontalStackFormItem.razor +++ b/src/CSharp/Blazor/EasyMicroservices.UI.TemplateGenerator.Blazor/Pages/Generators/Components/HorizontalStackFormItem.razor @@ -43,7 +43,10 @@ protected override void OnAfterRender(bool firstRender) { base.OnAfterRender(firstRender); - if (Controls.All(x => ((FormItemSingleItemGenerator)x).ViewModel.FormItem != null)) + if (Parent != null && viewModel.FormItem != null) + ComponentPool.SetParent(Parent, this, viewModel.FormItem); + + if (Controls.All(x => ((FormItemSingleItemGenerator)x).ViewModel.FormItem != null) && Controls.Count == viewModel.FormItem?.Items?.Count) { foreach (var item in Controls) { diff --git a/src/CSharp/Blazor/EasyMicroservices.UI.TemplateGenerator.Blazor/Pages/Generators/Components/NavMenuFormItem.razor b/src/CSharp/Blazor/EasyMicroservices.UI.TemplateGenerator.Blazor/Pages/Generators/Components/NavMenuFormItem.razor index 7b51c63..011d610 100644 --- a/src/CSharp/Blazor/EasyMicroservices.UI.TemplateGenerator.Blazor/Pages/Generators/Components/NavMenuFormItem.razor +++ b/src/CSharp/Blazor/EasyMicroservices.UI.TemplateGenerator.Blazor/Pages/Generators/Components/NavMenuFormItem.razor @@ -43,7 +43,10 @@ protected override void OnAfterRender(bool firstRender) { base.OnAfterRender(firstRender); - if (Controls.All(x => ((FormItemSingleItemGenerator)x).ViewModel.FormItem != null)) + if (Parent != null && viewModel.FormItem != null) + ComponentPool.SetParent(Parent, this, viewModel.FormItem); + + if (Controls.All(x => ((FormItemSingleItemGenerator)x).ViewModel.FormItem != null) && Controls.Count == viewModel.FormItem?.Items?.Count) { foreach (var item in Controls) { diff --git a/src/CSharp/Blazor/EasyMicroservices.UI.TemplateGenerator.Blazor/Pages/Generators/Components/NavMenuGroupFormItem.razor b/src/CSharp/Blazor/EasyMicroservices.UI.TemplateGenerator.Blazor/Pages/Generators/Components/NavMenuGroupFormItem.razor index cbb5c71..4938161 100644 --- a/src/CSharp/Blazor/EasyMicroservices.UI.TemplateGenerator.Blazor/Pages/Generators/Components/NavMenuGroupFormItem.razor +++ b/src/CSharp/Blazor/EasyMicroservices.UI.TemplateGenerator.Blazor/Pages/Generators/Components/NavMenuGroupFormItem.razor @@ -43,7 +43,10 @@ protected override void OnAfterRender(bool firstRender) { base.OnAfterRender(firstRender); - if (Controls.All(x => ((FormItemSingleItemGenerator)x).ViewModel.FormItem != null)) + if (Parent != null && viewModel.FormItem != null) + ComponentPool.SetParent(Parent, this, viewModel.FormItem); + + if (Controls.All(x => ((FormItemSingleItemGenerator)x).ViewModel.FormItem != null) && Controls.Count == viewModel.FormItem?.Items?.Count) { foreach (var item in Controls) { diff --git a/src/CSharp/Blazor/EasyMicroservices.UI.TemplateGenerator.Blazor/Pages/Generators/Components/NavMenuLinkFormItem.razor b/src/CSharp/Blazor/EasyMicroservices.UI.TemplateGenerator.Blazor/Pages/Generators/Components/NavMenuLinkFormItem.razor index 610a4fc..b4a7ddd 100644 --- a/src/CSharp/Blazor/EasyMicroservices.UI.TemplateGenerator.Blazor/Pages/Generators/Components/NavMenuLinkFormItem.razor +++ b/src/CSharp/Blazor/EasyMicroservices.UI.TemplateGenerator.Blazor/Pages/Generators/Components/NavMenuLinkFormItem.razor @@ -40,7 +40,10 @@ protected override void OnAfterRender(bool firstRender) { base.OnAfterRender(firstRender); - if (Controls.All(x => ((FormItemSingleItemGenerator)x).ViewModel.FormItem != null)) + if (Parent != null && viewModel.FormItem != null) + ComponentPool.SetParent(Parent, this, viewModel.FormItem); + + if (Controls.All(x => ((FormItemSingleItemGenerator)x).ViewModel.FormItem != null) && Controls.Count == viewModel.FormItem?.Items?.Count) { foreach (var item in Controls) { diff --git a/src/CSharp/Blazor/EasyMicroservices.UI.TemplateGenerator.Blazor/Pages/Generators/Components/VerticalStackFormItem.razor b/src/CSharp/Blazor/EasyMicroservices.UI.TemplateGenerator.Blazor/Pages/Generators/Components/VerticalStackFormItem.razor index 6125be3..cbcc498 100644 --- a/src/CSharp/Blazor/EasyMicroservices.UI.TemplateGenerator.Blazor/Pages/Generators/Components/VerticalStackFormItem.razor +++ b/src/CSharp/Blazor/EasyMicroservices.UI.TemplateGenerator.Blazor/Pages/Generators/Components/VerticalStackFormItem.razor @@ -12,7 +12,7 @@ @foreach (var formItem in viewModel.FormItem?.Items?.OrderBy(x => x.Index)) { - + } @@ -39,7 +39,10 @@ protected override void OnAfterRender(bool firstRender) { base.OnAfterRender(firstRender); - if (Controls.All(x => ((FormItemSingleItemGenerator)x).ViewModel.FormItem != null)) + if (Parent != null && viewModel.FormItem != null) + ComponentPool.SetParent(Parent, this, viewModel.FormItem); + + if (Controls.All(x => ((FormItemSingleItemGenerator)x).ViewModel.FormItem != null) && Controls.Count == viewModel.FormItem?.Items?.Count) { foreach (var item in Controls) { @@ -50,7 +53,7 @@ } List Controls = new List(); - public IParentComponent Control + public IParentComponent ChildControl { set { diff --git a/src/CSharp/Blazor/EasyMicroservices.UI.TemplateGenerator.Blazor/Pages/Generators/FormItemListGenerator.razor b/src/CSharp/Blazor/EasyMicroservices.UI.TemplateGenerator.Blazor/Pages/Generators/FormItemListGenerator.razor index c057c37..3942536 100644 --- a/src/CSharp/Blazor/EasyMicroservices.UI.TemplateGenerator.Blazor/Pages/Generators/FormItemListGenerator.razor +++ b/src/CSharp/Blazor/EasyMicroservices.UI.TemplateGenerator.Blazor/Pages/Generators/FormItemListGenerator.razor @@ -35,10 +35,24 @@ } } + [Parameter] + [Category("Behavior")] + public FormItemContract FormItem + { + set + { + viewModel.FormItem = value; + _ = viewModel.InitializeFormItems(value.Items); + } + } + protected override void OnAfterRender(bool firstRender) { base.OnAfterRender(firstRender); - if (Controls.All(x => ((FormItemSingleItemGenerator)x).ViewModel.FormItem != null)) + if (Parent != null && viewModel.FormItem != null) + ComponentPool.SetParent(Parent, this, viewModel.FormItem); + + if (Controls.Count == viewModel.FormItems.Count) { foreach (var item in Controls) { diff --git a/src/CSharp/Cores/EasyMicroservices.UI.TemplateGenerator.ProcessExecutor/EasyMicroservices.UI.TemplateGenerator.ProcessExecutor.csproj b/src/CSharp/Cores/EasyMicroservices.UI.TemplateGenerator.ProcessExecutor/EasyMicroservices.UI.TemplateGenerator.ProcessExecutor.csproj index 69a05f5..2351592 100644 --- a/src/CSharp/Cores/EasyMicroservices.UI.TemplateGenerator.ProcessExecutor/EasyMicroservices.UI.TemplateGenerator.ProcessExecutor.csproj +++ b/src/CSharp/Cores/EasyMicroservices.UI.TemplateGenerator.ProcessExecutor/EasyMicroservices.UI.TemplateGenerator.ProcessExecutor.csproj @@ -4,7 +4,7 @@ net6.0;net7.0;net8.0 EasyMicroservices true - 0.0.0.34 + 0.0.0.35 TemplateGenerator process maker core EasyMicroservices@gmail.com component,microcomponent,ui,core,templategenerator,generator,template,form,formgenerator diff --git a/src/CSharp/Cores/EasyMicroservices.UI.TemplateGenerator.ProcessExecutor/Helpers/TreeComponentHelper.cs b/src/CSharp/Cores/EasyMicroservices.UI.TemplateGenerator.ProcessExecutor/Helpers/TreeComponentHelper.cs index 9636b02..1e127cd 100644 --- a/src/CSharp/Cores/EasyMicroservices.UI.TemplateGenerator.ProcessExecutor/Helpers/TreeComponentHelper.cs +++ b/src/CSharp/Cores/EasyMicroservices.UI.TemplateGenerator.ProcessExecutor/Helpers/TreeComponentHelper.cs @@ -16,6 +16,20 @@ public ICollection GetAllComponents(IComponent component) return items; } + public IComponent FindByInstance(object instance) + { + if (Root == null) + return null; + return GetAllComponents(Root).FirstOrDefault(x => x.ControlInstance == instance); + } + + public IComponent FindByValueInstance(object instance) + { + if (Root == null) + return null; + return GetAllComponents(Root).FirstOrDefault(x => x.ValueInstance == instance); + } + public IComponent GetRoot(IComponent component) { IComponent current = component; diff --git a/src/CSharp/Cores/EasyMicroservices.UI.TemplateGenerator.ProcessExecutor/Interfaces/IComponent.cs b/src/CSharp/Cores/EasyMicroservices.UI.TemplateGenerator.ProcessExecutor/Interfaces/IComponent.cs index 7629308..48decc4 100644 --- a/src/CSharp/Cores/EasyMicroservices.UI.TemplateGenerator.ProcessExecutor/Interfaces/IComponent.cs +++ b/src/CSharp/Cores/EasyMicroservices.UI.TemplateGenerator.ProcessExecutor/Interfaces/IComponent.cs @@ -2,7 +2,11 @@ public interface IComponent { string LocalVariableName { get; } + object ControlInstance { get; set; } + object ValueInstance { get; set; } IComponent Parent { get; set; } ICollection Children { get; } void AddChild(IComponent component); + void AddChildren(IEnumerable components); + void RemoveChild(IComponent component); } diff --git a/src/CSharp/Cores/EasyMicroservices.UI.TemplateGenerator.ViewModels/EasyMicroservices.UI.TemplateGenerator.ViewModels.csproj b/src/CSharp/Cores/EasyMicroservices.UI.TemplateGenerator.ViewModels/EasyMicroservices.UI.TemplateGenerator.ViewModels.csproj index 02f88f9..c415ddf 100644 --- a/src/CSharp/Cores/EasyMicroservices.UI.TemplateGenerator.ViewModels/EasyMicroservices.UI.TemplateGenerator.ViewModels.csproj +++ b/src/CSharp/Cores/EasyMicroservices.UI.TemplateGenerator.ViewModels/EasyMicroservices.UI.TemplateGenerator.ViewModels.csproj @@ -4,7 +4,7 @@ net6.0;net7.0;net8.0 EasyMicroservices true - 0.0.0.34 + 0.0.0.35 TemplateGenerator view model. EasyMicroservices@gmail.com component,microcomponent,ui,core,templategenerator,generator,template,form,formgenerator diff --git a/src/CSharp/Cores/EasyMicroservices.UI.TemplateGenerator.ViewModels/ViewModels/Generators/FormItemListGeneratorViewModel.cs b/src/CSharp/Cores/EasyMicroservices.UI.TemplateGenerator.ViewModels/ViewModels/Generators/FormItemListGeneratorViewModel.cs index 6982605..1d8953a 100644 --- a/src/CSharp/Cores/EasyMicroservices.UI.TemplateGenerator.ViewModels/ViewModels/Generators/FormItemListGeneratorViewModel.cs +++ b/src/CSharp/Cores/EasyMicroservices.UI.TemplateGenerator.ViewModels/ViewModels/Generators/FormItemListGeneratorViewModel.cs @@ -3,7 +3,7 @@ using TemplateGenerators.GeneratedServices; namespace EasyMicroservices.UI.TemplateGenerator.ViewModels.Generators; -public class FormItemListGeneratorViewModel : BaseViewModel +public class FormItemListGeneratorViewModel : BaseGeneratorViewModel { public FormItemListGeneratorViewModel() {