mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 17:56:25 +00:00
feature tag search
This commit is contained in:
@@ -12,8 +12,8 @@ import CSSModules from 'browser/lib/CSSModules'
|
|||||||
|
|
||||||
const TagListItem = (({name, handleClickTagButton}) => {
|
const TagListItem = (({name, handleClickTagButton}) => {
|
||||||
return (
|
return (
|
||||||
<button onClick={handleClickTagButton}>
|
<button onClick={(e) => handleClickTagButton(e, name)}>
|
||||||
{name}
|
{`# ${name}`}
|
||||||
</button>
|
</button>
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -229,7 +229,7 @@ class NoteList extends React.Component {
|
|||||||
let { data, params, location } = this.props
|
let { data, params, location } = this.props
|
||||||
let { router } = this.context
|
let { router } = this.context
|
||||||
|
|
||||||
if (location.pathname.match(/\/home/)) {
|
if (location.pathname.match(/\/home/) || location.pathname.match(/\alltags/)) {
|
||||||
const allNotes = data.noteMap.map((note) => note)
|
const allNotes = data.noteMap.map((note) => note)
|
||||||
this.contextNotes = allNotes
|
this.contextNotes = allNotes
|
||||||
return allNotes
|
return allNotes
|
||||||
@@ -255,6 +255,14 @@ class NoteList extends React.Component {
|
|||||||
return trashedNotes
|
return trashedNotes
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (location.pathname.match(/\/tags/)) {
|
||||||
|
return data.noteMap.map(note => {
|
||||||
|
return note
|
||||||
|
}).filter(note => {
|
||||||
|
return note.tags.includes(params.tagname)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
return this.getContextNotes()
|
return this.getContextNotes()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -454,7 +462,6 @@ class NoteList extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
console.log(this.props)
|
|
||||||
let { location, notes, config, dispatch } = this.props
|
let { location, notes, config, dispatch } = this.props
|
||||||
let sortFunc = config.sortBy === 'CREATED_AT'
|
let sortFunc = config.sortBy === 'CREATED_AT'
|
||||||
? sortByCreatedAt
|
? sortByCreatedAt
|
||||||
|
|||||||
@@ -53,7 +53,6 @@ class SideNav extends React.Component {
|
|||||||
|
|
||||||
SideNavComponent (isFolded, isHomeActive, isStarredActive, isTrashedActive, storageList) {
|
SideNavComponent (isFolded, isHomeActive, isStarredActive, isTrashedActive, storageList) {
|
||||||
let { location, data } = this.props
|
let { location, data } = this.props
|
||||||
console.log(data)
|
|
||||||
let component
|
let component
|
||||||
if (!location.pathname.match('/tags') && !location.pathname.match('/alltags')) {
|
if (!location.pathname.match('/tags') && !location.pathname.match('/alltags')) {
|
||||||
component = (
|
component = (
|
||||||
@@ -85,12 +84,12 @@ class SideNav extends React.Component {
|
|||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
let tagList = data.tagNoteMap.map((tag, key) => {
|
let tagList = data.tagNoteMap.map((tag, key) => {
|
||||||
return `# ${key}`
|
return key
|
||||||
})
|
})
|
||||||
component = (
|
component = (
|
||||||
tagList.map(tag => {
|
tagList.map(tag => {
|
||||||
return (
|
return (
|
||||||
<TagListItem name={tag} handleClickTagButton={(e) => this.handleClickTagButton(e)} />
|
<TagListItem name={tag} handleClickTagButton={this.handleClickTagButton.bind(this)} />
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
@@ -99,8 +98,10 @@ class SideNav extends React.Component {
|
|||||||
return component
|
return component
|
||||||
}
|
}
|
||||||
|
|
||||||
handleClickTagButton (e) {
|
handleClickTagButton (e, name) {
|
||||||
console.log('TAGBUTTON!!!')
|
console.log(name)
|
||||||
|
let { router } = this.context
|
||||||
|
router.push(`/tags/${name}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
|
|||||||
Reference in New Issue
Block a user