mirror of
https://gitlab.com/bmcgonag/get_my.git
synced 2026-03-27 00:08:49 +00:00
Added Task Mgmt, and framework for Recipes.
This commit is contained in:
parent
3b9a54daf1
commit
947abfb76f
13 changed files with 430 additions and 1 deletions
93
imports/api/tasks.js
Normal file
93
imports/api/tasks.js
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
import { Meteor } from 'meteor/meteor';
|
||||
import { Mongo } from 'meteor/mongo';
|
||||
import { check } from 'meteor/check';
|
||||
|
||||
export const TaskItems = new Mongo.Collection('taskitems');
|
||||
|
||||
TaskItems.allow({
|
||||
insert: function(userId, doc){
|
||||
// if use id exists, allow insert
|
||||
return !!userId;
|
||||
},
|
||||
});
|
||||
|
||||
Meteor.methods({
|
||||
'add.task' (taskName, assignedTo, taskDate) {
|
||||
check(taskName, String);
|
||||
check(assignedTo, String);
|
||||
check(taskDate, String);
|
||||
|
||||
if (!this.userId) {
|
||||
throw new Meteor.Error('You are not allowed to add tasks. Make sure you are logged in with valid user credentials.');
|
||||
}
|
||||
|
||||
return TaskItems.insert({
|
||||
taskName: taskName,
|
||||
taskDate: taskDate,
|
||||
assignedTo: assignedTo,
|
||||
isComplete: false,
|
||||
completedOn: null,
|
||||
assignedOn: new Date(),
|
||||
assignedBy: this.userId,
|
||||
});
|
||||
},
|
||||
'edit.task' (taskId, taskName, assignedTo, taskDate) {
|
||||
check(taskId, String);
|
||||
check(taskName, String);
|
||||
check(assignedTo, String);
|
||||
check(taskDate, String);
|
||||
|
||||
if (!this.userId) {
|
||||
throw new Meteor.Error('You are not allowed to edit tasks. Make sure you are logged in with valid user credentials.');
|
||||
}
|
||||
|
||||
return TaskItems.update({ _id: taskId }, {
|
||||
$set: {
|
||||
taskName: taskName,
|
||||
taskDate: taskDate,
|
||||
assignedTo: assignedTo,
|
||||
changedOn: new Date(),
|
||||
changedBy: this.userId,
|
||||
}
|
||||
});
|
||||
},
|
||||
'delete.task' (taskId) {
|
||||
check(taskId, String);
|
||||
|
||||
if (!this.userId) {
|
||||
throw new Meteor.Error('You are not allowed to delete tasks. Make sure you are logged in with valid user credentials.');
|
||||
}
|
||||
|
||||
return TaskItems.remove({ _id: taskId });
|
||||
},
|
||||
'markTask.complete' (taskId) {
|
||||
check(taskId, String);
|
||||
|
||||
if (!this.userId) {
|
||||
throw new Meteor.Error('You are not allowed to mark tasks complete. Make sure you are logged in with valid user credentials.');
|
||||
}
|
||||
|
||||
return TaskItems.update({ _id: taskId }, {
|
||||
$set: {
|
||||
isComplete: true,
|
||||
completedOn: new Date(),
|
||||
completedBy: this.userId,
|
||||
}
|
||||
});
|
||||
},
|
||||
'markTask.notComplete' (taskId) {
|
||||
check(taskId, String);
|
||||
|
||||
if (!this.userId) {
|
||||
throw new Meteor.Error('You are not allowed to mark tasks not complete. Make sure you are logged in with valid user credentials.');
|
||||
}
|
||||
|
||||
return TaskItems.update({ _id: taskId }, {
|
||||
$set: {
|
||||
isComplete: false,
|
||||
markedUncomplteOn: new Date(),
|
||||
markedUncompleteBy: this.userId,
|
||||
}
|
||||
});
|
||||
},
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue