From faede4821792a48e727c1fba2cc3bf26b0674652 Mon Sep 17 00:00:00 2001 From: Sosuke Suzuki Date: Sat, 30 Sep 2017 16:59:03 +0900 Subject: [PATCH] feature tag search --- browser/components/TagListItem.js | 4 ++-- browser/main/NoteList/index.js | 11 +++++++++-- browser/main/SideNav/index.js | 11 ++++++----- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/browser/components/TagListItem.js b/browser/components/TagListItem.js index bd7a0f07..14a0321a 100644 --- a/browser/components/TagListItem.js +++ b/browser/components/TagListItem.js @@ -12,8 +12,8 @@ import CSSModules from 'browser/lib/CSSModules' const TagListItem = (({name, handleClickTagButton}) => { return ( - ) }) diff --git a/browser/main/NoteList/index.js b/browser/main/NoteList/index.js index 03ab6906..feee7343 100644 --- a/browser/main/NoteList/index.js +++ b/browser/main/NoteList/index.js @@ -229,7 +229,7 @@ class NoteList extends React.Component { let { data, params, location } = this.props 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) this.contextNotes = allNotes return allNotes @@ -255,6 +255,14 @@ class NoteList extends React.Component { 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() } @@ -454,7 +462,6 @@ class NoteList extends React.Component { } render () { - console.log(this.props) let { location, notes, config, dispatch } = this.props let sortFunc = config.sortBy === 'CREATED_AT' ? sortByCreatedAt diff --git a/browser/main/SideNav/index.js b/browser/main/SideNav/index.js index 10231aa0..617c9680 100644 --- a/browser/main/SideNav/index.js +++ b/browser/main/SideNav/index.js @@ -53,7 +53,6 @@ class SideNav extends React.Component { SideNavComponent (isFolded, isHomeActive, isStarredActive, isTrashedActive, storageList) { let { location, data } = this.props - console.log(data) let component if (!location.pathname.match('/tags') && !location.pathname.match('/alltags')) { component = ( @@ -85,12 +84,12 @@ class SideNav extends React.Component { ) } else { let tagList = data.tagNoteMap.map((tag, key) => { - return `# ${key}` + return key }) component = ( tagList.map(tag => { return ( - this.handleClickTagButton(e)} /> + ) }) ) @@ -99,8 +98,10 @@ class SideNav extends React.Component { return component } - handleClickTagButton (e) { - console.log('TAGBUTTON!!!') + handleClickTagButton (e, name) { + console.log(name) + let { router } = this.context + router.push(`/tags/${name}`) } render () {