Browse Source

Update custom name in ItemView

pull/187/head
Artur Arseniev 9 years ago
parent
commit
6c993d79a7
  1. 4
      src/dom_components/model/Component.js
  2. 14
      src/navigator/view/ItemView.js

4
src/dom_components/model/Component.js

@ -254,7 +254,9 @@ module.exports = Backbone.Model.extend({
* */
getName() {
let customName = this.get('custom-name');
let name = this.get('type') || this.get('tagName');
let tag = this.get('tagName');
tag = tag == 'div' ? 'box' : tag;
let name = this.get('type') || tag;
name = name.charAt(0).toUpperCase() + name.slice(1);
return customName || name;
},

14
src/navigator/view/ItemView.js

@ -43,7 +43,6 @@ module.exports = Backbone.View.extend({
this.inputNameCls = this.ppfx + 'nav-comp-name';
this.caretCls = this.ppfx + 'nav-item-caret';
this.titleCls = this.pfx + 'title';
this.customNameProp = 'custom-name';
this.events = {};
this.events['click > #'+this.pfx+'btn-eye'] = 'toggleVisibility';
this.events['click .' + this.caretCls] = 'toggleOpening';
@ -77,7 +76,7 @@ module.exports = Backbone.View.extend({
e.stopPropagation();
var inputName = this.getInputName();
inputName.readOnly = true;
this.model.set(this.customNameProp, inputName.value);
this.model.set('custom-name', inputName.value);
},
/**
@ -255,12 +254,13 @@ module.exports = Backbone.View.extend({
},
render() {
let model = this.model;
var pfx = this.pfx;
var vis = this.isVisible();
var count = this.countChildren(this.model);
var count = this.countChildren(model);
this.$el.html( this.template({
title: this.model.get(this.customNameProp) || this.model.getName(),
title: model.getName(),
addClass: (count ? '' : pfx+'no-chld'),
editBtnCls: this.editBtnCls,
inputNameCls: this.inputNameCls,
@ -275,15 +275,15 @@ module.exports = Backbone.View.extend({
if(typeof ItemsView == 'undefined')
ItemsView = require('./ItemsView');
this.$components = new ItemsView({
collection : this.model.components,
collection : model.components,
config: this.config,
sorter: this.sorter,
opened: this.opt.opened,
parent: this.model
parent: model
}).render().$el;
this.$el.find('.'+ pfx +'children').html(this.$components);
this.$caret = this.$el.find('> .' + pfx + 'title-c > .' + pfx + 'title > #' + pfx + 'caret');
if(!this.model.get('draggable') || !this.config.sortable){
if(!model.get('draggable') || !this.config.sortable){
this.$el.find('> #' + pfx + 'move').detach();
}
if(!vis)

Loading…
Cancel
Save