]> uap-core.de Git - note.git/commitdiff
prepare FileNote actions main
authorOlaf Wintermann <olaf.wintermann@gmail.com>
Tue, 14 Jul 2026 20:03:44 +0000 (22:03 +0200)
committerOlaf Wintermann <olaf.wintermann@gmail.com>
Tue, 14 Jul 2026 20:03:44 +0000 (22:03 +0200)
application/note/src/file.rs

index 916f32075fd5f39ac1a7a57fe78f437dc03df1e7..36068f926f7b946dd8c3f2aee5f3355d189d032f 100644 (file)
@@ -42,10 +42,13 @@ pub struct FileNote {
     pub collection_id: i32,
 
     pub id: NoteId,
-    pub nodename: Option<String>,
+    pub nodename: String,
 
     #[bind("note_type")]
     pub note_type: UiInteger,
+
+    #[bind("note_nodename")]
+    pub note_nodename: UiString,
 }
 
 #[ui_actions]
@@ -58,16 +61,53 @@ impl FileNote {
             collection_id,
 
             id,
-            nodename: None,
+            nodename: String::default(),
 
             note_type: Default::default(),
+            note_nodename: Default::default(),
         }
     }
 
     pub fn into_doc(self, model: &entity::note::Model) -> UiDoc<FileNote> {
         UiDoc::new2(self, |n,d| {
             n.doc = d.doc_ref();
+            n.nodename = model.nodename.clone();
+
             n.note_type.set(NoteTypeTabView::File as i64);
+            n.note_nodename.set(model.nodename.as_str());
         })
     }
+
+    #[action]
+    pub fn open_extern(&mut self, _event: &ActionEvent) {
+        // TODO: request open from backend
+    }
+
+    #[action]
+    pub fn save(&mut self, _event: &ActionEvent) {
+        self.save_note();
+    }
+
+    pub fn save_note(&mut self) {
+        // TODO
+    }
+
+    #[action]
+    pub fn notebook_view_changed(&mut self, event: &mut ActionEvent) {
+        // TODO: duplicated code in note.rs
+        //       maybe move this code to the notebook
+
+        // This action is for the toolbar button, to change the notebook view
+        // (dual view or maximized note), however, the view status variable is stored
+        // in the notebook.
+        let Some(obj) = &mut event.obj else {
+            return;
+        };
+        let Some(doc) = self.doc.get_doc() else {
+            return;
+        };
+
+        obj.splitview_set_visible(0, event.intval == 0);
+        doc.ctx.set_state(AppStates::NoteMaximized as i32);
+    }
 }