Skip to content

Commit

Permalink
fix formitem events
Browse files Browse the repository at this point in the history
  • Loading branch information
Ali-YousefiTelori committed Jan 15, 2024
1 parent 2f25a1b commit ade40ed
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<Authors>EasyMicroservices</Authors>
<IsPackable>true</IsPackable>
<Version>0.0.0.22</Version>
<Version>0.0.0.23</Version>
<Description>TemplateGenerator UI compoents.</Description>
<Copyright>[email protected]</Copyright>
<PackageTags>component,microcomponent,ui,core,templategenerator,generator,template,form,formgenerator</PackageTags>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,19 @@
}
}

public ObservableCollection<FormItemEventContract> FormItemEvents
{
get
{
return ViewModel.FormItemEvents;
}
set
{
ViewModel.FormItemEvents = value;
StateHasChanged();
}
}

AddOrUpdateFormItemEvent AddOrUpdateFormItemEventView;
SaveChangeBaseDialog<FormItemEventContract> addOrUpdateDialog;
DeleteBaseDialog<FormItemEventContract> deleteDialog;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
</MudDataGrid>
</MudTabPanel>
<MudTabPanel Text="@viewModel.GetInnerTranslatedByKey("Events")">
<FormItemEventsList />
<FormItemEventsList @ref="formItemEventsList" />
</MudTabPanel>
</MudTabs>
<MudButton Variant="Variant.Filled" StartIcon="@Icons.Material.Filled.Save" Color="Color.Info" Disabled="viewModel.IsBusy" OnClick="(arg) => viewModel.SaveCommand.Execute(null)">
Expand Down Expand Up @@ -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);
Expand All @@ -155,6 +156,7 @@
addDialog.ShowDialog(() =>
{
AddOrUpdateFormItemView.ViewModel.Clear();
viewModel.FormItemEvents = formItemEventsList.FormItemEvents;
AddOrUpdateFormItemView.ViewModel.OnSuccess = (contract) =>
{
viewModel.FormItems.Add(contract);
Expand All @@ -172,6 +174,8 @@
{
AddOrUpdateFormItemView.ViewModel.Clear();
AddOrUpdateFormItemView.ViewModel.UpdateFormItemContract = formItemContract;
if (formItemContract.Events != null)
viewModel.FormItemEvents = formItemEventsList.FormItemEvents = new System.Collections.ObjectModel.ObservableCollection<FormItemEventContract>(formItemContract.Events);
AddOrUpdateFormItemView.ViewModel.OnSuccess = (item) =>
{
var index = viewModel.FormItems.IndexOf(formItemContract);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<Authors>EasyMicroservices</Authors>
<IsPackable>true</IsPackable>
<Version>0.0.0.22</Version>
<Version>0.0.0.23</Version>
<Description>TemplateGenerator view model.</Description>
<Copyright>[email protected]</Copyright>
<PackageTags>component,microcomponent,ui,core,templategenerator,generator,template,form,formgenerator</PackageTags>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public FormItemContract UpdateFormItemContract
}

public ObservableCollection<FormItemContract> FormItems { get; set; } = new ObservableCollection<FormItemContract>();
public ObservableCollection<EventContract> Events { get; set; } = new ObservableCollection<EventContract>();
public ObservableCollection<FormItemEventContract> FormItemEvents { get; set; } = new ObservableCollection<FormItemEventContract>();
public ObservableCollection<FormItemContract> NoParentFormItems { get; set; } = new ObservableCollection<FormItemContract>();

public IndexOrderingCollection<FormItemContract> OrderingFormItems { get; }
Expand Down Expand Up @@ -149,6 +149,7 @@ FormItemContract GetContract()
Title = Title,
Items = FormItems,
PrimaryFormItemId = SelectedNoParentFormItem?.Id,
Events = FormItemEvents
};
}

Expand All @@ -161,6 +162,7 @@ CreateFormItemRequestContract GetCreateContract()
Title = Title,
Items = JsonSerializer.Deserialize<List<CreateFormItemContract>>(JsonSerializer.Serialize(FormItems)),
PrimaryFormItemId = SelectedNoParentFormItem?.Id,
Events = FormItemEvents
};
}

Expand All @@ -174,6 +176,7 @@ UpdateFormItemRequestContract GetUpdateContract()
Title = Title,
Items = FormItems,
PrimaryFormItemId = SelectedNoParentFormItem?.Id,
Events = FormItemEvents
};
}

Expand Down

0 comments on commit ade40ed

Please sign in to comment.