Add players array and related mutations
This commit is contained in:
parent
dd365dde86
commit
f31341ffd8
2 changed files with 33 additions and 9 deletions
|
|
@ -64,7 +64,10 @@ export default {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
history.replaceState(null, ``, `?game=${data.game_code}`);
|
||||||
|
|
||||||
// Save the data in the store
|
// Save the data in the store
|
||||||
|
this.$store.commit(`playerList`, data.players);
|
||||||
this.$store.commit(`game_code`, this.game_code);
|
this.$store.commit(`game_code`, this.game_code);
|
||||||
this.$store.commit(`player`, {
|
this.$store.commit(`player`, {
|
||||||
name: this.name,
|
name: this.name,
|
||||||
|
|
@ -79,7 +82,10 @@ export default {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
history.replaceState(null, ``, `?game=${data.game_code}`);
|
||||||
|
|
||||||
// Update storage
|
// Update storage
|
||||||
|
this.$store.commit(`playerList`, data.players);
|
||||||
this.$store.commit(`game_code`, data.game_code);
|
this.$store.commit(`game_code`, data.game_code);
|
||||||
this.$store.commit(`player`, {
|
this.$store.commit(`player`, {
|
||||||
name: this.name,
|
name: this.name,
|
||||||
|
|
|
||||||
|
|
@ -4,20 +4,22 @@
|
||||||
<div class="flex-row">
|
<div class="flex-row">
|
||||||
<button
|
<button
|
||||||
class="clickable"
|
class="clickable"
|
||||||
@click.stop=""
|
v-clipboard:copy="gameURL"
|
||||||
|
v-clipboard:success="copySuccess"
|
||||||
|
v-clipboard:error="copyError"
|
||||||
>
|
>
|
||||||
Click to Copy Game Link
|
{{ copyURLButtonText }}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex-row">
|
<div class="flex-row">
|
||||||
<role-select
|
<role-select
|
||||||
:team_name="$store.state.team_1.name"
|
:teamID="1"
|
||||||
:player_name="playerName"
|
@error="$emit(`error`, $event)"
|
||||||
/>
|
/>
|
||||||
<player-list />
|
<player-list @error="$emit(`error`, $event)" />
|
||||||
<role-select
|
<role-select
|
||||||
:team_name="$store.state.team_2.name"
|
:teamID="2"
|
||||||
:player_name="playerName"
|
@error="$emit(`error`, $event)"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex-row">
|
<div class="flex-row">
|
||||||
|
|
@ -41,12 +43,29 @@ export default {
|
||||||
"RoleSelect": TeamRoleSelect,
|
"RoleSelect": TeamRoleSelect,
|
||||||
"PlayerList": PlayerList,
|
"PlayerList": PlayerList,
|
||||||
},
|
},
|
||||||
|
data() {return {
|
||||||
|
copyURLButtonText: `Click to Copy Game Link`,
|
||||||
|
}},
|
||||||
computed: {
|
computed: {
|
||||||
playerName() {
|
playerName() {
|
||||||
return this.$store.state.name;
|
return this.$store.state.name;
|
||||||
|
},
|
||||||
|
gameURL() {
|
||||||
|
return `${window.location.protocol}//${window.location.host}?game=${this.$store.state.game_code}`;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
copySuccess() {
|
||||||
|
this.copyURLButtonText = `Game Link Copied!`;
|
||||||
|
setTimeout(() => { this.copyURLButtonText = `Click to Copy Game Link`; }, 1000)
|
||||||
|
},
|
||||||
|
copyError(e) {
|
||||||
|
this.$emit(`error`, {
|
||||||
|
status: 418,
|
||||||
|
message: `Failed to copy game URL`,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {},
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
@ -55,7 +74,6 @@ export default {
|
||||||
@import "../css/style.css";
|
@import "../css/style.css";
|
||||||
|
|
||||||
#GameLobby {
|
#GameLobby {
|
||||||
justify-content: center;
|
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: stretch;
|
align-items: stretch;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue