Skip to main content

reinhardt_admin/types/
models.rs

1//! Model information types
2
3use serde::{Deserialize, Serialize};
4
5/// Model information for dashboard
6#[derive(Debug, Clone, Serialize, Deserialize)]
7pub struct ModelInfo {
8	/// Model name
9	pub name: String,
10	/// List URL
11	pub list_url: String,
12}
13
14/// Field metadata for dynamic form generation
15#[derive(Debug, Clone, Serialize, Deserialize)]
16pub struct FieldInfo {
17	/// Field name (e.g., "username", "email")
18	pub name: String,
19	/// Display label (e.g., "Username", "Email Address")
20	pub label: String,
21	/// Field type
22	pub field_type: FieldType,
23	/// Whether the field is required
24	pub required: bool,
25	/// Whether the field is readonly
26	pub readonly: bool,
27	/// Help text displayed below the field
28	pub help_text: Option<String>,
29	/// Placeholder text for input
30	pub placeholder: Option<String>,
31}
32
33/// Field type for form rendering
34#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
35#[serde(tag = "type", content = "options")]
36pub enum FieldType {
37	/// Text input (single line)
38	Text,
39	/// Textarea (multi-line)
40	TextArea,
41	/// Number input
42	Number,
43	/// Boolean checkbox
44	Boolean,
45	/// Email input
46	Email,
47	/// Date input
48	Date,
49	/// DateTime input
50	DateTime,
51	/// Select dropdown with choices
52	Select { choices: Vec<(String, String)> },
53	/// Multiple select
54	MultiSelect { choices: Vec<(String, String)> },
55	/// File upload
56	File,
57	/// Hidden field
58	Hidden,
59}
60
61/// Filter type for UI rendering
62#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
63#[serde(tag = "type", content = "options")]
64pub enum FilterType {
65	/// Boolean filter (Yes/No checkbox)
66	Boolean,
67	/// Choice filter (dropdown with predefined options)
68	Choice { choices: Vec<FilterChoice> },
69	/// Date range filter (predefined ranges like "Today", "Last 7 days")
70	DateRange { ranges: Vec<FilterChoice> },
71	/// Number range filter (predefined ranges)
72	NumberRange { ranges: Vec<FilterChoice> },
73}
74
75/// Filter choice for Choice/DateRange/NumberRange filters
76#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
77pub struct FilterChoice {
78	/// Value to send to API
79	pub value: String,
80	/// Display label for UI
81	pub label: String,
82}
83
84/// Filter metadata sent from backend to frontend
85#[derive(Debug, Clone, Serialize, Deserialize)]
86pub struct FilterInfo {
87	/// Field name (e.g., "status", "is_active")
88	pub field: String,
89	/// Display title (e.g., "Status", "Active")
90	pub title: String,
91	/// Filter type and options
92	pub filter_type: FilterType,
93	/// Current value (if filter is active)
94	pub current_value: Option<String>,
95}
96
97/// Column metadata for list view display
98#[derive(Debug, Clone, Serialize, Deserialize)]
99pub struct ColumnInfo {
100	/// Field name to extract from data
101	pub field: String,
102	/// Display label for column header
103	pub label: String,
104	/// Whether column is sortable
105	pub sortable: bool,
106}