Get subtasks by computed property

This commit is contained in:
Raimund Schlüßler 2018-11-12 20:33:47 +01:00
parent 9383b9f634
commit a23e3498c3
No known key found for this signature in database
GPG key ID: 036FA7EB1A599178

View file

@ -105,7 +105,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
@keyup.27="showSubtaskInput = false">
</form>
</li>
<task-body-component v-for="subtask in getTasksByParentId(task.uid)"
<task-body-component v-for="subtask in subTasks"
:key="subtask.uid"
:task="subtask" :tasks="tasks" :base-url="baseUrl"
class="subtask" />
@ -173,6 +173,18 @@ export default {
} else if (this.task.priority > 0 && this.task.priority < 5) {
return 'icon-task-star-high'
}
},
/**
* Returns all tasks which are direct children of the current task
*
* @returns {Array} the sub-tasks of the current task
*/
subTasks: function() {
return Object.values(this.tasks)
.filter(task => {
return task.related === this.task.uid
})
}
},
methods: Object.assign(
@ -198,19 +210,6 @@ export default {
}
},
/**
* Returns all tasks which are direct children of the task with Id parentId
*
* @param {String} parentId the Id of the parent task
* @returns {Array} the sub-tasks of the task with parentId
*/
getTasksByParentId: function(parentId) {
return Object.values(this.tasks)
.filter(task => {
return task.related === parentId
})
},
/**
* Returns the placeholder string shown in the subtasks input field
*