Generalised some dialogs
This commit is contained in:
@@ -1,48 +1,34 @@
|
||||
<template name="spellListDialog">
|
||||
{{#with spellList}}
|
||||
<core-header-panel fit class="spellListDialog">
|
||||
<core-toolbar hero-id="toolbar" class={{colorClass}} hero>
|
||||
<paper-icon-button id="backButton" role="button" tabindex="0" icon="arrow-back" aria-label="close"></paper-icon-button>
|
||||
<div flex hero-id="title" hero>{{name}}</div>
|
||||
<paper-icon-button id="deleteSpellList"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
icon="delete"
|
||||
aria-label="Delete Feature"
|
||||
noink></paper-icon-button>
|
||||
</core-toolbar>
|
||||
<div class="detailContent">
|
||||
<!--Name-->
|
||||
<div horizontal layout>
|
||||
<paper-input id="spellListNameInput" label="Name" floatinglabel value={{name}} flex></paper-input>
|
||||
<!--Color-->
|
||||
{{> colorDropdown}}<br>
|
||||
</div>
|
||||
<!--Save DC-->
|
||||
<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}}
|
||||
style="width: 100%;"></paper-input><br>
|
||||
<!--Max Prepared-->
|
||||
<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>
|
||||
<paper-autogrow-textarea>
|
||||
<textarea id="spellListDescriptionInput" placeholder value={{description}}></textarea>
|
||||
</paper-autogrow-textarea>
|
||||
</paper-input-decorator>
|
||||
{{#baseDialog title=name class=colorClass}}
|
||||
<!--Name-->
|
||||
<div horizontal layout>
|
||||
<paper-input id="spellListNameInput" label="Name" floatinglabel value={{name}} flex></paper-input>
|
||||
</div>
|
||||
</core-header-panel>
|
||||
<!--Save DC-->
|
||||
<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}}
|
||||
style="width: 100%;"></paper-input><br>
|
||||
<!--Max Prepared-->
|
||||
<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>
|
||||
<paper-autogrow-textarea>
|
||||
<textarea id="spellListDescriptionInput" placeholder value={{description}}></textarea>
|
||||
</paper-autogrow-textarea>
|
||||
</paper-input-decorator>
|
||||
{{/baseDialog}}
|
||||
{{/with}}
|
||||
</template>
|
||||
@@ -1,29 +1,10 @@
|
||||
Template.spellListDialog.rendered = function(){
|
||||
var self = this;
|
||||
//update all autogrows after they've been filled
|
||||
var pata = this.$("paper-autogrow-textarea");
|
||||
pata.each(function(index, el){
|
||||
el.update($(el).children().get(0));
|
||||
})
|
||||
//update all input fields as well
|
||||
var input = this.$("paper-input");
|
||||
input.each(function(index, el){
|
||||
el.valueChanged();
|
||||
})
|
||||
//after the dialog is built, open it
|
||||
if (!this.alreadyRendered){
|
||||
Session.set("global.ui.detailShow", true);
|
||||
this.alreadyRendered = true;
|
||||
}
|
||||
}
|
||||
|
||||
Template.spellListDialog.events({
|
||||
"tap #backButton": function(){
|
||||
GlobalUI.closeDetail();
|
||||
"color-change": function(event, instance){
|
||||
SpellLists.update(instance.data.spellListId, {$set: {color: event.color}});
|
||||
},
|
||||
"tap #deleteSpellList": function(){
|
||||
SpellLists.remove(this._id);
|
||||
GlobalUI.closeDetail();
|
||||
"tap #deleteButton": function(event, instance){
|
||||
SpellLists.remove(instance.data.spellListId);
|
||||
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
|
||||
@@ -43,20 +24,14 @@ Template.spellListDialog.events({
|
||||
var value = event.currentTarget.value
|
||||
SpellLists.update(this._id, {$set: {maxPrepared: value}});
|
||||
},
|
||||
//TODO change #spellListDescription
|
||||
"core-select .colorDropdown": function(event){
|
||||
var detail = event.originalEvent.detail;
|
||||
if(!detail.isSelected) return;
|
||||
var value = detail.item.getAttribute("name");
|
||||
SpellLists.update(this._id, {$set: {color: value}});
|
||||
}
|
||||
"change #spellListDescriptionInput": function(event){
|
||||
var value = event.currentTarget.value
|
||||
SpellLists.update(this._id, {$set: {description: value}});
|
||||
},
|
||||
});
|
||||
|
||||
Template.spellListDialog.helpers({
|
||||
spellList: function(){
|
||||
return SpellLists.findOne(this.spellListId);
|
||||
},
|
||||
colorClass: function(){
|
||||
return getColorClass(this.color)
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user