Open Closed

Payment Module Plan ViewModel where are the 3 x Count Fields comming from #2713


User avatar
0
learnabp created

Today i am playing around with the Payment Module and i see that there are 3 x Count field in thePlan entity

can you please explain what they are for and where they come from please


11 Answer(s)
  • User Avatar
    0
    learnabp created

    I think this is a bug because the ViewModel is and ExtensibleObject the ExtraProperties Count is being rendered

    how can we fix this??

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    What version are you using and can you share the steps to reproduce?

  • User Avatar
    0
    learnabp created

    I am using 5.1.4 commercial version Download the payment module and check the plan createmodal under the admin folder. It uses a dynamic form with the view model which has extra properties when null produces 3 count fields.

  • User Avatar
    0
    EngincanV created
    Support Team .NET Developer

    Hi @learnabp, I will test it and write you back asap. Did you add any extra properties to your Plan entity?

  • User Avatar
    0
    learnabp created

    No I didn’t have any extra properties

  • User Avatar
    0
    EngincanV created
    Support Team .NET Developer

    No I didn’t have any extra properties

    Thanks, I will test and inform you asap.

  • User Avatar
    0
    EngincanV created
    Support Team .NET Developer

    I've tested just before and there is a problem indeed. Thanks for reporting the problem, it'll be fixed in the next release. FYI @learnabp

  • User Avatar
    0
    learnabp created

    Hi I would like to know how you fix it … can you give me the issue number or the commit which this is fixed in so I can learn my self please I think it will be in dynamic taghelperservice ?

  • User Avatar
    0
    EngincanV created
    Support Team .NET Developer

    Hi @learnabp, as you've mentioned problem was related with dynamic-form creating 3 form-group for ExtraProperties. To be able to solve this problem, we've changed it as a form tag.

    You can override the CreateModal and UpdateModal razor pages for Plan as below to fix this problem:

    • CreateModal.cs(Pages/Payment/Plans/CreateModal.cshtml)
    @page
    
    @using Microsoft.Extensions.Localization
    @using Volo.Abp.Data
    @using Volo.Payment.Admin.Web.Pages.Payment.Plans
    @using Volo.Payment.Admin.Web.Pages
    @using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Modal
    @using Volo.Abp.Localization
    @using Volo.Abp.ObjectExtending
    @inherits PaymentAdminPageBase
    @model CreateModalModel
    @inject IStringLocalizerFactory StringLocalizerFactory
    
    @{
        Layout = null;
    }
    
    <form asp-page="/Payment/Plans/CreateModal">
        <abp-modal>
            <abp-modal-header title="@L["NewPlan"].Value"></abp-modal-header>
            <abp-modal-body>
                <abp-input asp-for="ViewModel.Name" />
    
                @foreach (var propertyInfo in ObjectExtensionManager.Instance.GetProperties<CreateModalModel.PlanCreateViewModel>())
                {
                    if (!propertyInfo.Name.EndsWith("_Text"))
                    {
                        if (propertyInfo.Type.IsEnum || !propertyInfo.Lookup.Url.IsNullOrEmpty())
                        {
                            if (propertyInfo.Type.IsEnum)
                            {
                                Model.ViewModel.ExtraProperties.ToEnum(propertyInfo.Name, propertyInfo.Type);
                            }
    
                            <abp-select asp-for="ViewModel.ExtraProperties[propertyInfo.Name]"
                                        label="@propertyInfo.GetLocalizedDisplayName(StringLocalizerFactory)"
                                        autocomplete-api-url="@propertyInfo.Lookup.Url"
                                        autocomplete-selected-item-name="@Model.ViewModel.GetProperty(propertyInfo.Name + "_Text")"
                                        autocomplete-selected-item-value="@Model.ViewModel.GetProperty(propertyInfo.Name)"
                                        autocomplete-filter-param-name="@propertyInfo.Lookup.FilterParamName"
                                        autocomplete-items-property-name="@propertyInfo.Lookup.ResultListPropertyName"
                                        autocomplete-display-property-name="@propertyInfo.Lookup.DisplayPropertyName"
                                        autocomplete-value-property-name="@propertyInfo.Lookup.ValuePropertyName">
                            </abp-select>
                        }
                        else
                        {
                            <abp-input type="@propertyInfo.GetInputType()"
                                       asp-for="ViewModel.ExtraProperties[propertyInfo.Name]"
                                       label="@propertyInfo.GetLocalizedDisplayName(StringLocalizerFactory)"
                                       asp-format="@propertyInfo.GetInputFormatOrNull()"
                                       value="@propertyInfo.GetInputValueOrNull(Model.ViewModel.GetProperty(propertyInfo.Name))"/>
                        }
                    }
                }
            </abp-modal-body>
            <abp-modal-footer buttons="@(AbpModalButtons.Cancel | AbpModalButtons.Save)"></abp-modal-footer>
        </abp-modal>
    </form>
    
    • UpdateModal.cshtml (Pages/Payment/Plans/UpdateModal.cshtml)
    @page
    
    @using Microsoft.Extensions.Localization
    @using Volo.Abp.Data
    @using Volo.Payment.Admin.Web.Pages.Payment.Plans
    @using Volo.Payment.Admin.Web.Pages
    @using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Modal
    @using Volo.Abp.Localization
    @using Volo.Abp.ObjectExtending
    @inherits PaymentAdminPageBase
    @model UpdateModalModel
    @inject IStringLocalizerFactory StringLocalizerFactory
    
    @{
        Layout = null;
    }
    
    <form asp-page="/Payment/Plans/UpdateModal">
        <abp-modal>
            <abp-modal-header title="@L["Edit"].Value"></abp-modal-header>
            <abp-modal-body>
                <abp-input asp-for="Id"/>
                <abp-input asp-for="ViewModel.Name" />
                <abp-input asp-for="ViewModel.ConcurrencyStamp" />
    
                @foreach (var propertyInfo in ObjectExtensionManager.Instance.GetProperties<UpdateModalModel.PlanUpdateViewModel>())
                {
                    if (!propertyInfo.Name.EndsWith("_Text"))
                    {
                        if (propertyInfo.Type.IsEnum || !propertyInfo.Lookup.Url.IsNullOrEmpty())
                        {
                            if (propertyInfo.Type.IsEnum)
                            {
                                Model.ViewModel.ExtraProperties.ToEnum(propertyInfo.Name, propertyInfo.Type);
                            }
    
                            <abp-select asp-for="ViewModel.ExtraProperties[propertyInfo.Name]"
                                        label="@propertyInfo.GetLocalizedDisplayName(StringLocalizerFactory)"
                                        autocomplete-api-url="@propertyInfo.Lookup.Url"
                                        autocomplete-selected-item-name="@Model.ViewModel.GetProperty(propertyInfo.Name + "_Text")"
                                        autocomplete-selected-item-value="@Model.ViewModel.GetProperty(propertyInfo.Name)"
                                        autocomplete-filter-param-name="@propertyInfo.Lookup.FilterParamName"
                                        autocomplete-items-property-name="@propertyInfo.Lookup.ResultListPropertyName"
                                        autocomplete-display-property-name="@propertyInfo.Lookup.DisplayPropertyName"
                                        autocomplete-value-property-name="@propertyInfo.Lookup.ValuePropertyName">
                            </abp-select>
                        }
                        else
                        {
                            <abp-input type="@propertyInfo.GetInputType()"
                                       asp-for="ViewModel.ExtraProperties[propertyInfo.Name]"
                                       label="@propertyInfo.GetLocalizedDisplayName(StringLocalizerFactory)"
                                       asp-format="@propertyInfo.GetInputFormatOrNull()"
                                       value="@propertyInfo.GetInputValueOrNull(Model.ViewModel.GetProperty(propertyInfo.Name))"/>
                        }
                    }
                }
            </abp-modal-body>
            <abp-modal-footer buttons="@(AbpModalButtons.Cancel | AbpModalButtons.Save)"></abp-modal-footer>
        </abp-modal>
    </form>
    
  • User Avatar
    0
    learnabp created

    So you mean you are not using the dynamic form tag anymore ?

  • User Avatar
    0
    EngincanV created
    Support Team .NET Developer

    So you mean you are not using the dynamic form tag anymore ?

    Yes, if the model has ExtraProperties property then dynamic-form try to create inputs for this property and therefore it duplicates input tags.

    The problem will be fixed in the next release, you can either wait for the next release and upgrade or try to override the CreateModal and UpdateModal as mentioned above comment.

Made with ❤️ on ABP v9.1.0-preview. Updated on December 10, 2024, 06:38