Side panels: finger-sized rows and controls on desktop too (one layout, as OsmAnd); track and folder actions (edit, download, delete) behind one ⋯ menu
This commit is contained in:
1 parent
cc833d5793
commit
3f4b30d737
2 files changed
+44
-59
No files matched your search
+18
-28
@@ -346,12 +346,12 @@ export class GpxPanelControl {
|
||||
row.appendChild(name);
|
||||
if (isLoggedIn()) {
|
||||
row.appendChild(
|
||||
this._menuButton("⋯", "Edit", [
|
||||
this._menuButton("⋯", "Actions", [
|
||||
{ label: "Rename…", run: () => this._renameFolder(folder) },
|
||||
...this._exportEntries(folder.path, folder.name),
|
||||
{ label: "Delete…", run: () => this._deleteFolder(folder.path) },
|
||||
]),
|
||||
);
|
||||
row.appendChild(this._deleteButton(() => this._deleteFolder(folder.path)));
|
||||
// Dragged onto another folder (or the tree's blank space) moves it.
|
||||
summary.draggable = true;
|
||||
summary.addEventListener("dragstart", (event) => {
|
||||
@@ -400,14 +400,9 @@ export class GpxPanelControl {
|
||||
if (checkbox.checked) this._zoomTo(file.path);
|
||||
});
|
||||
row.appendChild(label);
|
||||
// Delete/download require login (app.rb); shown only once logged in
|
||||
// rather than shown-but-failing-on-click.
|
||||
if (loggedIn) {
|
||||
row.appendChild(this._downloadButton(file));
|
||||
// A folder's "Points (N)" node has no name or color of its own.
|
||||
if (file.path.startsWith("item:")) row.appendChild(this._editButton(file));
|
||||
row.appendChild(this._deleteButton(() => this._deleteFile(file)));
|
||||
}
|
||||
// Every action behind one ⋯ menu (as OsmAnd does), shown only once
|
||||
// logged in: they all require login (app.rb).
|
||||
if (loggedIn) row.appendChild(this._fileMenu(file));
|
||||
|
||||
return row;
|
||||
}
|
||||
@@ -428,30 +423,25 @@ export class GpxPanelControl {
|
||||
return icon;
|
||||
}
|
||||
|
||||
// One button, one obvious place for both download kinds — clicking it
|
||||
// opens a small menu (Original / GeoJSON) instead of splitting them
|
||||
// across two differently-shaped click targets.
|
||||
_downloadButton(file) {
|
||||
_fileMenu(file) {
|
||||
const geojsonUrl = `${gpxFileUrl(file.path)}?${new URLSearchParams({ download: "geojson", name: file.name })}`;
|
||||
return this._menuButton(DOWNLOAD_ICON, "Download", [
|
||||
// A folder's "Points (N)" node has no name or color of its own.
|
||||
const item = file.path.startsWith("item:");
|
||||
return this._menuButton("⋯", "Actions", [
|
||||
item && { label: "Rename…", run: () => this._renameFile(file) },
|
||||
item && { label: "Color…", run: () => this._pickColor(file) },
|
||||
item && file.color && { label: "Default color", run: () => this._patchNode(file.path, { color: "" }) },
|
||||
item && file.layer && { label: "Split into items", run: () => this._splitLayer(file) },
|
||||
item && (file.kinds || []).includes("route") && { label: "Edit route", run: () => this._editRoute(file) },
|
||||
// A folder's loose points have no single file they came from.
|
||||
file.original && { label: "Original file", run: () => this._download(`${gpxFileUrl(file.path)}?download=original`, file.name) },
|
||||
{ label: "GeoJSON", run: () => this._download(geojsonUrl, `${file.name}.geojson`) },
|
||||
file.original && { label: "Download original file", run: () => this._download(`${gpxFileUrl(file.path)}?download=original`, file.name) },
|
||||
{ label: "Download GeoJSON", run: () => this._download(geojsonUrl, `${file.name}.geojson`) },
|
||||
// A course for a Garmin/Wahoo device to follow.
|
||||
file.kinds?.some((kind) => kind === "track" || kind === "route") && {
|
||||
label: "FIT course (Garmin, Wahoo)",
|
||||
label: "Download FIT course (Garmin, Wahoo)",
|
||||
run: () => this._download(`${gpxFileUrl(file.path)}?${new URLSearchParams({ download: "fit", name: file.name })}`, `${file.name}.fit`),
|
||||
},
|
||||
]);
|
||||
}
|
||||
|
||||
_editButton(file) {
|
||||
return this._menuButton("⋯", "Edit", [
|
||||
{ label: "Rename…", run: () => this._renameFile(file) },
|
||||
{ label: "Color…", run: () => this._pickColor(file) },
|
||||
file.color && { label: "Default color", run: () => this._patchNode(file.path, { color: "" }) },
|
||||
file.layer && { label: "Split into items", run: () => this._splitLayer(file) },
|
||||
(file.kinds || []).includes("route") && { label: "Edit route", run: () => this._editRoute(file) },
|
||||
{ label: "Delete…", run: () => this._deleteFile(file) },
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user