|
@@ -56,7 +56,13 @@ if (Meteor.isClient) {
|
|
|
Template.navbar.events({
|
|
|
"click .js-add-doc": function (event) {
|
|
|
event.preventDefault();
|
|
|
- Meteor._debug("Add new doc", event, this);
|
|
|
+
|
|
|
+ if (!Meteor.user()) {
|
|
|
+ alert("You need to login first.");
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ Meteor.call("addDoc");
|
|
|
+ }
|
|
|
}
|
|
|
});
|
|
|
}
|
|
@@ -72,6 +78,22 @@ if (Meteor.isServer) {
|
|
|
|
|
|
|
|
|
Meteor.methods({
|
|
|
+ addDoc: function () {
|
|
|
+ Meteor._debug("addDoc, this", this);
|
|
|
+
|
|
|
+ if (!this.userId) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ let doc = {
|
|
|
+ owner: this.userId,
|
|
|
+ createdOn: new Date(),
|
|
|
+ title: "my new doc"
|
|
|
+ };
|
|
|
+ Documents.insert(doc);
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
addEditingUser: function () {
|
|
|
let doc = Documents.findOne();
|
|
|
if (!doc) {
|