pub local_path: Option<PathBuf>,
pub is_tmp_file: bool,
pub is_opening: bool,
+ pub read_only: bool,
#[bind("note_type")]
pub note_type: UiInteger,
local_path: None,
is_tmp_file: false,
is_opening: false,
+ read_only: false,
note_type: Default::default(),
preview_tab: Default::default(),
}
}
- pub fn into_doc(self, model: &entity::note::Model) -> UiDoc<dyn NoteViewModel> {
+ pub fn into_doc(self, model: &entity::note::Model, readonly: bool) -> UiDoc<dyn NoteViewModel> {
let doc: UiDoc<FileNote> = UiDoc::new_from_box2(Box::new(self), |n,d| {
n.doc = d.doc_ref();
n.nodename = model.nodename.clone();
n.content_type = model.content_type.clone();
+ n.read_only = readonly;
n.note_type.set(NoteTypeTabView::File as i64);
n.note_nodename.set(model.nodename.as_str());
NoteShowExtModInfo,
NoteMaximized,
NoteTitleInput,
+ NoteEditable,
}
impl From<AppStates> for i32 {
modified: bool,
is_saving: bool,
fixed_title: bool,
+ read_only: bool,
pub local_path: Option<PathBuf>,
pub local_lastmodified: Option<SystemTime>,
modified: false,
is_saving: false,
fixed_title: false,
+ read_only: false,
local_path: None,
local_lastmodified: None,
}
}
- pub fn into_doc(self, model: &entity::note::Model) -> UiDoc<dyn NoteViewModel> {
+ pub fn into_doc(self, model: &entity::note::Model, readonly: bool) -> UiDoc<dyn NoteViewModel> {
let doc: UiDoc<Note> = UiDoc::new_from_box2(Box::new(self), |n,d| {
n.doc = d.doc_ref();
+ n.read_only = readonly;
if n.id.is_new() {
n.init_new();
d.ctx.suppress_state(AppStates::NoteEnableNew);
}
// make sure we receive an event, when this note is attached or detached
d.ctx.on_attachment_status_change_action("attachment_status_changed");
+
+ if readonly {
+ n.text.set_readonly(true);
+ d.ctx.suppress_state(AppStates::NoteEditable);
+ }
});
doc_cast!(doc, dyn NoteViewModel)
}
pub instance_id: u64,
pub broadcast_rx: tokio::sync::broadcast::Receiver<BroadcastMessage>,
pub collection_id: i32,
+ pub read_only: bool,
pub selected_note: Option<NoteSelection>,
instance_id: INSTANCE_ID.fetch_add(1, std::sync::atomic::Ordering::Relaxed),
broadcast_rx: backend.btx.subscribe(),
collection_id: id,
+ read_only: false,
selected_note: None,
note_maximized: Default::default(),
notes: Default::default()
match note.data.kind {
NoteType::File => {
let note_data = crate::file::FileNote::new(self.instance_id, note.id.clone(), self.collection_id, self.backend.clone());
- note_data.into_doc(¬e.data)
+ note_data.into_doc(¬e.data, self.read_only)
},
_ => {
// default: text note (plain text or md)
let note_data = crate::note::Note::new(self.instance_id, note.id.clone(), self.collection_id, self.backend.clone());
- note_data.into_doc(¬e.data)
+ note_data.into_doc(¬e.data, self.read_only)
}
}
};
pub fn show_trash(&mut self, _event: &ActionEvent) {
let (doc, nav) = if let Some(trash) = &mut self.trash {
let nav = NavigationItem { collection_id: trash.data.collection_id, ..Default::default() };
- let notebook_doc = trash.get_doc(&self.backend);
+ let mut notebook = Notebook::new(trash.data.collection_id, &self.backend);
+ notebook.read_only = true;
+ let notebook_doc = notebook.into_doc();
(notebook_doc, nav)
} else {
return;
init_window_data(data, app);
data.obj = obj.obj_ref();
- // this state is basically always set, however there are some situations, where
- // it is suppressed
+ // These states are basically always set, however there are some situations, where
+ // they are suppressed (for example by a note)
obj.ctx.set_state(AppStates::NoteEnableNew);
+ obj.ctx.set_state(AppStates::NoteEditable);
obj.sidebar().create(|obj|{
sourcelist!(obj,