Files
metabuilder/packages/admin_dialog/seed/scripts/user.lua
JohnDoe6345789 bf1401fe34 Enhance module definitions and add type annotations across various packages
- Added type annotations and class definitions in the dashboard layout, stats, and data table modules for improved type safety and documentation.
- Introduced new classes for UI components, props, and configuration in the form builder, navigation menu, notification center, and UI dialogs packages.
- Implemented detailed type definitions for actions, fields, and pagination components to streamline usage and enhance clarity.
- Updated initialization functions in multiple packages to include versioning and installation context.
- Improved structure and readability of the codebase by organizing and documenting component properties and methods.
2025-12-30 10:21:33 +00:00

53 lines
1.5 KiB
Lua

-- User management dialog
---@class UserDialog
local M = {}
---@class User
---@field username string
---@field email string
---@field role string
---@field active boolean
---@class UIComponent
---@field type string
---@field props? table
---@field children? table
---@return UIComponent
function M.render_create()
return {
type = "dialog",
props = {
title = "Create User",
size = "medium"
},
children = {
{ type = "text_field", props = { label = "Username", name = "username", required = true } },
{ type = "text_field", props = { label = "Email", name = "email", type = "email", required = true } },
{ type = "password_field", props = { label = "Password", name = "password", required = true } },
{ type = "select", props = { label = "Role", name = "role", options = {"user", "admin"} } }
}
}
end
---@param user User
---@return UIComponent
function M.render_edit(user)
return {
type = "dialog",
props = {
title = "Edit User",
size = "medium"
},
children = {
{ type = "text_field", props = { label = "Username", name = "username", value = user.username } },
{ type = "text_field", props = { label = "Email", name = "email", value = user.email } },
{ type = "select", props = { label = "Role", name = "role", value = user.role, options = {"user", "admin"} } },
{ type = "checkbox", props = { label = "Active", name = "active", checked = user.active } }
}
}
end
return M