mirror of
https://github.com/Nutomic/ibis.git
synced 2024-12-24 13:51:23 +00:00
Redirect to main page after edit (fixes #84)
This commit is contained in:
parent
678ba64fef
commit
96233ba52a
2 changed files with 22 additions and 6 deletions
|
@ -1,5 +1,12 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
common::{newtypes::ConflictId, ApiConflict, ArticleView, EditArticleForm, Notification},
|
common::{
|
||||||
|
newtypes::ConflictId,
|
||||||
|
ApiConflict,
|
||||||
|
ArticleView,
|
||||||
|
EditArticleForm,
|
||||||
|
Notification,
|
||||||
|
MAIN_PAGE_NAME,
|
||||||
|
},
|
||||||
frontend::{
|
frontend::{
|
||||||
api::CLIENT,
|
api::CLIENT,
|
||||||
components::{
|
components::{
|
||||||
|
@ -10,7 +17,7 @@ use crate::{
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use leptos::{html::Textarea, prelude::*};
|
use leptos::{html::Textarea, prelude::*};
|
||||||
use leptos_router::hooks::use_params_map;
|
use leptos_router::{components::Redirect, hooks::use_params_map};
|
||||||
use leptos_use::{use_textarea_autosize, UseTextareaAutosizeReturn};
|
use leptos_use::{use_textarea_autosize, UseTextareaAutosizeReturn};
|
||||||
|
|
||||||
#[derive(Clone, PartialEq)]
|
#[derive(Clone, PartialEq)]
|
||||||
|
@ -176,8 +183,11 @@ pub fn EditArticle() -> impl IntoView {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
|
<Redirect path={
|
||||||
Edit successful!
|
let params = use_params_map();
|
||||||
|
let title = params.get().get("title").clone().unwrap_or(MAIN_PAGE_NAME.to_string());
|
||||||
|
format!("/article/{title}?edit_successful")
|
||||||
|
} />
|
||||||
</Show>
|
</Show>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,10 +4,13 @@ use crate::frontend::{
|
||||||
pages::article_resource,
|
pages::article_resource,
|
||||||
};
|
};
|
||||||
use leptos::prelude::*;
|
use leptos::prelude::*;
|
||||||
|
use leptos_router::hooks::use_query_map;
|
||||||
|
|
||||||
#[component]
|
#[component]
|
||||||
pub fn ReadArticle() -> impl IntoView {
|
pub fn ReadArticle() -> impl IntoView {
|
||||||
let article = article_resource();
|
let article = article_resource();
|
||||||
|
let query = use_query_map();
|
||||||
|
let edit_successful = query.get_untracked().get("edit_successful").is_some();
|
||||||
|
|
||||||
view! {
|
view! {
|
||||||
<ArticleNav article=article active_tab=ActiveTab::Read />
|
<ArticleNav article=article active_tab=ActiveTab::Read />
|
||||||
|
@ -26,8 +29,11 @@ pub fn ReadArticle() -> impl IntoView {
|
||||||
></div>
|
></div>
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}}
|
}} <Show when=move || edit_successful>
|
||||||
|
<div class="toast toast-center">
|
||||||
|
<div class="alert alert-success">Edit successful</div>
|
||||||
|
</div>
|
||||||
|
</Show>
|
||||||
</Suspense>
|
</Suspense>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue