Files
DiceCloud/rpg-docs/client/views/characterList/characterList.js
Stefan Zermatten 3227cd0934 Add character names to the end of their URL's
Closes #21, makes links to characters human readable
2017-07-13 13:14:04 +02:00

45 lines
804 B
JavaScript

Template.characterList.helpers({
characters(){
var userId = Meteor.userId();
return Characters.find(
{
$or: [
{readers: userId},
{writers: userId},
{owner: userId},
]
},
{
fields: {
name: 1,
urlName: 1,
picture: 1,
color: 1,
race: 1,
alignment: 1,
gender: 1,
},
sort: {name: 1},
}
);
},
initials(name){
return name.replace(/[^A-Z]/g, "");
},
})
Template.characterList.events({
"tap .addCharacter": function(event, template) {
pushDialogStack({
template: "newCharacterDialog",
element: event.currentTarget,
callback(character){
if (!character) return;
character.owner = Meteor.userId();
let _id = Characters.insert(character);
Router.go("characterSheet", {_id});
},
})
},
});