added update feature
This commit is contained in:
parent
7438a6df12
commit
fb377b2625
@ -28,11 +28,20 @@ Meteor.methods({
|
|||||||
add_button: function(chrome, pre, post) {
|
add_button: function(chrome, pre, post) {
|
||||||
if ((Meteor.user() != undefined) && (Meteor.user().services.google.email in allowed) && !(pre === "")) {
|
if ((Meteor.user() != undefined) && (Meteor.user().services.google.email in allowed) && !(pre === "")) {
|
||||||
mymoment = moment(pre.replace("/", "-"), "MM-DD-YYYY");
|
mymoment = moment(pre.replace("/", "-"), "MM-DD-YYYY");
|
||||||
schedule.insert({
|
thepretext = mymoment.toISOString().split("T")[0];
|
||||||
"pretext": mymoment.toISOString().split("T")[0],
|
time = mymoment.format("X");
|
||||||
|
previous = schedule.find({"pretext": thepretext}).fetch();
|
||||||
|
if (previous.length > 0) {
|
||||||
|
entry = previous[0]
|
||||||
|
schedule.update(entry._id, {"aftertext": post, "pretext": entry.pretext, "timestamp": entry.timestamp});
|
||||||
|
} else {
|
||||||
|
schedule.insert({
|
||||||
|
"pretext": thepretext,
|
||||||
"aftertext": post,
|
"aftertext": post,
|
||||||
"timestamp": mymoment.format("X")
|
"timestamp": time
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
remove: function(chrome) {
|
remove: function(chrome) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user