1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-13 17:56:25 +00:00

フォルダーで検索するときに in:じゃなくて /にする +バグ修正

This commit is contained in:
Rokt33r
2015-11-15 00:57:29 +09:00
parent ef84c4e3da
commit 41e1630aac
5 changed files with 15 additions and 14 deletions

View File

@@ -119,9 +119,9 @@ FinderMain.propTypes = {
function remap (state) { function remap (state) {
let { articles, folders, status } = state let { articles, folders, status } = state
let filters = status.search.split(' ').map(key => key.trim()).filter(key => key.length > 0 && !key.match(/^#$/)).map(key => { let filters = status.search.split(' ').map(key => key.trim()).filter(key => key.length > 0 && !key.match(/^\/$/) && !key.match(/^#$/)).map(key => {
if (key.match(/^in:.+$/)) { if (key.match(/^\/.+$/)) {
return {type: FOLDER_FILTER, value: key.match(/^in:(.+)$/)[1]} return {type: FOLDER_FILTER, value: key.match(/^\/(.+)$/)[1]}
} }
if (key.match(/^#(.+)/)) { if (key.match(/^#(.+)/)) {
return {type: TAG_FILTER, value: key.match(/^#(.+)$/)[1]} return {type: TAG_FILTER, value: key.match(/^#(.+)$/)[1]}
@@ -134,7 +134,7 @@ function remap (state) {
if (folders != null) { if (folders != null) {
let targetFolders = folders.filter(folder => { let targetFolders = folders.filter(folder => {
return _.findWhere(folderFilters, {value: folder.name}) return _.find(folderFilters, filter => folder.name.match(new RegExp(`^${filter.value}`)))
}) })
status.targetFolders = targetFolders status.targetFolders = targetFolders
@@ -164,6 +164,7 @@ function remap (state) {
let activeArticle = _.findWhere(articles, {key: status.articleKey}) let activeArticle = _.findWhere(articles, {key: status.articleKey})
if (activeArticle == null) activeArticle = articles[0] if (activeArticle == null) activeArticle = articles[0]
console.log(status.search)
return { return {
articles, articles,
activeArticle, activeArticle,

View File

@@ -14,10 +14,10 @@ function status (state = initialStatus, action) {
switch (action.type) { switch (action.type) {
case SELECT_ARTICLE: case SELECT_ARTICLE:
state.articleKey = action.data.key state.articleKey = action.data.key
return state return Object.assign({}, state)
case SEARCH_ARTICLE: case SEARCH_ARTICLE:
state.search = action.data.input state.search = action.data.input
return state return Object.assign({}, state)
default: default:
return state return state
} }

View File

@@ -143,9 +143,9 @@ function remap (state) {
}) })
// Filter articles // Filter articles
let filters = status.search.split(' ').map(key => key.trim()).filter(key => key.length > 0 && !key.match(/^#$/)).map(key => { let filters = status.search.split(' ').map(key => key.trim()).filter(key => key.length > 0 && !key.match(/^\/$/) && !key.match(/^#$/)).map(key => {
if (key.match(/^in:.+$/)) { if (key.match(/^\/.+/)) {
return {type: FOLDER_FILTER, value: key.match(/^in:(.+)$/)[1]} return {type: FOLDER_FILTER, value: key.match(/^\/(.+)$/)[1]}
} }
if (key.match(/^#(.+)/)) { if (key.match(/^#(.+)/)) {
return {type: TAG_FILTER, value: key.match(/^#(.+)$/)[1]} return {type: TAG_FILTER, value: key.match(/^#(.+)$/)[1]}
@@ -158,7 +158,7 @@ function remap (state) {
if (folders != null) { if (folders != null) {
let targetFolders = folders.filter(folder => { let targetFolders = folders.filter(folder => {
return _.findWhere(folderFilters, {value: folder.name}) return _.find(folderFilters, filter => folder.name.match(new RegExp(`^${filter.value}`)))
}) })
status.targetFolders = targetFolders status.targetFolders = targetFolders
@@ -204,7 +204,7 @@ function remap (state) {
let newArticle = _.findWhere(articles, {status: 'NEW'}) let newArticle = _.findWhere(articles, {status: 'NEW'})
let FolderKey = folders[0].key let FolderKey = folders[0].key
if (folderFilters.length > 0) { if (folderFilters.length > 0) {
let targetFolder = _.findWhere(folders, {name: folderFilters[0].value}) let targetFolder = _.find(folders, folder => folder.name.match(new RegExp(`^${folderFilters[0].value}`)))
if (targetFolder != null) FolderKey = targetFolder.key if (targetFolder != null) FolderKey = targetFolder.key
} }

View File

@@ -10,7 +10,7 @@ const searchTutorialElement = (
<text x='450' y='33' fill={BRAND_COLOR} fontSize='24'>Search some posts!!</text> <text x='450' y='33' fill={BRAND_COLOR} fontSize='24'>Search some posts!!</text>
<text x='450' y='60' fill={BRAND_COLOR} fontSize='18'>{'- Search by tag : #{string}'}</text> <text x='450' y='60' fill={BRAND_COLOR} fontSize='18'>{'- Search by tag : #{string}'}</text>
<text x='450' y='85' fill={BRAND_COLOR} fontSize='18'> <text x='450' y='85' fill={BRAND_COLOR} fontSize='18'>
{'- Search by folder : in:{folder_name}\n'}</text> {'- Search by folder : /{folder_name}\n'}</text>
<svg width='500' height='300'> <svg width='500' height='300'>
<path fill='white' d='M54.5,51.5c-12.4,3.3-27.3-1.4-38.4-7C11.2,42,5,38.1,5.6,31.8c0.7-6.9,8.1-11.2,13.8-13.7 <path fill='white' d='M54.5,51.5c-12.4,3.3-27.3-1.4-38.4-7C11.2,42,5,38.1,5.6,31.8c0.7-6.9,8.1-11.2,13.8-13.7
@@ -117,7 +117,7 @@ export default class ArticleTopBar extends React.Component {
} }
<div className={'tooltip' + (this.state.isTooltipHidden ? ' hide' : '')}> <div className={'tooltip' + (this.state.isTooltipHidden ? ' hide' : '')}>
- Search by tag : #{'{string}'}<br/> - Search by tag : #{'{string}'}<br/>
- Search by folder : in:{'{folder_name}'} - Search by folder : /{'{folder_name}'}
</div> </div>
</div> </div>

View File

@@ -131,7 +131,7 @@ function status (state = initialStatus, action) {
return state return state
case SWITCH_FOLDER: case SWITCH_FOLDER:
state.mode = IDLE_MODE state.mode = IDLE_MODE
state.search = `in:${action.data} ` state.search = `/${action.data} `
return state return state
case SWITCH_MODE: case SWITCH_MODE: