Seperate discounts for ship and components, added discounts for 5,10,15,20,25 percent off

This commit is contained in:
Colin McLeod
2015-06-25 20:26:22 -07:00
parent 9009a2a434
commit 10d5611dcd
11 changed files with 128 additions and 31 deletions

View File

@@ -13,8 +13,10 @@ angular.module('app').directive('shipyardHeader', ['lodash', '$rootScope', 'Pers
scope.bs = Persist.state;
var insIndex = _.findIndex($rootScope.insurance.opts, 'name', Persist.getInsurance());
var savedDiscounts = Persist.getDiscount() || [1, 1];
$rootScope.insurance.current = $rootScope.insurance.opts[insIndex != -1 ? insIndex : 0];
$rootScope.discounts.current = $rootScope.discounts.opts[Persist.getDiscount() || 0];
$rootScope.discounts.ship = savedDiscounts[0];
$rootScope.discounts.components = savedDiscounts[1];
// Close menus if a navigation change event occurs
$rootScope.$on('$stateChangeStart', function() {
@@ -38,7 +40,8 @@ angular.module('app').directive('shipyardHeader', ['lodash', '$rootScope', 'Pers
* Save selected discount option
*/
scope.updateDiscount = function() {
Persist.setDiscount($rootScope.discounts.opts.indexOf($rootScope.discounts.current));
Persist.setDiscount([$rootScope.discounts.ship, $rootScope.discounts.components]);
$rootScope.$broadcast('discountChange');
};
scope.openMenu = function(e, menu) {