fix export

This commit is contained in:
vcoppe
2025-10-19 13:51:56 +02:00
parent 3f103323c7
commit 307eed86e3

View File

@@ -11,7 +11,6 @@
exportState, exportState,
} from '$lib/components/export/utils.svelte'; } from '$lib/components/export/utils.svelte';
import { currentTool } from '$lib/components/toolbar/tools'; import { currentTool } from '$lib/components/toolbar/tools';
// import { gpxStatistics } from '$lib/stores';
import { import {
Download, Download,
Zap, Zap,
@@ -26,6 +25,8 @@
import { ListRootItem } from '$lib/components/file-list/file-list'; import { ListRootItem } from '$lib/components/file-list/file-list';
import { fileStateCollection } from '$lib/logic/file-state'; import { fileStateCollection } from '$lib/logic/file-state';
import { selection } from '$lib/logic/selection'; import { selection } from '$lib/logic/selection';
import { gpxStatistics } from '$lib/logic/statistics';
import { get } from 'svelte/store';
let open = $derived(exportState.current !== ExportState.NONE); let open = $derived(exportState.current !== ExportState.NONE);
let exportOptions: Record<string, boolean> = $state({ let exportOptions: Record<string, boolean> = $state({
@@ -37,36 +38,7 @@
extensions: false, extensions: false,
}); });
let hide: Record<string, boolean> = $derived.by(() => { let hide: Record<string, boolean> = $derived.by(() => {
// if (exportState.current === ExportState.NONE) { if (exportState.current === ExportState.NONE) {
// return {
// time: false,
// hr: false,
// cad: false,
// atemp: false,
// power: false,
// extensions: false,
// };
// } else {
// let statistics = $gpxStatistics;
// if (exportState.current === ExportState.ALL) {
// statistics = Array.from(fileStateCollection.files.values())
// .map((file) => file.statistics)
// .reduce((acc, cur) => {
// if (cur !== undefined) {
// acc.mergeWith(cur.getStatisticsFor(new ListRootItem()));
// }
// return acc;
// }, new GPXStatistics());
// }
// return {
// time: statistics.global.time.total === 0,
// hr: statistics.global.hr.count === 0,
// cad: statistics.global.cad.count === 0,
// atemp: statistics.global.atemp.count === 0,
// power: statistics.global.power.count === 0,
// extensions: Object.keys(statistics.global.extensions).length === 0,
// };
// }
return { return {
time: false, time: false,
hr: false, hr: false,
@@ -75,6 +47,27 @@
power: false, power: false,
extensions: false, extensions: false,
}; };
} else {
let statistics = $gpxStatistics;
if (exportState.current === ExportState.ALL) {
statistics = Array.from(get(fileStateCollection).values())
.map((file) => file.statistics)
.reduce((acc, cur) => {
if (cur !== undefined) {
acc.mergeWith(cur.getStatisticsFor(new ListRootItem()));
}
return acc;
}, new GPXStatistics());
}
return {
time: statistics.global.time.total === 0,
hr: statistics.global.hr.count === 0,
cad: statistics.global.cad.count === 0,
atemp: statistics.global.atemp.count === 0,
power: statistics.global.power.count === 0,
extensions: Object.keys(statistics.global.extensions).length === 0,
};
}
}); });
let exclude = $derived(Object.keys(exportOptions).filter((key) => !exportOptions[key])); let exclude = $derived(Object.keys(exportOptions).filter((key) => !exportOptions[key]));
@@ -158,15 +151,6 @@
{i18n._('quantities.time')} {i18n._('quantities.time')}
</Label> </Label>
</div> </div>
<div
class="flex flex-row items-center gap-1.5 {hide.extensions ? 'hidden' : ''}"
>
<Checkbox id="export-extensions" bind:checked={exportOptions.extensions} />
<Label for="export-extensions" class="flex flex-row items-center gap-1">
<Earth size="16" />
{i18n._('quantities.osm_extensions')}
</Label>
</div>
<div class="flex flex-row items-center gap-1.5 {hide.hr ? 'hidden' : ''}"> <div class="flex flex-row items-center gap-1.5 {hide.hr ? 'hidden' : ''}">
<Checkbox id="export-heartrate" bind:checked={exportOptions.hr} /> <Checkbox id="export-heartrate" bind:checked={exportOptions.hr} />
<Label for="export-heartrate" class="flex flex-row items-center gap-1"> <Label for="export-heartrate" class="flex flex-row items-center gap-1">
@@ -195,6 +179,15 @@
{i18n._('quantities.power')} {i18n._('quantities.power')}
</Label> </Label>
</div> </div>
<div
class="flex flex-row items-center gap-1.5 {hide.extensions ? 'hidden' : ''}"
>
<Checkbox id="export-extensions" bind:checked={exportOptions.extensions} />
<Label for="export-extensions" class="flex flex-row items-center gap-1">
<Earth size="16" />
{i18n._('quantities.osm_extensions')}
</Label>
</div>
</div> </div>
</div> </div>
</Dialog.Content> </Dialog.Content>