Creating a module
The application uses a module structure. Each functional package must export an object in the Module format defined in the CORE package.
A module is defined with the following elements:
export interface Module {
name: string;
title?: string;
subtitle?: string;
icon?: string;
compatibilityAOS?: {
/** Name of the web module */
moduleName: string;
/** Version of the web module, this value will be filled in automatically with the information obtained from the web instance. */
moduleVersion?: version;
/** Minimum web module version (included) */
downToVersion?: version;
/** Maximum web module version (excluded) */
upToVersion?: version;
};
disabled?: boolean;
menus?: {
[menuKey: string]: Menu;
};
screens?: {
[screenKey: string]: Screen;
};
translations?: {
[languageKey: string]: any;
};
reducers?: {
[key: string]: Reducer;
};
backgroundFunctions?: Function[];
models?: {
objectFields?: ObjectFields;
sortFields?: SortFields;
searchFields?: SearchFields;
formsRegister?: FormConfigs;
headerRegisters?: Function;
};
}
A module therefore has :
- a name (name) to give the module an identity key. This name must be unique among the modules used in the application, to avoid confusion.
- a title (title) to be displayed to the user on the drawer when no app is selected.
- a subtitle (subtitle) to be displayed to the user under the module button in the drawer to aid comprehension. The display of these subtitles can be configured in the Application component using the showModulesSubtitle. attribute.
- an icon name (icon) to be displayed on the module button in the drawer. Please note that this icon must belong to the FontAwesome 5 database (https://oblador.github.io/react-native-vector-icons/).
- web instance compatibility information (compatibilityAOS). It's possible to overload this information from another module by indicating different versions of the same web module name. A version must be a string composed of three numbers. The web module version is automatically retrieved from the server information.
- a set of menus (menus) to be displayed in the drawer.
- a set of screens belonging to the module (screens).
- a set of translations for the module (translations). Translations must be supplied in key-value format for each supported language.
- a set of reducers for the module (reducers). A reducer is a simple function that updates the state of an object according to the action passed to it. In our context, reducers are the redux functions that update the store during API calls, for example. All reducers created in the module must be exported to access the corresponding part of the store in the various screens.
- a list of functions to be executed in the background if necessary (backgroundFunctions). These functions are executed every 5 minutes.
- a configuration of templates for API calls (models).