wip: add labels to address types
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed

This commit is contained in:
Tomáš Mládek 2023-06-28 18:50:33 +02:00
parent d2a81173ee
commit d077726894

View file

@ -9,7 +9,7 @@
import NotesEditor from "./utils/NotesEditor.svelte"; import NotesEditor from "./utils/NotesEditor.svelte";
import type { AttributeChange } from "../types/base"; import type { AttributeChange } from "../types/base";
import Selector from "./utils/Selector.svelte"; import Selector from "./utils/Selector.svelte";
import type { EntityInfo, IValue } from "upend/types"; import type { ADDRESS_TYPE, EntityInfo, IValue } from "upend/types";
import IconButton from "./utils/IconButton.svelte"; import IconButton from "./utils/IconButton.svelte";
import type { BrowseContext } from "../util/browse"; import type { BrowseContext } from "../util/browse";
import { Link, useParams } from "svelte-navigator"; import { Link, useParams } from "svelte-navigator";
@ -76,16 +76,34 @@
const labelsQuery = await api.query( const labelsQuery = await api.query(
`(matches (in ${typeAddressesIn}) "${ATTR_LABEL}" ?)` `(matches (in ${typeAddressesIn}) "${ATTR_LABEL}" ?)`
); );
typeAddresses.forEach((address) => { await Promise.all(
typeAddresses.map(async (address) => {
let labels = labelsQuery.getObject(address).identify(); let labels = labelsQuery.getObject(address).identify();
let typeLabel: string | undefined;
await Promise.all(
(["Hash", "Uuid", "Attribute", "Url"] as ADDRESS_TYPE[]).map(
async (t) => {
if ((await api.getAddress(t)) == address) {
labels.push(`[${t}]`);
}
}
)
);
if (typeLabel) {
labels.unshift(typeLabel);
}
if (!labels.length) { if (!labels.length) {
labels.push(address); labels.push(address);
} }
allTypes[address] = { allTypes[address] = {
labels, labels,
attributes: [], attributes: [],
}; };
}); })
);
const attributes = await api.query( const attributes = await api.query(
`(matches ? "${ATTR_OF}" (in ${typeAddressesIn}))` `(matches ? "${ATTR_OF}" (in ${typeAddressesIn}))`