Aspen-Discovery / aspen-discovery

GNU General Public License v2.0
45 stars 60 forks source link

Save button in the administration section should "save in place" #2017

Open kylemhall opened 1 month ago

kylemhall commented 1 month ago

Right now clicking the save icon in the administration causes the entire page to reload, and does not place the browser back on the section that was previously visible. Submitting this form via a javascript POST would avoid this issue entirely. The response (200/4xx) can trigger a temporary message that the changes were saved successfully.

The following jquery is an example of how it could work:

$('#update-settings').on('click', function(e){
    e.preventDefault();
    $.post(url, $('#settings-form').serialize(), function(){
        DisplayMessage( "success", _("Settings updated.") );
    })
    .fail(function() {
        DisplayMessage( "error", _("Settings not updated.") );
    });
});
mdnoble73 commented 1 month ago

This would not account for all of the logic that takes place when the form is submitted and does not display messages that appear from the submittal.

kylemhall commented 1 month ago

Bummer! So on the reload there are differences in the rendered page? I wonder if there is a way to get the browser to jump back to the visible area as an alternative. Something like https://brianshim.com/webtricks/scroll-back-to-form-after-submission-fake-ajax/ might work!

mdnoble73 commented 1 month ago

There is logic in the submit that tells it where to go back to. Every once in awhile that gets off. But fixing that logic is the way to go.