Make Menu/Homepage Entries for modules configurable via mini Modules
Some of the modules provide menu or home page entries. Configuring them through .provideEntries() static method has proven to be a bit tedious, so here's a new attempt :)
The goal is to have as much of the configuration process done through module imports as possible. Now every menu or home page entry gets its own mini module. If the module is imported the entry is provided, if not - not :)
Scope
For the moment this concerns all modules with a static method .provideEntries()
and modules that already appear on the home screen.
What is do be done?
- For each module XModule Create a mini module for every menu or home page entry they might provide: e.g. XMainMenuEntryModule
- For each mini module: Have it import the original XModule
- For each mini module XYEntry add a
.configure()
static method that allows to further configure the entry. (see below) - Make sure that the mini module can only be imported once!
.configure
I suggest the following interface:
interface EntryConfig {
position?: number
}
public static configure(config?: EntryConfig): ModuleWithProviders<...> {
//...
}
If no position or no config is provided the module picks a reasonably adequate position on its own.
Maybe in the future we will have to extend Entry Config for some special cases. For the moment I think
it is still helpful to have an explicit property on config instead of just asking for a number:
.configure({position:1})
seems more readable than .configure(1)
.
Where to start
/lib/common/src/qr-codes/qr-code.module.ts
has a static method provideEntries()
Note
Every implementation detail is up to discussion, so feel free to share your ideas
Why should the mini modules not be importable more than once?
Since their job is kind of to centralize the menu and homepage configuration, it should not be possible to use them in multiple places.
But more importantly, we avoid the problem of conflicting imports: What happens if a mini module gets imported twice? -> avoid having a menu entry added twice. What happens if one import sets the position to 2 and another on to 3? -> avoid having to prioritize.