From ade40eda528e8d5deb3271ac56f24544922973d3 Mon Sep 17 00:00:00 2001 From: Ali Yousefi Date: Tue, 16 Jan 2024 00:29:27 +0330 Subject: [PATCH] fix formitem events --- ...Microservices.UI.TemplateGenerator.Blazor.csproj | 2 +- .../Pages/Events/FormItemEventsList.razor | 13 +++++++++++++ .../Pages/FormItems/AddOrUpdateFormItem.razor | 8 ++++++-- ...oservices.UI.TemplateGenerator.ViewModels.csproj | 2 +- .../FormItems/AddOrUpdateFormItemViewModel.cs | 5 ++++- 5 files changed, 25 insertions(+), 5 deletions(-) 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 74ceed5..3de08cc 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.22 + 0.0.0.23 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/Events/FormItemEventsList.razor b/src/CSharp/Blazor/EasyMicroservices.UI.TemplateGenerator.Blazor/Pages/Events/FormItemEventsList.razor index 0e83de3..7700645 100644 --- a/src/CSharp/Blazor/EasyMicroservices.UI.TemplateGenerator.Blazor/Pages/Events/FormItemEventsList.razor +++ b/src/CSharp/Blazor/EasyMicroservices.UI.TemplateGenerator.Blazor/Pages/Events/FormItemEventsList.razor @@ -64,6 +64,19 @@ } } + public ObservableCollection FormItemEvents + { + get + { + return ViewModel.FormItemEvents; + } + set + { + ViewModel.FormItemEvents = value; + StateHasChanged(); + } + } + AddOrUpdateFormItemEvent AddOrUpdateFormItemEventView; SaveChangeBaseDialog addOrUpdateDialog; DeleteBaseDialog deleteDialog; diff --git a/src/CSharp/Blazor/EasyMicroservices.UI.TemplateGenerator.Blazor/Pages/FormItems/AddOrUpdateFormItem.razor b/src/CSharp/Blazor/EasyMicroservices.UI.TemplateGenerator.Blazor/Pages/FormItems/AddOrUpdateFormItem.razor index 13c7696..1b37279 100644 --- a/src/CSharp/Blazor/EasyMicroservices.UI.TemplateGenerator.Blazor/Pages/FormItems/AddOrUpdateFormItem.razor +++ b/src/CSharp/Blazor/EasyMicroservices.UI.TemplateGenerator.Blazor/Pages/FormItems/AddOrUpdateFormItem.razor @@ -60,7 +60,7 @@ - + @@ -137,11 +137,12 @@ return viewModel; } } + BaseDialog addDialog; BaseDialog deleteDialog; BaseDialog previewDialog; AddOrUpdateFormItem AddOrUpdateFormItemView { get; set; } - + FormItemEventsList formItemEventsList { get; set; } protected override Task OnInitializedAsync() { viewModel.BindPropertyChanged(StateHasChanged); @@ -155,6 +156,7 @@ addDialog.ShowDialog(() => { AddOrUpdateFormItemView.ViewModel.Clear(); + viewModel.FormItemEvents = formItemEventsList.FormItemEvents; AddOrUpdateFormItemView.ViewModel.OnSuccess = (contract) => { viewModel.FormItems.Add(contract); @@ -172,6 +174,8 @@ { AddOrUpdateFormItemView.ViewModel.Clear(); AddOrUpdateFormItemView.ViewModel.UpdateFormItemContract = formItemContract; + if (formItemContract.Events != null) + viewModel.FormItemEvents = formItemEventsList.FormItemEvents = new System.Collections.ObjectModel.ObservableCollection(formItemContract.Events); AddOrUpdateFormItemView.ViewModel.OnSuccess = (item) => { var index = viewModel.FormItems.IndexOf(formItemContract); 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 cb1e007..7c021e1 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.22 + 0.0.0.23 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/FormItems/AddOrUpdateFormItemViewModel.cs b/src/CSharp/Cores/EasyMicroservices.UI.TemplateGenerator.ViewModels/ViewModels/FormItems/AddOrUpdateFormItemViewModel.cs index 932d389..5121fd9 100644 --- a/src/CSharp/Cores/EasyMicroservices.UI.TemplateGenerator.ViewModels/ViewModels/FormItems/AddOrUpdateFormItemViewModel.cs +++ b/src/CSharp/Cores/EasyMicroservices.UI.TemplateGenerator.ViewModels/ViewModels/FormItems/AddOrUpdateFormItemViewModel.cs @@ -62,7 +62,7 @@ public FormItemContract UpdateFormItemContract } public ObservableCollection FormItems { get; set; } = new ObservableCollection(); - public ObservableCollection Events { get; set; } = new ObservableCollection(); + public ObservableCollection FormItemEvents { get; set; } = new ObservableCollection(); public ObservableCollection NoParentFormItems { get; set; } = new ObservableCollection(); public IndexOrderingCollection OrderingFormItems { get; } @@ -149,6 +149,7 @@ FormItemContract GetContract() Title = Title, Items = FormItems, PrimaryFormItemId = SelectedNoParentFormItem?.Id, + Events = FormItemEvents }; } @@ -161,6 +162,7 @@ CreateFormItemRequestContract GetCreateContract() Title = Title, Items = JsonSerializer.Deserialize>(JsonSerializer.Serialize(FormItems)), PrimaryFormItemId = SelectedNoParentFormItem?.Id, + Events = FormItemEvents }; } @@ -174,6 +176,7 @@ UpdateFormItemRequestContract GetUpdateContract() Title = Title, Items = FormItems, PrimaryFormItemId = SelectedNoParentFormItem?.Id, + Events = FormItemEvents }; }