+use std::rc::Rc;
use sea_orm::prelude::DateTimeWithTimeZone;
use sea_orm::sea_query::prelude::Utc;
use sea_orm::{NotSet, Set};
use crate::backend::BackendHandle;
use crate::window::NoteTypeTabView;
-#[derive(UiModel, Default)]
+#[derive(UiModel)]
pub struct Note {
+ pub backend: Rc<BackendHandle>,
+
+ pub collection_id: i32,
pub note_id: i32,
pub content_id: i32,
#[ui_actions]
impl Note {
+ pub fn new(collection_id: i32, backend: Rc<BackendHandle>) -> Self {
+ Note {
+ backend: backend,
+ collection_id: collection_id,
+
+ note_id: 0,
+ content_id: 0,
+ kind: NoteType::PlainTextNote,
+ created: Default::default(),
+ title_start: -1,
+ title_end: -1,
+
+ note_type: Default::default(),
+ text: Default::default(),
+ }
+ }
+
pub fn init_from_model(&mut self, model: &entity::note::Model) {
self.note_id = model.note_id;
use ui_rs::ui::*;
use entity::note::{Model as Note};
-use crate::backend::BackendHandle;
+use crate::backend::{BackendHandle, BroadcastMessage};
#[derive(UiModel)]
pub struct Notebook {
pub doc_ref: UiDocRef<Notebook>,
pub backend: Rc<BackendHandle>,
+ pub broadcast_rx: tokio::sync::broadcast::Receiver<BroadcastMessage>,
pub collection_id: i32,
pub selected_note: Option<UiDoc<crate::note::Note>>,
Notebook {
doc_ref: Default::default(),
backend: Rc::new(backend.clone()),
+ broadcast_rx: backend.btx.subscribe(),
collection_id: id,
selected_note: None,
notes: Default::default()
self.selected_note = None;
// Create the new note
- let note_data: crate::note::Note = Default::default();
+ let note_data = crate::note::Note::new(self.collection_id, self.backend.clone());
// Create the note document object
let note_doc = UiDoc::new2(note_data, |n,d| {
}
}
}
+
+ #[action]
+ pub fn message(&mut self, _event: &ActionEvent) {
+ while let Ok(msg) = self.broadcast_rx.try_recv() {
+ match msg {
+ _ => {
+
+ },
+ }
+ }
+ }
}
pub fn notelist_getvalue<'a>(elm: &Note, col: i32, _row: i32) -> ListValue<'a> {