mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 22:57:21 +01:00
client: add task component
This commit is contained in:
35
website/client/components/task.vue
Normal file
35
website/client/components/task.vue
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
<template lang="pug">
|
||||||
|
li
|
||||||
|
ul
|
||||||
|
li
|
||||||
|
strong {{task.text}}
|
||||||
|
li(v-if="task.type === 'habit'") up: {{task.up}}, down: {{task.down}}
|
||||||
|
li value: {{task.value}}
|
||||||
|
template(v-if="task.type === 'daily' || task.type === 'todo'")
|
||||||
|
li completed: {{task.completed}}
|
||||||
|
li
|
||||||
|
span checklist
|
||||||
|
ul
|
||||||
|
li(v-for="checklist in task.checklist") {{checklist.text}}
|
||||||
|
template(v-if="task.type === 'daily'")
|
||||||
|
li streak: {{task.streak}}
|
||||||
|
li repeat: {{task.repeat}}
|
||||||
|
li(v-if="task.type === 'todo'") due date: {{task.date}}
|
||||||
|
li attribute {{task.attribute}}
|
||||||
|
li difficulty {{task.priority}}
|
||||||
|
li tags {{taskTags}}
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
props: ['task'],
|
||||||
|
computed: {
|
||||||
|
taskTags () {
|
||||||
|
let taskTags = this.task.tags;
|
||||||
|
return this.$store.state.user.tags
|
||||||
|
.filter(tag => taskTags.indexOf(tag.id) !== -1)
|
||||||
|
.map(tag => tag.name);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
@@ -1,18 +1,19 @@
|
|||||||
<template lang="pug">
|
<template lang="pug">
|
||||||
.row
|
.row
|
||||||
.sixteen.wide.column
|
|
||||||
p You have {{tasksCount}} tasks!
|
|
||||||
.four.wide.column(v-for="taskType in tasksTypes")
|
.four.wide.column(v-for="taskType in tasksTypes")
|
||||||
h3 {{taskType}}s ()
|
h3 {{taskType}}s
|
||||||
ul
|
ul
|
||||||
li(v-for="task in tasks", v-if="task.type === taskType", :key="task.id")
|
task(v-for="task in tasks", v-if="task.type === taskType", :key="task.id", :task="task")
|
||||||
span {{task.text}}
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import Task from './task';
|
||||||
import { mapState } from '../store';
|
import { mapState } from '../store';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
components: {
|
||||||
|
Task,
|
||||||
|
},
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
tasksTypes: ['habit', 'daily', 'todo', 'reward'],
|
tasksTypes: ['habit', 'daily', 'todo', 'reward'],
|
||||||
@@ -20,9 +21,6 @@ export default {
|
|||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(['tasks']),
|
...mapState(['tasks']),
|
||||||
...mapState({
|
|
||||||
tasksCount: (state) => state.tasks.length,
|
|
||||||
}),
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
Reference in New Issue
Block a user