menu.item("Rename").action("note_rename").create();
menu.item("Delete").action("note_delete").create();
menu.item("Edit Title").action("note_edit_title").create();
+ menu.separator();
+ menu.item("Show Trash").action("show_trash").create();
});
}
menu.item("Rename").action("note_rename").create();
menu.item("Delete").action("delete_note").create();
menu.item("Edit Title").action("note_edit_title").create();
+ menu.separator();
+ menu.item("Show Trash").action("show_trash").create();
});
}
selected_notebook: Option<UiDoc<Notebook>>,
groups: Vec<Collection>,
+ trash: Option<NotebookItem>,
#[bind]
notebooks: UiSourceList<NotebookItem>
navigation: Navigation::default(),
selected_notebook: None,
groups: Vec::new(),
+ trash: None,
notebooks: UiSourceList::default()
}
}
}
}
+ #[action]
+ pub fn show_trash(&mut self, _event: &ActionEvent) {
+ let Some(mut obj) = self.obj.get_object() else {
+ return;
+ };
+
+ if let Some(trash) = &mut self.trash {
+ let nav = NavigationItem { collection_id: trash.data.collection_id, ..Default::default() };
+ // detach current notebook
+ if let Some(current) = &self.selected_notebook {
+ current.ctx.call_action("save");
+ obj.ctx.detach(current);
+ }
+
+ let notebook_doc = trash.get_doc(&self.backend);
+ obj.splitview_set_visible(0, true);
+ obj.ctx.attach(¬ebook_doc);
+ self.selected_notebook = Some(notebook_doc);
+ //e.obj.splitview_set_visible(0, !nav.note_maximized);
+
+ self.navigation.push(nav);
+ }
+ }
+
pub fn do_nav(&mut self, direction: NavDirection) -> Option<()> {
let nav = match direction {
NavDirection::Forward => self.navigation.go_forward(),
for elm in nodes.iter() {
if elm.collection.kind == CollectionType::Trash {
- // TODO: add to trash list
+ let trash = NotebookItem::from_model(elm.collection.clone());
+ self.trash = Some(trash);
continue;
}