diff --git a/rpg-docs/client/views/character/characterSettings/unshareCharacterConfirmation.html b/rpg-docs/client/views/character/characterSettings/unshareCharacterConfirmation.html
new file mode 100644
index 00000000..c5c689d8
--- /dev/null
+++ b/rpg-docs/client/views/character/characterSettings/unshareCharacterConfirmation.html
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+ Unshare Character
+
+
+
+
+
+
+
diff --git a/rpg-docs/client/views/character/characterSettings/unshareCharacterConfirmation.js b/rpg-docs/client/views/character/characterSettings/unshareCharacterConfirmation.js
new file mode 100644
index 00000000..de240ee3
--- /dev/null
+++ b/rpg-docs/client/views/character/characterSettings/unshareCharacterConfirmation.js
@@ -0,0 +1,31 @@
+Template.unshareCharacterConfirmation.onCreated(function() {
+ this.canUnshare = new ReactiveVar(false);
+});
+
+Template.unshareCharacterConfirmation.helpers({
+ cantUnshare: function() {
+ return !Template.instance().canUnshare.get();
+ },
+ getStyle: function() {
+ if (Template.instance().canUnshare.get()) {
+ return "background: #d23f31; color: white;";
+ }
+ }
+});
+
+Template.unshareCharacterConfirmation.events({
+ "change #nameInput, input #nameInput": function(event, instance) {
+ var can = instance.find("#nameInput").value === this.name;
+ instance.canUnshare.set(can);
+ },
+ "click #unshareButton": function(event, instance) {
+ if (instance.find("#nameInput").value === this.name) {
+ setTimeout(popDialogStack, 100); //weird things happen without the delay.
+ Router.go("/characterList");
+ Meteor.call("removeMeFromReaders", this._id);
+ }
+ },
+ "click .cancelButton": function(event, instance){
+ popDialogStack();
+ },
+});
diff --git a/rpg-docs/client/views/character/characterSheet.html b/rpg-docs/client/views/character/characterSheet.html
index cc6f11e3..9fd7a65f 100644
--- a/rpg-docs/client/views/character/characterSheet.html
+++ b/rpg-docs/client/views/character/characterSheet.html
@@ -30,6 +30,16 @@
+ {{else}}
+
{{/if}}
diff --git a/rpg-docs/client/views/character/characterSheet.js b/rpg-docs/client/views/character/characterSheet.js
index c7052c44..528cf42d 100644
--- a/rpg-docs/client/views/character/characterSheet.js
+++ b/rpg-docs/client/views/character/characterSheet.js
@@ -210,4 +210,11 @@ Template.characterSheet.events({
element: event.currentTarget.parentElement.parentElement,
});
},
+ "click #unshareCharacter": function(event, instance){
+ pushDialogStack({
+ data: this,
+ template: "unshareCharacterConfirmation",
+ element: event.currentTarget.parentElement.parentElement,
+ });
+ },
});
diff --git a/rpg-docs/lib/methods/removeMeFromReaders.js b/rpg-docs/lib/methods/removeMeFromReaders.js
new file mode 100644
index 00000000..72e8fb63
--- /dev/null
+++ b/rpg-docs/lib/methods/removeMeFromReaders.js
@@ -0,0 +1,11 @@
+Meteor.methods({
+ removeMeFromReaders: function(charId) {
+ var userId = Meteor.userId();
+ var character = Characters.findOne(charId);
+
+ if (!character) return;
+ if (!_.contains(character.readers, userId)) return;
+
+ Characters.update(charId, {$pull: {"readers": userId}}); //we don't check write permission as you should always be able to remove youself from readers
+ }
+});
\ No newline at end of file