mirror of
https://github.com/lxsang/antos-frontend.git
synced 2024-12-26 09:28:21 +01:00
multiselect
This commit is contained in:
parent
0de9f88dcf
commit
5d987f8fb6
@ -71,12 +71,16 @@ class ListViewTag extends Ant.OS.GUI.BaseTag
|
||||
@setopt "itemtag", "afx-list-item"
|
||||
@setopt "multiselect", false
|
||||
@setopt "selectedItem", undefined
|
||||
@setopt "selectedIndex", -1
|
||||
@setopt "selectedItems", []
|
||||
@items = []
|
||||
$(@root)
|
||||
.css "display", "flex"
|
||||
.css "flex-direction", "column"
|
||||
|
||||
multiselect: () ->
|
||||
@get "multiselect"
|
||||
|
||||
|
||||
on_buttons_changed: (v) ->
|
||||
return if @get "dropdown"
|
||||
|
||||
@ -94,21 +98,36 @@ class ListViewTag extends Ant.OS.GUI.BaseTag
|
||||
.set "ondbclick", (e) ->
|
||||
me.idbclick e
|
||||
.set "onclick", (e) ->
|
||||
return if not e.item or e.item is me.selectedItem
|
||||
e.item.set "selected", true
|
||||
me.iclick e
|
||||
.set "onselect", (e) ->
|
||||
me.iselect e
|
||||
.set "onclose", (e) ->
|
||||
me.iclose e
|
||||
|
||||
iclick: (e) ->
|
||||
return if not e.item
|
||||
list = @get("selectedItems")
|
||||
if @multiselect() and list.includes(e.item)
|
||||
list.splice(list.indexOf(e.item))
|
||||
return e.item.set "selected", false
|
||||
|
||||
e.item.set "selected", true
|
||||
|
||||
icontextmenu: (e) ->
|
||||
console.log "context menu", e
|
||||
idbclick: (e) ->
|
||||
console.log "db click", e
|
||||
iselect: (e) ->
|
||||
return unless e.item
|
||||
@selectedItem.set "selected", false if @selectedItem
|
||||
@selectedItem = e.item
|
||||
if @multiselect()
|
||||
return if @get("selectedItems").includes e.item
|
||||
@set "selectedItem", e.item
|
||||
@get("selectedItems").push e.item
|
||||
e.items = @get("selectedItems")
|
||||
else
|
||||
@get("selectedItem").set "selected", false if @get("selectedItem")
|
||||
@set "selectedItem", e.item
|
||||
@set "selectedItems", [e.item]
|
||||
@get("onlistselect")(e)
|
||||
|
||||
iclose: (e) ->
|
||||
|
@ -50,7 +50,7 @@ class ShowCase extends this.OS.GUI.BaseApplication
|
||||
</afx-hbox>
|
||||
<afx-resizer data-height="5" />
|
||||
<afx-hbox>
|
||||
<afx-list-view data-id="list" />
|
||||
<afx-list-view data-id="list" multiselect="true" />
|
||||
</afx-hbox>
|
||||
<afx-hbox data-height="150">
|
||||
<div>box center 3</div>
|
||||
@ -90,6 +90,9 @@ class ShowCase extends this.OS.GUI.BaseApplication
|
||||
{ text: "some thing 4" },
|
||||
{ text: "some thing 5" }
|
||||
]
|
||||
list[0].set "onlistselect", (e) ->
|
||||
console.log(e.items)
|
||||
|
||||
|
||||
ShowCase.singleton = true
|
||||
this.OS.register "ShowCase", ShowCase
|
Loading…
Reference in New Issue
Block a user