delete pages/spaces
This commit is contained in:
54
src/app.rs
54
src/app.rs
@@ -128,6 +128,51 @@ impl NewPageDialog {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct NewSpaceDialog {
|
||||
pub name: String,
|
||||
pub creating: bool,
|
||||
pub error: Option<String>,
|
||||
}
|
||||
|
||||
impl NewSpaceDialog {
|
||||
pub fn new() -> Self {
|
||||
Self { name: String::new(), creating: false, error: None }
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum DeleteTarget {
|
||||
Space { id: String, name: String },
|
||||
Page { id: String, title: String },
|
||||
}
|
||||
|
||||
impl DeleteTarget {
|
||||
pub fn display_name(&self) -> &str {
|
||||
match self {
|
||||
DeleteTarget::Space { name, .. } => name,
|
||||
DeleteTarget::Page { title, .. } => title,
|
||||
}
|
||||
}
|
||||
pub fn kind(&self) -> &str {
|
||||
match self {
|
||||
DeleteTarget::Space { .. } => "space",
|
||||
DeleteTarget::Page { .. } => "page",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct DeleteConfirmDialog {
|
||||
pub target: DeleteTarget,
|
||||
pub deleting: bool,
|
||||
pub error: Option<String>,
|
||||
}
|
||||
|
||||
impl DeleteConfirmDialog {
|
||||
pub fn new(target: DeleteTarget) -> Self {
|
||||
Self { target, deleting: false, error: None }
|
||||
}
|
||||
}
|
||||
|
||||
pub struct MainView {
|
||||
pub spaces: Vec<Space>,
|
||||
pub pages: Vec<Page>,
|
||||
@@ -139,6 +184,8 @@ pub struct MainView {
|
||||
pub loading_page_content: bool,
|
||||
pub error: Option<String>,
|
||||
pub new_page_dialog: Option<NewPageDialog>,
|
||||
pub new_space_dialog: Option<NewSpaceDialog>,
|
||||
pub delete_dialog: Option<DeleteConfirmDialog>,
|
||||
}
|
||||
|
||||
impl MainView {
|
||||
@@ -154,6 +201,8 @@ impl MainView {
|
||||
loading_page_content: false,
|
||||
error: None,
|
||||
new_page_dialog: None,
|
||||
new_space_dialog: None,
|
||||
delete_dialog: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -267,6 +316,11 @@ pub enum AppMsg {
|
||||
SaveError(String),
|
||||
PageCreated { page_id: String, title: String },
|
||||
CreateError(String),
|
||||
SpaceCreated(Space),
|
||||
CreateSpaceError(String),
|
||||
SpaceDeleted(String),
|
||||
PageDeleted(String),
|
||||
DeleteError(String),
|
||||
SearchResults(Vec<SearchResult>),
|
||||
SearchError(String),
|
||||
ApiError(String),
|
||||
|
||||
Reference in New Issue
Block a user