Skip to content

Commit

Permalink
send task back from today tab to backlog tab (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
bukinoshita committed Jan 5, 2018
1 parent 5a8ea0e commit 72c4e78
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 7 deletions.
27 changes: 26 additions & 1 deletion renderer/components/task.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import renderHTML from 'react-render-html'
const Task = ({ task, onMove, onDelete, isDone }) => {
const { id, title, description, project, type } = task
const isToday = type === 'today' ? 'done' : 'today'
const nextType = type === 'today' ? 'today' : 'backlog'
const desc =
description.length >= 30 ? `${description.substr(0, 30)}...` : description
const hasProject = project ? (
Expand All @@ -21,10 +22,34 @@ const Task = ({ task, onMove, onDelete, isDone }) => {
`}</style>
</span>
) : null
const backBacklog =
type === 'today' ? (
<li onClick={() => onMove('back', task)}>
backlog
<style jsx>{`
li {
color: white;
display: inline-block;
font-size: 11px;
font-weight: 600;
margin-right: 10px;
color: #868e96;
cursor: pointer;
}
li:hover {
color: white;
}
`}</style>
</li>
) : null
const hasFooter = isDone ? null : (
<div>
<ul>
<li onClick={() => onMove(task)}>{isToday}</li>
<li onClick={() => onMove(nextType, task)}>{isToday}</li>

{backBacklog}

<li>
<Link href={`/task?id=${id}`}>
<span>view</span>
Expand Down
25 changes: 19 additions & 6 deletions renderer/pages/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ class Home extends Component {
}

onMove(type, task) {
if (type === 'backlog') {
const { user } = getUser()
const { user } = getUser()

if (type === 'backlog') {
const taskUpdated = user.tasks.map(t => {
if (t.id === task.id) {
t.type = 'today'
Expand All @@ -70,8 +70,6 @@ class Home extends Component {
}

if (type === 'today') {
const { user } = getUser()

const taskUpdated = user.tasks.map(t => {
if (t.id === task.id) {
t.type = 'done'
Expand All @@ -85,6 +83,21 @@ class Home extends Component {
updateUser(user)
return this.setState({ user })
}

if (type === 'back') {
const taskUpdated = user.tasks.map(t => {
if (t.id === task.id) {
t.type = 'backlog'
return t
}

return t
})

user.tasks = taskUpdated
updateUser(user)
return this.setState({ user })
}
}

render() {
Expand All @@ -101,7 +114,7 @@ class Home extends Component {
<Today
tasks={todayTasks}
onDelete={this.onDelete}
onMove={task => this.onMove('today', task)}
onMove={(type, task) => this.onMove(type, task)}
/>
)
break
Expand All @@ -114,7 +127,7 @@ class Home extends Component {
<Backlog
tasks={backlogTasks}
onDelete={this.onDelete}
onMove={task => this.onMove('backlog', task)}
onMove={(type, task) => this.onMove(type, task)}
/>
)
break
Expand Down

0 comments on commit 72c4e78

Please sign in to comment.