Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default spinner for embedded crud editor #169

Open
estambakio-sc opened this issue Dec 21, 2017 · 1 comment
Open

Default spinner for embedded crud editor #169

estambakio-sc opened this issue Dec 21, 2017 · 1 comment
Assignees

Comments

@estambakio-sc
Copy link
Contributor

estambakio-sc commented Dec 21, 2017

If we have crud1 and crud2, where crud2 is embedded in a custom tab on crud1 edit/show view, crud2 should (?) inherit parent spinner. Otherwise we can end up having 2 different spinners on an assumingly single app.

Proposed solution: move custom spinner from model definition into uiConfig props. In this case developer can just pass spinner from parent's uiConfig into the embedded one. (Crud will have defaultProps.spinner with the default value anyway, so passing a prop won't be mandatory).

@estambakio-sc
Copy link
Contributor Author

Current proposable solution: single spinner (singleton) passed from parent app via React context.

Spinner singleton is an instance of a class, which exposes start and stop methods. Any child can execute these methods to signal that is started/finished some async task.

Upon start spinner increments its counter, upon stop counter is decremented.

If counter is equal 1, spinner renders its component. If counter is 0, component is unmounted.

Apps should properly inform spinner with start/stop methods; if one stop is lost spinner will spin indefinitely.

Spinner singleton adds spinner class which can be used to position custom spinner in the center of the screen.

How crud editor decides where to get the spinner from:

  • if spinner prop exists in context -> pass it to own context
  • otherwise check modelDefinition.ui.spinner. If it's found - pass a built-in spinner singleton to own context, with this custom component to be rendered instead of the default one
  • if none is true - pass built-in singleton spinner with default spinner component.

Current implementation (branch issue-169-singleton): spinner singleton, spinner manager component

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant