Generalised some dialogs
This commit is contained in:
@@ -1,36 +1,22 @@
|
||||
<template name="containerDialog">
|
||||
{{#with container}}
|
||||
<core-header-panel fit>
|
||||
<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="deleteContainer"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
icon="delete"
|
||||
aria-label="Delete Feature"
|
||||
noink></paper-icon-button>
|
||||
</core-toolbar>
|
||||
<div class="detailContent">
|
||||
<!--Name and plural name-->
|
||||
<paper-input id="containerNameInput" label="Name" floatinglabel value={{name}}></paper-input>
|
||||
<!--Color-->
|
||||
{{> colorDropdown}}
|
||||
<!--Weight-->
|
||||
<paper-input-decorator label="Weight" floatinglabel>
|
||||
<input id="weightInput" type="number" value={{weight}}>
|
||||
</paper-input-decorator>
|
||||
<!--Value-->
|
||||
<paper-input-decorator label="Value" floatinglabel>
|
||||
<input id="valueInput" type="number" value={{value}}>
|
||||
</paper-input-decorator>
|
||||
<!--Description-->
|
||||
<paper-input-decorator label="Description" floatinglabel layout vertical>
|
||||
<paper-autogrow-textarea>
|
||||
<textarea id="containerDescriptionInput" placeholder aria-label="Description" value={{description}}></textarea>
|
||||
</paper-autogrow-textarea>
|
||||
</paper-input-decorator>
|
||||
</div>
|
||||
</core-header-panel>
|
||||
{{#baseDialog title=name class=colorClass}}
|
||||
<!--Name and plural name-->
|
||||
<paper-input id="containerNameInput" label="Name" floatinglabel value={{name}}></paper-input>
|
||||
<!--Weight-->
|
||||
<paper-input-decorator label="Weight" floatinglabel>
|
||||
<input id="weightInput" type="number" value={{weight}}>
|
||||
</paper-input-decorator>
|
||||
<!--Value-->
|
||||
<paper-input-decorator label="Value" floatinglabel>
|
||||
<input id="valueInput" type="number" value={{value}}>
|
||||
</paper-input-decorator>
|
||||
<!--Description-->
|
||||
<paper-input-decorator label="Description" floatinglabel layout vertical>
|
||||
<paper-autogrow-textarea>
|
||||
<textarea id="containerDescriptionInput" placeholder aria-label="Description" value={{description}}></textarea>
|
||||
</paper-autogrow-textarea>
|
||||
</paper-input-decorator>
|
||||
{{/baseDialog}}
|
||||
{{/with}}
|
||||
</template>
|
||||
@@ -1,31 +1,17 @@
|
||||
Template.containerDialog.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.containerDialog.helpers({
|
||||
container: function(){
|
||||
return Containers.findOne(this.containerId);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Template.containerDialog.events({
|
||||
"tap #backButton": function(){
|
||||
GlobalUI.closeDetail();
|
||||
"color-change": function(event, instance){
|
||||
Containers.update(instance.data.containerId, {$set: {color: event.color}});
|
||||
},
|
||||
"tap #deleteContainer": function(){
|
||||
Containers.remove(this._id);
|
||||
GlobalUI.closeDetail();
|
||||
"tap #deleteButton": function(event, instance){
|
||||
Containers.remove(instance.data.containerId);
|
||||
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 #containerNameInput, input #containerNameInput": function(event){
|
||||
console.log("changed Nameinput")
|
||||
@@ -33,30 +19,15 @@ Template.containerDialog.events({
|
||||
Containers.update(this._id, {$set: {name: name}});
|
||||
},
|
||||
"change #weightInput, input #weightInput": function(event){
|
||||
var weight = Template.instance().find("#weightInput").value;
|
||||
var weight = +Template.instance().find("#weightInput").value;
|
||||
Containers.update(this._id, {$set: {weight: weight}});
|
||||
},
|
||||
"change #valueInput, input #valueInput": function(event){
|
||||
var value = Template.instance().find("#valueInput").value;
|
||||
var value = +Template.instance().find("#valueInput").value;
|
||||
Containers.update(this._id, {$set: {value: value}});
|
||||
},
|
||||
"change #containerDescriptionInput": function(event){
|
||||
var description = Template.instance().find("#containerDescriptionInput").value;
|
||||
Containers.update(this._id, {$set: {description: description}});
|
||||
},
|
||||
"core-select .colorDropdown": function(event){
|
||||
var detail = event.originalEvent.detail;
|
||||
if(!detail.isSelected) return;
|
||||
var value = detail.item.getAttribute("name");
|
||||
Containers.update(this._id, {$set: {color: value}});
|
||||
}
|
||||
});
|
||||
|
||||
Template.containerDialog.helpers({
|
||||
container: function(){
|
||||
return Containers.findOne(this.containerId);
|
||||
},
|
||||
colorClass: function(){
|
||||
return getColorClass(this.color)
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user