[ui] uplink now works outside of /browse
parent
ec691b3717
commit
849c697061
|
@ -7,14 +7,14 @@
|
||||||
|
|
||||||
<div class="entry">
|
<div class="entry">
|
||||||
<div class="entity">
|
<div class="entity">
|
||||||
<UpObject address={entry.entity} />
|
<UpObject link address={entry.entity} />
|
||||||
</div>
|
</div>
|
||||||
<div class="attribute">
|
<div class="attribute">
|
||||||
{entry.attribute}
|
{entry.attribute}
|
||||||
</div>
|
</div>
|
||||||
<div class="value value-{entry.value.t.toLowerCase()}">
|
<div class="value value-{entry.value.t.toLowerCase()}">
|
||||||
{#if entry.value.t === "Address"}
|
{#if entry.value.t === "Address"}
|
||||||
<UpObject address={String(entry.value.c)} />
|
<UpObject link address={String(entry.value.c)} />
|
||||||
{:else}
|
{:else}
|
||||||
{entry.value.c}
|
{entry.value.c}
|
||||||
{/if}
|
{/if}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
import { getContext } from "svelte";
|
import { getContext } from "svelte";
|
||||||
|
|
||||||
import { useNavigate, useLocation, useParams } from "svelte-navigator";
|
import { useNavigate, useLocation, useParams } from "svelte-navigator";
|
||||||
import type { Writable } from "svelte/store";
|
import { readable, Writable } from "svelte/store";
|
||||||
import type { Address, VALUE_TYPE } from "upend/types";
|
import type { Address, VALUE_TYPE } from "upend/types";
|
||||||
const params = useParams();
|
const params = useParams();
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
|
@ -14,21 +14,29 @@
|
||||||
value?: { t: VALUE_TYPE; c: string };
|
value?: { t: VALUE_TYPE; c: string };
|
||||||
};
|
};
|
||||||
|
|
||||||
const { index } = getContext("browse") as { index: Writable<number> };
|
const context = getContext("browse") as
|
||||||
|
| { index: Writable<number> }
|
||||||
|
| undefined;
|
||||||
|
|
||||||
|
const index = Boolean(context) ? context.index : readable(0);
|
||||||
|
|
||||||
function onClick() {
|
function onClick() {
|
||||||
if ($location.pathname.startsWith("/browse") && to.entity) {
|
if (to.entity) {
|
||||||
let addresses = $params.addresses.split(",");
|
if ($location.pathname.startsWith("/browse")) {
|
||||||
|
let addresses = $params.addresses.split(",");
|
||||||
|
|
||||||
const routerTo =
|
const routerTo =
|
||||||
"/browse/" +
|
"/browse/" +
|
||||||
addresses
|
addresses
|
||||||
.slice(0, $index + 1)
|
.slice(0, $index + 1)
|
||||||
.concat([to.entity])
|
.concat([to.entity])
|
||||||
.join(",");
|
.join(",");
|
||||||
|
|
||||||
navigate(routerTo);
|
navigate(routerTo);
|
||||||
return true;
|
return true;
|
||||||
|
} else {
|
||||||
|
navigate(`/browse/${to.entity}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in New Issue