Prettified all remaining detail boxes to be view -> edit

This commit is contained in:
Thaum
2015-04-20 14:06:35 +00:00
parent 6ec9f09b6a
commit 012aad5ae9
41 changed files with 334 additions and 164 deletions

View File

@@ -1,11 +1,9 @@
<template name="spellDialog">
{{#with spell}}
{{#baseDialog title=name class=colorClass showEdit=true editing=editing}}
{{#if editing}}
{{> spellEdit}}
{{else}}
{{> spellDetails}}
{{/if}}
{{#baseDialog title=name class=colorClass startEditing=../startEditing}}
{{> spellDetails}}
{{else}}
{{> spellEdit}}
{{/baseDialog}}
{{/with}}
</template>

View File

@@ -11,30 +11,16 @@ var spellLevels = [
{ name: "Level 9", level: 9 },
];
Template.spellDialog.onCreated(function(){
this.editing = new ReactiveVar(false);
});
Template.spellDialog.helpers({
spell: function(){
return Spells.findOne(this.spellId);
},
editing: function(){
return Template.instance().editing.get();
},
}
});
Template.spellDialog.events({
"color-change": function(event, instance){
Spells.update(instance.data.spellId, {$set: {color: event.color}});
},
"tap #editButton": function(event, instance){
instance.editing.set(true);
},
"tap #doneEditingButton": function(event, instance){
instance.editing.set(false);
},
"tap #deleteButton": function(event, instance){
Spells.softRemoveNode(instance.data.spellId);
GlobalUI.deletedToast(instance.data.spellId, "Spells", "Spell");

View File

@@ -1,27 +1,51 @@
<template name="spellListDialog">
{{#with spellList}}
{{#baseDialog title=name class=colorClass}}
<!--Name-->
<div horizontal layout>
<paper-input id="spellListNameInput" label="Name" floatinglabel value={{name}} flex></paper-input>
{{#baseDialog title=name class=colorClass startEditing=../startEditing}}
<div>
<div layout horizontal justified wrap class="subhead">
{{#if attackBonus}}
<div>
Attack Bonus: {{evaluate charId attackBonus}}
</div>
{{/if}}
{{#if saveDC}}
<div>
Save DC: {{evaluate charId saveDC}}
</div>
{{/if}}
{{#if maxPrepared}}
<div>
Max Prepared: {{evaluateSigned charId maxPrepared}}
</div>
{{/if}}
</div>
<hr class="vertMargin">
<div class="prewrap">{{description}}</div>
</div>
{{else}}
<!--Name-->
<paper-input id="spellListNameInput"
class="fullwidth"
label="Name"
floatinglabel
value={{name}}></paper-input>
<!--Save DC-->
<paper-input id="spellListSaveDCInput"
label="Save DC"
floatinglabel
value={{saveDC}}
<paper-input id="spellListSaveDCInput"
label="Save DC"
floatinglabel
value={{saveDC}}
style="width: 100%;"></paper-input><br>
<!--Attack Bonus-->
<paper-input id="spellListAttackBonusInput"
label="Attack Bonus"
floatinglabel
value={{attackBonus}}
<paper-input id="spellListAttackBonusInput"
label="Attack Bonus"
floatinglabel
value={{attackBonus}}
style="width: 100%;"></paper-input><br>
<!--Max Prepared-->
<paper-input id="spellListMaxPreparedInput"
label="Maximum Prepared Spells"
floatinglabel
value={{maxPrepared}}
<paper-input id="spellListMaxPreparedInput"
label="Maximum Prepared Spells"
floatinglabel
value={{maxPrepared}}
style="width: 100%;"></paper-input><br>
<!--Description-->
<paper-input-decorator label="Description" floatinglabel layout vertical>

View File

@@ -1,3 +1,7 @@
Template.spellListDialog.onRendered(function(){
updatePolymerInputs(this);
});
Template.spellListDialog.events({
"color-change": function(event, instance){
SpellLists.update(instance.data.spellListId, {$set: {color: event.color}});
@@ -5,28 +9,28 @@ Template.spellListDialog.events({
"tap #deleteButton": function(event, instance){
SpellLists.softRemoveNode(instance.data.spellListId);
GlobalUI.deletedToast(instance.data.spellListId, "SpellLists", "Spell list and contents");
GlobalUI.closeDetail()
GlobalUI.closeDetail();
},
//TODO clean up String -> num here so they don't need casting by Schema.clean
//TODO validate input (integer, non-negative, etc) for these inputs and give validation errors
"change #spellListNameInput, input #spellListNameInput": function(event){
var value = event.currentTarget.value
var value = event.currentTarget.value;
SpellLists.update(this._id, {$set: {name: value}});
},
"change #spellListSaveDCInput, input #spellListSaveDCInput": function(event){
var value = event.currentTarget.value
var value = event.currentTarget.value;
SpellLists.update(this._id, {$set: {saveDC: value}});
},
"change #spellListAttackBonusInput, input #spellListAttackBonusInput": function(event){
var value = event.currentTarget.value
var value = event.currentTarget.value;
SpellLists.update(this._id, {$set: {attackBonus: value}});
},
"change #spellListMaxPreparedInput, input #spellListMaxPreparedInput": function(event){
var value = event.currentTarget.value
var value = event.currentTarget.value;
SpellLists.update(this._id, {$set: {maxPrepared: value}});
},
"change #spellListDescriptionInput": function(event){
var value = event.currentTarget.value
var value = event.currentTarget.value;
SpellLists.update(this._id, {$set: {description: value}});
},
});

View File

@@ -161,7 +161,7 @@ Template.spells.events({
if(!error){
GlobalUI.setDetail({
template: "spellListDialog",
data: {spellListId: id, charId: charId},
data: {spellListId: id, charId: charId, startEditing: true},
heroId: id
});
}
@@ -182,7 +182,7 @@ Template.spells.events({
if(!error){
GlobalUI.setDetail({
template: "spellDialog",
data: {spellId: id, charId: charId},
data: {spellId: id, charId: charId, startEditing: true},
heroId: id
});
}