Skip to content

Commit 2bbb5ef

Browse files
committed
articleのタイトルの基本タイトル追加 / 何も書かれていない時にUntitled labelをだす
1 parent 91eb7fe commit 2bbb5ef

3 files changed

Lines changed: 21 additions & 2 deletions

File tree

browser/main/HomePage/ArticleDetail.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,9 @@ export default class ArticleDetail extends React.Component {
267267
newArticle.updatedAt = new Date()
268268
if (newArticle.createdAt == null) {
269269
newArticle.createdAt = new Date()
270+
if (newArticle.title.trim().length === 0) {
271+
newArticle.title = `Created at ${moment(newArticle.createdAt).format('YYYY/MM/DD HH:mm')}`
272+
}
270273
activityRecord.emit('ARTICLE_CREATE')
271274
} else {
272275
activityRecord.emit('ARTICLE_UPDATE')
@@ -464,7 +467,15 @@ export default class ArticleDetail extends React.Component {
464467
<div className='detailPanel'>
465468
<div className='header'>
466469
<div className='title'>
467-
<input onKeyDown={e => this.handleTitleKeyDown(e)} placeholder='Title' ref='title' value={this.state.article.title} onChange={e => this.handleTitleChange(e)}/>
470+
<input
471+
onKeyDown={e => this.handleTitleKeyDown(e)}
472+
placeholder={this.state.article.createdAt == null
473+
? `Created at ${moment().format('YYYY/MM/DD HH:mm')}`
474+
: 'Title'}
475+
ref='title'
476+
value={this.state.article.title}
477+
onChange={e => this.handleTitleChange(e)}
478+
/>
468479
</div>
469480
<ModeSelect
470481
ref='mode'

browser/main/HomePage/ArticleList.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,12 @@ export default class ArticleList extends React.Component {
8080
: (<span>Not tagged yet</span>)
8181
let folder = _.findWhere(folders, {key: article.FolderKey})
8282

83+
let title = article.status !== NEW
84+
? article.title.trim().length === 0
85+
? <small>(Untitled)</small>
86+
: article.title
87+
: '(New article)'
88+
8389
return (
8490
<div key={'article-' + article.key}>
8591
<div onClick={e => this.handleArticleClick(article)(e)} className={'articleItem' + (activeArticle.key === article.key ? ' active' : '')}>
@@ -91,7 +97,7 @@ export default class ArticleList extends React.Component {
9197
<span className='updatedAt'>{article.status != null ? article.status : moment(article.updatedAt).fromNow()}</span>
9298
</div>
9399
<div className='middle'>
94-
<ModeIcon className='mode' mode={article.mode}/> <div className='title'>{article.status !== NEW ? article.title : '(New article)'}</div>
100+
<ModeIcon className='mode' mode={article.mode}/> <div className='title'>{title}</div>
95101
</div>
96102
<div className='bottom'>
97103
<div className='tags'><i className='fa fa-fw fa-tags'/>{tagElements}</div>

browser/styles/main/HomeContainer/components/ArticleList.styl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ articleItemColor = #777
4848
left 19px
4949
right 0
5050
overflow ellipsis
51+
small
52+
color #AAA
5153
.bottom
5254
padding 5px 0
5355
overflow-x auto

0 commit comments

Comments
 (0)