Browse Source

Update layer name editing

pull/2062/head
Artur Arseniev 7 years ago
parent
commit
c2c3cc6f81
  1. 2
      dist/css/grapes.min.css
  2. 22
      src/navigator/view/ItemView.js
  3. 7
      src/styles/scss/_gjs_layers.scss

2
dist/css/grapes.min.css

File diff suppressed because one or more lines are too long

22
src/navigator/view/ItemView.js

@ -19,14 +19,14 @@ export default Backbone.View.extend({
}, },
template(model) { template(model) {
const { pfx, ppfx, config, clsEllip } = this; const { pfx, ppfx, config, clsNoEdit } = this;
const { hidable } = config; const { hidable } = config;
const count = this.countChildren(model); const count = this.countChildren(model);
const addClass = !count ? this.clsNoChild : ''; const addClass = !count ? this.clsNoChild : '';
const clsTitle = `${this.clsTitle} ${addClass}`; const clsTitle = `${this.clsTitle} ${addClass}`;
const clsTitleC = `${this.clsTitleC} ${ppfx}one-bg`; const clsTitleC = `${this.clsTitleC} ${ppfx}one-bg`;
const clsCaret = `${this.clsCaret} fa fa-chevron-right`; const clsCaret = `${this.clsCaret} fa fa-chevron-right`;
const clsInput = `${this.inputNameCls} ${clsEllip} ${ppfx}no-app`; const clsInput = `${this.inputNameCls} ${clsNoEdit} ${ppfx}no-app`;
const level = this.level + 1; const level = this.level + 1;
const gut = `${30 + level * 10}px`; const gut = `${30 + level * 10}px`;
const name = model.getName(); const name = model.getName();
@ -84,7 +84,8 @@ export default Backbone.View.extend({
this.clsMove = `${pfx}layer-move`; this.clsMove = `${pfx}layer-move`;
this.clsChildren = `${pfx}layer-children`; this.clsChildren = `${pfx}layer-children`;
this.clsNoChild = `${pfx}layer-no-chld`; this.clsNoChild = `${pfx}layer-no-chld`;
this.clsEllip = `${this.inputNameCls}--ell`; this.clsEdit = `${this.inputNameCls}--edit`;
this.clsNoEdit = `${this.inputNameCls}--no-edit`;
this.$el.data('model', model); this.$el.data('model', model);
this.$el.data('collection', components); this.$el.data('collection', components);
model.viewLayer = this; model.viewLayer = this;
@ -135,12 +136,15 @@ export default Backbone.View.extend({
*/ */
handleEdit(e) { handleEdit(e) {
e && e.stopPropagation(); e && e.stopPropagation();
const { em, $el, clsEllip } = this; const { em, $el, clsNoEdit, clsEdit } = this;
const inputEl = this.getInputName(); const inputEl = this.getInputName();
inputEl[inputProp] = true; inputEl[inputProp] = true;
inputEl.focus(); inputEl.focus();
em && em.setEditing(1); em && em.setEditing(1);
$el.find(`.${this.inputNameCls}`).removeClass(clsEllip); $el
.find(`.${this.inputNameCls}`)
.removeClass(clsNoEdit)
.addClass(clsEdit);
}, },
/** /**
@ -148,13 +152,17 @@ export default Backbone.View.extend({
*/ */
handleEditEnd(e) { handleEditEnd(e) {
e && e.stopPropagation(); e && e.stopPropagation();
const { em, $el, clsEllip } = this; const { em, $el, clsNoEdit, clsEdit } = this;
const inputEl = this.getInputName(); const inputEl = this.getInputName();
const name = inputEl.textContent; const name = inputEl.textContent;
inputEl.scrollLeft = 0;
inputEl[inputProp] = false; inputEl[inputProp] = false;
this.model.set({ name }); this.model.set({ name });
em && em.setEditing(0); em && em.setEditing(0);
$el.find(`.${this.inputNameCls}`).addClass(clsEllip); $el
.find(`.${this.inputNameCls}`)
.addClass(clsNoEdit)
.removeClass(clsEdit);
}, },
/** /**

7
src/styles/scss/_gjs_layers.scss

@ -1,4 +1,5 @@
$layerIconSize: 15px !default; $layerIconSize: 15px !default;
$layerNameSpacing: 5px !default;
.#{$nv-prefix} { .#{$nv-prefix} {
&selected-parent { &selected-parent {
@ -80,15 +81,15 @@ $layerIconSize: 15px !default;
} }
&-name { &-name {
padding: 5px; padding: $layerNameSpacing 0;
display: inline-block; display: inline-block;
box-sizing: content-box; box-sizing: content-box;
overflow: hidden; overflow: hidden;
white-space: nowrap; white-space: nowrap;
margin-right: 20px; margin: 0 30px 0 $layerNameSpacing;
@extend .#{$app-prefix}no-user-select; @extend .#{$app-prefix}no-user-select;
&--ell { &--no-edit {
text-overflow: ellipsis; text-overflow: ellipsis;
} }
} }

Loading…
Cancel
Save