From 012aad5ae91a50bfc8eed6ed8b6499e760c6ef9e Mon Sep 17 00:00:00 2001 From: Thaum Date: Mon, 20 Apr 2015 14:06:35 +0000 Subject: [PATCH] Prettified all remaining detail boxes to be view -> edit --- rpg-docs/Model/Inventory/Containers.js | 20 ++++--- .../client/globalHelpers/openParentDialog.js | 27 +++++++++ rpg-docs/client/globalHelpers/valueString.js | 27 ++++++++- rpg-docs/client/views/GeneralCSS/general.css | 8 ++- .../features/featureDialog/featureDialog.html | 10 ++-- .../features/featureDialog/featureDialog.js | 13 ---- .../views/character/features/features.js | 10 +--- .../containerDialog/containerDialog.css | 8 +++ .../containerDialog/containerDialog.html | 60 +++++++++++++------ .../containerDialog/containerDialog.js | 6 +- .../views/character/inventory/inventory.css | 1 - .../views/character/inventory/inventory.js | 4 +- .../inventory/itemDialog/itemDialog.html | 10 ++-- .../inventory/itemDialog/itemDialog.js | 2 +- .../journal/classDialog/classDialog.html | 14 ++++- .../journal/classDialog/classDialog.js | 4 ++ .../experienceDialog/experienceDialog.html | 10 +++- .../experienceDialog/experienceDialog.js | 6 ++ .../client/views/character/journal/journal.js | 12 ++-- .../journal/noteDialog/noteDialog.html | 6 +- .../journal/noteDialog/noteDialog.js | 4 ++ .../journal/raceDialog/raceDialog.html | 5 +- .../journal/raceDialog/raceDialog.js | 4 ++ .../personaDetailsDialog.html | 4 +- .../personaDetailsDialog.js | 4 ++ .../views/character/persona/persona.html | 2 +- .../persona/textDialog/textDialog.html | 4 +- .../persona/textDialog/textDialog.js | 4 ++ .../proficiencyEditList.js | 10 +++- .../proficiencyListItem.html | 4 +- .../proficiencyListItem.js | 6 ++ .../proficiencyViewList.js | 9 ++- .../spells/spellDialog/spellDialog.html | 10 ++-- .../spells/spellDialog/spellDialog.js | 16 +---- .../spellListDialog/spellListDialog.html | 56 ++++++++++++----- .../spells/spellListDialog/spellListDialog.js | 16 +++-- .../client/views/character/spells/spells.js | 4 +- .../client/views/character/stats/stats.html | 8 +-- .../client/views/character/stats/stats.js | 4 ++ .../paperTemplates/baseDialog/baseDialog.html | 42 ++++++------- .../paperTemplates/baseDialog/baseDialog.js | 24 ++++++-- 41 files changed, 334 insertions(+), 164 deletions(-) create mode 100644 rpg-docs/client/globalHelpers/openParentDialog.js create mode 100644 rpg-docs/client/views/character/inventory/containerDialog/containerDialog.css diff --git a/rpg-docs/Model/Inventory/Containers.js b/rpg-docs/Model/Inventory/Containers.js index c942e3a4..b473216d 100644 --- a/rpg-docs/Model/Inventory/Containers.js +++ b/rpg-docs/Model/Inventory/Containers.js @@ -2,9 +2,9 @@ Containers = new Mongo.Collection("containers"); Schemas.Container = new SimpleSchema({ - name: { type: String, trim: false }, - charId: { type: String, regEx: SimpleSchema.RegEx.Id}, - isCarried: { type: Boolean }, + name: { type: String, trim: false }, + charId: { type: String, regEx: SimpleSchema.RegEx.Id}, + isCarried: { type: Boolean }, weight: {type: Number, min: 0, defaultValue: 0, decimal: true}, value: {type: Number, min: 0, defaultValue: 0, decimal: true}, description:{type: String, optional: true, trim: false}, @@ -14,20 +14,26 @@ Schemas.Container = new SimpleSchema({ Containers.attachSchema(Schemas.Container); Containers.helpers({ - totalValue: function(){ - var value = this.value; + contentsValue: function(){ + var value = 0; Items.find({"parent.id": this._id}, {fields: {quantity: 1, value: 1}}).forEach(function(item){ value += item.totalValue(); }); return value; }, - totalWeight: function(){ - var weight = this.weight; + totalValue: function(){ + return this.contentsValue() + this.value; + }, + contentsWeight: function(){ + var weight = 0; Items.find({"parent.id": this._id}, {fields: {quantity: 1, weight: 1}}).forEach(function(item){ weight += item.totalWeight(); }); return weight; }, + totalWeight: function(){ + return this.contentsWeight() + this.weight; + }, moveToCharacter: function(characterId){ if(this.charId === characterId) return; Items.update(this._id, {$set: {charId: characterId}}); diff --git a/rpg-docs/client/globalHelpers/openParentDialog.js b/rpg-docs/client/globalHelpers/openParentDialog.js new file mode 100644 index 00000000..68ca7b9f --- /dev/null +++ b/rpg-docs/client/globalHelpers/openParentDialog.js @@ -0,0 +1,27 @@ +openParentDialog = function(parent, charId, heroId){ + var detail; + if(parent.collection === "Characters" && parent.group === "racial"){ + detail = { + template: "raceDialog", + data: {charId: parent.id}, + }; + } else if( parent.collection === "Features" ){ + detail = { + template: "featureDialog", + data: {featureId: parent.id}, + }; + } else if( parent.collection === "Classes" ){ + detail = { + template: "classDialog", + data: {classId: parent.id}, + }; + } else if( parent.collection === "Items" ){ + detail = { + template: "itemDialog", + data: {itemId: parent.id}, + }; + } + detail.heroId = heroId; + detail.charId = charId; + GlobalUI.setDetail(detail); +}; diff --git a/rpg-docs/client/globalHelpers/valueString.js b/rpg-docs/client/globalHelpers/valueString.js index c99ceb0b..4b0dc703 100644 --- a/rpg-docs/client/globalHelpers/valueString.js +++ b/rpg-docs/client/globalHelpers/valueString.js @@ -21,4 +21,29 @@ Template.registerHelper("valueString", function(value){ result += resultArray[i]; } return result; -}); \ No newline at end of file +}); + +Template.registerHelper("longValueString", function(value){ + var resultArray = []; + //sp + var gp = Math.floor(value); + if(gp > 0) resultArray.push(gp + "gp"); + //sp + var sp = Math.floor(10 * (value % 1)); + if(sp > 0 || resultArray.length) resultArray.push(sp + "sp"); + //cp + var cp = 10 * ((value * 10) % 1); + cp = Math.round(cp * 1000) / 1000; + if(cp > 0 || resultArray.length) resultArray.push(cp + "cp"); + + //build string with correct spacing + var result = ""; + for(var i = 0; i < resultArray.length; i++){ + //add a space between values + if(i !== 0){ + result += " "; + } + result += resultArray[i]; + } + return result; +}); diff --git a/rpg-docs/client/views/GeneralCSS/general.css b/rpg-docs/client/views/GeneralCSS/general.css index b0f51b64..2e437c17 100644 --- a/rpg-docs/client/views/GeneralCSS/general.css +++ b/rpg-docs/client/views/GeneralCSS/general.css @@ -94,10 +94,14 @@ paper-button { color: rgba(0, 0, 0, 0.54); } -.statCard, .clickable { +.clickable { cursor: pointer; } +.skillRow { + cursor: initial; +} + .resourceCards { padding: 4px 4px 0 4px; margin-bottom: -4px; @@ -186,6 +190,8 @@ paper-slider { } .whiteTop { + cursor: initial; + border-bottom: black solid 0.5px; border-bottom: rgba(0,0,0,0.12) solid 1px; background: white; padding: 16px; diff --git a/rpg-docs/client/views/character/features/featureDialog/featureDialog.html b/rpg-docs/client/views/character/features/featureDialog/featureDialog.html index 2f6d20ab..b4923a47 100644 --- a/rpg-docs/client/views/character/features/featureDialog/featureDialog.html +++ b/rpg-docs/client/views/character/features/featureDialog/featureDialog.html @@ -1,11 +1,9 @@ diff --git a/rpg-docs/client/views/character/features/featureDialog/featureDialog.js b/rpg-docs/client/views/character/features/featureDialog/featureDialog.js index 5ffa015e..d1faf4b3 100644 --- a/rpg-docs/client/views/character/features/featureDialog/featureDialog.js +++ b/rpg-docs/client/views/character/features/featureDialog/featureDialog.js @@ -1,11 +1,4 @@ -Template.featureDialog.onCreated(function(){ - this.editing = new ReactiveVar(false); -}); - Template.featureDialog.helpers({ - editing: function(){ - return Template.instance().editing.get(); - }, feature: function(){ return Features.findOne(this.featureId); }, @@ -15,12 +8,6 @@ Template.featureDialog.events({ "color-change": function(event, instance){ Features.update(instance.data.featureId, {$set: {color: event.color}}); }, - "tap #editButton": function(event, instance){ - instance.editing.set(true); - }, - "tap #doneEditingButton": function(event, instance){ - instance.editing.set(false); - }, "tap #deleteButton": function(event, instance){ Features.softRemoveNode(instance.data.featureId); GlobalUI.deletedToast(instance.data.featureId, "Features", "Feature"); diff --git a/rpg-docs/client/views/character/features/features.js b/rpg-docs/client/views/character/features/features.js index 3dc8f907..44a02841 100644 --- a/rpg-docs/client/views/character/features/features.js +++ b/rpg-docs/client/views/character/features/features.js @@ -40,7 +40,7 @@ Template.features.events({ var featureId = Features.insert({name: "New Feature", charId: this._id}); GlobalUI.setDetail({ template: "featureDialog", - data: {featureId: featureId, charId: this._id}, + data: {featureId: featureId, charId: this._id, startEditing: true}, heroId: featureId }); }, @@ -68,13 +68,7 @@ Template.features.events({ }); }, "tap .attack": function(event){ - var itemId = this.parent.id; - var charId = this.charId; - GlobalUI.setDetail({ - template: "itemDialog", - data: {itemId: itemId, charId: charId}, - heroId: this._id - }); + openParentDialog(this.parent, this.charId, this._id); }, "tap .useFeature": function(event){ var featureId = this._id; diff --git a/rpg-docs/client/views/character/inventory/containerDialog/containerDialog.css b/rpg-docs/client/views/character/inventory/containerDialog/containerDialog.css new file mode 100644 index 00000000..988b0159 --- /dev/null +++ b/rpg-docs/client/views/character/inventory/containerDialog/containerDialog.css @@ -0,0 +1,8 @@ +.containerSummaryTable td{ + text-align: right; + padding: 4px; +} + +.containerSummaryTable td:first-child { + text-align: left; +} diff --git a/rpg-docs/client/views/character/inventory/containerDialog/containerDialog.html b/rpg-docs/client/views/character/inventory/containerDialog/containerDialog.html index 5b13c831..f6ddfbc8 100644 --- a/rpg-docs/client/views/character/inventory/containerDialog/containerDialog.html +++ b/rpg-docs/client/views/character/inventory/containerDialog/containerDialog.html @@ -1,22 +1,46 @@ \ No newline at end of file + + + + + diff --git a/rpg-docs/client/views/character/inventory/containerDialog/containerDialog.js b/rpg-docs/client/views/character/inventory/containerDialog/containerDialog.js index 7e112f42..05662f4e 100644 --- a/rpg-docs/client/views/character/inventory/containerDialog/containerDialog.js +++ b/rpg-docs/client/views/character/inventory/containerDialog/containerDialog.js @@ -4,7 +4,11 @@ Template.containerDialog.helpers({ } }); -Template.containerDialog.events({ +Template.containerEdit.onRendered(function(){ + updatePolymerInputs(this); +}); + +Template.containerEdit.events({ "color-change": function(event, instance){ Containers.update(instance.data.containerId, {$set: {color: event.color}}); }, diff --git a/rpg-docs/client/views/character/inventory/inventory.css b/rpg-docs/client/views/character/inventory/inventory.css index f7cb5b0a..5a041ec4 100644 --- a/rpg-docs/client/views/character/inventory/inventory.css +++ b/rpg-docs/client/views/character/inventory/inventory.css @@ -40,7 +40,6 @@ div#stats { .containerRight { padding: 16px; - cursor: pointer; /* same style as subhead */ font-size: 16px; diff --git a/rpg-docs/client/views/character/inventory/inventory.js b/rpg-docs/client/views/character/inventory/inventory.js index 65575356..c1450c8d 100644 --- a/rpg-docs/client/views/character/inventory/inventory.js +++ b/rpg-docs/client/views/character/inventory/inventory.js @@ -84,7 +84,7 @@ Template.inventory.events({ if(err) throw err; GlobalUI.setDetail({ template: "itemDialog", - data: {itemId: itemId, charId: charId}, + data: {itemId: itemId, charId: charId, startEditing: true}, heroId: itemId }); }); @@ -93,7 +93,7 @@ Template.inventory.events({ var containerId = Containers.insert({name: "New Container", isCarried: true, charId: this._id}); GlobalUI.setDetail({ template: "containerDialog", - data: {containerId: containerId, charId: this.charId}, + data: {containerId: containerId, charId: this.charId, startEditing: true}, heroId: containerId }); }, diff --git a/rpg-docs/client/views/character/inventory/itemDialog/itemDialog.html b/rpg-docs/client/views/character/inventory/itemDialog/itemDialog.html index 2e8508ac..47a21d86 100644 --- a/rpg-docs/client/views/character/inventory/itemDialog/itemDialog.html +++ b/rpg-docs/client/views/character/inventory/itemDialog/itemDialog.html @@ -1,11 +1,9 @@ diff --git a/rpg-docs/client/views/character/inventory/itemDialog/itemDialog.js b/rpg-docs/client/views/character/inventory/itemDialog/itemDialog.js index 90f617fb..cb7a42b2 100644 --- a/rpg-docs/client/views/character/inventory/itemDialog/itemDialog.js +++ b/rpg-docs/client/views/character/inventory/itemDialog/itemDialog.js @@ -3,7 +3,7 @@ var getContainers = function(charId){ }; Template.itemDialog.onCreated(function(){ - this.editing = new ReactiveVar(false); + this.editing = new ReactiveVar(!!this.data.startEditing); }); Template.itemDialog.helpers({ diff --git a/rpg-docs/client/views/character/journal/classDialog/classDialog.html b/rpg-docs/client/views/character/journal/classDialog/classDialog.html index 5352781b..292c3469 100644 --- a/rpg-docs/client/views/character/journal/classDialog/classDialog.html +++ b/rpg-docs/client/views/character/journal/classDialog/classDialog.html @@ -1,6 +1,18 @@