Draft: [carbon]Introduce a new module loader
Rationale:
- Allow a better parameterization/decoupling of the modules(buildings, purchases ...) loaded and there associated collection method (how the data are fed in the database)
- This paramerization/decoupling is crucial to support new entities (Campus, Conference ... )
Current Shortcoming: the current trends is to duplicate configuration elements between frontend and backend. The configuration workflow is not part of this patch.
The following describe what's a module in the current implementation and examplify how it can be used to support the collection of the precice source/destination information for Travels without changing much code.
In the current patch, a module is mainly composed of the following:
- a set of forms to collect the data (vue + js) [e.g Purchases.Main + all the associated forms]
- a frontend model that represent the collected data in the frontend (js) [e.g Purchase javascript class]
- a backend model that represent the data stored in the database [e.g Purchase model in the database]
- in and out operations [e.g createFromObj and toDatabase method of the above javascript model class]
The choice here is to list the available modules are found in src/ActiveModules.js. For each module, the client application (vuejs) the above parameter will be described.
Application can now composes its available modules by specifying which one to use by their names in the configuration. By default we activate the following for lab and entity:
const DEFAULT_MODULE_NAMES = [
'buildings/form',
'purchases/form',
'devices/form',
'vehicles/form',
'travels/form',
'commutes/survey',
'foods/survey',
'ractivities/form'
]
The name of an activable module is "type/descriptor" where type is picked in the list of Modules (travels, purchases ...) and the descriptor is an arbitrary string.
The module is then registered from the list of available modules.
Example of use: allow to choose how travels are stored/loaded How: change the dumps function (the 'out' function) of the travel module type. Note that this is a particular case, because the original forms (frontend) doesn't need to be changed nor the backend model (except for adding the cities related fields)