|
@@ -59,6 +59,24 @@ if (Meteor.isClient) {
|
|
|
}
|
|
|
});
|
|
|
|
|
|
+ Template.docMeta.helpers({
|
|
|
+ document: function () {
|
|
|
+ return Documents.findOne({ _id: Session.get("docid") });
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ Template.editableText.helpers({
|
|
|
+ userCanEdit: function (doc, collection) {
|
|
|
+ Meteor._debug("userCanEdit", doc, collection);
|
|
|
+ // Can edit if the document is owned by me.
|
|
|
+ doc = Documents.findOne({
|
|
|
+ _id: Session.get("docid"),
|
|
|
+ owner: Meteor.userId()
|
|
|
+ });
|
|
|
+ return !!doc;
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
Template.navbar.events({
|
|
|
"click .js-add-doc": function (event) {
|
|
|
event.preventDefault();
|
|
@@ -81,6 +99,17 @@ if (Meteor.isClient) {
|
|
|
Session.set("docid", this._id);
|
|
|
}
|
|
|
});
|
|
|
+
|
|
|
+ Template.docMeta.events({
|
|
|
+ "click .js-tog-private": function (event) {
|
|
|
+ const docid = Session.get("docid");
|
|
|
+ if (docid) {
|
|
|
+ const doc = { _id: docid, isPrivate: event.target.checked };
|
|
|
+ Meteor.call("updateDocPrivacy", doc);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
} // end isClient...
|
|
|
|
|
|
if (Meteor.isServer) {
|
|
@@ -111,6 +140,15 @@ Meteor.methods({
|
|
|
}
|
|
|
},
|
|
|
|
|
|
+ updateDocPrivacy: function (doc) {
|
|
|
+ Meteor._debug("updatedocPrivacy", this.userId, doc)
|
|
|
+ if (!this.userId) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ let res = Documents.update({ _id: doc._id, owner: this.userId }, { $set: { private: doc.isPrivate } });
|
|
|
+ Meteor._debug("update", res);
|
|
|
+ },
|
|
|
+
|
|
|
addEditingUser: function () {
|
|
|
let doc = Documents.findOne();
|
|
|
if (!doc) {
|