From 6c993d79a7fd1cbcff155cca646086d60caa0ec5 Mon Sep 17 00:00:00 2001 From: Artur Arseniev Date: Fri, 14 Jul 2017 13:33:58 +0200 Subject: [PATCH] Update custom name in ItemView --- src/dom_components/model/Component.js | 4 +++- src/navigator/view/ItemView.js | 14 +++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/dom_components/model/Component.js b/src/dom_components/model/Component.js index 5d237c475..1b215a83b 100644 --- a/src/dom_components/model/Component.js +++ b/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; }, diff --git a/src/navigator/view/ItemView.js b/src/navigator/view/ItemView.js index 13c47ba91..9d54258e7 100644 --- a/src/navigator/view/ItemView.js +++ b/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)