Base solution for your next web application

Activities of "alukaszewski"

I have extended the User Entity using the development guide, to add a new user setting for 'refresh interval' and a new migration is created OK, and the user can get/set this value OK. The Users table is extended OK with new column with default integer value of 300. However, when new users are created how do I set default value there instead of 0 (zero).

I think something in this line is required in the _CreateOrEditModal.cshtml to specify a default value of 300 if no value already set? I'd also wonder how to prevent value enter less than 60?

<input id="EditUser_RefreshInterval" type="text" name="RefreshInterval" class="form-control edited" value="@Model.User.RefreshInterval" maxlength="5">

Also, when new user is created by LDAP authentication - how to ensure default value of 300 is set?

If I create row manually in the database, default value is set to 300 as per the 'default value' attribute of the column - so must be in abp I am missing something?

Thanks,

Andy

I think you have to migrate your solution INTO a new blank 4.1 project, and make your code revisions in 4.1, either that, or review the changed files in 4.1 and make the same modifications in your existing 4.0.

I'm not creating a new Entity, I'm extending the existing User Entity by adding additional property.

If I set a value of 300, this is saved and retrieved fine by the user settings modal and the user edit modal. Here is what I have in my Migration;

public partial class Added_RefreshInterval_To_User : DbMigration
    {
        public override void Up()
        {
            AddColumn("dbo.AbpUsers", "RefreshInterval", c => c.Int(nullable: false, defaultValue: 300));
        }
        
        public override void Down()
        {
            DropColumn("dbo.AbpUsers", "RefreshInterval");
        }
    }

The design of the table for the "RefreshInterval" column added to the database shows as having default value of 300, but a value of 300 is not displayed by new user modal or set when a new user is created by LDAP Auth.

I believe problem is that the LDAP user creation user process and the user create modal need to know what default value to display/use and insert into the table, otherwise it inserts 0 (zero). Does that make sense? It is no use having default value set on database table column design as the creation process is overriding this with 0.

What is "EF" ?

Where do I set a default value in the constructor of a User? Is there an example? I was looking to see how existing code works but I cannot find any existing property which uses an integer and sets a default value.

Do you please have an example of setting a default value for a new integer property in the constructor?

Is it possible to pass additional parameters using ModalManager, such as "myParam" below. I wish to pass an id so that the .js loaded as specified by the scriptURL can access this value.

var _MyCustomModal = new app.ModalManager({
    viewUrl: abp.appPath + 'Mpa/MyCustomModal',
    scriptUrl: abp.appPath + 'Areas/Mpa/Views/Common/Modals/_MyCustomModal.js',
    modalClass: 'MyCustomModal',
    myParam: '16777328'
});

In User.cs I already tried this;

public static User CreateTenantAdminUser(int tenantId, string emailAddress, string password)
        {
            return new User
                   {
                       TenantId = tenantId,
                       UserName = AdminUserName,
                       Name = AdminUserName,
                       Surname = AdminUserName,
                       EmailAddress = emailAddress,
                       Password = new PasswordHasher().HashPassword(password),
                       RefreshInterval = 300
                   };
        }

...but when new user accounts are created by LDAP or by admin user, the RefreshInterval is not set to 300. It is still 0 (zero).

As a temporary workaround in my _CreateOrEditModal.cshtml I have this;

<input id="EditUser_RefreshInterval" type="text" name="RefreshInterval" class="form-control edited" @Html.Raw(Model.User.RefreshInterval < 60 ? "value=\"300\"" : "value=\"" + Model.User.RefreshInterval + "\"") maxlength="5">

It's not ideal.

Ah, good idea thanks.

I had previously not been using the modalManager to show modals, instead including modal html and code on the page or loading from another controller - with that method I could throw a value into a field on the modal before modal.shown and then have the modal execute code based on the value in that field during modal.shown. With modalManager, the modal DOM elements are not available until modal Manager.open but I don't want modal code to execute until I have first established an id value.

Bah, this does not appear to work with modals/modalManager. The parameters passed in the URL are not available when the modal loads. There must be a way to extend modal Manager - I can see an 'Args' I wonder what those are?

I think I solved this, by adding myParams to new modalManager modal;

var _myCustomModal = new app.ModalManager({
        viewUrl: abp.appPath + 'Mpa/Modals/MyCustomModal',
        scriptUrl: abp.appPath + 'Areas/Mpa/Views/Common/Modals/_MyCustomModal.js',
        modalClass: 'MyCustomModal',
        myParams: { "param1": "16777328", "param2": "XX1XX1XX2" }
    });

I added some extra functionality to ModalManager.js;

I include myParams in ModalManager.js _normalizeOptions;

return function (options) {

            _normalizeOptions(options);

            var _$modal = null;
            var _modalId = options.modalId;
            var _modalSelector = '#' + _modalId;
            var _modalObject = null;
            var _myParams = options.myParams;

I then have an extra custom Api call which returns my parameters;

getMyParams: function () {
                    return _myParams
                },

Then in _MyCustomModal.js I can use;

var myParams = _modalManager.getMyParams();
            var myParam1 = myParams.param1;

before I run any other code such as DataTables or AmChart.

Showing 51 to 60 of 65 entries