Always update body text when editing, it could be changed server-side due to merging

This commit is contained in:
Magnus Hoff 2017-11-21 09:57:59 +01:00
parent 0f835fa312
commit 07c3f4204f
3 changed files with 8 additions and 7 deletions

View file

@ -78,10 +78,8 @@ function openEditor() {
// Update body:
rendered.innerHTML = result.rendered;
if (result.conflict) {
form.elements.title.value = result.title;
form.elements.body.value = result.body;
}
shadow.value = textarea.value = result.body;
// Update form:
form.elements.base_revision.value = result.revision;
@ -94,6 +92,7 @@ function openEditor() {
}
textarea.disabled = false;
autosizeTextarea(textarea, shadow);
if (result.conflict) {
alert("Your edit came into conflict with another change and has not been saved.\n" +

View file

@ -137,7 +137,7 @@ impl Resource for ArticleResource {
slug: &'a str,
revision: i32,
title: &'a str,
body: Option<&'a str>,
body: &'a str,
rendered: &'a str,
last_updated: &'a str,
}
@ -162,7 +162,7 @@ impl Resource for ArticleResource {
slug: &updated.slug,
revision: updated.revision,
title: &updated.title,
body: None,
body: &updated.body,
rendered: &Template {
title: &updated.title,
rendered: render_markdown(&updated.body),
@ -187,7 +187,7 @@ impl Resource for ArticleResource {
slug: &base_article.slug,
revision: base_article.revision,
title: &title,
body: Some(&body),
body: &body,
rendered: &Template {
title: &title,
rendered: render_markdown(&body),

View file

@ -120,6 +120,7 @@ impl Resource for NewArticleResource {
article_id: i32,
revision: i32,
title: &'a str,
body: &'a str,
rendered: &'a str,
last_updated: &'a str,
}
@ -146,6 +147,7 @@ impl Resource for NewArticleResource {
article_id: updated.article_id,
revision: updated.revision,
title: &updated.title,
body: &updated.body,
rendered: &Template {
title: &updated.title,
rendered: render_markdown(&updated.body),