Skip to content

Commit b97f568

Browse files
committed
Make fouls editable in UI as well
1 parent 7a28c19 commit b97f568

File tree

6 files changed

+128
-9
lines changed

6 files changed

+128
-9
lines changed

src/components/common/EditableLabelText.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,20 +54,23 @@
5454
this.$refs.input.focus();
5555
})
5656
},
57+
},
58+
computed: {
5759
inputId() {
5860
if (this.id) {
5961
return this.id;
6062
}
6163
return 'edit-input';
62-
}
63-
},
64+
},
65+
}
6466
}
6567
</script>
6668

6769
<style scoped>
6870
input {
6971
text-align: center;
7072
}
73+
7174
label {
7275
margin-bottom: 0;
7376
}

src/components/team/TeamFoulCounter.vue renamed to src/components/team/TeamFouls.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
<template>
2-
<div>
2+
<span>
33
<a>{{teamState.fouls.length}}</a>
4-
</div>
4+
</span>
55
</template>
66

77
<script>
88
import EditableLabelNumber from "../common/EditableLabelNumber";
99
1010
export default {
11-
name: "TeamFoulCounter",
11+
name: "TeamFouls",
1212
components: {EditableLabelNumber},
1313
props: {
1414
teamColor: String,

src/components/team/TeamFoulsEdit.vue

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<template>
2+
<span class="edit-link">
3+
<a v-b-modal="modalId" v-if="editMode.active">
4+
<img alt="pen" src="@/assets/img/icons8-ball-point-pen-16.png">
5+
</a>
6+
<b-modal :id="modalId"
7+
:title="'Fouls for team ' + teamColor"
8+
:lazy="true">
9+
<TeamFoulsEditTable :edit-mode="{active: true}" :team-color="teamColor"/>
10+
<div slot="modal-footer">
11+
<!-- hide modal buttons -->
12+
</div>
13+
</b-modal>
14+
</span>
15+
</template>
16+
17+
<script>
18+
import {TEAM_BLUE, TEAM_YELLOW} from "../../refereeState";
19+
import EditableLabelDuration from "../common/EditableLabelDuration";
20+
import TeamFoulsEditTable from "./TeamFoulsEditTable";
21+
22+
export default {
23+
name: "TeamFoulsEdit",
24+
components: {TeamFoulsEditTable, EditableLabelDuration},
25+
props: {
26+
teamColor: String,
27+
editMode: Object,
28+
},
29+
data() {
30+
return {
31+
TEAM_YELLOW: TEAM_YELLOW,
32+
TEAM_BLUE: TEAM_BLUE
33+
}
34+
},
35+
computed: {
36+
modalId() {
37+
return `fouls-${this.teamColor}-modal`;
38+
},
39+
}
40+
}
41+
</script>
42+
43+
<style scoped>
44+
.edit-link {
45+
margin-left: 0.3em;
46+
}
47+
</style>
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<template>
2+
<div>
3+
<table>
4+
<tr>
5+
<th>Id</th>
6+
<th>Cause</th>
7+
<th>Remove</th>
8+
</tr>
9+
<tr v-for="foul of team.fouls" v-bind:key="foul.id">
10+
<td>
11+
{{foul.id}}
12+
</td>
13+
<td>
14+
<span v-if="foul.causedByGameEvent">
15+
{{foul.causedByGameEvent.type}}
16+
</span>
17+
<span v-else>
18+
-
19+
</span>
20+
</td>
21+
<td>
22+
<a class="btn-remove" v-on:click="removeFoul(foul.id)">
23+
<font-awesome-icon
24+
class="fa-xs"
25+
icon="times-circle"/>
26+
</a>
27+
</td>
28+
</tr>
29+
</table>
30+
</div>
31+
</template>
32+
33+
<script>
34+
import {submitChange} from "../../submit";
35+
36+
export default {
37+
name: "TeamFoulsEditTable",
38+
props: {
39+
teamColor: String,
40+
editMode: Object,
41+
},
42+
methods: {
43+
removeFoul(id) {
44+
submitChange({
45+
updateTeamState: {
46+
forTeam: this.teamColor,
47+
removeFoul: id
48+
}
49+
});
50+
}
51+
},
52+
computed: {
53+
team() {
54+
return this.$store.state.matchState.teamState[this.teamColor]
55+
}
56+
}
57+
}
58+
</script>
59+
60+
<style scoped>
61+
table {
62+
width: 100%;
63+
}
64+
</style>

src/components/team/TeamOverviewView.vue

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,13 @@
8181
</tr>
8282
<tr>
8383
<td>
84-
<TeamFoulCounter :team-color="TEAM_YELLOW"/>
84+
<TeamFouls :team-color="TEAM_YELLOW"/>
85+
<TeamFoulsEdit :edit-mode="editMode" :team-color="TEAM_YELLOW"/>
8586
</td>
8687
<td class="label-column">Fouls</td>
8788
<td>
88-
<TeamFoulCounter :team-color="TEAM_BLUE"/>
89+
<TeamFouls :team-color="TEAM_BLUE"/>
90+
<TeamFoulsEdit :edit-mode="editMode" :team-color="TEAM_BLUE"/>
8991
</td>
9092
</tr>
9193
<tr>
@@ -131,23 +133,25 @@
131133
import TeamRedCards from "./TeamRedCards";
132134
import TeamBotSubstitution from "./TeamBotSubstitution";
133135
import TeamConnection from "./TeamConnection";
134-
import TeamFoulCounter from "./TeamFoulCounter";
136+
import TeamFouls from "./TeamFouls";
135137
import TeamPlacementFailures from "./TeamPlacementFailures";
136138
import TeamTimeoutTime from "./TeamTimeoutTime";
137139
import TeamYellowCardNextDue from "./TeamYellowCardNextDue";
138140
import TeamYellowCardsActive from "./TeamYellowCardsActive";
139141
import {TEAM_BLUE, TEAM_YELLOW} from "../../refereeState";
140142
import TeamYellowCardsEdit from "./TeamYellowCardsEdit";
141143
import TeamRedCardsEdit from "./TeamRedCardsEdit";
144+
import TeamFoulsEdit from "./TeamFoulsEdit";
142145
143146
export default {
144147
name: "TeamOverviewView",
145148
components: {
149+
TeamFoulsEdit,
146150
TeamRedCardsEdit,
147151
TeamYellowCardsActive,
148152
TeamTimeoutTime,
149153
TeamPlacementFailures,
150-
TeamFoulCounter,
154+
TeamFouls,
151155
TeamConnection,
152156
TeamBotSubstitution,
153157
TeamRedCards,

src/components/team/TeamYellowCardsEditTable.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
</td>
1414
<td>
1515
<EditableLabelText
16+
:id="'yellow-card-' + card.id"
1617
:edit-mode="editMode"
1718
:value="card.timeRemaining"
1819
:callback="(v) => updateCardTime(v, card.id)"/>

0 commit comments

Comments
 (0)