ElkArte Community

Elk Development => Feature Discussion => Topic started by: emanuele on November 13, 2014, 06:05:35 pm

Title: Admin panel and errors
Post by: emanuele on November 13, 2014, 06:05:35 pm
At the moment almost any time you do a mistake on the admin panel, you get a fatal_lang_error and are sent back to the page. Then the page is refreshed, because with the new tokens it cannot be submitted twice and the values you entered are obliterated.

This is indeed a pain.

What I would like to see in 1.1 is a major improvement in that area.
I see two ways of "fixing" this.

The first is the one I applied to my topic prefixes addon:
https://github.com/emanuele45/TopicPrefix/blob/master/ManagePrefix.controller.php#L60
https://github.com/emanuele45/TopicPrefix/blob/master/ManagePrefix.controller.php#L101
if the "save" action fails, the new settings are stored in the session and loaded when the page is refreshed.
This has a huge drawback: is something goes "out of sync" (i.e. for any reason the session is not cleared) you may end up with unwanted settings in the page.

The second is more in line with the times and is: on saving, instead of submitting the form, send an AJAX request, wait for the result, and if the result is "green light" refresh the page and "happy saved" (actually the data were already saved on the AJAX request), while if the save failed, update the tokens and highlight the errors.
The drawback of this one is... well, it requires javascript to work "properly", and may require some adjustments to the template (namely each setting has to have an id attached to the input or to the area that should be highlighted with the error), though it avoids any problem that may arise with using $_SESSION.

I personally lean towards the second option, even though it may require some more work.

What do you think?
Title: Re: Admin panel and errors
Post by: Jorin on November 14, 2014, 01:11:27 am
Me too (the second one). That's the behaviour we know from any forms on the net. But what will happen when Javascript isn't active? This is a problem on tablets, or am I wrong?
Title: Re: Admin panel and errors
Post by: emanuele on November 14, 2014, 03:26:35 am
I doubt tablets do not handle javascript, in the web of today they (the tablets) would be useless if this was true.
Title: Re: Admin panel and errors
Post by: Jorin on November 14, 2014, 03:37:02 am
Okay, I am only using this devices and trust you completely on this. No problem for me then, go ahead. ;)
Title: Re: Admin panel and errors
Post by: IchBin on November 14, 2014, 04:40:00 pm
I prefer to move up with the times. :)