Rename 'published' to 'public' (for recipe)
This commit is contained in:
parent
eaef6dc77e
commit
4f739593b8
20 changed files with 92 additions and 91 deletions
|
|
@ -226,16 +226,16 @@ pub fn setup_page(recipe_id: i64) {
|
|||
.forget();
|
||||
}
|
||||
|
||||
// Is published.
|
||||
// Is public.
|
||||
{
|
||||
let is_published: HtmlInputElement = by_id("input-is-published");
|
||||
EventListener::new(&is_published.clone(), "input", move |_event| {
|
||||
let body = ron_api::SetIsPublished {
|
||||
let is_public: HtmlInputElement = by_id("input-is-public");
|
||||
EventListener::new(&is_public.clone(), "input", move |_event| {
|
||||
let body = ron_api::SetIsPublic {
|
||||
recipe_id,
|
||||
is_published: is_published.checked(),
|
||||
is_public: is_public.checked(),
|
||||
};
|
||||
spawn_local(async move {
|
||||
let _ = request::patch::<(), _>("recipe/is_published", body).await;
|
||||
let _ = request::patch::<(), _>("recipe/is_public", body).await;
|
||||
reload_recipes_list(recipe_id).await;
|
||||
});
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,3 +1,7 @@
|
|||
/// This module provides a simple API for making HTTP requests to the server.
|
||||
/// For requests with a body (POST, PUT, PATCH, etc.), it uses the RON format.
|
||||
/// The RON data structures should come from the `ron_api` module.
|
||||
/// For requests with parameters (GET), it uses the HTML form format.
|
||||
use common::ron_api;
|
||||
use gloo::net::http::{Request, RequestBuilder};
|
||||
use serde::{Serialize, de::DeserializeOwned};
|
||||
|
|
@ -82,6 +86,13 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
/// Sends a request to the server with the given API name and body.
|
||||
/// # Example
|
||||
/// ```rust
|
||||
/// use common::ron_api;
|
||||
/// let body = ron_api::SetLang { lang : "en".to_string() };
|
||||
/// request::put::<(), _>("lang", body).await;
|
||||
/// ```
|
||||
pub async fn put<T, U>(api_name: &str, body: U) -> Result<T>
|
||||
where
|
||||
T: DeserializeOwned,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue