auto generate summit log on gpx upload

This commit is contained in:
Christian Beutel
2024-11-02 13:55:24 +01:00
parent ebfd6f0e72
commit 0d8ff5c83b
3 changed files with 31 additions and 19 deletions

View File

@@ -133,7 +133,7 @@
> >
<span <span
><i class="fa fa-clock mr-2"></i>{formatTimeHHMM( ><i class="fa fa-clock mr-2"></i>{formatTimeHHMM(
totals.duration, totals.duration / 1000 / 60,
)}</span )}</span
> >
</div> </div>

View File

@@ -98,7 +98,7 @@
<td> <td>
{formatElevation(totals?.elevationGain)} {formatElevation(totals?.elevationGain)}
</td><td> </td><td>
{formatTimeHHMM(totals?.duration)} {formatTimeHHMM(totals ? (totals?.duration / 1000 / 60) : undefined)}
</td> </td>
<td> <td>
{#if log.text} {#if log.text}

View File

@@ -290,6 +290,12 @@
$form.expand.gpx_data = gpxData; $form.expand.gpx_data = gpxData;
$form.category = $page.data.settings.category || $categories[0].id; $form.category = $page.data.settings.category || $categories[0].id;
const log = new SummitLog(parseResult.trail.date as string, {})
log.expand.gpx_data = gpxData;
log._gpx = selectedFile;
$form.expand.summit_logs.push(log);
setRoute(parseResult.gpx); setRoute(parseResult.gpx);
initRouteAnchors(parseResult.gpx); initRouteAnchors(parseResult.gpx);
@@ -423,7 +429,7 @@
function saveSummitLog(e: CustomEvent<SummitLog>) { function saveSummitLog(e: CustomEvent<SummitLog>) {
const savedSummitLog = e.detail; const savedSummitLog = e.detail;
console.log(savedSummitLog); console.log(savedSummitLog);
let editedSummitLogIndex = $form.expand.summit_logs.findIndex( let editedSummitLogIndex = $form.expand.summit_logs.findIndex(
(s) => s.id == savedSummitLog.id, (s) => s.id == savedSummitLog.id,
); );
@@ -763,22 +769,28 @@
label={$_("describe-your-trail")} label={$_("describe-your-trail")}
bind:value={$form.description} bind:value={$form.description}
></Textarea> ></Textarea>
<Select <div class="grid grid-cols-1 md:grid-cols-2 gap-y-4">
name="difficulty" <Select
label={$_("difficulty")} name="difficulty"
bind:value={$form.difficulty} label={$_("difficulty")}
items={[ bind:value={$form.difficulty}
{ text: $_("easy"), value: "easy" }, items={[
{ text: $_("moderate"), value: "moderate" }, { text: $_("easy"), value: "easy" },
{ text: $_("difficult"), value: "difficult" }, { text: $_("moderate"), value: "moderate" },
]} { text: $_("difficult"), value: "difficult" },
></Select> ]}
<Select ></Select>
name="category" <Select
label={$_("category")} name="category"
bind:value={$form.category} label={$_("category")}
items={$categories.map((c) => ({ text: $_(c.name), value: c.id }))} bind:value={$form.category}
></Select> items={$categories.map((c) => ({
text: $_(c.name),
value: c.id,
}))}
></Select>
</div>
<Toggle name="public" label={$_("public")} bind:value={$form.public} <Toggle name="public" label={$_("public")} bind:value={$form.public}
></Toggle> ></Toggle>
<hr class="border-separator" /> <hr class="border-separator" />