In-progress implementing usernames for share dialog
This commit is contained in:
@@ -1,18 +1,22 @@
|
|||||||
<template name="shareDialog">
|
<template name="shareDialog">
|
||||||
<div>
|
<div>
|
||||||
<div>
|
<div>
|
||||||
<div class="subhead">
|
{{#if writers.count}}
|
||||||
Can View
|
<div class="subhead">
|
||||||
</div>
|
Can View
|
||||||
{{#each readers}}
|
</div>
|
||||||
{{this}}<br>
|
{{#each readers}}
|
||||||
{{/each}}
|
{{username}}<br>
|
||||||
<div class="subhead">
|
{{/each}}
|
||||||
Can Edit
|
{{/if}}
|
||||||
</div>
|
{{#if writers.count}}
|
||||||
{{#each writers}}
|
<div class="subhead">
|
||||||
{{this}}<br>
|
Can Edit
|
||||||
{{/each}}
|
</div>
|
||||||
|
{{#each writers}}
|
||||||
|
{{username}}<br>
|
||||||
|
{{/each}}
|
||||||
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
<paper-input id="userNameOrEmailInput" label="Username or email" floatinglabel></paper-input><br>
|
<paper-input id="userNameOrEmailInput" label="Username or email" floatinglabel></paper-input><br>
|
||||||
{{#if userFindError}}<p style="color: red;">{{userFindError}}</p>{{/if}}
|
{{#if userFindError}}<p style="color: red;">{{userFindError}}</p>{{/if}}
|
||||||
|
|||||||
@@ -5,11 +5,11 @@ Template.shareDialog.onCreated(function(){
|
|||||||
Template.shareDialog.helpers({
|
Template.shareDialog.helpers({
|
||||||
readers: function(){
|
readers: function(){
|
||||||
var char = Characters.findOne(this._id, {fields: {readers: 1}});
|
var char = Characters.findOne(this._id, {fields: {readers: 1}});
|
||||||
return char && char.readers;
|
return Meteor.users.find({_id: {$in: char.readers}});
|
||||||
},
|
},
|
||||||
writers: function(){
|
writers: function(){
|
||||||
var char = Characters.findOne(this._id, {fields: {writers: 1}});
|
var char = Characters.findOne(this._id, {fields: {writers: 1}});
|
||||||
return char && char.writers;
|
return Meteor.users.find({_id: {$in: char.writers}});
|
||||||
},
|
},
|
||||||
shareButtonDisabled: function(){
|
shareButtonDisabled: function(){
|
||||||
return !Template.instance().userId.get();
|
return !Template.instance().userId.get();
|
||||||
@@ -18,7 +18,7 @@ Template.shareDialog.helpers({
|
|||||||
if (!Template.instance().userId.get()){
|
if (!Template.instance().userId.get()){
|
||||||
return "User not found";
|
return "User not found";
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
Template.shareDialog.events({
|
Template.shareDialog.events({
|
||||||
@@ -44,13 +44,13 @@ Template.shareDialog.events({
|
|||||||
if (permission === "write"){
|
if (permission === "write"){
|
||||||
Characters.update(self._id, {
|
Characters.update(self._id, {
|
||||||
$addToSet: {writers: userId},
|
$addToSet: {writers: userId},
|
||||||
$pull: {readers: userId}
|
$pull: {readers: userId},
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
Characters.update(self._id, {
|
Characters.update(self._id, {
|
||||||
$addToSet: {readers: userId},
|
$addToSet: {readers: userId},
|
||||||
$pull: {writers: userId}
|
$pull: {writers: userId},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,14 +1,13 @@
|
|||||||
Meteor.publish("singleCharacter", function(characterId, userId){
|
Meteor.publish("singleCharacter", function(characterId, userId){
|
||||||
if (
|
var char = Characters.findOne({
|
||||||
Characters.findOne({
|
_id: characterId,
|
||||||
_id: characterId,
|
$or: [
|
||||||
$or: [
|
{readers: userId},
|
||||||
{readers: userId},
|
{writers: userId},
|
||||||
{writers: userId},
|
{owner: userId},
|
||||||
{owner: userId},
|
],
|
||||||
],
|
});
|
||||||
})
|
if (char){
|
||||||
){
|
|
||||||
return [
|
return [
|
||||||
Characters.find({_id: characterId}),
|
Characters.find({_id: characterId}),
|
||||||
//get all the assets for this character including soft deleted ones
|
//get all the assets for this character including soft deleted ones
|
||||||
@@ -25,6 +24,10 @@ Meteor.publish("singleCharacter", function(characterId, userId){
|
|||||||
SpellLists.find ({charId: characterId}, {removed: true}),
|
SpellLists.find ({charId: characterId}, {removed: true}),
|
||||||
TemporaryHitPoints.find({charId: characterId}, {removed: true}),
|
TemporaryHitPoints.find({charId: characterId}, {removed: true}),
|
||||||
Proficiencies.find ({charId: characterId}, {removed: true}),
|
Proficiencies.find ({charId: characterId}, {removed: true}),
|
||||||
|
Meteor.users.find (
|
||||||
|
{_id: {$in: _.union(char.readers, char.writers)}},
|
||||||
|
{fields: {username: 1}}
|
||||||
|
),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user