]> uap-core.de Git - note.git/commitdiff
add notebook uidoc
authorOlaf Wintermann <olaf.wintermann@gmail.com>
Thu, 21 May 2026 17:10:56 +0000 (19:10 +0200)
committerOlaf Wintermann <olaf.wintermann@gmail.com>
Thu, 21 May 2026 17:10:56 +0000 (19:10 +0200)
application/src/main.rs
application/src/notebook.rs [new file with mode: 0644]
application/src/window.rs
entity/src/lib.rs
entity/src/note.rs [new file with mode: 0644]

index 4a5620ac9f391f0304c2faebe0997bef0191c644..fe08b483c809e6dc9c2e359e78531ac3af5440fa 100644 (file)
@@ -29,6 +29,7 @@
 mod window;
 mod backend;
 mod newnotebook;
+mod notebook;
 
 use std::env;
 use entity::collection::{create_notebook_hierarchy, Node};
diff --git a/application/src/notebook.rs b/application/src/notebook.rs
new file mode 100644 (file)
index 0000000..80df474
--- /dev/null
@@ -0,0 +1,17 @@
+use ui_rs::{action, ui_actions, UiModel};
+use ui_rs::ui::*;
+
+use entity::note::Model as Note;
+
+#[derive(UiModel, Default)]
+pub struct Notebook {
+    #[bind]
+    pub notes: UiList<Note>
+}
+
+#[ui_actions]
+impl Notebook {
+    pub fn new() -> Self {
+        Default::default()
+    }
+}
index fad873053a0ec6061e6de4add56fa8d83f599391..d1bd531779e4e95d44eb6eb7090c86ed5cc12894 100644 (file)
@@ -32,6 +32,7 @@ use crate::App;
 use entity::collection::{Model as Collection, Node};
 use crate::backend::{BackendHandle, BroadcastMessage};
 use crate::newnotebook::new_notebook_dialog;
+use crate::notebook::Notebook;
 
 #[derive(UiModel)]
 pub struct MainWindow {
@@ -39,6 +40,8 @@ pub struct MainWindow {
 
     pub backend: BackendHandle,
 
+    selected_notebook: Option<UiDoc<Notebook>>,
+
     groups: Vec<Collection>,
 
     #[bind]
@@ -51,6 +54,7 @@ impl MainWindow {
         MainWindow {
             obj: UiObjRef::default(),
             backend: app.backend.clone(),
+            selected_notebook: None,
             groups: Vec::new(),
             notebooks: UiSourceList::default()
         }
@@ -120,6 +124,9 @@ pub fn create_window(app: &App, ctx: &AppContext<MainWindow>) -> UiObject<MainWi
                 b.getvalue(|elm,_row,item|{
                     item.label = Some(elm.name.clone());
                 });
+                b.onactivate(|e|{
+                    
+                });
             });
         });
 
index 8a998bb6cc62b8fe80e51ffa88315e184b3539b1..96fecfd0baabd58330cfc19a2f60a5c9d8debf35 100644 (file)
@@ -1,3 +1,4 @@
 mod prelude;
 pub mod profile;
-pub mod collection;
\ No newline at end of file
+pub mod collection;
+pub mod note;
\ No newline at end of file
diff --git a/entity/src/note.rs b/entity/src/note.rs
new file mode 100644 (file)
index 0000000..8d5bfe1
--- /dev/null
@@ -0,0 +1,29 @@
+use sea_orm::entity::prelude::*;
+
+
+#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
+#[sea_orm(table_name = "note")]
+pub struct Model {
+    #[sea_orm(primary_key)]
+    pub note_id: i32,
+    pub collection_id: i32,
+
+    pub kind: NoteType,
+    pub title: String,
+    pub content: String,
+
+    pub lastmodified: DateTimeWithTimeZone,
+    pub created_at: DateTimeWithTimeZone,
+}
+
+#[derive(EnumIter, DeriveActiveEnum, Clone, Debug, PartialEq)]
+#[sea_orm(rs_type = "i32", db_type = "Integer")]
+pub enum NoteType {
+    PlainTextNote = 0,
+    MDTextNote = 1,
+}
+
+#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
+pub enum Relation {}
+
+impl ActiveModelBehavior for ActiveModel {}