Showing a Loading Image During Entity Creation
When a user is entering some information into Entity attributes, it is entirely possible that one of those entity attributes may take its information from a Search extension. For example, you are entering instances of the Person entity and each Person has a location, so you want to select the location using a Search extension.
The Search, given that it is perhaps an Ajax call, could take some time. So you want to signal to the user that there is nothing to worry about, but they need to wait. Typically this is done through some sort of icon or image being displayed, much in the style of the Windows egg-timer or similar. This probably will also need a CSS style rule or two, in order to make it a bit funky.
We want to make sure that this is displayed in the right place, even if the user is creating several instances of the same entity. I mean that the icon should be displayed in the correct area of the screen, especially if you have instances whose screen layout takes up some space.
Anyway as always a picture is worth a thousand words. Here is the instance collection form:
The Destination attribute is a Search extension that helps the user search for a Train Station in the United Kingdom. It take a few seconds for the search to happen.
So our timer needs to be shown in the right place whenever the user is searching. It needs to be instance A or B for example, depending on the instance the user is working on.
In the example above the user has typed the Search criteria. The loader is shown in the centre of the instance while the search is happening. So we are Showing a Loading Image During Entity Creation.
When the search data is returned, as in the example above, the user should no longer see the loader and the operation can continue as normal.
If the user moves to another instance, then the process should start again but the loader should be instance-aware and show in the correct place so as not to confuse.
- Check to see if we have already displayed the special icon
- If we have not, create it, center it on the instance we are working on, show it and make the Search
- If the icon already exists, move it to the correct instance and show it then make the Search
- When the search data is returned, hide the icon until the next time.
This example will work with non-tabular forms. I’ll be back with a second post investigating them in a couple of days.
You can find this simple example (with all the usual caveats and reminders that this is just for fun) in the OPA Hub Shop. The official documentation is here, as always. Thanks to Shankar for the great example of Showing a Loading Image During Entity Creation!