group form nodes based on groups

This commit is contained in:
Skye 2022-12-18 16:29:16 +09:00
parent a8b145382c
commit 692f7249a6
Signed by: me
GPG key ID: 0104BC05F41B77B8

View file

@ -9,10 +9,21 @@
isUiNodeImageAttributes, isUiNodeImageAttributes,
isUiNodeInputAttributes, isUiNodeInputAttributes,
isUiNodeScriptAttributes, isUiNodeScriptAttributes,
isUiNodeTextAttributes isUiNodeTextAttributes,
filterNodesByGroups
} from '@ory/integrations/ui'; } from '@ory/integrations/ui';
export let ui: UiContainer; export let ui: UiContainer;
let groups = [
...new Set(ui.nodes.map((node) => node.group).filter((group) => group != 'default'))
];
export let grouped_nodes = groups.map((group) =>
filterNodesByGroups({
nodes: ui.nodes,
groups: group
})
);
</script> </script>
{#if ui.messages} {#if ui.messages}
@ -48,8 +59,9 @@
{/each} {/each}
{/if} {/if}
{#each grouped_nodes as node_group}
<form action={ui.action} method={ui.method} class="space-y-3"> <form action={ui.action} method={ui.method} class="space-y-3">
{#each ui.nodes as node} {#each node_group as node}
{#if isUiNodeTextAttributes(node.attributes)} {#if isUiNodeTextAttributes(node.attributes)}
{node.attributes.text.text} {node.attributes.text.text}
{:else if isUiNodeInputAttributes(node.attributes)} {:else if isUiNodeInputAttributes(node.attributes)}
@ -131,3 +143,4 @@
{/if} {/if}
{/each} {/each}
</form> </form>
{/each}