diff options
author | Christian <git-developer@users.noreply.github.com> | 2020-11-29 15:30:01 +0100 |
---|---|---|
committer | Christian <git-developer@users.noreply.github.com> | 2020-11-29 15:35:55 +0100 |
commit | f2fe53c65f46c584f4a4cf26bfb7e19cb4093f56 (patch) | |
tree | b32633c3619725760b137fa455da18638a6491f8 | |
parent | 64b5a5ed69e7ee822a41883308d1a5b2c5d69aaf (diff) |
feat(BCR2000): add support for a default component definition in a container
-rw-r--r-- | res/controllers/midi-components-extension.js | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/res/controllers/midi-components-extension.js b/res/controllers/midi-components-extension.js index ede4fe86a7..5ff05303c6 100644 --- a/res/controllers/midi-components-extension.js +++ b/res/controllers/midi-components-extension.js @@ -826,7 +826,9 @@ * +- components: An object of component definitions for the component container. * | +- component: A component definition in the same format as described for decks * +- type: (function, optional) Constructor; default: `components.ComponentContainer` - * +- options: (object, optional) Constructor argument + * +- options: (object, optional) Constructor argument for the container + * +- defaultDefinition: (object, optional) Default definition for components in the + * | container * +- init: (function, optional) A function that is called after component creation * and before first use * @@ -1101,7 +1103,9 @@ var containerType = containerDefinition.type || components.ComponentContainer; var container = new containerType(containerDefinition.options); containerDefinition.components.forEach(function(componentDefinition, index) { - container[index] = new componentDefinition.type(componentDefinition.options); + var definition = _.merge( + {}, containerDefinition.defaultDefinition || {}, componentDefinition); + container[index] = new definition.type(definition.options); }, this); if (typeof containerDefinition.init === "function") { containerDefinition.init.call(container); |