- {{#each containers}}
-
- {{name}}
- {{#each items ../_id _id}}
-
- {{#if stackable}}{{quantity}}{{/if}} {{pluralName}}
-
- {{/each}}
-
- {{/each}}
+
-
-
-
\ No newline at end of file
diff --git a/rpg-docs/client/views/character/inventory/inventory.js b/rpg-docs/client/views/character/inventory/inventory.js
index c3fdb3b0..e4662631 100644
--- a/rpg-docs/client/views/character/inventory/inventory.js
+++ b/rpg-docs/client/views/character/inventory/inventory.js
@@ -1,3 +1,7 @@
+Template.inventory.created = function(){
+ this.showAddButtons = new ReactiveVar(false);
+}
+
Template.inventory.helpers({
containers: function(){
return Containers.find({charId: this._id})
@@ -10,18 +14,44 @@ Template.inventory.helpers({
},
equipment: function(){
return Items.find({ charId: this._id, equipped: true, equipmentSlot: {$ne: "armor"} })
+ },
+ showAddButtons: function(){
+ return Template.instance().showAddButtons.get();
+ },
+ gt1: function(num){
+ return num > 1;
}
});
Template.inventory.events({
- "tap #addItem": function(){
- GlobalUI.showDialog({
- template: "itemDialog",
- data: null,
- fullOnMobile: true
- })
+ "tap #addItem": function(event){
+ var charId = this._id;
+ var container = Containers.findOne({charId: charId}, {sort: {name: 1, _id: 1}, fields: {_id: 1}});
+ var containerId;
+ if(container){
+ containerId = container._id;
+ } else{
+ console.log("no container was found for new item, adding a new container");
+ containerId = Containers.insert({name: "New Container", isCarried: true, charId: this._id});
+ }
+ _.defer(function(){
+ var itemId = Items.insert({charId: charId, container: containerId});
+ GlobalUI.showDialog({
+ template: "itemDialog",
+ data: {itemId: itemId, charId: charId},
+ fullOnMobile: true
+ });
+ });
},
- "tap #addContainer": function(){
- Containers.insert({name: "New Container", isCarried: true, charId: this._id});
+ "tap #addContainer": function(event){
+ var containerId = Containers.insert({name: "New Container", isCarried: true, charId: this._id});
+ //TODO show container dialog
+ },
+ "tap .inventoryItem": function(event){
+ GlobalUI.setDialog({
+ template: "itemDialog",
+ data: {itemId: this._id, charId: this.charId},
+ fullOnMobile: true
+ });
}
})
\ No newline at end of file
diff --git a/rpg-docs/client/views/character/inventory/itemDialog.html b/rpg-docs/client/views/character/inventory/itemDialog.html
deleted file mode 100644
index 0f7f6b20..00000000
--- a/rpg-docs/client/views/character/inventory/itemDialog.html
+++ /dev/null
@@ -1,5 +0,0 @@
-
- {{> quickForm collection="Items" id="insertItemForm" type="insert"}}
- Cancel
- Save Item
-
\ No newline at end of file
diff --git a/rpg-docs/client/views/character/inventory/itemDialog/itemDialog.css b/rpg-docs/client/views/character/inventory/itemDialog/itemDialog.css
new file mode 100644
index 00000000..ef3dda4d
--- /dev/null
+++ b/rpg-docs/client/views/character/inventory/itemDialog/itemDialog.css
@@ -0,0 +1,3 @@
+body /deep/ .itemDialogWidth {
+ width: 560px;
+}
diff --git a/rpg-docs/client/views/character/inventory/itemDialog/itemDialog.html b/rpg-docs/client/views/character/inventory/itemDialog/itemDialog.html
new file mode 100644
index 00000000..2a1e137e
--- /dev/null
+++ b/rpg-docs/client/views/character/inventory/itemDialog/itemDialog.html
@@ -0,0 +1,77 @@
+
+ {{#with item}}
+
+
+
+
+ Delete Item
+ Cancel
+
+
+
+
+
+
+ {{# if quantity}}{{/if}}
+
+ {{# if canEquip}}
+
+ {{/if}}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Effects
+ {{#each effects}}
+ {{>effectEdit}}
+ {{/each}}
+
+
+ {{/with}}
+ Done
+
\ No newline at end of file
diff --git a/rpg-docs/client/views/character/inventory/itemDialog/itemDialog.js b/rpg-docs/client/views/character/inventory/itemDialog/itemDialog.js
new file mode 100644
index 00000000..1866d910
--- /dev/null
+++ b/rpg-docs/client/views/character/inventory/itemDialog/itemDialog.js
@@ -0,0 +1,102 @@
+Template.itemDialog.rendered = function(){
+ var self = this;
+ this.autorun(function(){
+ var item = Items.findOne(Template.currentData().itemId, {fields: {name: 1}});
+ if(item) Session.set("global.ui.dialogHeader", item.pluralName());
+ })
+ //after the dialog is built, open it
+ _.defer(function(){GlobalUI.dialog.open()});
+}
+
+Template.itemDialog.events({
+ "tap #deleteItem": function(){
+ Items.remove(this._id);
+ GlobalUI.closeDialog()
+ },
+ "tap #addEffectButton": function(){
+ Effects.insert({
+ charId: Template.currentData().charId,
+ sourceId: this._id,
+ operation: "add",
+ type: "equipment"
+ });
+ },
+ //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 #itemNameInput, input #itemNameInput": function(event){
+ console.log("changed Nameinput")
+ var name = Template.instance().find("#itemNameInput").value;
+ Items.update(this._id, {$set: {name: name}});
+ },
+ "change #itemPluralInput, input #itemPluralInput": function(event){
+ var plural = Template.instance().find("#itemPluralInput").value;
+ Items.update(this._id, {$set: {plural: plural}});
+ },
+ "change #quantityInput, input #quantityInput": function(event){
+ var quantity = Template.instance().find("#quantityInput").value;
+ Items.update(this._id, {$set: {quantity: quantity}});
+ },
+ "change #weightInput, input #weightInput": function(event){
+ var weight = Template.instance().find("#weightInput").value;
+ Items.update(this._id, {$set: {weight: weight}});
+ },
+ "change #valueInput, input #valueInput": function(event){
+ var value = Template.instance().find("#valueInput").value;
+ Items.update(this._id, {$set: {value: value}});
+ },
+ "change #itemDescriptionInput": function(event){
+ var description = Template.instance().find("#itemDescriptionInput").value;
+ Items.update(this._id, {$set: {description: description}});
+ },
+ "change #equippedInput": function(event){
+ var equipped = Template.instance().find("#equippedInput").checked;
+ Items.update(this._id, {$set: {equipped: equipped}});
+ },
+ "tap .containerMenuItem": function(event){
+ Items.update(Template.currentData().itemId, {$set: {container: this._id}});
+ },
+ "tap .slotMenuItem": function(event){
+ Items.update(Template.currentData().itemId, {$set: {equipmentSlot: this.value}});
+ }
+});
+
+var getContainers = function(charId){
+ return Containers.find({charId: charId}, {sort: {name: 1, _id: 1}, fields: {name: 1}}).fetch();
+};
+
+var equipmentSlots = [
+ {name: "None", value: "none"},
+ {name: "Held", value: "held"},
+ {name: "Armor", value: "armor"},
+ {name: "Head", value: "head"},
+ {name: "Arms", value: "arms"},
+ {name: "Hands", value: "hands"},
+ {name: "Feet", value: "feet"}
+];
+
+Template.itemDialog.helpers({
+ item: function(){
+ return Items.findOne(this.itemId);
+ },
+ effects: function(){
+ var cursor = Effects.find({charId: this.charId, type: "equipment", sourceId: this._id})
+ return cursor;
+ },
+ containers: function(){
+ return getContainers(this.charId);
+ },
+ containerIndex: function(){
+ var containers = getContainers(this.charId);
+ var containerIds = _.pluck(containers, "_id");
+ return _.indexOf(containerIds, this.container);
+ },
+ equipmentSlots: function(){
+ return equipmentSlots;
+ },
+ equipmentSlotIndex: function(){
+ return _.indexOf(_.pluck(equipmentSlots, "value"), this.equipmentSlot);
+ },
+ canEquip: function(){
+ return this.equipmentSlot !== "none";
+ }
+});
\ No newline at end of file
diff --git a/rpg-docs/client/views/layout/imports.html b/rpg-docs/client/views/layout/imports.html
index a78c84e2..d4af595e 100644
--- a/rpg-docs/client/views/layout/imports.html
+++ b/rpg-docs/client/views/layout/imports.html
@@ -16,6 +16,7 @@
+
@@ -25,6 +26,7 @@
+
diff --git a/rpg-docs/nohup.out b/rpg-docs/nohup.out
deleted file mode 100644
index 7e1185b8..00000000
--- a/rpg-docs/nohup.out
+++ /dev/null
@@ -1,8 +0,0 @@
-[[[[[ ~/workspace/rpg-docs ]]]]]
-
-=> Started proxy.
-=> Started MongoDB.
-Vulcanize: Adding all imports...
-=> Started your app.
-
-=> App running at: http://localhost:3000/