1
0
mirror of https://github.com/BoostIo/Boostnote synced 2026-01-02 11:39:25 +00:00

addTag search

This commit is contained in:
Rokt33r
2015-10-22 08:30:39 +09:00
parent c507dfa6c4
commit f56df7c16d
10 changed files with 63 additions and 14 deletions

View File

@@ -9,6 +9,7 @@ export const SWITCH_FOLDER = 'SWITCH_FOLDER'
export const SWITCH_MODE = 'SWITCH_MODE'
export const SWITCH_ARTICLE = 'SWITCH_ARTICLE'
export const SET_SEARCH_FILTER = 'SET_SEARCH_FILTER'
export const SET_TAG_FILTER = 'SET_TAG_FILTER'
// Status - mode
export const IDLE_MODE = 'IDLE_MODE'
@@ -84,3 +85,10 @@ export function setSearchFilter (search) {
data: search
}
}
export function setTagFilter (tag) {
return {
type: SET_TAG_FILTER,
data: tag
}
}

View File

@@ -1,5 +1,5 @@
import React from 'react'
let ReactDOM = require('react-dom')
var ace = window.ace
module.exports = React.createClass({
@@ -16,7 +16,7 @@ module.exports = React.createClass({
}
},
componentDidMount: function () {
var el = React.findDOMNode(this.refs.target)
var el = ReactDOM.findDOMNode(this.refs.target)
var editor = ace.edit(el)
editor.$blockScrolling = Infinity
editor.setValue(this.props.code)

20
lib/components/TagLink.js Normal file
View File

@@ -0,0 +1,20 @@
import React, { PropTypes } from 'react'
import store from '../store'
import { setTagFilter } from '../actions'
export default class TagLink extends React.Component {
handleClick (e) {
store.dispatch(setTagFilter(this.props.tag.name))
}
render () {
return (
<a onClick={e => this.handleClick(e)}>{this.props.tag.name}</a>
)
}
}
TagLink.propTypes = {
tag: PropTypes.shape({
name: PropTypes.string
})
}

View File

@@ -27,7 +27,7 @@ export default class CreateNewFolder extends React.Component {
api.createFolder(input)
.then(res => {
console.log(res)
console.log(res.body)
close()
})
.catch(err => {

View File

@@ -1,6 +1,6 @@
import { combineReducers } from 'redux'
import { findIndex } from 'lodash'
import { SWITCH_USER, SWITCH_FOLDER, SWITCH_MODE, SWITCH_ARTICLE, SET_SEARCH_FILTER, USER_UPDATE, ARTICLE_REFRESH, ARTICLE_UPDATE, ARTICLE_DESTROY, IDLE_MODE, CREATE_MODE } from './actions'
import { SWITCH_USER, SWITCH_FOLDER, SWITCH_MODE, SWITCH_ARTICLE, SET_SEARCH_FILTER, SET_TAG_FILTER, USER_UPDATE, ARTICLE_REFRESH, ARTICLE_UPDATE, ARTICLE_DESTROY, IDLE_MODE, CREATE_MODE } from './actions'
import auth from 'boost/auth'
const initialStatus = {
@@ -40,6 +40,7 @@ function status (state, action) {
case SWITCH_USER:
state.userId = action.data
state.mode = IDLE_MODE
state.search = ''
return state
case SWITCH_FOLDER:
state.mode = IDLE_MODE
@@ -58,6 +59,10 @@ function status (state, action) {
state.search = action.data
state.mode = IDLE_MODE
return state
case SET_TAG_FILTER:
state.search = `#${action.data}`
state.mode = IDLE_MODE
return state
default:
if (state == null) return initialStatus
return state