mirror of
https://github.com/lxsang/antos-frontend.git
synced 2024-11-08 14:08:22 +01:00
support drag and drop in file
This commit is contained in:
parent
53df50f196
commit
33eab1d30a
@ -33,7 +33,7 @@ Ant.OS or=
|
||||
system: {}
|
||||
register: (name, x) ->
|
||||
if x.type is 3 then Ant.OS.GUI.subwindows[name] = x else Ant.OS.APP[name] = x
|
||||
|
||||
|
||||
# import proprety from an App
|
||||
|
||||
|
||||
|
@ -50,6 +50,7 @@ class FileViewTag extends Ant.OS.GUI.BaseTag
|
||||
|
||||
__ondragndrop__: (v) ->
|
||||
@refs.treeview.set "ondragndrop", v
|
||||
@refs.listview.set "ondragndrop", v
|
||||
|
||||
sortByType: (a, b) ->
|
||||
if a.type < b.type
|
||||
@ -187,6 +188,7 @@ class FileViewTag extends Ant.OS.GUI.BaseTag
|
||||
.catch (e) -> reject e
|
||||
@refs.gridview.set "header", @header
|
||||
@refs.treeview.set "dragndrop", true
|
||||
@refs.listview.set "dragndrop", true
|
||||
# even handles
|
||||
@refs.listview.set "onlistselect", (e) =>
|
||||
@fileselect e.data.item.get("data")
|
||||
|
@ -21,6 +21,7 @@ class ListViewItemTag extends Ant.OS.GUI.BaseTag
|
||||
@get("onselect")({ item: @root })
|
||||
|
||||
mount: () ->
|
||||
$(@refs.item).attr "dataref", "afx-list-item"
|
||||
$(@refs.item).contextmenu (e) =>
|
||||
e.item = @root
|
||||
@get("oncontextmenu")(e)
|
||||
@ -73,6 +74,7 @@ class ListViewTag extends Ant.OS.GUI.BaseTag
|
||||
super r, o
|
||||
@setopt "onlistselect", () ->
|
||||
@setopt "onlistdbclick", () ->
|
||||
@setopt "ondragndrop", () ->
|
||||
@setopt "onitemclose", () -> true
|
||||
@setopt "buttons", []
|
||||
@setopt "data", []
|
||||
@ -82,6 +84,7 @@ class ListViewTag extends Ant.OS.GUI.BaseTag
|
||||
@setopt "selectedItem", undefined
|
||||
@setopt "selectedItems", []
|
||||
@setopt "selected", -1
|
||||
@setopt "dragndrop", false
|
||||
$(@root)
|
||||
.css "display", "flex"
|
||||
.css "flex-direction", "column"
|
||||
@ -173,6 +176,9 @@ class ListViewTag extends Ant.OS.GUI.BaseTag
|
||||
$( @refs.mlist).empty()
|
||||
for item in data
|
||||
@push item, false
|
||||
$(@refs.container).off "mousedown", @onmousedown
|
||||
if @__("dragndrop") and not @__("dropdown")
|
||||
$(@refs.container).on "mousedown", @onmousedown
|
||||
|
||||
|
||||
unselect: () ->
|
||||
@ -223,6 +229,41 @@ class ListViewTag extends Ant.OS.GUI.BaseTag
|
||||
@observable.trigger "listselect", evt
|
||||
|
||||
mount: () ->
|
||||
@dnd = {}
|
||||
@onmousedown = (e) =>
|
||||
el = $(e.target).closest("li[dataref='afx-list-item']")
|
||||
return if el.length is 0
|
||||
el = el.parent()[0]
|
||||
@dnd.from = el
|
||||
@dnd.to = undefined
|
||||
$(window).on "mouseup", @onmouseup
|
||||
$(window).on "mousemove", @onmousemove
|
||||
|
||||
@onmouseup = (e) =>
|
||||
$(window).off "mouseup", @onmouseup
|
||||
$(window).off "mousemove", @onmousemove
|
||||
($ "#systooltip").hide()
|
||||
el = $(e.target).closest("li[dataref='afx-list-item']")
|
||||
return if el.length is 0
|
||||
el = el.parent()[0]
|
||||
return if el is @dnd.from
|
||||
@dnd.to = el
|
||||
@__("ondragndrop") { id: @aid(), data: @dnd }
|
||||
@dnd = {}
|
||||
|
||||
@onmousemove = (e) =>
|
||||
return unless e
|
||||
return unless @dnd.from
|
||||
data = @dnd.from.get("data")
|
||||
$label = $("#systooltip")
|
||||
top = e.clientY + 5
|
||||
left = e.clientX + 5
|
||||
$label.show()
|
||||
$label[0].set "*", data
|
||||
$label
|
||||
.css "top", top + "px"
|
||||
.css "left", left + "px"
|
||||
|
||||
$(@refs.btlist).hide()
|
||||
@observable.on "resize", (e) => @calibrate()
|
||||
@calibrate()
|
||||
|
@ -220,7 +220,6 @@ class TreeViewTag extends Ant.OS.GUI.BaseTag
|
||||
return if el.length is 0
|
||||
el = el[0]
|
||||
return if el is @root
|
||||
e.source = el
|
||||
@dnd.from = el
|
||||
@dnd.to = undefined
|
||||
$(window).on "mouseup", @treemouseup
|
||||
|
@ -1,7 +1,8 @@
|
||||
{
|
||||
"app":null,
|
||||
"className": "CoreServices",
|
||||
"services": [ "Calendar", "PushNotification" ],
|
||||
"name":"CoreServices",
|
||||
"name": "Core services",
|
||||
"description":"This is the core services",
|
||||
"info":{
|
||||
"author": "Xuan Sang LE",
|
||||
|
@ -83,6 +83,19 @@ class Files extends this.OS.GUI.BaseApplication
|
||||
resolve d.result
|
||||
.catch (e) -> reject e
|
||||
|
||||
@view.set "ondragndrop", (e) =>
|
||||
return unless e
|
||||
src = e.data.from.get("data")
|
||||
des = e.data.to.get("data")
|
||||
return if des.type is "file"
|
||||
file = src.path.asFileHandle()
|
||||
file.move "#{des.path}/#{file.basename}"
|
||||
.then () =>
|
||||
@view.set "path", @view.get("path")
|
||||
@view.update file.parent().path
|
||||
@view.update des.path
|
||||
.catch (e) => @error __("Unable to move: {0} -> {1}", src.path, des.path), e
|
||||
|
||||
@setting.sidebar = true if @setting.sidebar is undefined
|
||||
@setting.nav = true if @setting.nav is undefined
|
||||
@setting.showhidden = false if @setting.showhidden is undefined
|
||||
|
@ -54,7 +54,7 @@ class MarketPlace extends this.OS.GUI.BaseApplication
|
||||
|
||||
@btinstall.set "onbtclick", (e) =>
|
||||
if @btinstall.get "dirty"
|
||||
return @update()
|
||||
return @updatePackage()
|
||||
.then () => @notify __("Package updated")
|
||||
.catch (e) => @error e.toString(), e
|
||||
@remoteInstall()
|
||||
@ -108,7 +108,7 @@ class MarketPlace extends this.OS.GUI.BaseApplication
|
||||
list = []
|
||||
for k, v of pkgcache
|
||||
list.push {
|
||||
className: v.app,
|
||||
className: if v.app then v.app else v.className,
|
||||
name: v.name,
|
||||
text: v.name,
|
||||
icon: v.icon,
|
||||
@ -293,6 +293,11 @@ class MarketPlace extends this.OS.GUI.BaseApplication
|
||||
if r.error
|
||||
return reject @_api.throwe __("Cannot uninstall package: {0}", r.error)
|
||||
@notify __("Package uninstalled")
|
||||
# stop all the services if any
|
||||
if app.services
|
||||
for srv in app.services
|
||||
@_gui.unloadApp srv
|
||||
|
||||
delete @systemsetting.system.packages[name]
|
||||
@_gui.unloadApp name
|
||||
if sel.download
|
||||
@ -304,7 +309,7 @@ class MarketPlace extends this.OS.GUI.BaseApplication
|
||||
.catch (e) -> reject e
|
||||
.catch (e) -> reject e
|
||||
|
||||
update: () ->
|
||||
updatePackage: () ->
|
||||
new Promise (resolve, reject) =>
|
||||
@uninstall().then () =>
|
||||
@remoteInstall()
|
||||
|
Loading…
Reference in New Issue
Block a user