Skip to content
This repository has been archived by the owner on Mar 27, 2024. It is now read-only.

Commit

Permalink
issue #14 fixed - set default chain - no nav guard
Browse files Browse the repository at this point in the history
  • Loading branch information
tbfuerst committed May 16, 2019
1 parent 1df8e73 commit 74e2eec
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 24 deletions.
28 changes: 9 additions & 19 deletions src/components/ProductionChains.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,18 @@
</template>

<script>
import BottomNavBar from './BottomNavBar.vue';
import VisualProductionChain from './production_chains/VisualProductionChain.vue';
import store from '../store.js';
import BottomNavBar from "./BottomNavBar.vue";
import VisualProductionChain from "./production_chains/VisualProductionChain.vue";
import { helperFunctionMixin } from "./helperFunctionMixin.js";
import store from "../store.js";
export default {
name: 'ProductionChains',
name: "ProductionChains",
mixins: [helperFunctionMixin],
components: {
'bottom-nav-bar': BottomNavBar,
'visual-production-chain': VisualProductionChain,
},
beforeRouteEnter(to, from, next) {
const chain = store.state.selectedProductionChain;
if (chain === null) {
store.commit('resetSelectionIDs');
}
next((vm) => {
// gets executed when component is loaded. has access to component
});
},
"bottom-nav-bar": BottomNavBar,
"visual-production-chain": VisualProductionChain
}
};
</script>

Expand Down
26 changes: 21 additions & 5 deletions src/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,25 @@ export default new Vuex.Store({
],

state: {
selectedProductionChain: null,
selectedWorldID: 0,
selectedSocialClassID: 0,
selectedProductionChainID: 0,
selectedProductionChain: {
id: 1,
worldID: 1,
chain: 'Timber',
socialClassID: 1,
finalProduct: 'Timber',
name: 'Sawmill',
img: 'farmers/timber.webp',
alternative: '',
children: [{
name: 'Lumberjack Hut',
worldID: 1,
alternative: '',
children: null,
}],
},
selectedWorldID: 1,
selectedSocialClassID: 1,
selectedProductionChainID: 1,

buildingQueue: [],

Expand Down Expand Up @@ -152,7 +167,8 @@ export default new Vuex.Store({
state.selectedProductionChainID = chainID;
},

resetSelectionIDs(state) {
resetSelectionIDs(state, initChain) {
state.selectedProductionChain = initChain;
state.selectedProductionChainID = 1;
state.selectedSocialClassID = 1;
state.selectedWorldID = 1;
Expand Down

0 comments on commit 74e2eec

Please sign in to comment.