Module: Core/MetadataManager

The metadata manager is responsible for parsing and returning various metadata to components that request it.

Members


<static> fieldTypeMap :Object

Map of fields types.

Specifies correspondence between field types and field widget types.

Type:
  • Object

Methods


<static> addSyncTask(task)

Adds a task/file/app to be fetched and synced

Parameters:
Name Type Description
task Promise | function

<static> clearCache()

Purges metadata from the persistent cache.


<static> copy(meta [, options])

Copies a metadata fragment.

The default implementation performs a deep copy. Client apps may override this behavior.

Parameters:
Name Type Argument Description
meta Object

Metadata object to be copied.

options Object <optional>

Options that describe the type of metadata to copy. The default implementation does not use them as it always performs deep copy regardless of metadata type.

Returns:

Copy of the given metadata object.

Type
Object

<static> get()

Gets the whole metadata object returned by the server.

Returns:

The metadata object.

Type
Object

<static> getBaseCurrencyId()

Gets the base currency Id. Currently it returns the hardcoded value -99.

Returns:

The value -99;

Type
string

<static> getConfig()

Gets Config.

Returns:

Dictionary of Configs.

Type
Object

<static> getCurrencies()

Gets currencies.

Returns:

the currency dictionary.

Type
Object

<static> getCurrency(currencyId)

Gets a currency.

Parameters:
Name Type Description
currencyId string

Identifier for the currency to retrieve.

Returns:

The currency object.

Type
Object

<static> getEditableDropdownFilter(dropdown)

Gets the list of dropdown keys that can be used when modifying a record.

Parameters:
Name Type Description
dropdown string

The dropdown field to get the filter for.

Returns:

The list of dropdown keys.

Type
Array.<Array> | Object

<static> getField(options)

Gets a field metadata or all fields metadata.

Parameters:
Name Type Description
options Object

A hash of options.

Properties
Name Type Argument Description
module string

The module that we want to get the vardefs.

name string <optional>

The field name to get the field def.

Returns:

Field def for the given Module, or all fields if no options.name is supplied.

Type
Object | undefined

<static> getFilterOperators( [module])

Gets the list of filter operators.

If any filter operators of a certain field type are defined at module level, these will take precedence over the ones available on core, thus completely overriding the latter.

Parameters:
Name Type Argument Description
module string <optional>

The module to get the filters for.

Returns:

The list of filter operators.

Type
Object

<static> getFullModuleList()

Gets the full module list.

Returns:

Full module list. Keys and values are equal.

Type
Object

<static> getHash(isPublic)

Gets metadata hash.

Parameters:
Name Type Description
isPublic boolean

Flag indicating if the public metadata hash is requested.

Returns:

Metadata hash.

Type
string

<static> getHiddenSubpanels()

Gets the list of module names that need to be hidden in subpanels.

Returns:

Collection of module names that are hidden in subpanels.

Type
Object

<static> getLayout(module [, layout] [, loadModule])

Gets a layout metadata or all layouts metadata.

Parameters:
Name Type Argument Description
module string

The module name.

layout string <optional>

Layout name.

loadModule string <optional>

The module that should be considered base. Defaults to core metadata.

Returns:

Layout metadata if layout name is specified. Otherwise, metadata for all layouts of the given module. If the optional layout parameter is provided we instead return null if layout for module not found.

Type
Object | null

<static> getLogoUrl()

Gets the company logo url.

Returns:

The logo url

Type
string

<static> getModule(module [, type])

Gets module metadata.

Parameters:
Name Type Argument Description
module string

The module name.

type string <optional>

Metadata type. e.g 'fields', 'layouts', etc.

Returns:

Module metadata of specific type if type is specified. Otherwise, module's overall metadata.

Type
Object

<static> getModuleNames( [options])

Gets an array of module names.

Parameters:
Name Type Argument Description
options Object <optional>

A hash of options.

Properties
Name Type Argument Description
filter string <optional>

Returns only modules that have this property enabled.

access string <optional>

Returns only modules the user has permission to perform this given action on.

Returns:

List of module names sorted by user settings.

Type
Array

<static> getModules()

Gets metadata for all modules.

Returns:

Metadata for all modules.

Type
Object

<static> getModuleTabMap()

Gets the module tab mapping for megamenu.

Returns:

Mapping object.

Type
Object

<static> getRelationship(name)

Gets a relationship definition.

Parameters:
Name Type Description
name string

Relationship name.

Returns:

Relationship metadata or nothing if not found.

Type
Object

<static> getServerInfo()

Gets server information.

Returns:

Server information.

Type
Object

<static> getStrings(type)

Gets language strings for a given type.

Parameters:
Name Type Description
type string

Type of string pack: app_strings, app_list_strings or mod_strings.

Returns:

Dictionary of strings.

Type
Object

<static> getTabMappedModule(module)

Gets the mapped module name for a menu item if one exists. Otherwise gets the module that was passed in.

Parameters:
Name Type Description
module string

The module to get the mapped module for.

Returns:

The mapped module name.

Type
string

<static> getView(module [, view] [, loadModule])

Gets a view metadata or all views metadata.

Parameters:
Name Type Argument Description
module string

The module name.

view string <optional>

The view name.

loadModule string <optional>

The module that should be considered base. Defaults to core metadata.

Returns:

View metadata if view name is specified. Otherwise, metadata for all views of the given module. If the optional view parameter is provided we instead return null if view for module not found.

Type
Object | null

<static> init()

Binds an event listeners on cache:clean global event and on the window storage event.

When storage is triggered by window, we will check re-sync the app if necessary. If cacheMeta config property is set to true, we grab the metadata from the local storage.


<static> isSyncing()

Used to check if a metadata sync is currently in progress.

Returns:

true if a sync is in progress.

Type
boolean

<static> removeSyncTask(task)

Removes a task/file/app from being fetched and synced

Parameters:
Name Type Description
task Promise | function

<static> reset()

Resets internal memory cache and clears persistent storage.


<static> set(data, isPublic, reset)

Sets the metadata.

By default this function is used by MetadataManager to translate server responses into metadata usable internally. The currently set metadata is preserved and extended by new metadata unless reset parameter equals to true.

Parameters:
Name Type Description
data Object

Metadata payload returned by the server.

isPublic boolean

Flag indicating if the public metadata must be fetched.

reset boolean

Flag indicating if the the current metadata must be deleted.


<static> storageHandler()

Checks to see if the metadata needs to sync with the server.


<static> sync( [callback] [, options])

Syncs metadata from the server. Saves the metadata to the local cache.

Parameters:
Name Type Argument Description
callback function <optional>

Callback function to be executed after sync completes.

options Object <optional>

A hash of options.

Properties
Name Type Argument Description
getPublic boolean <optional>

true to sync the public metadata. Defaults to false.

metadataTypes Array.<string> <optional>

The metadata types to sync. If omitted, the ones specified in the config will be used.