Merge branch 'master' into feature-custom-buffs

This commit is contained in:
Stefan Zermatten
2017-09-07 14:41:33 +02:00
committed by GitHub
15 changed files with 333 additions and 17 deletions

View File

@@ -0,0 +1,23 @@
<!-- shamelessly nicked and renamed from deleteCharacterConfirmation.html -->
<template name="unshareCharacterConfirmation">
<div class="fit layout vertical">
<app-header-layout has-scrolling-region class="feedback flex">
<app-header fixed effects="waterfall">
<app-toolbar>
<div main-title>Unshare Character</div>
</app-toolbar>
</app-header>
<div class="form flex">
Removing (unsharing) a character does not delete it.<br>
However, you will be no longer be able to access or view it, unless it is publicly visible.<br>
The character's owner or anyone with write permissions for the character can return read access.<br><br>
To continue type "{{name}}" into the box below.<br>
<paper-input id="nameInput" label="type the characters's name here" style="width: 100%;"></paper-input><br>
<paper-button id="unshareButton" style={{getStyle}} disabled={{cantUnshare}}>Unshare Character</paper-button>
</div>
</app-header-layout>
<div class="buttons layout horizontal end-justified">
<paper-button class="cancelButton"> Cancel </paper-button>
</div>
</div>
</template>

View File

@@ -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();
},
});

View File

@@ -30,6 +30,16 @@
</paper-icon-item>
</paper-menu>
</paper-menu-button>
{{else}}
<paper-menu-button class="character-menu" horizontal-align="right">
<paper-icon-button icon="more-vert" class="dropdown-trigger"></paper-icon-button>
<paper-menu class="dropdown-content black87">
<paper-icon-item id="unshareCharacter">
<iron-icon icon="delete" item-icon></iron-icon>
Unshare
</paper-icon-item>
</paper-menu>
</paper-menu-button>
{{/if}}
</div>
<div bottom-item>

View File

@@ -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,
});
},
});

View File

@@ -36,7 +36,9 @@
{{> effectsViewList charId=charId parentId=_id}}
{{> proficiencyViewList charId=charId parentId=_id}}
{{> attacksViewList charId=charId parentId=_id}}
{{> customBuffViewList charId=charId parentId=_id}}
</template>
<template name="featureEdit">
@@ -77,5 +79,6 @@
{{> effectsEditList parentId=_id parentCollection="Features" charId=charId name=name enabled=enabled}}
{{> proficiencyEditList parentId=_id parentCollection="Features" charId=charId enabled=enabled}}
{{> attackEditList parentId=_id parentCollection="Features" charId=charId enabled=enabled name=name}}
{{> customBuffEditList parentId=_id parentCollection="Features" charId=charId}}
</template>

View File

@@ -6,6 +6,10 @@
margin-bottom: 8px;
}
.card.featureCard .bottom {
padding-bottom: 8px;
}
.containerMain.featureDescription {
white-space: pre-line;
}

View File

@@ -78,7 +78,7 @@
</div>
{{/if}}
</div>
{{#if description}}
{{#if hasCharacters (evaluateShortString charId description)}}
<div class="bottom flex">
{{#markdown}}{{evaluateShortString charId description}}{{/markdown}}
{{> customBuffViewList charId=charId parentId=_id}}

View File

@@ -56,6 +56,9 @@ Template.features.helpers({
var profs = Proficiencies.find({charId: this._id, type: "tool"});
return removeDuplicateProficiencies(profs);
},
hasCharacters: function(string){
return string.match(/\S/);
},
});
Template.features.events({

View File

@@ -17,6 +17,9 @@
</paper-input>
<paper-input id="valueInput" label="Value" type="number" value={{value}}>
</paper-input>
<paper-toggle-button id="carriedToggle" checked={{isCarried}}>
Carried
</paper-toggle-button>
</div>
<hr class="vertMargin">

View File

@@ -54,4 +54,8 @@ Template.containerEdit.events({
trimStrings: false,
});
},
"change #carriedToggle": function(event, instance){
var carried = !this.isCarried;
Containers.update(this._id, {$set: {isCarried: carried}});
}
});

View File

@@ -331,21 +331,23 @@ Template.layout.events({
Session.set("inventory.dragItemId", null);
},
"drop .characterRepresentative": function(event, instance) {
var itemId = event.originalEvent.dataTransfer.getData("dicecloud-id/items");
if (event.ctrlKey){
//split the stack to the container
pushDialogStack({
template: "splitStackDialog",
data: {
id: itemId,
parentCollection: "Characters",
parentId: this._id,
},
});
} else {
//move item to the character
Meteor.call("moveItemToCharacter", itemId, this._id);
if (_.contains(event.originalEvent.dataTransfer.types, "dicecloud-id/items")){
var itemId = event.originalEvent.dataTransfer.getData("dicecloud-id/items");
if (event.ctrlKey){
//split the stack to the container
pushDialogStack({
template: "splitStackDialog",
data: {
id: itemId,
parentCollection: "Characters",
parentId: this._id,
},
});
} else {
//move item to the character
Meteor.call("moveItemToCharacter", itemId, this._id);
}
Session.set("inventory.dragItemId", null);
}
Session.set("inventory.dragItemId", null);
},
});

View File

@@ -83,7 +83,9 @@
{{#each spells ../_id ../../_id}}
{{#if showSpell ../../_id}}
<div class="item-slot">
<div class="tall spell item layout horizontal center" data-id={{_id}}>
<div class="tall spell item layout horizontal center spellItem"
data-id={{_id}}
draggable={{canEditCharacter charId}}>
<iron-icon icon="social:whatshot"
style="color: {{hexColor color}};
margin-right: 16px;"

View File

@@ -333,3 +333,49 @@ Template.spells.events({
event.stopPropagation();
},
});
Template.layout.events({
"dragstart .spellItem": function(event, instance){
event.originalEvent.dataTransfer.setData("dicecloud-id/spells", this._id);
Session.set("spellLists.dragSpellId", this._id);
},
"dragend .spellItem": function(event, instance){
Session.set("spellLists.dragSpellId", null);
},
"dragover .spellList, dragenter .spellList": function(event, instance){
if (_.contains(event.originalEvent.dataTransfer.types, "dicecloud-id/spells")){
event.preventDefault();
}
},
"drop .spellList": function(event, instance){
var spellId = event.originalEvent.dataTransfer.getData("dicecloud-id/spells");
if (event.ctrlKey){
//copy spell to new list
Meteor.call("copySpellToList", spellId, this._id);
} else {
//move spell to new list
Meteor.call("moveSpellToList", spellId, this._id);
}
Session.set("spellLists.dragSpellId", null);
},
"dragover .characterRepresentative, dragenter .characterRepresentative": function(event, instance){
if (_.contains(event.originalEvent.dataTransfer.types, "dicecloud-id/spells")){
event.preventDefault();
}
},
"drop .characterRepresentative": function(event, instance) {
if (_.contains(event.originalEvent.dataTransfer.types, "dicecloud-id/spells")){ //to prevent conflicts with item drag/drop
var spellId = event.originalEvent.dataTransfer.getData("dicecloud-id/spells");
if (event.ctrlKey){
//copy spell to character
Meteor.call("copySpellToCharacter", spellId, this._id);
} else {
//move spell to character
Meteor.call("moveSpellToCharacter", spellId, this._id);
}
Session.set("spellLists.dragSpellId", null);
}
},
});