Implemented container editing

This commit is contained in:
Thaum
2015-01-27 09:43:08 +00:00
parent dc6ea555e5
commit 80c2c3249d
7 changed files with 113 additions and 5 deletions

View File

@@ -0,0 +1,41 @@
Template.containerDialog.rendered = function(){
var self = this;
this.autorun(function(){
var container = Containers.findOne(Template.currentData().containerId, {fields: {name: 1}});
if(container) Session.set("global.ui.dialogHeader", container.name);
})
//after the dialog is built, open it
_.defer(function(){GlobalUI.dialog.open()});
}
Template.containerDialog.events({
"tap #deleteContainer": function(){
Containers.remove(this._id);
GlobalUI.closeDialog()
},
//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")
var name = Template.instance().find("#containerNameInput").value;
Containers.update(this._id, {$set: {name: name}});
},
"change #weightInput, input #weightInput": function(event){
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;
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}});
}
});
Template.containerDialog.helpers({
container: function(){
return Containers.findOne(this.containerId);
}
});