Permalink
Browse files

Add factions to sample data and parse them

  • Loading branch information...
markerikson committed Dec 30, 2017
1 parent 29eb97b commit da9dcbf1b6de59468c42b417ee5a0ea8e64be3dc
Showing with 14 additions and 3 deletions.
  1. +4 −3 src/app/reducers/entitiesReducer.js
  2. +10 −0 src/data/sampleData.js
@@ -10,19 +10,20 @@ export function loadData(state, payload) {
// Create a Redux-ORM session from our entities "tables"
const session = orm.session(state);
// Get a reference to the correct version of model classes for this Session
const {Unit, Pilot, Mech, MechDesign} = session;
const {Unit, Faction, Pilot, Mech, MechDesign} = session;
const {unit, designs} = payload;
const {unit, factions, designs} = payload;
// Clear out any existing models from state so that we can avoid
// conflicts from the new data coming in if data is reloaded
[Unit, Pilot, Mech, MechDesign].forEach(modelType => {
[Unit, Faction, Pilot, Mech, MechDesign].forEach(modelType => {
modelType.all().toModelArray().forEach(model => model.delete());
});
// Immutably update the session state as we insert items
Unit.parse(unit);
factions.forEach(faction => Faction.parse(faction));
designs.forEach(design => MechDesign.parse(design));
// Return the new "tables" object containing the updates
View
@@ -227,6 +227,16 @@ const sampleData = {
},
],
factions : [
{id : "cc", name : "Capellan Confederation"},
{id : "dc", name : "Draconis Combine"},
{id : "elh", name : "Eridani Light Horse"},
{id : "fs", name : "Federated Suns"},
{id : "fwl", name : "Free Worlds League"},
{id : "hr", name : "Hansen's Roughriders"},
{id : "lc", name : "Lyran Commonwealth"},
{id : "wd", name : "Wolf's Dragoons"},
]
};

0 comments on commit da9dcbf

Please sign in to comment.