From 9b12d46741dd8f16e4a92d82f12301fc3e6fef7c Mon Sep 17 00:00:00 2001 From: Husman Date: Sat, 11 Jun 2016 14:16:10 -0700 Subject: [PATCH] feat: Add group by button to equipment page Closes #7636 Closes #7651 This commit creates a new button on the equipment page that allows the user to group their equipment type (body location) instead of simply by class. --- common/locales/en/gear.json | 8 +++++ common/locales/es/backgrounds.json | 2 +- common/locales/es/loadingscreentips.json | 2 +- common/locales/it/loadingscreentips.json | 2 +- .../client/js/controllers/inventoryCtrl.js | 21 +++++++++--- .../js/controllers/sortableInventoryCtrl.js | 4 +++ .../views/options/inventory/equipment.jade | 34 ++++++++++++++++--- 7 files changed, 62 insertions(+), 11 deletions(-) diff --git a/common/locales/en/gear.json b/common/locales/en/gear.json index cf8c5ec8e1..3aca3a9674 100644 --- a/common/locales/en/gear.json +++ b/common/locales/en/gear.json @@ -1,7 +1,11 @@ { "set": "Set", + "equipmentType" : "Type", + "klass": "Class", + "groupBy": "Group By <%= type %>", "weapon": "weapon", + "waeaponCapitalized" : "Weapon", "weaponBase0Text": "No Weapon", "weaponBase0Notes": "No Weapon.", @@ -214,6 +218,7 @@ "weaponArmoireSandySpadeNotes": "A tool for digging, as well as flicking sand into the eyes of enemy monsters. Increases Strength by <%= str %>. Enchanted Armoire: Seaside Set (Item 1 of 3).", "armor": "armor", + "armorCapitalized": "Armor", "armorBase0Text": "Plain Clothing", "armorBase0Notes": "Ordinary clothing. Confers no benefit.", @@ -447,6 +452,7 @@ "armorArmoireStripedSwimsuitNotes": "What could be more fun than battling sea monsters on the beach? Increases Constitution by <%= con %>. Enchanted Armoire: Seaside Set (Item 2 of 3).", "headgear": "headgear", + "headgearCapitalized": "Headgear", "headBase0Text": "No Helm", "headBase0Notes": "No headgear.", @@ -694,6 +700,7 @@ "headArmoireGreenFloppyHatNotes": "Many spells have been sewn into this simple hat, giving it a gorgeous green color. Increases Constitution, Intelligence, and Perception by <%= attrs %> each. Enchanted Armoire: Independent Item.", "offhand": "shield-hand item", + "offhandCapitalized": "Shield-Hand Item", "shieldBase0Text": "No Shield-Hand Equipment", "shieldBase0Notes": "No shield or second weapon.", @@ -868,6 +875,7 @@ "bodySpecialSummer2015HealerNotes": "Yo ho ho? No, no, no! Confers no benefit. Limited Edition 2015 Summer Gear.", "headAccessory": "head accessory", + "headAccessoryCapitalizaed": "Head Accessory", "accessories": "Accessories", "animalEars": "Animal Ears", diff --git a/common/locales/es/backgrounds.json b/common/locales/es/backgrounds.json index 65b40c0e51..7a24857cd6 100644 --- a/common/locales/es/backgrounds.json +++ b/common/locales/es/backgrounds.json @@ -175,4 +175,4 @@ "backgroundLilypadNotes": "Salta sobre un nenúfar.", "backgroundWaterfallRockText": "Roca de cascada", "backgroundWaterfallRockNotes": "Chapotea junto a la roca de la cascada." -} \ No newline at end of file +} diff --git a/common/locales/es/loadingscreentips.json b/common/locales/es/loadingscreentips.json index 112e470312..896f99d684 100644 --- a/common/locales/es/loadingscreentips.json +++ b/common/locales/es/loadingscreentips.json @@ -32,4 +32,4 @@ "tip30": "Puedes invitar a otras personas a los gremios, no solo a grupos.", "tip31": "Para ver algunos ejemplos de tareas, echa un vistazo a las listas del gremio \"Library of Shared Lists\".", "tip32": "Gran parte del código, los diseños y los textos de Habitica es obra de colaboradores voluntarios. Todo el mundo puede ayudar." -} \ No newline at end of file +} diff --git a/common/locales/it/loadingscreentips.json b/common/locales/it/loadingscreentips.json index 96120bbd29..f6a474b5a5 100644 --- a/common/locales/it/loadingscreentips.json +++ b/common/locales/it/loadingscreentips.json @@ -32,4 +32,4 @@ "tip30": "You can invite people to Guilds, not just Parties.", "tip31": "Check out the pre-made lists in the Library of Shared Lists Guild for example tasks.", "tip32": "Lots of Habitica’s code, art, and writing is made by volunteer contributors! Anyone can help." -} \ No newline at end of file +} diff --git a/website/client/js/controllers/inventoryCtrl.js b/website/client/js/controllers/inventoryCtrl.js index b6ff45cbf7..90d88025ae 100644 --- a/website/client/js/controllers/inventoryCtrl.js +++ b/website/client/js/controllers/inventoryCtrl.js @@ -53,12 +53,25 @@ habitrpg.controller("InventoryCtrl", $scope.$watch('user.items.quests', function(quest){ $scope.questCount = countStacks(quest); }, true); $scope.$watch('user.items.gear', function(gear){ - $scope.gear = {}; + $scope.gearByClass = {}; + $scope.gearByType = {}; _.each(gear.owned, function(v,key){ - if (v === false) return; + if (v === false) { + return; + } + var item = Content.gear.flat[key]; - if (!$scope.gear[item.klass]) $scope.gear[item.klass] = []; - $scope.gear[item.klass].push(item); + + if (!$scope.gearByClass[item.klass]) { + $scope.gearByClass[item.klass] = []; + } + $scope.gearByClass[item.klass].push(item); + + if (!$scope.gearByType[item.type]) { + $scope.gearByType[item.type] = []; + } + + $scope.gearByType[item.type].push(item); }) }, true); diff --git a/website/client/js/controllers/sortableInventoryCtrl.js b/website/client/js/controllers/sortableInventoryCtrl.js index 73cea5b560..0c60b3a15f 100644 --- a/website/client/js/controllers/sortableInventoryCtrl.js +++ b/website/client/js/controllers/sortableInventoryCtrl.js @@ -15,6 +15,10 @@ habitrpg.controller('SortableInventoryController', ['$scope', } }; + $scope.setGrouping = function (grouping) { + $scope.groupingChoice = grouping; + }; + $scope.orderChoice = 'set'; $scope.setOrder($scope.orderChoice); }]); diff --git a/website/views/options/inventory/equipment.jade b/website/views/options/inventory/equipment.jade index f2d11be6da..cdb25f6bff 100644 --- a/website/views/options/inventory/equipment.jade +++ b/website/views/options/inventory/equipment.jade @@ -13,10 +13,16 @@ mixin orderByButton - each attr in ["constitution", "intelligence", "perception", "strength"] +choice(attr) -mixin equipmentList(type) - menu.pets-menu(label='{{::label}}', ng-show='gear[klass]', - ng-repeat='(klass,label) in {warrior:env.t("warrior"), wizard:env.t("mage"), rogue:env.t("rogue"), healer:env.t("healer"), special:env.t("special"), mystery:env.t("mystery"), armoire:env.t("armoireText")}') - div(ng-repeat='item in gear[klass] | orderBy: order') +mixin groupingButton + .btn-group + button.btn.btn-default.dropdown-toggle(type='button', data-toggle='dropdown', ng-init='setGrouping("klass")') + | {{env.t('groupBy', { type: env.t(groupingChoice) })}} #[span.caret] + ul.dropdown-menu + - each grouping in ["klass", "equipmentType"] + li(ng-class="{ 'active': groupingChoice === '#{grouping}' }") + a(ng-click="setGrouping('#{grouping}')")=env.t(grouping) + +mixin equipmentButton(type) button.customize-option(class='shop_{{::item.key}}', ng-class='{selectableInventory: user.items.gear.#{type}[item.type] == item.key}', ng-click='equip(item.key, "#{type}")', @@ -24,6 +30,16 @@ mixin equipmentList(type) popover-trigger='mouseenter', popover-placement='right', popover-append-to-body='true') +mixin equipmentList(equipmentType) + menu.pets-menu(label='{{::label}}', ng-show='gearByClass[klass]', ng-if='groupingChoice === "klass"', + ng-repeat='(klass,label) in {warrior:env.t("warrior"), wizard:env.t("mage"), rogue:env.t("rogue"), healer:env.t("healer"), special:env.t("special"), mystery:env.t("mystery"), armoire:env.t("armoireText")}') + div(ng-repeat='item in gearByClass[klass] | orderBy: order') + +equipmentButton(equipmentType) + menu.pets-menu(label='{{::label}}', ng-show='gearByType[type]', ng-if='groupingChoice === "equipmentType"', + ng-repeat='(type,label) in {headAccessory:env.t("headAccessoryCapitalized"), head:env.t("headgearCapitalized"), eyewear:env.t("eyewear"), weapon:env.t("weaponCapitalized"), shield:env.t("offhandCapitalized"), armor:env.t("armorCapitalized"), body:env.t("body"), back:env.t("back")}') + div(ng-repeat='item in gearByType[type] | orderBy: order', ng-show='item.klass !== "base"') + +equipmentButton(equipmentType) + .container-fluid .row .col-md-6.border-right(ng-controller="SortableInventoryController") @@ -41,6 +57,11 @@ mixin equipmentList(type) .btn-toolbar .btn-group button.btn.btn-default(type="button", ng-click='dequip("battleGear");') {{env.t("unequipBattleGear")}} + + br + + .btn-toolbar + +groupingButton +orderByButton li.customize-menu.inventory-gear @@ -62,6 +83,11 @@ mixin equipmentList(type) .btn-group button.btn.btn-default(type="button", ng-click='dequip("costume");') {{env.t("unequipCostume")}} button.btn.btn-default(type="button", ng-click='dequip("petMountBackground");') {{env.t("unequipPetMountBackground")}} + + br + + .btn-toolbar(ng-if='user.preferences.costume') + +groupingButton +orderByButton li.customize-menu(ng-if='!user.preferences.costume')