mirror of
https://gitlab.com/bmcgonag/get_my.git
synced 2026-03-27 08:18:50 +00:00
Updating tasks to show incomplete, overdue items
This commit is contained in:
parent
5e80ab7f6b
commit
cf715c9dbf
4 changed files with 37 additions and 4 deletions
|
|
@ -26,7 +26,7 @@ Template.myTasksForm.events({
|
||||||
showSnackbar("Task Name and Date are Required!", "red");
|
showSnackbar("Task Name and Date are Required!", "red");
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
Meteor.call("add.task", taskName, "self", "selfId", taskDate, actDate, function(err, result) {
|
Meteor.call("add.mytask", taskName, "self", "selfId", taskDate, actDate, function(err, result) {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log(" ERROR adding task for self: " + err);
|
console.log(" ERROR adding task for self: " + err);
|
||||||
showSnackbar("ERROR adding task for self!", "red");
|
showSnackbar("ERROR adding task for self!", "red");
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
<ul class="collapsible">
|
<ul class="collapsible">
|
||||||
{{#each tasks}}
|
{{#each tasks}}
|
||||||
<li>
|
<li>
|
||||||
<div class="collapsible-header {{#if $eq passedDate false}}yellow{{/if}}{{#if $eq isComplete true}}green lighten-2{{/if}}"><h5>{{taskName}}</h5></div>
|
<div class="collapsible-header {{#if $eq passedDate false}}yellow{{/if}}{{#if $eq isComplete true}}green lighten-2{{/if}}"><h5>{{taskName}} </h5></div>
|
||||||
<div class="collapsible-body">
|
<div class="collapsible-body">
|
||||||
<span>
|
<span>
|
||||||
<ul class="collection">
|
<ul class="collection">
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,8 @@ Template.myTasksTbl.helpers({
|
||||||
if (hide == true && onlyToday == false) {
|
if (hide == true && onlyToday == false) {
|
||||||
return TaskItems.find({ isComplete: false }, { sort: { actualDate: 1 }});
|
return TaskItems.find({ isComplete: false }, { sort: { actualDate: 1 }});
|
||||||
} else if (hide == true && onlyToday == true) {
|
} else if (hide == true && onlyToday == true) {
|
||||||
return TaskItems.find({ isComplete: false, taskDate: todayIs }, { sort: { actualDate: 1 }});
|
// return TaskItems.find({ isComplete: false, taskDate: todayIs }, { sort: { actualDate: 1 }});
|
||||||
|
return TaskItems.find({ isComplete: false, actualDate: { $lte: new Date()}}, { sort:{ actualDate: 1 }});
|
||||||
} else if (hide == false && onlyToday == true) {
|
} else if (hide == false && onlyToday == true) {
|
||||||
return TaskItems.find({ taskDate: todayIs }, { sort: { actualDate: 1 }});
|
return TaskItems.find({ taskDate: todayIs }, { sort: { actualDate: 1 }});
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -29,7 +30,8 @@ Template.myTasksTbl.helpers({
|
||||||
passedDate: function() {
|
passedDate: function() {
|
||||||
let taskDate = new Date(this.taskDate);
|
let taskDate = new Date(this.taskDate);
|
||||||
let now = new Date()
|
let now = new Date()
|
||||||
let diff = now < taskDate;
|
now.setHours(0,0,0,0);
|
||||||
|
let diff = now <= taskDate;
|
||||||
let comp = this.isComplete;
|
let comp = this.isComplete;
|
||||||
if (diff == false && comp == false) {
|
if (diff == false && comp == false) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,37 @@ Meteor.methods({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
'add.mytask' (taskName, assignedTo, assignedToId, taskDate, actDate) {
|
||||||
|
check(taskName, String);
|
||||||
|
check(taskDate, 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,
|
||||||
|
actualDate: actDate,
|
||||||
|
assignedTo: username,
|
||||||
|
assignedToId: assignedToId,
|
||||||
|
isComplete: false,
|
||||||
|
completedOn: null,
|
||||||
|
assignedOn: new Date(),
|
||||||
|
assignedBy: this.userId,
|
||||||
|
});
|
||||||
|
},
|
||||||
'edit.task' (taskId, taskName, assignedTo, taskDate) {
|
'edit.task' (taskId, taskName, assignedTo, taskDate) {
|
||||||
check(taskId, String);
|
check(taskId, String);
|
||||||
check(taskName, String);
|
check(taskName, String);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue