mirror of
https://github.com/EDCD/coriolis.git
synced 2025-12-09 14:45:35 +00:00
Adding founders world discount
This commit is contained in:
@@ -33,6 +33,8 @@ function($rootScope, $location, $window, $doc, $state, CArr, shipPurpose, sz, hp
|
||||
$rootScope.SZ = sz;
|
||||
$rootScope.HPC = hpc;
|
||||
$rootScope.GMAP = GroupMap;
|
||||
$rootScope.insurance = { opts: [{ name: 'Standard', pct: 0.05 }, { name: 'Alpha', pct: 0.025 }, { name: 'Beta', pct: 0.035 }] };
|
||||
$rootScope.discounts = { opts: [{ name: 'None', pct: 1 }, { name: 'Founders World - 10%', pct: 0.90 }] };
|
||||
$rootScope.STATUS = ['', 'DISABLED', 'OFF', 'ON'];
|
||||
$rootScope.STATUS_CLASS = ['', 'disabled', 'warning', 'secondary-disabled'];
|
||||
$rootScope.title = 'Coriolis';
|
||||
|
||||
@@ -12,17 +12,9 @@ angular.module('app').directive('shipyardHeader', ['lodash', '$rootScope', 'Pers
|
||||
scope.allComparisons = Persist.comparisons;
|
||||
scope.bs = Persist.state;
|
||||
|
||||
// Insurance options and management here for now.
|
||||
$rootScope.insurance = {
|
||||
opts: [
|
||||
{ name: 'Standard', pct: 0.05 },
|
||||
{ name: 'Alpha', pct: 0.025 },
|
||||
{ name: 'Beta', pct: 0.035 }
|
||||
]
|
||||
};
|
||||
|
||||
var insIndex = _.findIndex($rootScope.insurance.opts, 'name', Persist.getInsurance());
|
||||
$rootScope.insurance.current = $rootScope.insurance.opts[insIndex != -1 ? insIndex : 0];
|
||||
$rootScope.discounts.current = $rootScope.discounts.opts[Persist.getDiscount() || 0];
|
||||
|
||||
// Close menus if a navigation change event occurs
|
||||
$rootScope.$on('$stateChangeStart', function() {
|
||||
@@ -42,6 +34,13 @@ angular.module('app').directive('shipyardHeader', ['lodash', '$rootScope', 'Pers
|
||||
Persist.setInsurance($rootScope.insurance.current.name);
|
||||
};
|
||||
|
||||
/**
|
||||
* Save selected discount option
|
||||
*/
|
||||
scope.updateDiscount = function() {
|
||||
Persist.setDiscount($rootScope.discounts.opts.indexOf($rootScope.discounts.current));
|
||||
};
|
||||
|
||||
scope.openMenu = function(e, menu) {
|
||||
e.stopPropagation();
|
||||
if (menu == scope.openedMenu) {
|
||||
|
||||
@@ -183,6 +183,27 @@ angular.module('app').service('Persist', ['$window', 'lodash', function($window,
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Persist selected discount
|
||||
* @param {number} val Discount value/amount
|
||||
*/
|
||||
this.setDiscount = function(val) {
|
||||
if (this.lsEnabled) {
|
||||
return localStorage.setItem('discount', val);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the saved discount
|
||||
* @return {number} val Discount value/amount
|
||||
*/
|
||||
this.getDiscount = function() {
|
||||
if (this.lsEnabled) {
|
||||
return localStorage.getItem('discount');
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieve the last router state from local storage
|
||||
* @param {object} state State object containing state name and params
|
||||
|
||||
@@ -51,6 +51,10 @@
|
||||
<ul>
|
||||
Insurance
|
||||
<li><select ng-model="insurance.current" ng-options="ins.name for (i,ins) in insurance.opts" ng-change="updateInsurance()"></select></li>
|
||||
</ul><br>
|
||||
<ul>
|
||||
Discount
|
||||
<li><select ng-model="discounts.current" ng-options="d.name for (i,d) in discounts.opts" ng-change="updateDiscount()"></select></li>
|
||||
</ul>
|
||||
<hr />
|
||||
<ul>
|
||||
|
||||
@@ -242,21 +242,21 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr class="toggleable" ng-repeat="c in costList | orderBy:costPredicate:costDesc" ng-if="c.c.cost > 0" ng-class="{disabled:!c.incCost}" ng-click="toggleCost(c)">
|
||||
<td style="width:1em;">{{c.c.class}}{{c.c.rating}}</td>
|
||||
<td class="le shorten" ng-bind="cName(c)"></td>
|
||||
<td class="ri">{{fCrd(c.c.cost)}} <u>CR</u></td>
|
||||
<tr ng-repeat="c in costList | orderBy:costPredicate:costDesc" ng-if="c.c.cost > 0" ng-class="{disabled:!c.incCost}">
|
||||
<td class="toggleable" style="width:1em;" ng-click="toggleCost(c)">{{c.c.class}}{{c.c.rating}}</td>
|
||||
<td class="le toggleable shorten" ng-bind="cName(c)" ng-click="toggleCost(c)"></td>
|
||||
<td class="ri toggleable" ng-click="toggleCost(c)">{{fCrd(discounts.current.pct * c.c.cost)}} <u>CR</u></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<table class="total">
|
||||
<tr class="ri">
|
||||
<td class="lbl">Total</td>
|
||||
<td>{{fCrd(ship.totalCost)}} <u>CR</u></td>
|
||||
<td>{{fCrd(ship.totalCost * discounts.current.pct)}} <u>CR</u></td>
|
||||
</tr>
|
||||
<tr class="ri">
|
||||
<td class="lbl">Insurance</td>
|
||||
<td>{{fCrd(ship.totalCost * insurance.current.pct)}} <u>CR</u></td>
|
||||
<td>{{fCrd(ship.totalCost * discounts.current.pct * insurance.current.pct)}} <u>CR</u></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user