Fix article submission clone bug (#4505)
This commit is contained in:
parent
0d2506f9ef
commit
7cd279f3e1
2 changed files with 26 additions and 1 deletions
|
|
@ -18,6 +18,20 @@ export function previewArticle(payload, successCb, failureCb) {
|
|||
|
||||
export function getArticle() {}
|
||||
|
||||
function processPayload(payload) {
|
||||
const {
|
||||
previewShowing,
|
||||
helpShowing,
|
||||
previewResponse,
|
||||
helpHTML,
|
||||
imageManagementShowing,
|
||||
moreConfigShowing,
|
||||
errors,
|
||||
...neededPayload
|
||||
} = payload;
|
||||
return neededPayload;
|
||||
}
|
||||
|
||||
export function submitArticle(payload, clearStorage, errorCb, failureCb) {
|
||||
const method = payload.id ? 'PUT' : 'POST';
|
||||
const url = payload.id ? `/articles/${payload.id}` : '/articles';
|
||||
|
|
@ -29,7 +43,7 @@ export function submitArticle(payload, clearStorage, errorCb, failureCb) {
|
|||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({
|
||||
article: payload,
|
||||
article: processPayload(payload),
|
||||
}),
|
||||
credentials: 'same-origin',
|
||||
})
|
||||
|
|
|
|||
|
|
@ -83,8 +83,13 @@ export default class ArticleForm extends Component {
|
|||
this.url = window.location.href;
|
||||
|
||||
this.state = {
|
||||
id: this.article.id || null,
|
||||
title: this.article.title || '',
|
||||
tagList: this.article.cached_tag_list || '',
|
||||
description: '',
|
||||
canonicalUrl: this.article.canonical_url || '',
|
||||
series:this.state.series || '',
|
||||
allSeries: this.article.all_series || [],
|
||||
bodyMarkdown: this.article.body_markdown || '',
|
||||
published: this.article.published || false,
|
||||
previewShowing: false,
|
||||
|
|
@ -92,6 +97,7 @@ export default class ArticleForm extends Component {
|
|||
previewResponse: '',
|
||||
helpHTML: document.getElementById('editor-help-guide').innerHTML,
|
||||
submitting: false,
|
||||
editing: this.article.id !== null,
|
||||
imageManagementShowing: false,
|
||||
moreConfigShowing: false,
|
||||
mainImage: this.article.main_image || null,
|
||||
|
|
@ -284,6 +290,10 @@ export default class ArticleForm extends Component {
|
|||
this.setState({
|
||||
title: this.article.title || '',
|
||||
tagList: this.article.cached_tag_list || '',
|
||||
description: '',
|
||||
canonicalUrl: this.article.canonical_url || '',
|
||||
series:this.state.series || '',
|
||||
allSeries: this.article.all_series || [],
|
||||
bodyMarkdown: this.article.body_markdown || '',
|
||||
published: this.article.published || false,
|
||||
previewShowing: false,
|
||||
|
|
@ -291,6 +301,7 @@ export default class ArticleForm extends Component {
|
|||
previewResponse: '',
|
||||
helpHTML: document.getElementById('editor-help-guide').innerHTML,
|
||||
submitting: false,
|
||||
editing: this.artical.id !== null,
|
||||
imageManagementShowing: false,
|
||||
moreConfigShowing: false,
|
||||
mainImage: this.article.main_image || null,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue