diff --git a/src/canvas/config/config.js b/src/canvas/config/config.js index 4cf9dc6f9..084ac18da 100644 --- a/src/canvas/config/config.js +++ b/src/canvas/config/config.js @@ -24,4 +24,13 @@ module.exports = { */ styles: [], + /** + * Add custom badge naming strategy + * @example + * customBadgeLabel: function(ComponentModel) { + * return ComponentModel.getName(); + * } + */ + customBadgeLabel: '', + }; diff --git a/src/dom_components/model/Component.js b/src/dom_components/model/Component.js index 8ad54aa30..5d237c475 100644 --- a/src/dom_components/model/Component.js +++ b/src/dom_components/model/Component.js @@ -249,23 +249,14 @@ module.exports = Backbone.Model.extend({ }, /** - * Get name of the component + * Get the name of the component * @return {string} - * @private * */ getName() { - if(!this.name){ - var type = this.get('type'); - var tag = this.get('tagName'); - tag = tag == 'div' ? 'box' : tag; - tag = type ? type : tag; - this.name = tag.charAt(0).toUpperCase() + tag.slice(1); - } - return this.name; - }, - - getCurrentName() { - return this.get('custom-name') || this.getName(); + let customName = this.get('custom-name'); + let name = this.get('type') || this.get('tagName'); + name = name.charAt(0).toUpperCase() + name.slice(1); + return customName || name; }, /**