diff --git a/rpg-docs/Model/Character/Effects.js b/rpg-docs/Model/Character/Effects.js
index 9ce256c5..2c8b5367 100644
--- a/rpg-docs/Model/Character/Effects.js
+++ b/rpg-docs/Model/Character/Effects.js
@@ -61,7 +61,6 @@ Effects.attachSchema(Schemas.Effect);
if (Meteor.isServer) Characters.after.insert(function(userId, char) {
Effects.insert({
charId: char._id,
- type: "inate",
name: "Constitution modifier for each level",
stat: "hitPoints",
operation: "add",
@@ -69,11 +68,11 @@ if (Meteor.isServer) Characters.after.insert(function(userId, char) {
parent: {
id: char._id,
collection: "Characters",
+ group: "Inate",
},
});
Effects.insert({
charId: char._id,
- type: "inate",
name: "Proficiency bonus by level",
stat: "proficiencyBonus",
operation: "add",
@@ -81,11 +80,11 @@ if (Meteor.isServer) Characters.after.insert(function(userId, char) {
parent: {
id: char._id,
collection: "Characters",
+ group: "Inate",
},
});
Effects.insert({
charId: char._id,
- type: "inate",
name: "Dexterity Armor Bonus",
stat: "armor",
operation: "add",
@@ -93,11 +92,11 @@ if (Meteor.isServer) Characters.after.insert(function(userId, char) {
parent: {
id: char._id,
collection: "Characters",
+ group: "Inate",
},
});
Effects.insert({
charId: char._id,
- type: "inate",
name: "Natural Armor",
stat: "armor",
operation: "base",
@@ -105,6 +104,7 @@ if (Meteor.isServer) Characters.after.insert(function(userId, char) {
parent: {
id: char._id,
collection: "Characters",
+ group: "Inate",
},
});
});
diff --git a/rpg-docs/Routes/Routes.js b/rpg-docs/Routes/Routes.js
index 0c2a405d..6fc59ca2 100644
--- a/rpg-docs/Routes/Routes.js
+++ b/rpg-docs/Routes/Routes.js
@@ -53,7 +53,7 @@ Router.map(function() {
data: function() {
var data = Characters.findOne(
{_id: this.params._id},
- {fields: {_id: 1, name: 1, color: 1}}
+ {fields: {_id: 1, name: 1, color: 1, writers: 1, readers: 1}}
);
return data;
},
diff --git a/rpg-docs/client/globalHelpers/canEditCharacter.js b/rpg-docs/client/globalHelpers/canEditCharacter.js
new file mode 100644
index 00000000..95ba2ec6
--- /dev/null
+++ b/rpg-docs/client/globalHelpers/canEditCharacter.js
@@ -0,0 +1,6 @@
+Template.registerHelper("canEditCharacter", function(charId) {
+ var char = Characters.findOne(charId)
+ var userId = Meteor.userId();
+ return char.owner === userId ||
+ _.contains(char.writers, userId);
+});
diff --git a/rpg-docs/client/views/character/characterSheet.html b/rpg-docs/client/views/character/characterSheet.html
index 9ccb8270..9c4867e3 100644
--- a/rpg-docs/client/views/character/characterSheet.html
+++ b/rpg-docs/client/views/character/characterSheet.html
@@ -5,18 +5,24 @@
{{name}}
-
- {{> colorDropdown}}
-
-
-
-
-
-
-
+ {{#if canEditCharacter _id}}
+
+ {{> colorDropdown}}
+
+
+
+
+
+
+
+ {{/if}}
Stats
diff --git a/rpg-docs/client/views/character/characterSheet.js b/rpg-docs/client/views/character/characterSheet.js
index 03590890..a0192af7 100644
--- a/rpg-docs/client/views/character/characterSheet.js
+++ b/rpg-docs/client/views/character/characterSheet.js
@@ -13,7 +13,7 @@ var getTab = function(charId){
Template.characterSheet.helpers({
selectedTab: function(){
return getTab(this._id);
- }
+ },
});
Template.characterSheet.events({
diff --git a/rpg-docs/client/views/character/features/features.html b/rpg-docs/client/views/character/features/features.html
index a18b5184..86a9928c 100644
--- a/rpg-docs/client/views/character/features/features.html
+++ b/rpg-docs/client/views/character/features/features.html
@@ -104,14 +104,16 @@
-
+ {{#if canEditCharacter _id}}
+
+ {{/if}}
diff --git a/rpg-docs/client/views/character/inventory/inventory.html b/rpg-docs/client/views/character/inventory/inventory.html
index 2ffc2ab1..fddbfcb6 100644
--- a/rpg-docs/client/views/character/inventory/inventory.html
+++ b/rpg-docs/client/views/character/inventory/inventory.html
@@ -77,10 +77,12 @@
-
+ {{#if canEditCharacter _id}}
+
+ {{/if}}
diff --git a/rpg-docs/client/views/character/journal/journal.html b/rpg-docs/client/views/character/journal/journal.html
index 384a7bc1..d283493c 100644
--- a/rpg-docs/client/views/character/journal/journal.html
+++ b/rpg-docs/client/views/character/journal/journal.html
@@ -68,6 +68,7 @@
+ {{#if canEditCharacter _id}}
+ {{/if}}
\ No newline at end of file
diff --git a/rpg-docs/client/views/character/spells/spells.html b/rpg-docs/client/views/character/spells/spells.html
index 58661059..9da79085 100644
--- a/rpg-docs/client/views/character/spells/spells.html
+++ b/rpg-docs/client/views/character/spells/spells.html
@@ -91,8 +91,10 @@
-
+ {{#if canEditCharacter _id}}
+
+ {{/if}}
\ No newline at end of file
diff --git a/rpg-docs/client/views/paperTemplates/baseDialog/baseDialog.html b/rpg-docs/client/views/paperTemplates/baseDialog/baseDialog.html
index ad40f9a7..04de2d63 100644
--- a/rpg-docs/client/views/paperTemplates/baseDialog/baseDialog.html
+++ b/rpg-docs/client/views/paperTemplates/baseDialog/baseDialog.html
@@ -20,12 +20,12 @@
aria-label="Delete Feature"
noink>
{{else}}
- {{#unless hideEdit}}
+ {{#if showEdit}}
- {{/unless}}
+ {{/if}}
{{/if}}
diff --git a/rpg-docs/client/views/paperTemplates/baseDialog/baseDialog.js b/rpg-docs/client/views/paperTemplates/baseDialog/baseDialog.js
index 8d12bc0d..fb30542d 100644
--- a/rpg-docs/client/views/paperTemplates/baseDialog/baseDialog.js
+++ b/rpg-docs/client/views/paperTemplates/baseDialog/baseDialog.js
@@ -11,6 +11,18 @@ Template.baseDialog.helpers({
editing: function(){
return Template.instance().editing.get();
},
+ showEdit: function() {
+ if (this.hideEdit) return false;
+ var charId = Template.parentData().charId;
+ if (charId){
+ var char = Characters.findOne(charId);
+ var userId = Meteor.userId();
+ if (char && userId)
+ return char.owner === userId ||
+ _.contains(char.writers, userId);
+ }
+ return true;
+ },
});
Template.baseDialog.events({