Updated Features UI to include use limits
This commit is contained in:
@@ -19,6 +19,20 @@
|
|||||||
<textarea id="featureDescriptionInput" placeholder aria-label="Description" value={{description}}></textarea>
|
<textarea id="featureDescriptionInput" placeholder aria-label="Description" value={{description}}></textarea>
|
||||||
</paper-autogrow-textarea>
|
</paper-autogrow-textarea>
|
||||||
</paper-input-decorator>
|
</paper-input-decorator>
|
||||||
|
<hr style="margin: 16px 0 16px 0;">
|
||||||
|
<div layout horizontal center>
|
||||||
|
<div class="caption">Limit Uses <paper-toggle-button id="limitUseCheck"
|
||||||
|
checked={{usesSet}}
|
||||||
|
role="button"
|
||||||
|
aria-pressed="false"
|
||||||
|
tabindex="0"
|
||||||
|
touch-action="pan-y">
|
||||||
|
</paper-toggle-button>
|
||||||
|
{{#if usesSet}}
|
||||||
|
<paper-input id="usesInput" label="Uses" floatinglabel value={{uses}}></paper-input>
|
||||||
|
{{/if}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
{{#if effects}}
|
{{#if effects}}
|
||||||
<hr style="margin: 16px 0 16px 0;">
|
<hr style="margin: 16px 0 16px 0;">
|
||||||
<div id="effects">
|
<div id="effects">
|
||||||
|
|||||||
@@ -40,7 +40,21 @@ Template.featureDialog.events({
|
|||||||
"change #featureDescriptionInput": function(event){
|
"change #featureDescriptionInput": function(event){
|
||||||
var description = Template.instance().find("#featureDescriptionInput").value;
|
var description = Template.instance().find("#featureDescriptionInput").value;
|
||||||
Features.update(this._id, {$set: {description: description}});
|
Features.update(this._id, {$set: {description: description}});
|
||||||
}
|
},
|
||||||
|
"change #limitUseCheck": function(event){
|
||||||
|
var currentUses = this.uses;
|
||||||
|
var featureId = this._id;
|
||||||
|
if( event.target.checked && !_.isString(currentUses) ){
|
||||||
|
Features.update(featureId, {$set: {uses: ""}}, {removeEmptyStrings: false});
|
||||||
|
} else if (!event.target.checked && _.isString(currentUses)){
|
||||||
|
Features.update(featureId, {$unset: {uses: ""}});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"change #usesInput, input #quantityInput": function(event){
|
||||||
|
var value = event.target.value;
|
||||||
|
var featureId = this._id;
|
||||||
|
Features.update(featureId, {$set: {uses: value}});
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
Template.featureDialog.helpers({
|
Template.featureDialog.helpers({
|
||||||
@@ -50,5 +64,8 @@ Template.featureDialog.helpers({
|
|||||||
effects: function(){
|
effects: function(){
|
||||||
var cursor = Effects.find({sourceId: this._id, type: "feature"})
|
var cursor = Effects.find({sourceId: this._id, type: "feature"})
|
||||||
return cursor;
|
return cursor;
|
||||||
|
},
|
||||||
|
usesSet: function(){
|
||||||
|
return _.isString(this.uses);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -1,10 +1,5 @@
|
|||||||
paper-shadow.featureCard {
|
.containerTop {
|
||||||
width: 300px;
|
cursor: pointer;
|
||||||
padding: 16px;
|
|
||||||
margin: 4px;
|
|
||||||
background: white;
|
|
||||||
flex-grow: 1;
|
|
||||||
border-radius: 2px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.features {
|
.features {
|
||||||
@@ -19,6 +14,7 @@ paper-shadow.featureCard {
|
|||||||
margin-bottom: 8px;
|
margin-bottom: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.featureCardBottom {
|
.containerMain.featureDescription {
|
||||||
white-space: pre-line;
|
white-space: pre-line;
|
||||||
|
padding-bottom: 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,16 +7,24 @@
|
|||||||
<div class="actions">
|
<div class="actions">
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="features">
|
<div class="containers">
|
||||||
{{#each features}}
|
{{#each features}}
|
||||||
<paper-shadow class="featureCard" hero-id="main" {{detailHero}} animated>
|
<paper-shadow class="card container featureCard" hero-id="main" {{detailHero}}>
|
||||||
<div hero-id="toolbar" {{detailHero}}></div>
|
<div class="containerTop green white-text" hero-id="toolbar" layout horizontal center {{detailHero}}>
|
||||||
<div class="featureCardTop">
|
<div class="containerName title" hero-id="title" flex {{detailHero}}>{{name}}</div>
|
||||||
<h2>{{name}}</h2>
|
{{#if hasUses}}<div class="subhead" style="margin-right: 8px">{{usesLeft}}/{{usesValue}}</div>{{/if}}
|
||||||
</div>
|
<paper-ripple fit></paper-ripple>
|
||||||
<div class="featureCardBottom"><p>{{description}}</p></div>
|
</div>
|
||||||
<paper-ripple fit></paper-ripple>
|
<div flex class="containerMain body1 featureDescription">
|
||||||
</paper-shadow>
|
{{description}}
|
||||||
|
</div>
|
||||||
|
{{#if hasUses}}
|
||||||
|
<div class="containerFoot" layout horizontal center end-justified>
|
||||||
|
{{#if usesLeft}}<paper-button class="useFeature">Use</paper-button>{{/if}}
|
||||||
|
<paper-button class="resetFeature">Reset</paper-button>
|
||||||
|
</div>
|
||||||
|
{{/if}}
|
||||||
|
</paper-shadow>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</div>
|
</div>
|
||||||
<div class="fab-buffer"></div>
|
<div class="fab-buffer"></div>
|
||||||
|
|||||||
@@ -2,6 +2,9 @@ Template.features.helpers({
|
|||||||
features: function(){
|
features: function(){
|
||||||
var features = Features.find({charId: this._id});
|
var features = Features.find({charId: this._id});
|
||||||
return features;
|
return features;
|
||||||
|
},
|
||||||
|
hasUses: function(){
|
||||||
|
return this.usesValue() > 0;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -14,7 +17,7 @@ Template.features.events({
|
|||||||
heroId: featureId
|
heroId: featureId
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
"tap .featureCard": function(event){
|
"tap .containerTop": function(event){
|
||||||
var featureId = this._id;
|
var featureId = this._id;
|
||||||
var charId = Template.parentData()._id;
|
var charId = Template.parentData()._id;
|
||||||
GlobalUI.setDetail({
|
GlobalUI.setDetail({
|
||||||
@@ -22,5 +25,13 @@ Template.features.events({
|
|||||||
data: {featureId: featureId, charId: charId},
|
data: {featureId: featureId, charId: charId},
|
||||||
heroId: featureId
|
heroId: featureId
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
"tap .useFeature": function(event){
|
||||||
|
var featureId = this._id;
|
||||||
|
Features.update(featureId, {$inc: {used: 1}});
|
||||||
|
},
|
||||||
|
"tap .resetFeature": function(event){
|
||||||
|
var featureId = this._id;
|
||||||
|
Features.update(featureId, {$set: {used: 0}});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Reference in New Issue
Block a user