working prototype
This commit is contained in:
110
src/model.rs
Normal file
110
src/model.rs
Normal file
@@ -0,0 +1,110 @@
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct Item {
|
||||
pub id: i64,
|
||||
pub text: String,
|
||||
pub note: String,
|
||||
pub priority: i64,
|
||||
pub when_at: Option<String>,
|
||||
pub done_at: Option<String>,
|
||||
pub alarm_at: Option<String>,
|
||||
pub numeric_value: Option<f64>,
|
||||
pub recurrence: String,
|
||||
pub created_at: String,
|
||||
pub updated_at: String,
|
||||
pub discarded: bool,
|
||||
pub categories: Vec<Category>,
|
||||
}
|
||||
|
||||
impl Item {
|
||||
pub fn category_names(&self) -> String {
|
||||
self.categories
|
||||
.iter()
|
||||
.map(|c| c.name.as_str())
|
||||
.collect::<Vec<_>>()
|
||||
.join(", ")
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct Category {
|
||||
pub id: i64,
|
||||
pub name: String,
|
||||
pub parent_id: Option<i64>,
|
||||
pub kind: String,
|
||||
pub match_text: String,
|
||||
pub exclusive: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct ViewDef {
|
||||
pub id: i64,
|
||||
pub name: String,
|
||||
pub kind: String,
|
||||
pub filter_value: String,
|
||||
pub sort_key: String,
|
||||
pub show_done: bool,
|
||||
pub filter_expr: String,
|
||||
pub columns: Vec<ViewColumn>,
|
||||
pub sections: Vec<ViewSection>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct ViewColumn {
|
||||
pub field: String,
|
||||
pub heading: String,
|
||||
pub width: u16,
|
||||
pub aggregate: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct ViewSection {
|
||||
pub id: i64,
|
||||
pub heading: String,
|
||||
pub filter_expr: String,
|
||||
pub collapsed: bool,
|
||||
}
|
||||
|
||||
impl ViewDef {
|
||||
pub fn columns_spec(&self) -> String {
|
||||
self.columns
|
||||
.iter()
|
||||
.map(|c| format!("{}:{}:{}:{}", c.field, c.width, c.heading, c.aggregate))
|
||||
.collect::<Vec<_>>()
|
||||
.join(",")
|
||||
}
|
||||
pub fn sections_spec(&self) -> String {
|
||||
self.sections
|
||||
.iter()
|
||||
.map(|s| {
|
||||
format!(
|
||||
"{}|{}{}",
|
||||
s.heading,
|
||||
s.filter_expr,
|
||||
if s.collapsed { "|collapsed" } else { "" }
|
||||
)
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
.join(";")
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct CategoryRule {
|
||||
pub id: i64,
|
||||
pub category_id: i64,
|
||||
pub condition_expr: String,
|
||||
pub action_kind: String,
|
||||
pub action_value: String,
|
||||
pub enabled: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Default)]
|
||||
pub struct ItemChanges {
|
||||
pub text: Option<String>,
|
||||
pub note: Option<String>,
|
||||
pub priority: Option<i64>,
|
||||
pub when_at: Option<Option<String>>,
|
||||
pub alarm_at: Option<Option<String>>,
|
||||
pub numeric_value: Option<Option<f64>>,
|
||||
pub recurrence: Option<String>,
|
||||
}
|
||||
Reference in New Issue
Block a user