Add GPX drag & drop, folder management, delete, and folder-first sort
Uploading is now drag & drop (or click to browse) instead of a form; folders can be created any time, not just during upload; files can be dragged onto a folder to move them, or dropped elsewhere in the tree to move back to the top level; files and folders can be deleted. Both drag sources (an OS file drag and dragging an existing tree entry) land on the same drop targets, told apart by a custom drag payload type versus the browser's own "Files" type. Also sort folders before files in the tree (previously interleaved alphabetically).
This commit is contained in:
1 parent
4e0d2abbd0
commit
d813dd0b20
6 files changed
+440
-66
No files matched your search
@@ -63,5 +63,51 @@ module Maptool
|
||||
halt 422, json(error: "could not parse GPX file")
|
||||
end
|
||||
end
|
||||
|
||||
post "/api/gpx/folder" do
|
||||
begin
|
||||
GPX_STORE.create_folder(params[:path].to_s)
|
||||
rescue GpxStore::InvalidPath
|
||||
halt 400, json(error: "invalid path")
|
||||
end
|
||||
|
||||
json tree: GPX_STORE.tree
|
||||
end
|
||||
|
||||
delete "/api/gpx/file/*" do
|
||||
begin
|
||||
GPX_STORE.delete_file(params[:splat].first)
|
||||
rescue GpxStore::InvalidPath
|
||||
halt 400
|
||||
rescue Errno::ENOENT
|
||||
halt 404
|
||||
end
|
||||
|
||||
json tree: GPX_STORE.tree
|
||||
end
|
||||
|
||||
delete "/api/gpx/folder/*" do
|
||||
begin
|
||||
GPX_STORE.delete_folder(params[:splat].first)
|
||||
rescue GpxStore::InvalidPath
|
||||
halt 400
|
||||
rescue Errno::ENOENT
|
||||
halt 404
|
||||
end
|
||||
|
||||
json tree: GPX_STORE.tree
|
||||
end
|
||||
|
||||
post "/api/gpx/move" do
|
||||
begin
|
||||
path = GPX_STORE.move(from: params[:from].to_s, to_folder: params[:to_folder].to_s)
|
||||
rescue GpxStore::InvalidPath
|
||||
halt 400, json(error: "invalid path")
|
||||
rescue Errno::ENOENT
|
||||
halt 404
|
||||
end
|
||||
|
||||
json path: path, tree: GPX_STORE.tree
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user