Implemented enabling/disabling of features

This commit is contained in:
Thaum
2015-03-11 09:43:45 +00:00
parent 297e54cdc2
commit 2b9cbcf717
7 changed files with 92 additions and 4 deletions

View File

@@ -24,8 +24,17 @@
{{#if usesSet}}
<paper-input id="usesInput" label="Uses" floatinglabel value={{uses}}></paper-input>
{{/if}}
<paper-dropdown-menu id="enabledDropdown" label="Enable Feature">
<paper-dropdown layered class="dropdown">
<core-menu id="enabledMenu" class="menu" selected={{enabled}} on-tap="onStatMenuTap">
<paper-item name="alwaysEnabled"> Always Enabled </paper-item>
<paper-item name="enabled"> Enabled </paper-item>
<paper-item name="disabled"> Disabled </paper-item>
</core-menu>
</paper-dropdown>
</paper-dropdown-menu>
</div>
{{> effectsEditList sourceId=_id charId=charId type="feature"}}
{{> effectsEditList sourceId=_id charId=charId type="feature" name=name enabled=isEnabled}}
{{/baseDialog}}
{{/with}}
</template>

View File

@@ -27,7 +27,14 @@ Template.featureDialog.events({
var value = event.target.value;
var featureId = this._id;
Features.update(featureId, {$set: {uses: value}});
}
},
"core-select #enabledDropdown": function(event){
var detail = event.originalEvent.detail;
if(!detail.isSelected) return;
var value = detail.item.getAttribute("name");
if (value === this.enabled) return;
Features.update(this._id, {$set: {enabled: value}});
},
});
Template.featureDialog.helpers({
@@ -36,5 +43,8 @@ Template.featureDialog.helpers({
},
usesSet: function(){
return _.isString(this.uses);
},
isEnabled: function(){
return this.enabled !== "disabled";
}
});

View File

@@ -21,3 +21,37 @@
.resourceCards paper-shadow.healthCard {
width: 100%;
}
/*To change the ink color for checked state:*/
paper-checkbox.enabledCheckbox::shadow #ink[checked] {
color: #ffffff;
}
/*To change the checkbox checked color:*/
paper-checkbox.enabledCheckbox::shadow #checkbox.checked {
background-color: #ffffff;
background-color: rgba(255,255,255,0.27);
border-color: #ffffff;
border-color: rgba(255,255,255,0.27);
}
/*ensure the checkmark is shown when ticked*/
paper-checkbox.enabledCheckbox::shadow #checkbox.checked #checkmark {
display: initial;
}
/*To change the ink color for unchecked state:*/
paper-checkbox.enabledCheckbox::shadow #ink {
color: #ffffff;
}
/*To change the checkbox unchecked color:*/
paper-checkbox.enabledCheckbox::shadow #checkbox {
border-color: #ffffff;
border-color: rgba(255,255,255,0.54);
}
/*ensure checkmark isn't shown early*/
paper-checkbox.enabledCheckbox::shadow #checkbox #checkmark {
display: none;
}

View File

@@ -65,9 +65,15 @@
{{#each features}}
<paper-shadow class="card container featureCard" hero-id="main" {{detailHero}}>
<div class="containerTop {{colorClass}}" hero-id="toolbar" layout horizontal center {{detailHero}}>
<paper-ripple fit></paper-ripple>
<div class="containerName subhead" hero-id="title" flex {{detailHero}}>{{name}}</div>
{{#if hasUses}}<div class="subhead" style="margin-right: 8px">{{usesLeft}}/{{usesValue}}</div>{{/if}}
<paper-ripple fit></paper-ripple>
{{#if canEnable}}
<core-tooltip label="Feature enabled" position="left">
<paper-checkbox class="enabledCheckbox" checked={{isEnabled}}></paper-checkbox>
</core-tooltip>
{{/if}}
</div>
{{#if description}}<div flex class="containerMain body1 featureDescription">{{description}}</div>{{/if}}
{{#if hasUses}}

View File

@@ -24,6 +24,12 @@ Template.features.helpers({
characterProficiencies: function(){
var char = Characters.findOne(this._id);
return char && char.proficiencies;
},
canEnable: function(){
return this.enabled !== "alwaysEnabled";
},
isEnabled: function(){
return this.enabled !== "disabled";
}
});
@@ -83,6 +89,15 @@ Template.features.events({
data: {charId: charId, field: "proficiencies", title: "Proficiencies", color: "q"},
heroId: this._id + "proficiencies"
});
},
"tap .enabledCheckbox": function(event){
event.stopPropagation();
},
"change .enabledCheckbox": function(event){
var enabled;
if(this.enabled === "enabled") enabled = "disabled";
else enabled = "enabled";
Features.update(this._id, {$set: {enabled: enabled}});
}
});

View File

@@ -42,9 +42,13 @@
</div>
{{#if settings.showUnprepared}}
{{#if maxPrepared}}<div class="subhead">{{numPrepared}} / {{evaluate charId maxPrepared}}</div>{{/if}}
<paper-icon-button class="finishPrep" icon="done"></paper-icon-button>
<core-tooltip label="Done" position="left">
<paper-icon-button class="finishPrep" icon="done"></paper-icon-button>
</core-tooltip>
{{else}}
<paper-icon-button class="prepSpells" icon="book"></paper-icon-button>
<core-tooltip label="Change prepared spells" position="left">
<paper-icon-button class="prepSpells" icon="book"></paper-icon-button>
</core-tooltip>
{{/if}}
</div>
<div class="containerMain">