I'm currently developing a task management application using the Meteor tutorial as a reference. I have created lists based on the task model, but I am struggling to figure out how to connect them and display all tasks associated with a specific list when it is clicked.
Here's a snippet of my code in Tasks.js:
'tasks.insert'(text, privacy, priority, listId) {
...
Tasks.insert({
text,
listId: listId,
owner: this.userId,
username: Meteor.users.findOne(this.userId).username,
});
},
In Body.js:
Template.body.events({
'submit .new-task' (event) {
event.preventDefault();
const listId = ???
const target = event.target;
const text = target.text.value;
...
Meteor.call('tasks.insert', text, privacy, priority, listId);
...
},
When displaying the data:
Template.body.helpers({
tasks() {
const instance = Template.instance();
if (instance.state.get('hideCompleted')) {
return Tasks.find({ checked: { $ne: true } }, { sort: Session.get("sort_order") });
}
return Tasks.find({}, { sort: Session.get("sort_order")});
},
lists() {
return Lists.find({}, { sort: { createdAt: -1 } });
},
In my body.html file, I am currently displaying lists and tasks separately. However, I am struggling to establish the relationship between the two entities...
Any help or guidance would be greatly appreciated!
Thank you!