1
0
Fork 0
mirror of https://github.com/Nutomic/ibis.git synced 2024-11-25 22:11:10 +00:00

Minor changes to create/edit article page (fixes #24)

This commit is contained in:
Felix Ableitner 2024-03-14 10:11:32 +01:00
parent 0ccfe062e7
commit a057f00e24
2 changed files with 33 additions and 30 deletions

View file

@ -61,25 +61,26 @@ pub fn CreateArticle() -> impl IntoView {
set_text.update(|p| *p = val); set_text.update(|p| *p = val);
} > } >
</textarea> </textarea>
<div><a href="https://commonmark.org/help/" target="blank_">Markdown</a>" formatting is supported"</div>
{move || {
create_error
.get()
.map(|err| {
view! { <p style="color:red;">{err}</p> }
})
}}
<input type="text"
placeholder="Edit summary"
on:keyup=move |ev| {
let val = event_target_value(&ev);
set_summary.update(|p| *p = val);
}/>
<button
prop:disabled=move || button_is_disabled.get()
on:click=move |_| submit_action.dispatch((title.get(), text.get(), summary.get()))>
Submit
</button>
</div> </div>
{move || {
create_error
.get()
.map(|err| {
view! { <p style="color:red;">{err}</p> }
})
}}
<input type="text"
placeholder="Summary"
on:keyup=move |ev| {
let val = event_target_value(&ev);
set_summary.update(|p| *p = val);
}/>
<button
prop:disabled=move || button_is_disabled.get()
on:click=move |_| submit_action.dispatch((title.get(), text.get(), summary.get()))>
Submit
</button>
} }
}> }>
<Redirect path={format!("/article/{}", title.get().replace(' ', "_"))} /> <Redirect path={format!("/article/{}", title.get().replace(' ', "_"))} />

View file

@ -113,6 +113,7 @@ pub fn EditArticle() -> impl IntoView {
} }
// set initial text, otherwise submit with no changes results in empty text // set initial text, otherwise submit with no changes results in empty text
set_text.set(article.article.text.clone()); set_text.set(article.article.text.clone());
let article_ = article.clone();
view! { view! {
<div class="item-view"> <div class="item-view">
<h1>{article_title(&article.article)}</h1> <h1>{article_title(&article.article)}</h1>
@ -129,19 +130,20 @@ pub fn EditArticle() -> impl IntoView {
}> }>
{article.article.text.clone()} {article.article.text.clone()}
</textarea> </textarea>
<div><a href="https://commonmark.org/help/" target="blank_">Markdown</a>" formatting is supported"</div>
<input type="text"
placeholder="Edit summary"
value={summary.get_untracked()}
on:keyup=move |ev| {
let val = event_target_value(&ev);
set_summary.update(|p| *p = val);
}/>
<button
prop:disabled=move || button_is_disabled.get()
on:click=move |_| submit_action.dispatch((text.get(), summary.get(), article_.clone(), edit_response.get()))>
Submit
</button>
</div> </div>
<input type="text"
placeholder="Summary"
value={summary.get_untracked()}
on:keyup=move |ev| {
let val = event_target_value(&ev);
set_summary.update(|p| *p = val);
}/>
<button
prop:disabled=move || button_is_disabled.get()
on:click=move |_| submit_action.dispatch((text.get(), summary.get(), article.clone(), edit_response.get()))>
Submit
</button>
} }
}) })
} }