Changed item detail to a detail view with the option to edit
This commit is contained in:
@@ -1,20 +1,44 @@
|
||||
var getContainers = function(charId){
|
||||
return Containers.find({charId: charId}, {sort: {name: 1, _id: 1}, fields: {name: 1}}).fetch();
|
||||
return Containers.find({charId: charId}, {sort: {name: 1, _id: 1}, fields: {name: 1}});
|
||||
};
|
||||
|
||||
Template.itemDialog.onCreated(function(){
|
||||
this.editing = new ReactiveVar(false);
|
||||
});
|
||||
|
||||
Template.itemDialog.helpers({
|
||||
item: function(){
|
||||
return Items.findOne(this.itemId);
|
||||
},
|
||||
containers: function(){
|
||||
return getContainers(this.charId);
|
||||
editing: function(){
|
||||
return Template.instance().editing.get();
|
||||
},
|
||||
itemHeading: function(){
|
||||
if(this.quantity === 1){
|
||||
return this.name;
|
||||
} else{
|
||||
var pName = this.plural || this.name;
|
||||
return this.quantity + " " + pName;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Template.itemDialog.events({
|
||||
"tap #editButton": function(event, instance){
|
||||
instance.editing.set(true);
|
||||
},
|
||||
"tap #doneEditingButton": function(event, instance){
|
||||
instance.editing.set(false);
|
||||
},
|
||||
});
|
||||
|
||||
Template.itemEdit.helpers({
|
||||
ne1: function(num){
|
||||
return num != 1;
|
||||
}
|
||||
});
|
||||
|
||||
Template.itemDialog.events({
|
||||
Template.itemEdit.events({
|
||||
"color-change": function(event, instance){
|
||||
Items.update(instance.data.itemId, {$set: {color: event.color}});
|
||||
},
|
||||
@@ -62,12 +86,21 @@ Template.itemDialog.events({
|
||||
"change #attunementCheckbox": function(event){
|
||||
var value = event.currentTarget.checked;
|
||||
Items.update(this._id, {$set: {requiresAttunement: value}});
|
||||
},
|
||||
}
|
||||
});
|
||||
|
||||
Template.containerDropdown.helpers({
|
||||
containers: function(){
|
||||
return getContainers(this.charId);
|
||||
}
|
||||
});
|
||||
|
||||
Template.containerDropdown.events({
|
||||
"core-select #containerDropDown": function(event){
|
||||
var detail = event.originalEvent.detail;
|
||||
if(!detail.isSelected) return;
|
||||
var containerId = detail.item.getAttribute("name");
|
||||
var item = Items.findOne(Template.currentData().itemId);
|
||||
var item = Items.findOne(Template.currentData()._id);
|
||||
item.moveToContainer(containerId);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user