Why can't I save my user preferences here?



  • Bug: After editing things in my user preferences, the Save Changes button is disabled, the mouse cursor turns to a red circle-with-slash icon on hover.

    Expected: If the form auto-saves, there should be no Save Changes button. Or if the form does not auto-save, the button should be clickable.

    I took a screen capture however it didn't grab the mouse cursor and it's not obvious from the styling that the Save Changes button is disabled, so I won't post the image.



  • @mott555 said:

    Bug: After editing things in my user preferences, the Save Changes button is disabled, the mouse cursor turns to a red circle-with-slash icon on hover.

    Expected: If the form auto-saves, there should be no Save Changes button. Or if the form does not auto-save, the button should be clickable.

    Right bug, wrong reason (if I'm right) - this has been covered elsewhere. As a result of Alex's import the Name field (1st editable one) on your preferences will be blank; it's not allowed to be - this is what's causing the save button to be blank.

    If you have that field filled in then that's a separate problem...



  • @PJH said:

    mott555 said:

    Bug: After editing things in my user preferences, the Save Changes button is disabled, the mouse cursor turns to a red circle-with-slash icon on hover.
    Expected: If the form auto-saves, there should be no Save Changes button. Or if the form does not auto-save, the button should be clickable.

    Right bug, wrong reason (if I'm right) - this has been covered elsewhere. As a result of Alex's import the Name field (1st editable one) on your preferences will be blank; it's not allowed to be - this is what's causing the save button to be blank.

    If you have that field filled in then that's a separate problem...

    Okay, in that case the expected behavior is some kind of validation element on the Name field saying it's required.



  • On the save your pref changes thing, you can save without filling in the name field if you manually enable the save button and click it. Or at least when I did that it saved my changes.



  • Bug: Without name filled in the save button on profile is disabled.

    Profile page on first load:

    After changing a checkbox and editing the save button to manually enable:

    Upon reload of profile page after clicking save button and closing:

    Expected: Save button enabled by default as it functions if manually enabled.

    Solution: Do not disable the button if name is not filled in.


  • Discourse touched me in a no-no place

    It took me ages to realise that this was the problem. A fix would be to make the database query use the username as the name if the name is null or empty.



  • Nah, the fix is this:

    User.where(name: nil).each do |user|
      user.name = user.username
      user.save
    end
    

    It's a one-time fix because unvalidated data was inserted.


  • Discourse touched me in a no-no place

    I'd prefer to do it entirely in SQL:

    <!-- language: SQL -->
    UPDATE user SET name = username WHERE name IS NULL
    

    But then I don't like having to commit each user as I go or extract data just to put it straight back in again. (Anyone got the LINQ to SQL magic for this sort of thing? Just for laughs…)



  • User.exec_sql <<SQL
    UPDATE users
    SET name = username
    WHERE name IS NULL
    ;
    SQL
    

    ^ This is used throughout Discourse when speed is an issue. The above would be put into an interactive prompt, where speed is.. not an issue.

    (Of course, the main bottleneck is the JS rendering...)



  • foreach (User user in dataContext.Users)
    {
    user.Name = user.Username;
    }
    dataContext.SubmitChanges();



  • @mott555 said:

    foreach (User user in dataContext.Users) {     user.Name = user.Username;  }  dataContext.SubmitChanges();

    BZZT. Failure to verify that the Name is not already set. You lose! You get nothing! Good DAY to you, sir. *slams door*



  • One of my main developers could have done it in 5 minutes, but that was too expensive. So instead we hired a team of offshore developers lead by Nagesh and paid them $20,000 to develop it over a period of 6 weeks.


  • Banned

    @mott555 said:

    foreach (User user in dataContext.Users){ user.Name = user.Username;}dataContext.SubmitChanges();

    Status completed

    irb(main):003:0> User.exec_sql('update users set name = username where name is null')
    => #<PG::Result:0x007fcb618c6ea8 @connection=#<PG::Connection:0x007fcb5e7cb880>>
    irb(main):004:0> User.exec_sql('update users set name = username where name = \'\'')
    => #<PG::Result:0x007fcb618d7190 @connection=#<PG::Connection:0x007fcb5e7cb880>>
    

    FYI 506 users were fixed cc @apapadimoulis



  • Wow thanks @sam!!


  • Banned

    I believe @neil added a related fix too as this affects all Single Sign On sites.

    This topic is now closed. New replies are no longer allowed.


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.