[ui, lib] correct value types

feat/vaults
Tomáš Mládek 2022-01-28 20:51:34 +01:00
parent bd1655d61a
commit 7dec8f40a1
No known key found for this signature in database
GPG Key ID: ED21612889E75EC5
8 changed files with 35 additions and 15 deletions

View File

@ -1,4 +1,4 @@
import type { IEntry, IValue, ListingResult, VALUE_TYPE } from "./types";
import type { IEntry, IValue, ListingResult } from "./types";
// export function listingAsOrdered(listing: ListingResult): OrderedListing {
// const entries = Object.entries(listing) as [Address, IEntry][];

View File

@ -1,5 +1,5 @@
export type Address = string;
export type VALUE_TYPE = "Value" | "Address" | "Invalid";
export type VALUE_TYPE = "Address" | "String" | "Number" | "Invalid";
export interface IEntry {
entity: Address;
@ -7,10 +7,30 @@ export interface IEntry {
value: IValue;
}
export interface IValue {
t: VALUE_TYPE;
c: string | number;
}
const model: { [key in VALUE_TYPE as string]: unknown } = {
String: "string",
Address: "address",
Number: 123,
Invalid: null,
};
export type IValue =
| {
t: "Address";
c: string;
}
| {
t: "String";
c: string;
}
| {
t: "Number";
c: number;
}
| {
t: "Invalid";
c: null;
};
export interface ListingResult {
[key: string]: IEntry;

View File

@ -14,7 +14,7 @@
</div>
<div class="value value-{entry.value.t.toLowerCase()}">
{#if entry.value.t === "Address"}
<UpObject link address={String(entry.value.c)} />
<UpObject link address={entry.value.c} />
{:else}
{entry.value.c}
{/if}

View File

@ -31,14 +31,14 @@
type: "update",
address: noteEntry.address,
attribute: "NOTE",
value: { t: "Value", c: contentEl.innerText },
value: { t: "String", c: contentEl.innerText },
} as AttributeUpdate);
} else {
dispatch("change", {
type: "create",
address: address,
attribute: "NOTE",
value: { t: "Value", c: contentEl.innerText },
value: { t: "String", c: contentEl.innerText },
} as AttributeCreate);
}
}, 500);

View File

@ -43,7 +43,7 @@
options = [
{
value: {
t: "Value",
t: "String",
c: query,
},
},
@ -88,7 +88,7 @@
attribute = ev.detail;
} else {
value = {
t: "Value",
t: "String",
c: ev.detail,
};
}

View File

@ -138,7 +138,7 @@
addSortKeys(entry.entity, entry.listing.getObject(entry.entity).identify());
if (entry.value.t === "Address") {
addSortKeys(
String(entry.value.c),
entry.value.c,
entry.listing.getObject(String(entry.value.c)).identify(),
false
);

View File

@ -35,7 +35,7 @@ export async function createLabelled(label: string) {
body: JSON.stringify({
attribute: "LBL",
value: {
t: "Value",
t: "String",
c: label,
},
}),

View File

@ -4008,8 +4008,8 @@ __metadata:
"upend@file:../tools/upend_js::locator=svelte-app%40workspace%3A.":
version: 0.0.1
resolution: "upend@file:../tools/upend_js#../tools/upend_js::hash=2fee87&locator=svelte-app%40workspace%3A."
checksum: 51fd21439f8a42d901e03c06e4797f89fd7c505c21ce53d9cb7340ae7495f05d774dd7f0ff758b5470ebb1fb6725e33e06b09d98ec91f17e9766ae1c05d2bd58
resolution: "upend@file:../tools/upend_js#../tools/upend_js::hash=c32ff2&locator=svelte-app%40workspace%3A."
checksum: c684d7394bfbbd1a70becda61a596bb960a40703e6f12dc1bd7e789d05d3e0d87133c8d8e8a4343153b89ee9dce8b508a50669e15ca5dd039bb6d3ac4a0b0fff
languageName: node
linkType: hard