Browse Source

Update getName in Component and remove getCurrentName

pull/187/head
Artur Arseniev 9 years ago
parent
commit
54789a4852
  1. 9
      src/canvas/config/config.js
  2. 19
      src/dom_components/model/Component.js

9
src/canvas/config/config.js

@ -24,4 +24,13 @@ module.exports = {
*/ */
styles: [], styles: [],
/**
* Add custom badge naming strategy
* @example
* customBadgeLabel: function(ComponentModel) {
* return ComponentModel.getName();
* }
*/
customBadgeLabel: '',
}; };

19
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} * @return {string}
* @private
* */ * */
getName() { getName() {
if(!this.name){ let customName = this.get('custom-name');
var type = this.get('type'); let name = this.get('type') || this.get('tagName');
var tag = this.get('tagName'); name = name.charAt(0).toUpperCase() + name.slice(1);
tag = tag == 'div' ? 'box' : tag; return customName || name;
tag = type ? type : tag;
this.name = tag.charAt(0).toUpperCase() + tag.slice(1);
}
return this.name;
},
getCurrentName() {
return this.get('custom-name') || this.getName();
}, },
/** /**

Loading…
Cancel
Save