Preskoči na vsebino

std-messaging

Level: Molecule | Entity: ChatMessage | Persistence: persistent

1 states, 4 events, 2 transitions

Live Preview

orbital ChatMessageOrbital {
entity ChatMessage [persistent: chatmessages] {
id : string
name : string
description : string
status : string
createdAt : string
}
trait ChatMessageBrowse -> ChatMessage [interaction] {
state browsing {
INIT -> browsing
(fetch ChatMessage)
(render-ui main { type: "stack", direction: "vertical", gap: "lg", className: "max-w-5xl mx-auto w-full", children: [{ type: "stack", direction: "horizontal", gap: "md", justify: "space-between", align: "center", children: [{ type: "stack", direction: "horizontal", gap: "sm", align: "center", children: [{ type: "icon", name: "message-circle", size: "lg" }, { type: "typography", content: "ChatMessages", variant: "h2" }] }, { type: "stack", direction: "horizontal", gap: "sm", children: [{ type: "button", label: "Compose", event: "COMPOSE", variant: "primary", icon: "edit" }] }] }, { type: "divider" }, { type: "data-grid", entity: "ChatMessage", emptyIcon: "inbox", emptyTitle: "No messages yet", emptyDescription: "Start a new conversation.", itemActions: [{ label: "View", event: "VIEW", variant: "ghost", size: "sm" }], columns: [{ name: "name", label: "Name", variant: "h4", icon: "message-circle" }, { name: "description", label: "Description", variant: "caption" }, { name: "status", label: "Status", variant: "caption", format: "date" }], variant: "compact" }] })
SEND -> browsing
(fetch ChatMessage)
}
listens {
* SEND -> SEND
}
}
trait ChatMessageCompose -> ChatMessage [interaction] {
initial: closed
state closed {
INIT -> closed
(fetch ChatMessage)
COMPOSE -> open
(render-ui modal { type: "stack", direction: "vertical", gap: "md", children: [{ type: "stack", direction: "horizontal", gap: "sm", children: [{ type: "icon", name: "edit", size: "md" }, { type: "typography", content: "New ChatMessage", variant: "h3" }] }, { type: "divider" }, { type: "form-section", entity: "ChatMessage", mode: "create", submitEvent: "SEND", cancelEvent: "CLOSE", fields: ["name", "description", "status"] }] })
}
state open {
CLOSE -> closed
(render-ui modal null)
(notify Cancelled info)
SEND -> closed
(persist create ChatMessage @payload.data)
(fetch ChatMessage)
(render-ui modal null)
(emit SEND)
(notify "ChatMessage created successfully")
}
emits {
SEND
}
}
trait ChatMessageView -> ChatMessage [interaction] {
initial: closed
state closed {
INIT -> closed
(fetch ChatMessage)
VIEW -> open
(fetch ChatMessage { id: "@payload.id" })
(render-ui modal { type: "stack", direction: "vertical", gap: "md", children: [{ type: "stack", direction: "horizontal", gap: "sm", align: "center", children: [{ type: "icon", name: "eye", size: "md" }, { type: "typography", variant: "h3", content: "@entity.name" }] }, { type: "divider" }, { type: "stack", direction: "horizontal", gap: "md", children: [{ type: "typography", variant: "caption", content: "Name" }, { type: "typography", variant: "body", content: "@entity.name" }] }, { type: "stack", direction: "horizontal", gap: "md", children: [{ type: "typography", variant: "caption", content: "Description" }, { type: "typography", variant: "body", content: "@entity.description" }] }, { type: "stack", direction: "horizontal", gap: "md", children: [{ type: "typography", variant: "caption", content: "Status" }, { type: "typography", variant: "body", content: "@entity.status" }] }, { type: "stack", direction: "horizontal", gap: "md", children: [{ type: "typography", variant: "caption", content: "Created At" }, { type: "typography", variant: "body", content: "@entity.createdAt" }] }, { type: "divider" }, { type: "stack", direction: "horizontal", gap: "sm", justify: "end", children: [{ type: "button", label: "Close", event: "CLOSE", variant: "ghost" }] }] })
}
state open {
CLOSE -> closed
(render-ui modal null)
(notify Cancelled info)
}
}
page "/chatmessages" -> ChatMessageBrowse, ChatMessageCompose, ChatMessageView
}
Loading preview...

Orbital Visualization

Loading visualization...

Entity Fields

FieldTypeDefault
idstring-
namestring-
descriptionstring-
statusstring"active"
createdAtstring-

States

StateType
browsingInitial

Events

EventPayload
INIT-
COMPOSE-
VIEWid: string
SENDdata: object

Transitions

FromEventToEffects
browsingINITbrowsing2 effects
browsingSENDbrowsing1 effect

Listens

  • [object Object]