diff --git a/tools/upend_js/types.ts b/tools/upend_js/types.ts index 8a1e9c8..66b6873 100644 --- a/tools/upend_js/types.ts +++ b/tools/upend_js/types.ts @@ -38,10 +38,6 @@ export type IValue = | { t: "Null"; c: null; - } - | { - t: "Invalid"; - c: null; }; export interface InvariantEntry { diff --git a/webui/src/components/BrowseAdd.svelte b/webui/src/components/BrowseAdd.svelte index 3b3924e..338f6f4 100644 --- a/webui/src/components/BrowseAdd.svelte +++ b/webui/src/components/BrowseAdd.svelte @@ -31,8 +31,7 @@
{ dispatch("input", ev.detail); editable = false; diff --git a/webui/src/components/EntitySetEditor.svelte b/webui/src/components/EntitySetEditor.svelte index 405d44a..32d3dc4 100644 --- a/webui/src/components/EntitySetEditor.svelte +++ b/webui/src/components/EntitySetEditor.svelte @@ -1,8 +1,7 @@
(focus = ev.detail)} - on:input={() => selector.focus()} + on:input={onInput} />
+ export type SELECTOR_TYPE = + | "Address" + | "NewAddress" + | "Attribute" + | "NewAttribute" + | "String" + | "Number" + | "Null"; + + export type SelectorValue = { + t: SELECTOR_TYPE; + } & ( + | { + t: "Address"; + c: Address; + labels?: string[]; + } + | { + t: "Attribute"; + name: string; + labels?: string[]; + } + | { + t: "String"; + c: string; + } + | { + t: "Number"; + c: number; + } + | { + t: "Null"; + c: null; + } + ); + + export type SelectorOption = + | SelectorValue + | { t: "NewAddress"; c: string } + | { t: "NewAttribute"; name: string; label: string }; + + export async function selectorValueAsValue( + value: SelectorValue, + ): Promise { + switch (value.t) { + case "Address": + return { + t: "Address", + c: value.c, + }; + case "Attribute": + return { + t: "Address", + c: await api.componentsToAddress({ t: "Attribute", c: value.name }), + }; + case "String": + return { + t: "String", + c: value.c, + }; + case "Number": + return { + t: "Number", + c: value.c, + }; + case "Null": + return { + t: "Null", + c: null, + }; + } + } + +
- {#if value?.t == "Address" && inputValue} + {#if current?.t === "Address" && inputValue.length > 0}
- +
(inputValue = "")} />
@@ -303,12 +397,13 @@ (inputFocused = ev.detail)} on:keydown={handleArrowKeys} {disabled} {placeholder} - /> + > + + {/if}
    - {#if option.attribute} - {#if option.labelToCreate} -
    {option.labelToCreate}
    -
    Create attribute ({option.attribute.name})
    - {:else if option.attribute.labels.length} + {#if option.t === "Address"} + {@const address = option.c} + onAddressResolved(address, ev)} + /> + {:else if option.t === "NewAddress"} +
    {option.c}
    +
    {$i18n.t("Create object")}
    + {:else if option.t === "Attribute"} + {#if option.labels.length}
    - {#each option.attribute.labels as label} + {#each option.labels as label}
    {label}
    {/each}
    -
    {option.attribute.name}
    +
    {option.name}
    {:else}
    - {option.attribute.name} + {option.name}
    {/if} - {:else if option.value} - {#if option.value.t == "Address"} - - onAddressResolved(String(option.value.c), ev)} - /> - {:else} -
    {option.value.t}
    -
    {option.value.c}
    - {/if} - {:else if option.labelToCreate} -
    {$i18n.t("Add object")}
    -
    {option.labelToCreate}
    + {:else if option.t === "NewAttribute"} +
    {option.label}
    +
    {$i18n.t("Create attribute")} ({option.name})
    + {:else} +
    {option.t}
    +
    {option.c}
    {/if} {/each} diff --git a/webui/src/components/widgets/EntityList.svelte b/webui/src/components/widgets/EntityList.svelte index 0e278d1..8886ed2 100644 --- a/webui/src/components/widgets/EntityList.svelte +++ b/webui/src/components/widgets/EntityList.svelte @@ -1,14 +1,14 @@