Skip to content

Commit

Permalink
[feat]: update
Browse files Browse the repository at this point in the history
  • Loading branch information
pizn committed Feb 4, 2016
1 parent f89ee60 commit 8571e76
Show file tree
Hide file tree
Showing 2 changed files with 105 additions and 11 deletions.
102 changes: 93 additions & 9 deletions src/components/Post/Meta.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class MetaForm extends Component {
modalVisible: PropTypes.bool,
modalHandleOk: PropTypes.func,
modalHandleCancel: PropTypes.func,
metaData: PropTypes.string,
metaData: PropTypes.object,
form: PropTypes.object,
}

Expand Down Expand Up @@ -45,23 +45,107 @@ class MetaForm extends Component {
]}
>
<Form horizontal>
<FormItem
label="Title:"
labelCol={{ span: 6 }}
wrapperCol={{ span: 14 }}
validateStatus={getFieldError('title') ? 'error' : 'success'}
>
<Input type="text" name="title" autoComplete="off" placeholder="title"
{...getFieldProps('title', {
initialValue: metaData.title,
rules: [{
type: 'string',
required: true,
message: 'Please input the title',
},
] })
}
/>
<Col span="24">
<p className="ant-form-explain">{getFieldError('title') ? getFieldError('title').join('') : ''}</p>
</Col>
</FormItem>
<FormItem
label="Layout:"
labelCol={{ span: 6 }}
wrapperCol={{ span: 14 }}
validateStatus={getFieldError('layout') ? 'error' : 'success'}
>
<Input type="text" name="layout" autoComplete="off" placeholder="post"
{...getFieldProps('layout', {
initialValue: metaData.layout,
rules: [{
type: 'string',
required: true,
message: 'Please input the layout',
},
] })
}
/>
<Col span="24">
<p className="ant-form-explain">{getFieldError('layout') ? getFieldError('layout').join('') : ''}</p>
</Col>
</FormItem>
<FormItem
label="Description:"
labelCol={{ span: 6 }}
wrapperCol={{ span: 14 }}
validateStatus={getFieldError('description') ? 'error' : 'success'}
>
<Input type="textarea" name="description" autoComplete="off" rows="3"
{...getFieldProps('description', {
initialValue: metaData.description,
rules: [{
type: 'string',
required: true,
message: 'Please input the description',
},
] })
}
/>
<Col span="24">
<p className="ant-form-explain">{getFieldError('description') ? getFieldError('description').join('') : ''}</p>
</Col>
</FormItem>
<FormItem
wrapperCol={{ span: 24 }}
validateStatus={getFieldError('meta') ? 'error' : 'success'}
label="Categories:"
labelCol={{ span: 6 }}
wrapperCol={{ span: 14 }}
validateStatus={getFieldError('categories') ? 'error' : 'success'}
>
<Input type="textarea" name="meta" rows="8" autoComplete="off"
{...getFieldProps('meta', {
initialValue: metaData,
<Input type="textarea" name="categories" autoComplete="off" rows="2"
{...getFieldProps('categories', {
initialValue: metaData.categories,
rules: [{
type: 'string',
required: true,
message: 'Please input the meta info',
message: 'Please input the categories',
},
] })
}
/>
<Col span="24">
<p className="ant-form-explain">{getFieldError('categories') ? getFieldError('categories').join('') : ''}</p>
</Col>
</FormItem>
<FormItem
label="Tags:"
labelCol={{ span: 6 }}
wrapperCol={{ span: 14 }}
validateStatus={getFieldError('tags') ? 'error' : 'success'}
>
<Input type="textarea" name="tags" autoComplete="off" rows="2"
{...getFieldProps('tags', {
initialValue: metaData.tags,
rules: [{
type: 'string',
message: 'Please input the tags',
},
] })
}
/>
<Col span="24">
<p className="ant-form-explain">{getFieldError('meta') ? getFieldError('meta').join('') : ''}</p>
<p className="ant-form-explain">{getFieldError('tags') ? getFieldError('tags').join('') : ''}</p>
</Col>
</FormItem>
</Form>
Expand Down
14 changes: 12 additions & 2 deletions src/containers/Post.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,17 @@ class Post extends Component {
this.setState({
editMeta: false,
});
this.handleSaveMeta(data.meta);
let tmpData = '---\n' +
'layout: ' + data.layout + '\n' +
'title: ' + data.title + '\n' +
'description: ' + data.description + '\n';
if (data.categories) {
tmpData += 'categories: ' + data.categories + '\n';
}
if (data.tags) {
tmpData += 'tags: ' + data.tags + '\n';
}
this.handleSaveMeta(tmpData);
}

handleEditMetaCancel() {
Expand Down Expand Up @@ -264,7 +274,7 @@ class Post extends Component {
handleSave={this.handleSaveCnt.bind(this)}
/>
<MetaForm
metaData={this.state.head}
metaData={this.state.meta}
modalVisible={this.state.editMeta}
modalHandleOk={this.handleEditMetaSubmit.bind(this)}
modalHandleCancel={this.handleEditMetaCancel.bind(this)}
Expand Down

0 comments on commit 8571e76

Please sign in to comment.