Improved tree select feature - allow also to select node/parent of childs.
This commit is contained in:
parent
97eca99501
commit
ef282e187b
1 changed files with 11 additions and 5 deletions
|
@ -215,6 +215,7 @@ class App.SearchableSelect extends Spine.Controller
|
||||||
@invisiblePart.text('')
|
@invisiblePart.text('')
|
||||||
|
|
||||||
selectItem: (event) ->
|
selectItem: (event) ->
|
||||||
|
return if !event.currentTarget.textContent
|
||||||
@input.val event.currentTarget.textContent.trim()
|
@input.val event.currentTarget.textContent.trim()
|
||||||
@input.trigger('change')
|
@input.trigger('change')
|
||||||
@shadowInput.val event.currentTarget.getAttribute('data-value')
|
@shadowInput.val event.currentTarget.getAttribute('data-value')
|
||||||
|
@ -222,6 +223,7 @@ class App.SearchableSelect extends Spine.Controller
|
||||||
|
|
||||||
navigateIn: (event) ->
|
navigateIn: (event) ->
|
||||||
event.stopPropagation()
|
event.stopPropagation()
|
||||||
|
@selectItem(event)
|
||||||
@navigateDepth(1)
|
@navigateDepth(1)
|
||||||
|
|
||||||
navigateOut: (event) ->
|
navigateOut: (event) ->
|
||||||
|
@ -305,9 +307,7 @@ class App.SearchableSelect extends Spine.Controller
|
||||||
|
|
||||||
onEnter: (event) ->
|
onEnter: (event) ->
|
||||||
if @currentItem
|
if @currentItem
|
||||||
if @currentItem.hasClass('js-enter')
|
if @currentItem.hasClass('js-back')
|
||||||
return @navigateIn(event)
|
|
||||||
else if @currentItem.hasClass('js-back')
|
|
||||||
return @navigateOut(event)
|
return @navigateOut(event)
|
||||||
|
|
||||||
@clearAutocomplete()
|
@clearAutocomplete()
|
||||||
|
@ -326,10 +326,16 @@ class App.SearchableSelect extends Spine.Controller
|
||||||
@input.val valueName
|
@input.val valueName
|
||||||
@shadowInput.val value
|
@shadowInput.val value
|
||||||
|
|
||||||
@currentItem = null
|
|
||||||
|
|
||||||
@input.trigger('change')
|
@input.trigger('change')
|
||||||
@shadowInput.trigger('change')
|
@shadowInput.trigger('change')
|
||||||
|
|
||||||
|
if @currentItem
|
||||||
|
if @currentItem.hasClass('js-enter')
|
||||||
|
@navigateIn(event)
|
||||||
|
@currentItem = null
|
||||||
|
return
|
||||||
|
@currentItem = null
|
||||||
|
|
||||||
@toggle()
|
@toggle()
|
||||||
|
|
||||||
onBlur: ->
|
onBlur: ->
|
||||||
|
|
Loading…
Reference in a new issue