simplify tool

This commit is contained in:
vcoppe
2024-06-11 19:08:46 +02:00
parent 9c5ca84004
commit afbf60c5b2
10 changed files with 360 additions and 119 deletions

View File

@@ -1,8 +1,7 @@
import { dbUtils, fileObservers } from "$lib/db";
import { dbUtils } from "$lib/db";
import { castDraft, freeze } from "immer";
import { Track, TrackSegment, Waypoint } from "gpx";
import { selection } from "./Selection";
import { get } from "svelte/store";
import { newGPXFile } from "$lib/stores";
export enum ListLevel {
@@ -22,6 +21,7 @@ export abstract class ListItem {
}
abstract getId(): string | number;
abstract getFullId(): string;
abstract getIdAtLevel(level: ListLevel): string | number | undefined;
abstract getFileId(): string;
abstract extend(id: string | number): ListItem;
@@ -36,6 +36,10 @@ export class ListRootItem extends ListItem {
return 'root';
}
getFullId(): string {
return 'root';
}
getIdAtLevel(level: ListLevel): string | number | undefined {
return undefined;
}
@@ -61,6 +65,10 @@ export class ListFileItem extends ListItem {
return this.fileId;
}
getFullId(): string {
return this.fileId;
}
getIdAtLevel(level: ListLevel): string | number | undefined {
switch (level) {
case ListLevel.ROOT:
@@ -97,6 +105,10 @@ export class ListTrackItem extends ListItem {
return this.trackIndex;
}
getFullId(): string {
return `${this.fileId}-track-${this.trackIndex}`;
}
getIdAtLevel(level: ListLevel): string | number | undefined {
switch (level) {
case ListLevel.ROOT:
@@ -137,6 +149,10 @@ export class ListTrackSegmentItem extends ListItem {
return this.segmentIndex;
}
getFullId(): string {
return `${this.fileId}-track-${this.trackIndex}--${this.segmentIndex}`;
}
getIdAtLevel(level: ListLevel): string | number | undefined {
switch (level) {
case ListLevel.ROOT:
@@ -179,6 +195,10 @@ export class ListWaypointsItem extends ListItem {
return 'waypoints';
}
getFullId(): string {
return `${this.fileId}-waypoints`;
}
getIdAtLevel(level: ListLevel): string | number | undefined {
switch (level) {
case ListLevel.ROOT:
@@ -213,6 +233,10 @@ export class ListWaypointItem extends ListItem {
return this.waypointIndex;
}
getFullId(): string {
return `${this.fileId}-waypoint-${this.waypointIndex}`;
}
getIdAtLevel(level: ListLevel): string | number | undefined {
switch (level) {
case ListLevel.ROOT: