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