[ui] get LBL attrs in a single query
parent
1ee86a9da6
commit
52409a0195
|
@ -14,13 +14,12 @@
|
|||
const params = useParams();
|
||||
|
||||
export let address: string;
|
||||
export let labels: string[] = [];
|
||||
export let labels: string[] | undefined = undefined;
|
||||
export let link = false;
|
||||
export let resolve = true;
|
||||
export let banner = false;
|
||||
|
||||
let entity = readable(undefined);
|
||||
$: if (resolve) ({ entity } = useEntity(address));
|
||||
$: if (labels === undefined) ({ entity } = useEntity(address));
|
||||
|
||||
// isFile
|
||||
$: isFile = $entity?.get("IS") === BLOB_TYPE_ADDR;
|
||||
|
@ -28,10 +27,11 @@
|
|||
// Identification
|
||||
let inferredIds: string[] = [];
|
||||
$: inferredIds = $entity?.identify() || [];
|
||||
$: resolving = inferredIds.concat(labels).length == 0 && !$entity;
|
||||
$: resolving = inferredIds.concat(labels || []).length == 0 && !$entity;
|
||||
|
||||
$: displayLabel =
|
||||
Array.from(new Set(inferredIds.concat(labels))).join(" | ") || address;
|
||||
Array.from(new Set(inferredIds.concat(labels || []))).join(" | ") ||
|
||||
address;
|
||||
|
||||
$: dispatch("resolved", inferredIds);
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
import Selector from "../utils/Selector.svelte";
|
||||
import type { IValue } from "upend/types";
|
||||
import Editable from "../utils/Editable.svelte";
|
||||
import { query } from "../../lib/entity";
|
||||
const dispatch = createEventDispatcher();
|
||||
|
||||
export let columns: string;
|
||||
|
@ -55,6 +56,14 @@
|
|||
} as AttributeUpdate);
|
||||
}
|
||||
|
||||
// Labelling
|
||||
$: labelListing = query(
|
||||
() =>
|
||||
`(matches (in ${entries
|
||||
.map((e) => '"' + e.entity + '"')
|
||||
.join(" ")}) "LBL" ? )`
|
||||
).result;
|
||||
|
||||
// Sorting
|
||||
let sortedAttributes = entries;
|
||||
|
||||
|
@ -179,9 +188,6 @@
|
|||
}
|
||||
return String(value);
|
||||
}
|
||||
|
||||
// Optimizations
|
||||
let resolve = [];
|
||||
</script>
|
||||
|
||||
<table>
|
||||
|
@ -261,10 +267,9 @@
|
|||
<UpObject
|
||||
link
|
||||
address={String(entry.value.c)}
|
||||
labels={entry.listing
|
||||
.getObject(String(entry.value.c))
|
||||
.identify()}
|
||||
resolve={Boolean(resolve[entry.address]) || true}
|
||||
labels={$labelListing
|
||||
?.getObject(String(entry.value.c))
|
||||
?.identify()}
|
||||
on:resolved={(event) => {
|
||||
addSortKeys(String(entry.value.c), event.detail);
|
||||
}}
|
||||
|
|
Loading…
Reference in New Issue