Browse Source

Toggle the move icon in Layers when component `draggable` changes.

pull/5947/head
Artur Arseniev 2 years ago
parent
commit
f20d7d3b18
  1. 22
      src/navigator/view/ItemView.ts

22
src/navigator/view/ItemView.ts

@ -20,12 +20,13 @@ export type ItemViewProps = ViewOptions & {
}; };
const inputProp = 'contentEditable'; const inputProp = 'contentEditable';
const dataToggleMove = 'data-toggle-move';
export default class ItemView extends View { export default class ItemView extends View {
events() { events() {
return { return {
'mousedown [data-toggle-move]': 'startSort', [`mousedown [${dataToggleMove}]`]: 'startSort',
'touchstart [data-toggle-move]': 'startSort', [`touchstart [${dataToggleMove}]`]: 'startSort',
'click [data-toggle-visible]': 'toggleVisibility', 'click [data-toggle-visible]': 'toggleVisibility',
'click [data-toggle-open]': 'toggleOpening', 'click [data-toggle-open]': 'toggleOpening',
'click [data-toggle-select]': 'handleSelect', 'click [data-toggle-select]': 'handleSelect',
@ -76,7 +77,7 @@ export default class ItemView extends View {
</div> </div>
<div class="${pfx}layer-item-right"> <div class="${pfx}layer-item-right">
<div class="${this.clsCount}" data-count>${count || ''}</div> <div class="${this.clsCount}" data-count>${count || ''}</div>
<div class="${this.clsMove}" data-toggle-move>${move || ''}</div> <div class="${this.clsMove}" ${dataToggleMove}>${move || ''}</div>
</div> </div>
</div> </div>
<div class="${this.clsChildren}"></div> <div class="${this.clsChildren}"></div>
@ -151,6 +152,7 @@ export default class ItemView extends View {
['change:open', this.updateOpening], ['change:open', this.updateOpening],
['change:layerable', this.updateLayerable], ['change:layerable', this.updateLayerable],
['change:style:display', this.updateVisibility], ['change:style:display', this.updateVisibility],
['change:draggable', this.updateMove],
['rerender:layer', this.render], ['rerender:layer', this.render],
['change:name change:custom-name', this.updateName], ['change:name change:custom-name', this.updateName],
// @ts-ignore // @ts-ignore
@ -183,6 +185,15 @@ export default class ItemView extends View {
this.getVisibilityEl()[method](`${pfx}layer-off`); this.getVisibilityEl()[method](`${pfx}layer-off`);
} }
updateMove() {
const { model, config } = this;
const el = this.getItemContainer().find(`[${dataToggleMove}]`)[0];
if (el) {
const isDraggable = model.get('draggable') && config.sortable;
el.style.display = isDraggable ? '' : 'none';
}
}
/** /**
* Toggle visibility * Toggle visibility
* @param Event * @param Event
@ -421,16 +432,13 @@ export default class ItemView extends View {
el.find(`.${this.clsChildren}`).append(children); el.find(`.${this.clsChildren}`).append(children);
} }
if (!model.get('draggable') || !config.sortable) {
el.children(`.${this.clsMove}`).remove();
}
!module.isVisible(model) && (this.className += ` ${pfx}hide`); !module.isVisible(model) && (this.className += ` ${pfx}hide`);
hidden && (this.className += ` ${ppfx}hidden`); hidden && (this.className += ` ${ppfx}hidden`);
el.attr('class', this.className!); el.attr('class', this.className!);
this.updateStatus(); this.updateStatus();
this.updateOpening(); this.updateOpening();
this.updateVisibility(); this.updateVisibility();
this.updateMove();
this.__render(); this.__render();
this._rendered = true; this._rendered = true;
return this; return this;

Loading…
Cancel
Save