mirror of
https://github.com/EDCD/coriolis.git
synced 2025-12-08 22:33:24 +00:00
Merge branch 'develop'
This commit is contained in:
@@ -2,6 +2,7 @@ import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import TranslatedComponent from './TranslatedComponent';
|
||||
import ShortenUrl from '../utils/ShortenUrl';
|
||||
import Persist from '../stores/Persist';
|
||||
|
||||
/**
|
||||
* Permalink modal
|
||||
@@ -21,13 +22,7 @@ export default class ModalShoppingList extends TranslatedComponent {
|
||||
this.state = {
|
||||
matsList: '',
|
||||
mats: {},
|
||||
matsPerGrade: {
|
||||
1: 2,
|
||||
2: 2,
|
||||
3: 3,
|
||||
4: 4,
|
||||
5: 6
|
||||
}
|
||||
matsPerGrade: Persist.getRolls()
|
||||
};
|
||||
}
|
||||
|
||||
@@ -89,6 +84,7 @@ export default class ModalShoppingList extends TranslatedComponent {
|
||||
let newState = this.state.matsPerGrade;
|
||||
newState[grade] = parseInt(e.target.value);
|
||||
this.setState({ matsPerGrade: newState });
|
||||
Persist.setRolls(newState);
|
||||
this.renderMats();
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ const LS_KEY_STATE = 'state';
|
||||
const LS_KEY_SIZE_RATIO = 'sizeRatio';
|
||||
const LS_KEY_TOOLTIPS = 'tooltips';
|
||||
const LS_KEY_MODULE_RESISTANCES = 'moduleResistances';
|
||||
const LS_KEY_ROLLS = 'matsPerGrade';
|
||||
|
||||
let LS;
|
||||
|
||||
@@ -84,6 +85,7 @@ export class Persist extends EventEmitter {
|
||||
}
|
||||
|
||||
let moduleResistances = _get(LS_KEY_MODULE_RESISTANCES);
|
||||
let matsPerGrade = _get(LS_KEY_ROLLS);
|
||||
let tips = _get(LS_KEY_TOOLTIPS);
|
||||
let insurance = _getString(LS_KEY_INSURANCE);
|
||||
let shipDiscount = _get(LS_KEY_SHIP_DISCOUNT);
|
||||
@@ -102,6 +104,13 @@ export class Persist extends EventEmitter {
|
||||
this.outfittingTab = _getString(LS_KEY_OUTFITTING_TAB);
|
||||
this.state = _get(LS_KEY_STATE);
|
||||
this.sizeRatio = _get(LS_KEY_SIZE_RATIO) || 1;
|
||||
this.matsPerGrade = matsPerGrade || {
|
||||
1: 2,
|
||||
2: 2,
|
||||
3: 4,
|
||||
4: 4,
|
||||
5: 10
|
||||
};
|
||||
this.tooltipsEnabled = tips === null ? true : tips;
|
||||
this.moduleResistancesEnabled = moduleResistances === null ? true : moduleResistances;
|
||||
|
||||
@@ -152,6 +161,10 @@ export class Persist extends EventEmitter {
|
||||
this.moduleResistancesEnabled = !!newValue && newValue.toLowerCase() == 'true';
|
||||
this.emit('moduleresistances', this.moduleResistancesEnabled);
|
||||
break;
|
||||
case LS_KEY_ROLLS:
|
||||
this.matsPerGrade = JSON.parse(newValue);
|
||||
this.emit('matsPerGrade', this.matsPerGrade);
|
||||
break;
|
||||
}
|
||||
} catch (e) {
|
||||
// On JSON.Parse Error - don't sync or do anything
|
||||
@@ -457,6 +470,23 @@ export class Persist extends EventEmitter {
|
||||
return this.moduleDiscount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the saved ship discount
|
||||
* @param {Object} matsPerGrade # of rolls per grade
|
||||
*/
|
||||
setRolls(matsPerGrade) {
|
||||
this.matsPerGrade = matsPerGrade;
|
||||
_put(LS_KEY_ROLLS, this.matsPerGrade);
|
||||
this.emit('matsPerGrade');
|
||||
}
|
||||
/**
|
||||
* Get the saved Mats per grade
|
||||
* @return {Object} # of rolls per grade
|
||||
*/
|
||||
getRolls() {
|
||||
return this.matsPerGrade;
|
||||
}
|
||||
|
||||
/**
|
||||
* Persist selected cost tab
|
||||
* @param {number} tabName Cost tab name
|
||||
|
||||
Reference in New Issue
Block a user