Skip to content

wrap the form mounting into the loading state - show a spinner while loading form components and form data

Inside the Form.mount() method is the call of the init store action. Inside this action, there are requests to the server that may be processed for a long time, especially for poor networks. The general way on the web to show the state of processing of requests to the server is by showing a spinner.

Firstly, we should encourage developers to return from module.exports.mount function a pending promise, which will be a result of the Form.mount() call in 99% of cases. This allows use to await the data loading/creating (with beforeInit, inited, beforeLoad, loaded hooks) from await formController.mount().

Secondly, we should wrap the await formController.mount() call into try/finally and switch the loading state accordingly. By default, it is made with $App.fireEvent('portal:loader', { text: 'portal.loader.form', show: true/false }). It is like a previous implementation but now the init action is also awaited.

Finally, we should allow overriding the displaying spinner behavior. If we open a form from UTableEntity, the UTableEntity spinner should be displayed. The same for other places like USelectEntity or PreviewForm

Edited by Mazur Volodymyr

Merge request reports

Loading