Skip to content

Commit 499764b

Browse files
committed
Add selection for team name
1 parent b9967c7 commit 499764b

File tree

4 files changed

+130
-18
lines changed

4 files changed

+130
-18
lines changed

refBoxState.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ func NewRefBoxState(config RefBoxConfig) (refBoxState *RefBoxState) {
8888

8989
refBoxState.TeamState = map[Team]*RefBoxTeamState{}
9090
refBoxState.TeamState[TeamYellow] = new(RefBoxTeamState)
91-
refBoxState.TeamState[TeamYellow].Name = "Yellow"
91+
refBoxState.TeamState[TeamYellow].Name = ""
9292
refBoxState.TeamState[TeamYellow].Goals = 0
9393
refBoxState.TeamState[TeamYellow].Goalie = 0
9494
refBoxState.TeamState[TeamYellow].YellowCards = 0
@@ -99,7 +99,7 @@ func NewRefBoxState(config RefBoxConfig) (refBoxState *RefBoxState) {
9999
refBoxState.TeamState[TeamYellow].OnPositiveHalf = true
100100

101101
refBoxState.TeamState[TeamBlue] = new(RefBoxTeamState)
102-
refBoxState.TeamState[TeamBlue].Name = "Blue"
102+
refBoxState.TeamState[TeamBlue].Name = ""
103103
refBoxState.TeamState[TeamBlue].Goals = 0
104104
refBoxState.TeamState[TeamBlue].Goalie = 0
105105
refBoxState.TeamState[TeamBlue].YellowCards = 0
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<template>
2+
<div>
3+
<label v-show="edit === false"
4+
@dblclick="switchToEdit">
5+
{{label}} {{value}}
6+
</label>
7+
<label v-show="edit === true">
8+
{{label}}
9+
</label>
10+
<b-form-select v-show="edit === true"
11+
id="edit-input"
12+
v-model="editValue"
13+
:options="options"
14+
class="mb-3"></b-form-select>
15+
</div>
16+
</template>
17+
18+
<script>
19+
export default {
20+
name: "EditableLabelSelect",
21+
props: {
22+
label: String,
23+
value: String,
24+
options: Array,
25+
callback: Function
26+
},
27+
data: function () {
28+
return {edit: false, editValue: ""}
29+
},
30+
methods: {
31+
updateValue: function () {
32+
this.g.edit = false;
33+
this.callback(this.g.value)
34+
},
35+
switchToEdit: function () {
36+
this.edit = true;
37+
this.editValue = this.value;
38+
}
39+
},
40+
watch: {
41+
editValue: function (newTeamName) {
42+
this.edit = false;
43+
this.callback(this.editValue)
44+
}
45+
}
46+
}
47+
</script>
48+
49+
<style scoped>
50+
51+
</style>

ui/src/components/team/TeamName.vue

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<template>
2+
<div>
3+
<EditableLabelSelect
4+
label="Name: "
5+
:value="team.name"
6+
:options="teams"
7+
:callback="updateTeamName"
8+
/>
9+
</div>
10+
11+
</template>
12+
13+
<script>
14+
import EditableLabelSelect from "../common/EditableLabelSelect";
15+
16+
export const TEAMS = [
17+
"",
18+
"AIS",
19+
"AMC",
20+
"CMμs",
21+
"ER-Force",
22+
"Immortals",
23+
"KIKS",
24+
"MCT Susano Logics",
25+
"MRL",
26+
"NEUIslanders",
27+
"OMID",
28+
"Parsian",
29+
"RoboDragons",
30+
"RoboFEI",
31+
"RoboIME",
32+
"RoboJackets",
33+
"RoboTeam Twente",
34+
"SRC",
35+
"SSH",
36+
"STOx’s",
37+
"TIGERs Mannheim",
38+
"ULtron",
39+
"UMass Minutebots",
40+
"UBC Thunderbots",
41+
"ZJUNlict"];
42+
43+
export default {
44+
name: "TeamName",
45+
components: {EditableLabelSelect},
46+
props: {
47+
teamColor: String
48+
},
49+
computed: {
50+
team: function () {
51+
return this.$store.state.refBoxState.teamState[this.teamColor]
52+
},
53+
teams: function () {
54+
return TEAMS
55+
}
56+
},
57+
methods: {
58+
updateTeamName: function (v) {
59+
this.$socket.sendObj({
60+
'modify': {
61+
'forTeam': this.teamColor,
62+
'modifyType': 'teamName',
63+
'valueStr': v
64+
}
65+
})
66+
}
67+
}
68+
}
69+
</script>
70+
71+
<style scoped>
72+
73+
</style>

ui/src/components/team/TeamOverview.vue

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
<template>
22
<div class="team-overview">
33
<h2> Team {{teamColor}}</h2>
4-
<EditableLabelText
5-
label="Name: "
6-
:value="team.name"
7-
:callback="updateTeamName"/>
4+
<TeamName
5+
:team-color="teamColor"/>
86
<TeamScore
97
:team-color="teamColor"
108
:score="team.goals"
@@ -37,28 +35,18 @@
3735
import TeamCards from "./TeamCards";
3836
import EditableLabelText from "../common/EditableLabelText";
3937
import TeamHalf from "./TeamHalf";
38+
import TeamName from "./TeamName";
4039
4140
export default {
4241
name: "TeamOverview",
43-
components: {TeamHalf, EditableLabelText, TeamGoalie, TeamTimeouts, TeamScore, TeamCards},
42+
components: {TeamName, TeamHalf, EditableLabelText, TeamGoalie, TeamTimeouts, TeamScore, TeamCards},
4443
props: {
4544
teamColor: String
4645
},
4746
computed: {
4847
team: function () {
4948
return this.$store.state.refBoxState.teamState[this.teamColor]
5049
},
51-
},
52-
methods: {
53-
updateTeamName: function (v) {
54-
this.$socket.sendObj({
55-
'modify': {
56-
'forTeam': this.teamColor,
57-
'modifyType': 'teamName',
58-
'valueStr': v
59-
}
60-
})
61-
}
6250
}
6351
}
6452
</script>

0 commit comments

Comments
 (0)