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

feat/type-attributes
Tomáš Mládek 2023-06-28 18:50:33 +02:00
parent d2a81173ee
commit d077726894
1 changed files with 29 additions and 11 deletions

View File

@ -9,7 +9,7 @@
import NotesEditor from "./utils/NotesEditor.svelte";
import type { AttributeChange } from "../types/base";
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 type { BrowseContext } from "../util/browse";
import { Link, useParams } from "svelte-navigator";
@ -76,16 +76,34 @@
const labelsQuery = await api.query(
`(matches (in ${typeAddressesIn}) "${ATTR_LABEL}" ?)`
);
typeAddresses.forEach((address) => {
let labels = labelsQuery.getObject(address).identify();
if (!labels.length) {
labels.push(address);
}
allTypes[address] = {
labels,
attributes: [],
};
});
await Promise.all(
typeAddresses.map(async (address) => {
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) {
labels.push(address);
}
allTypes[address] = {
labels,
attributes: [],
};
})
);
const attributes = await api.query(
`(matches ? "${ATTR_OF}" (in ${typeAddressesIn}))`