ui: widget tree tweaks

This commit is contained in:
jean-emmanuel 2021-12-15 11:28:28 +01:00
parent 21982b6bc7
commit ac74d28d0e
2 changed files with 33 additions and 17 deletions

View file

@ -59,12 +59,14 @@ class UiTree extends UiWidget {
super(options)
this.mounted = false
this.container.appendChild(html`<div class="fragment-mode-warning" title="${locales('fragment_mode_explanation')}">${raw(icon('exclamation-triangle'))} ${locales('fragment_mode_warning')}</div>`)
this.filter = this.container.appendChild(html`<input class="filter" type="text" placeholder="${locales('tree_filter')}..."/>`)
this.list = this.container.appendChild(html`<ol style="--depth: 1"></ol`)
this.fragment = this.container.appendChild(html`<div class="fragment-mode-warning" title="${locales('fragment_mode_explanation')}">${raw(icon('exclamation-triangle'))} ${locales('fragment_mode_warning')}</div>`)
this.wrapper = this.container.appendChild(html`<div class="tree"></div>`)
this.list = this.wrapper.appendChild(html`<ol style="--depth: 1"></ol`)
this.dragDummy = html`<span></span>`
this.deferredUpdateTimeout = null
this.expanded = {}
this.init = false
@ -217,6 +219,7 @@ class UiTree extends UiWidget {
parent = parent.parentNode
}
node[0].scrollIntoView({block: 'center'})
this.wrapper.scrollLeft = (node[0].depth - 1) * 20
}
if (this.parent.minimized) this.parent.restore()
@ -228,6 +231,7 @@ class UiTree extends UiWidget {
DOM.each(this.list, '.editing', (el)=>{
el.classList.add('editor-blink')
el.scrollIntoView({block: 'center'})
this.wrapper.scrollLeft = (el.depth - 1) * 20
setTimeout(()=>{
el.classList.remove('editor-blink')
}, 800)
@ -263,6 +267,9 @@ class UiTree extends UiWidget {
data-widget="${widget.hash}" data-type="${widget.getProp('type')}">
${raw(icon(widgetIcons[widget.getProp('type')] || 'root'))}${id}</li>`
node.depth = depth
if (widget instanceof Panel && !(widget instanceof Matrix || widget instanceof Keyboard)) {
node.insertBefore(html`<span class="toggle no-widget-select"></span>`, node.childNodes[0])
node.classList.add('container')