Base solution for your next web application
Open Closed

Dynamic Entity Property Values on Create Edit Modal #10047


User avatar
0
williepieterse created
  • What is your product version? 10.1
  • What is your product type (Angular or MVC)? MVC
  • What is product framework type (.net framework or .net core)? .net core

Will it possible to add the Dynamic Entity Property Values to your CeateEditModal in a tab layout? Let the tab only be visible if there are any Dynamic Properties configured for the entity and also the appropriate permissions set.

I know you would require to perform await CurrentUnitOfWork.SaveChangesAsync(); in order to return the entityID on the create method in the appservice in order to save any Dynamic Entity Property Values post the initial entity save in js.

I looked at the ManageDynamicEntityPropertyValuesModal js & chtml but can’t see how that would be possible to display before the related entity exists.

Please feel free to discourage me from attempting this … 😊 If this is not possble how would I disable tie Dynamic Values button if there are no dynamic propertie configured for the entity?


2 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @williepieterse,

    Yes, you can also use such a design in your Modals. You can add a tab and add a similar content to _ManageDynamicEntityPropertyValuesModal.cshtml into this new tab. Then, you can initialize dynamic properties as we do in ManageDynamicEntityPropertyValuesModal.js.

    If you want to hide DynamicProperties action button in the data grid, you can return a boolean value in UserController's Index action and use it on the client side. You can use IDynamicEntityPropertyManager to get count of dynamic properties for an Entity.

  • User Avatar
    0
    williepieterse created

    Thanks, I manged to implement this successfully, I had to add a new function to manage-dynamic-entity-property-values-modal-min.js

    function savefor(entityId) {...

    This allowed me to pass the EntityId for a newly Created entity. And also does not set the Busy and Succes Message otherwize it would dispay twice.

    this.save = function () {
                if (!_$employeeInformationForm.valid()) {
                    return;
                }
                var employee = _$employeeInformationForm.serializeFormToObject();
                _modalManager.setBusy(true);
                _employeesService.createOrEdit(
                    employee
                ).done(function (Id) {
                    //Save DynamicEntityPropertyValue after receiving ID from createOrEdit
                    _manageDynamicEntityPropertyValueBase.savefor(Id);
    
                    abp.notify.info(app.localize('SavedSuccessfully'));
                    _modalManager.close();
                    abp.event.trigger('app.createOrEditEmployeeModalSaved');
                }).always(function () {
                    _modalManager.setBusy(false);
                });
            };