Adding functionality for Tasks.

This commit is contained in:
Brian McGonagill 2022-09-05 15:30:20 -05:00
parent 947abfb76f
commit 56b27d6b05
13 changed files with 234 additions and 9 deletions

View file

@ -12,19 +12,33 @@ TaskItems.allow({
});
Meteor.methods({
'add.task' (taskName, assignedTo, taskDate) {
'add.task' (taskName, assignedTo, assignedToId, taskDate, actDate) {
check(taskName, String);
check(assignedTo, String);
check(taskDate, String);
check(assignedToId, String);
check(actDate, Date);
if (!this.userId) {
throw new Meteor.Error('You are not allowed to add tasks. Make sure you are logged in with valid user credentials.');
}
let username;
if (assignedTo == "self") {
let userInfo = Meteor.users.findOne({ _id: this.userId });
username = userInfo.profile.fullname;
assignedToId = this.userId;
} else {
username = assignedTo;
}
return TaskItems.insert({
taskName: taskName,
taskDate: taskDate,
assignedTo: assignedTo,
actualDate: actDate,
assignedTo: username,
assignedToId: assignedToId,
isComplete: false,
completedOn: null,
assignedOn: new Date(),