From 35544f14c599d2ba44b5d240231e17926a056555 Mon Sep 17 00:00:00 2001 From: Blade Barringer Date: Tue, 24 May 2016 07:13:09 -0500 Subject: [PATCH] fix: Armoire sends back data from server rather than relying on client closes #5376 --- website/client/js/controllers/tasksCtrl.js | 5 +++++ website/client/js/services/userServices.js | 11 +++++++++++ .../views/shared/tasks/task_view/static_rewards.jade | 10 ++++++---- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/website/client/js/controllers/tasksCtrl.js b/website/client/js/controllers/tasksCtrl.js index 995b910122..d09ebe1f24 100644 --- a/website/client/js/controllers/tasksCtrl.js +++ b/website/client/js/controllers/tasksCtrl.js @@ -259,6 +259,11 @@ habitrpg.controller("TasksCtrl", ['$scope', '$rootScope', '$location', 'User','N User.buy({params:{key:item.key}}); }; + $scope.buyArmoire = function () { + playRewardSound($scope.armoire); + User.buyArmoire(); + } + /* ------------------------ Hiding Tasks diff --git a/website/client/js/services/userServices.js b/website/client/js/services/userServices.js index 70b8821c6d..edf07a4a86 100644 --- a/website/client/js/services/userServices.js +++ b/website/client/js/services/userServices.js @@ -355,6 +355,17 @@ angular.module('habitrpg') callOpsFunctionAndRequest('buy', 'buy', "POST", data.params.key, data); }, + buyArmoire: function () { + $http({ + method: "POST", + url: '/api/v3/user/buy-armoire', + }) + .then(function (response) { + Notification.text(response.data.message); + sync(); + }) + }, + buyQuest: function (data) { callOpsFunctionAndRequest('buyQuest', 'buy-quest', "POST", data.params.key, data); }, diff --git a/website/views/shared/tasks/task_view/static_rewards.jade b/website/views/shared/tasks/task_view/static_rewards.jade index 3ce7ab78b8..668c8de4ff 100644 --- a/website/views/shared/tasks/task_view/static_rewards.jade +++ b/website/views/shared/tasks/task_view/static_rewards.jade @@ -1,4 +1,6 @@ -mixin reward(item) +mixin reward(item, action) + - action = action || "buy(" + item + ")" + li.task.reward-item(popover-trigger='mouseenter', popover-placement='top', popover='{{::#{item}.notes()}}')&attributes(attributes) // right-hand side control buttons .task-meta-controls @@ -8,8 +10,8 @@ mixin reward(item) .task-controls.task-primary input.reward.visuallyhidden( type='checkbox', - ui-keypress='{13:"buy(#{item})"}') - a.money.btn-buy.item-btn(ng-class='::{highValue: #{item}.value >= 1000}', ng-click='::buy(#{item})') + ui-keypress='{13:"#{action}"}') + a.money.btn-buy.item-btn(ng-class='::{highValue: #{item}.value >= 1000}', ng-click='::#{action}') span.shop_gold span.reward-cost {{::#{item}.value}} // main content @@ -19,5 +21,5 @@ mixin reward(item) ul.items.rewards(ng-if='main && list.type=="reward"') +reward('item')(ng-repeat='item in itemStore') +reward('healthPotion') - +reward('armoire')(ng-if='user.flags.armoireEnabled', + +reward('armoire', 'buyArmoire()')(ng-if='user.flags.armoireEnabled', popover='{{armoire.notes(user, armoireCount(user.items.gear.owned))}}')