Add code props variable as ship hash to update changes

This commit is contained in:
Felix Linker
2020-04-16 15:12:38 +02:00
parent 904498b20c
commit ba9e7f1a32
5 changed files with 11 additions and 20 deletions

View File

@@ -32,6 +32,7 @@ function getClass(selected, relDraw) {
export default class PowerBands extends TranslatedComponent {
static propTypes = {
ship: PropTypes.instanceOf(Ship).isRequired,
code: PropTypes.string.isRequired,
width: PropTypes.number.isRequired,
};

View File

@@ -45,6 +45,7 @@ function getPowerIcon(enabled) {
export default class PowerManagement extends TranslatedComponent {
static propTypes = {
ship: PropTypes.instanceOf(Ship).isRequired,
code: PropTypes.string.isRequired,
onChange: PropTypes.func.isRequired
};
@@ -215,7 +216,7 @@ export default class PowerManagement extends TranslatedComponent {
* @return {React.Component} contents
*/
render() {
let { ship } = this.props;
let { ship, code } = this.props;
let { translate, formats } = this.context.language;
let pp = ship.getPowerPlant();
@@ -248,7 +249,7 @@ export default class PowerManagement extends TranslatedComponent {
{this._renderPowerRows(ship, translate, formats.f2, formats.pct1)}
</tbody>
</table>
<PowerBands width={this.state.width} ship={ship} available={pp.get('powercapacity')} />
<PowerBands width={this.state.width} ship={ship} code={code} />
</div>
);
}

View File

@@ -11,7 +11,6 @@ const {
ARMOUR_METRICS, CARGO_CAPACITY, FUEL_CAPACITY, UNLADEN_MASS, MAXIMUM_MASS,
MODULE_PROTECTION_METRICS
} = ShipProps;
import { OBJECT_EVENT } from 'ed-forge/lib/Ship';
/**
* Ship Summary Table / Stats
@@ -19,6 +18,7 @@ import { OBJECT_EVENT } from 'ed-forge/lib/Ship';
export default class ShipSummaryTable extends TranslatedComponent {
static propTypes = {
ship: PropTypes.object.isRequired,
code: PropTypes.string.isRequired,
};
/**
@@ -33,18 +33,6 @@ export default class ShipSummaryTable extends TranslatedComponent {
};
}
_onChange() {
this.forceUpdate();
}
componentWillMount() {
this.props.ship.on(OBJECT_EVENT, this._onChange);
}
componentWillUnmount() {
this.props.ship.removeListener(OBJECT_EVENT, this._onChange);
}
/**
* Render the table
* @return {React.Component} Summary table

View File

@@ -15,6 +15,7 @@ const browser = require('detect-browser');
export default class SlotSection extends TranslatedComponent {
static propTypes = {
ship: PropTypes.instanceOf(Ship),
code: PropTypes.string.isRequired,
togglePwr: PropTypes.func,
};

View File

@@ -631,11 +631,11 @@ export default class OutfittingPage extends Page {
</div>
{/* Main tables */}
<ShipSummaryTable ship={ship} />
<StandardSlotSection ship={ship} currentMenu={menu} />
<InternalSlotSection ship={ship} currentMenu={menu} />
<HardpointSlotSection ship={ship} currentMenu={menu} />
<UtilitySlotSection ship={ship} currentMenu={menu} />
<ShipSummaryTable ship={ship} code={code} />
<StandardSlotSection ship={ship} code={code} currentMenu={menu} />
<InternalSlotSection ship={ship} code={code} currentMenu={menu} />
<HardpointSlotSection ship={ship} code={code} currentMenu={menu} />
<UtilitySlotSection ship={ship} code={code} currentMenu={menu} />
{/* Control of ship and opponent */}
{/* <div className="group quarter">