adds requests state for Request component

This commit is contained in:
2019-06-14 15:38:24 +02:00
parent 0e71776f4f
commit dc7a0da95d
4 changed files with 51 additions and 31 deletions

View File

@@ -17,7 +17,7 @@
<div class="dropdown-menu" id="dropdown-menu" role="menu"
v-closable="{ exclude: ['dropdown_btn'], handler: 'closeDropdown', visible: show_dropdown }">
<div class="dropdown-content">
<a v-for="(p,i) in player_list" :key="i"
<a v-for="(p,i) in state.player_list" :key="i"
@click="setActivePlayer(i)"
href="#" class="dropdown-item">
{{ p.name }}</a>
@@ -41,9 +41,9 @@
<a href="#" class="card-footer-item disabled">Historique</a>
</footer>
</div>
<div class="card" v-show="app_state.show_player_chest" style="margin-top: 1em;">
<div class="card" v-show="state.show_player_chest" style="margin-top: 1em;">
<div class="card-content">
<Chest :player="app_state.player_id"></Chest>
<Chest :player="state.player_id"></Chest>
</div>
</div>
</div>
@@ -74,13 +74,7 @@
components: { Chest, Wealth },
data () {
return {
app_state: store.state,
player_list: [
{id: 0, name: "Groupe", wealth: [0,0,0,0], debt: 0},
{id: 1, name: "Lomion", wealth: [0,0,0,0], debt: 0},
{id: 4, name: "Oilosse", wealth: [0,0,0,0], debt: 0},
{id: 3, name: "Fefi", wealth: [0,0,0,0], debt: 0},
],
state: store.state,
show_dropdown: false,
edit_wealth: false,
handleOutsideClick: null,
@@ -88,16 +82,16 @@
},
computed: {
player () {
const id = this.app_state.player_id;
const idx = this.player_list.findIndex(p => p.id == id);
return this.player_list[idx];
const id = this.state.player_id;
const idx = this.state.player_list.findIndex(p => p.id == id);
return this.state.player_list[idx];
},
name () {
return this.player.name;
},
// Check if the active player is the special 'Group' player
playerIsGroup () {
return this.app_state.player_id == 0;
return this.state.player_id == 0;
}
},
methods: {
@@ -105,15 +99,15 @@
store.switchPlayerChestVisibility();
},
hidePlayerChest () {
if (this.app_state.show_player_chest) {
if (this.state.show_player_chest) {
this.switchPlayerChestVisibility();
}
},
setActivePlayer (playerIdx) {
const newId = this.player_list[playerIdx].id;
const newId = this.state.player_list[playerIdx].id;
store.setActivePlayer(newId);
if (newId == 0) { this.hidePlayerChest() }
this.player.name = this.player_list[playerIdx].name
this.player.name = this.state.player_list[playerIdx].name
},
closeDropdown () {
this.show_dropdown = false