-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cd8a045
commit 735c07f
Showing
8 changed files
with
141 additions
and
187 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,23 @@ | ||
import * as React from 'react'; | ||
import React from 'react'; | ||
|
||
export default class Counter extends React.Component { | ||
state = { | ||
count: 0 | ||
}; | ||
function Counter({ name }) { | ||
const [count, setCount] = useState(0); | ||
|
||
increment = () => { | ||
this.setState({ | ||
count: (this.state.count + 1) | ||
}); | ||
}; | ||
function onClick() { | ||
setCount(count => count + 1); | ||
} | ||
|
||
decrement = () => { | ||
this.setState({ | ||
count: (this.state.count - 1) | ||
}); | ||
}; | ||
|
||
render () { | ||
return ( | ||
<div> | ||
<h1>{this.state.count}</h1> | ||
<button onClick={this.increment}>Increment</button> | ||
<button onClick={this.decrement}>Decrement</button> | ||
</div> | ||
<div> | ||
<h2 | ||
style={{ | ||
color: 'teal', | ||
fontSize: 24, | ||
}} | ||
> | ||
{name}'s count: {count} | ||
</h2> | ||
<button onClick={onClick}>+</button> | ||
<div/> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,153 +1,38 @@ | ||
<template> | ||
<div class="columns"> | ||
<div class="column is-half is-offset-one-quarter task-list"> | ||
<div class="box"> | ||
<h2 class="title">My tasks</h2> | ||
<hr> | ||
<div class="field has-addons"> | ||
<div class="control is-expanded"> | ||
<input class="input" type="text" placeholder="New task" v-model="task.body"> | ||
</div> | ||
<div class="control"> | ||
<a class="button is-primary" @click="createTask()"> | ||
Add task | ||
</a> | ||
</div> | ||
</div> | ||
|
||
<div class="tabs is-centered"> | ||
<ul> | ||
<li :class="{'is-active' : isActive('current')}"> | ||
<h3 class="title"> | ||
<a href="#" v-on:click.prevent="fetchTaskList()"> | ||
Current task | ||
</a> | ||
</h3> | ||
</li> | ||
<li :class="{'is-active' : isActive('archive')}"> | ||
<h3 class="title"> | ||
<a href="#" v-on:click.prevent="fetchTaskList(1)"> | ||
Archived tasks | ||
</a> | ||
</h3> | ||
</li> | ||
</ul> | ||
</div> | ||
<div class="card" v-for="task in list"> | ||
<header class="card-header"> | ||
<p class="card-header-title"> | ||
Task {{ task.id }} | ||
</p> | ||
<a href="#" class="card-header-icon" aria-label="more options" | ||
v-on:click.prevent="archiveTask(task.id)"> | ||
<span class="icon"> | ||
<i class="fa " :class="{'fa-square-o': !task.archive, | ||
check: !task.archive, | ||
'fa-check-square-o': task.archive, | ||
done: task.archive}" aria-hidden="true"></i> | ||
</span> | ||
</a> | ||
</header> | ||
<div class="card-content"> | ||
<div class="content"> | ||
<p v-if="task !== editingTask" @dblclick="editTask(task)" v-bind:title="message"> | ||
{{ task.body }} | ||
</p> | ||
<input class="input" v-if="task === editingTask" v-autofocus @keyup.enter="endEditing(task)" @blur="endEditing(task)" type="text" placeholder="New task" v-model="task.body"> | ||
</div> | ||
</div> | ||
<footer class="card-footer"> | ||
<a class="card-footer-item" v-on:click.prevent="deleteTask(task.id)">Delete</a> | ||
</footer> | ||
</div> | ||
|
||
</div> | ||
<div id="app"> | ||
<Users /> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
/* eslint-disable */ | ||
export default { | ||
directives: { | ||
'autofocus': { | ||
inserted(el) { | ||
el.focus(); | ||
} | ||
} | ||
}, | ||
data() { | ||
return { | ||
message: 'Double click for editing.', | ||
list: [], | ||
task: { | ||
id: '', | ||
body: '', | ||
archive: '' | ||
}, | ||
editingTask: {}, | ||
activeItem: 'current' | ||
} | ||
}, | ||
created() { | ||
this.fetchTaskList(); | ||
}, | ||
methods: { | ||
fetchTaskList(archive = null) { | ||
if (archive === null) { | ||
var url = 'current_tasks'; | ||
this.setActive('current'); | ||
} else { | ||
var url = 'archived_tasks'; | ||
this.setActive('archive'); | ||
} | ||
axios.get(url).then(result => { | ||
this.list = result.data | ||
}); | ||
}, | ||
isActive(menuItem) { | ||
return this.activeItem === menuItem; | ||
}, | ||
setActive(menuItem) { | ||
this.activeItem = menuItem; | ||
}, | ||
createTask() { | ||
axios.post('create_task', this.task).then(result => { | ||
this.task.body = ''; | ||
this.fetchTaskList(); | ||
}).catch(err => { | ||
console.log(err); | ||
}); | ||
}, | ||
editTask(task) { | ||
this.editingTask = task; | ||
}, | ||
endEditing(task) { | ||
this.editingTask = {}; | ||
if (task.body.trim() === '') { | ||
this.deleteTask(task.id); | ||
} else { | ||
axios.post('edit_task', task).then(result => { | ||
console.log('success!') | ||
}).catch(err => { | ||
console.log(err); | ||
}); | ||
} | ||
}, | ||
deleteTask(id) { | ||
axios.post('delete_task/' + id).then(result => { | ||
this.fetchTaskList(); | ||
}).catch(err => { | ||
console.log(err); | ||
}); | ||
import Users from './components/Users.vue'; | ||
export default { | ||
name: 'app', | ||
components: { | ||
Users, | ||
}, | ||
data() { | ||
return { | ||
employee: { | ||
name: '', | ||
email: '', | ||
}, | ||
archiveTask(id) { | ||
axios.post('archive_task/' + id).then(result => { | ||
this.fetchTaskList(); | ||
}).catch(err => { | ||
console.log(err); | ||
}); | ||
} | ||
} | ||
} | ||
}; | ||
}, | ||
methods: { | ||
handleSubmit() { | ||
console.log('testing handleSubmit'); | ||
}, | ||
}, | ||
}; | ||
</script> | ||
|
||
<style> | ||
#app { | ||
font-family: 'Avenir', Helvetica, Arial, sans-serif; | ||
text-align: center; | ||
color: #2c3e50; | ||
margin-top: 60px; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.