1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-23 06:31:51 +00:00

add Tag filter

This commit is contained in:
Rokt33r
2015-07-25 02:04:27 +09:00
parent 054daac6db
commit 465b315ae0
4 changed files with 18 additions and 9 deletions

View File

@@ -63,7 +63,7 @@ function blueprintFilter (articles) {
function tagFilter (keyword, articles) {
return articles.filter(function (article) {
return article.Tags.some(function (tag) {
return tag.name.match(new RegExp(keyword, 'i'))
return tag.name.match(new RegExp('^' + keyword, 'i'))
})
})
}
@@ -336,6 +336,11 @@ module.exports = React.createClass({
showOnlyBlueprints: function () {
this.setState({search: '$b'})
},
showOnlyWithTag: function (tag) {
return function () {
this.setState({search: '#' + tag})
}.bind(this)
},
openLaunchModal: function () {
this.setState({isLaunchModalOpen: true})
},
@@ -547,9 +552,9 @@ module.exports = React.createClass({
showAll={this.showAll}
showOnlySnippets={this.showOnlySnippets} showOnlyBlueprints={this.showOnlyBlueprints} currentPlanet={this.state.currentPlanet}/>
<PlanetArticleList ref='list' articles={filteredArticles}/>
<PlanetArticleList showOnlyWithTag={this.showOnlyWithTag} ref='list' articles={filteredArticles}/>
<PlanetArticleDetail ref='detail' article={article} onOpenEditModal={this.openEditModal} onOpenDeleteModal={this.openDeleteModal}/>
<PlanetArticleDetail ref='detail' article={article} onOpenEditModal={this.openEditModal} onOpenDeleteModal={this.openDeleteModal} showOnlyWithTag={this.showOnlyWithTag}/>
</div>
)
}