@dcrackel/hematournamentui 1.0.98 → 1.0.99

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/dist/{HemaTouranmentUI-lib.es.js → HemaTournamentUI-lib.es.js} +1578 -1474
  2. package/dist/{HemaTouranmentUI-lib.umd.js → HemaTournamentUI-lib.umd.js} +4 -4
  3. package/package.json +3 -1
  4. package/src/assets/portrait1.png +0 -0
  5. package/src/config/boutScreenConfigurations.js +54 -0
  6. package/src/mocks/eventRules.js +31 -0
  7. package/src/mocks/getPoolsWithBouts.js +405 -0
  8. package/src/mocks/getPoolsWithBoutsByPoolId.js +921 -0
  9. package/src/mocks/getPoolsWithBoutsClubColors.js +6 -0
  10. package/src/mocks/getPoolsWithBoutsComplete.js +926 -0
  11. package/src/stories/Atoms/Icon/BaseIcon.vue +8 -4
  12. package/src/stories/Atoms/Text/BaseText.vue +8 -2
  13. package/src/stories/Molecules/Boxes/BoutBoxes/PassesBox/PassesBox.stories.js +60 -0
  14. package/src/stories/Molecules/Boxes/BoutBoxes/PassesBox/PassesBox.vue +94 -0
  15. package/src/stories/Molecules/Boxes/BoutBoxes/ScoreBox/ScoreBox.stories.js +113 -0
  16. package/src/stories/Molecules/Boxes/BoutBoxes/ScoreBox/ScoreBox.vue +110 -0
  17. package/src/stories/Molecules/Boxes/BoutBoxes/TimerBox/TimerBox.stories.js +39 -0
  18. package/src/stories/Molecules/Boxes/BoutBoxes/TimerBox/TimerBox.vue +112 -0
  19. package/src/stories/Molecules/Breadcrumb/Admin/Breadcrumb.test.js +0 -2
  20. package/src/stories/Molecules/Buttons/BaseButton/BaseButton.vue +6 -8
  21. package/src/stories/Molecules/Modals/BaseModal/BaseModal.vue +0 -5
  22. package/src/stories/Molecules/Modals/DirectorModal/DirectorModal.stories.js +52 -0
  23. package/src/stories/Molecules/Modals/DirectorModal/DirectorModal.vue +64 -0
  24. package/src/stories/Molecules/Modals/EditBoutModal/EditBoutModal.stories.js +56 -0
  25. package/src/stories/Molecules/Modals/EditBoutModal/EditBoutModal.vue +57 -0
  26. package/src/stories/Organisms/Cards/BoutCard/BoutCard.stories.js +81 -0
  27. package/src/stories/Organisms/Cards/BoutCard/BoutCard.vue +212 -0
  28. package/src/stories/Organisms/Cards/Director/DirectorCard.stories.js +34 -0
  29. package/src/stories/Organisms/Cards/Director/DirectorCard.vue +100 -0
  30. package/src/stories/Organisms/Cards/EditBout/EditBout.stories.js +53 -0
  31. package/src/stories/Organisms/Cards/EditBout/EditBout.vue +150 -0
  32. package/src/stories/Organisms/Cards/PoolBoutMatchCard/PoolBoutMatchCard.stories.js +202 -0
  33. package/src/stories/Organisms/Cards/PoolBoutMatchCard/PoolBoutMatchCard.vue +59 -0
  34. package/src/stories/Organisms/Cards/PoolFencerCard/PoolFencerCard.vue +30 -20
  35. package/src/stories/Organisms/ComplexInputs/FindLocation/FindLocation.vue +0 -2
  36. package/src/stories/Organisms/ComplexInputs/FindOrAddPerson/FindOrAddPerson.vue +0 -5
  37. package/src/stories/Organisms/Containers/Pool/Pool.vue +25 -5
  38. package/src/stories/Organisms/Containers/PoolGrid/PoolGrid.stories.js +30 -0
  39. package/src/stories/Organisms/Containers/PoolGrid/PoolGrid.vue +204 -0
  40. package/src/stories/Organisms/Headers/PoolSummary/PoolSummary.stories.js +42 -1
  41. package/src/stories/Organisms/Headers/PoolSummary/PoolSummary.vue +15 -4
  42. package/src/stories/Organisms/Headers/ToggleHeader/ToggleHeader.stories.js +52 -0
  43. package/src/stories/Organisms/Headers/{StaffSummary/StaffSummary.vue → ToggleHeader/ToggleHeader.vue} +20 -11
  44. package/src/stories/Templates/EventManagement/ListEvents/ListEvents.vue +0 -3
  45. package/src/stories/Templates/EventManagement/PoolLive/PoolLive.stories.js +32 -0
  46. package/src/stories/Templates/EventManagement/PoolLive/PoolLive.vue +206 -0
  47. package/src/stories/Templates/EventManagement/PoolManagement/PoolManagement.stories.js +1 -1
  48. package/src/stories/Templates/EventManagement/PoolManagement/PoolManagement.vue +1 -1
  49. package/src/stories/Templates/EventManagement/StaffList/StaffList.vue +3 -3
  50. package/src/stories/Templates/Menus/EditEventsTopMenu/EditEventsTopMenu.vue +0 -5
  51. package/src/stories/Templates/TournamentManagement/EditTournament/EditPageOne/EditTournamentPageOne.vue +0 -3
  52. package/tailwind.config.js +46 -3
  53. package/vite.config.js +9 -8
  54. package/src/stories/Organisms/Headers/StaffSummary/StaffSummary.stories.js +0 -35
@@ -0,0 +1,52 @@
1
+ import DirectorModal from './DirectorModal.vue';
2
+ import eventRules from '../../../../mocks/eventRules.js';
3
+ import getPoolsWithBouts from "../../../../mocks/getPoolsWithBouts.js";
4
+
5
+ export default {
6
+ title: 'Molecules/Modals/DirectorModal',
7
+ component: DirectorModal,
8
+ tags: ['autodocs'],
9
+ args: {
10
+ show: true,
11
+ eventRules: eventRules,
12
+ bout: getPoolsWithBouts[0],
13
+ hostingClubColors: {
14
+ Color1: 'red',
15
+ Color2: 'blue'
16
+ },
17
+ ringName: 'Ring 1'
18
+ },
19
+ argTypes: {
20
+ show: { control: 'boolean' },
21
+ eventRules: { control: 'object' },
22
+ bout: { control: 'object' },
23
+ hostingClubColors: { control: 'object' },
24
+ ringName: { control: 'text' }
25
+ },
26
+ };
27
+
28
+ export const Default = {
29
+ args: {
30
+ show: true,
31
+ eventRules: eventRules,
32
+ bout: getPoolsWithBouts[0],
33
+ hostingClubColors: {
34
+ Color1: 'red',
35
+ Color2: 'blue'
36
+ },
37
+ ringName: 'Ring 1'
38
+ }
39
+ };
40
+
41
+ export const WithDEBout = {
42
+ args: {
43
+ show: true,
44
+ eventRules: eventRules,
45
+ bout: getPoolsWithBouts[0],
46
+ hostingClubColors: {
47
+ Color1: 'red',
48
+ Color2: 'blue'
49
+ },
50
+ ringName: 'Ring 2'
51
+ }
52
+ };
@@ -0,0 +1,64 @@
1
+ <template>
2
+ <transition
3
+ enter-active-class="transition-opacity duration-500"
4
+ enter-class="opacity-0"
5
+ enter-to-class="opacity-100"
6
+ leave-active-class="transition-opacity duration-500"
7
+ leave-class="opacity-100"
8
+ leave-to-class="opacity-0"
9
+ >
10
+ <div v-if="show" class="fixed inset-0 bg-secondary bg-opacity-75 flex items-center justify-center z-50"
11
+ @click="close">
12
+ <div class="w-1/3 min-w-[30rem] bg-neutral rounded-lg shadow-lg pb-6 px-2" @click.stop>
13
+ <div class="flex w-full justify-end mt-1">
14
+ <BaseIcon icon-name="fa-circle-xmark" size="lg" color="quaternary" hover="alarm" @click="close"/>
15
+ </div>
16
+ <DirectorCard :eventRules="eventRules" :bout="bout" :hostingClubColors="hostingClubColors" :ringName="ringName"
17
+ @update:bout="handleBoutChange" @submit:bout="handleSubmitBout"/>
18
+ </div>
19
+ </div>
20
+ </transition>
21
+ </template>
22
+
23
+ <script>
24
+ import DirectorCard from "../../../Organisms/Cards/Director/DirectorCard.vue";
25
+ import BaseIcon from "../../../Atoms/Icon/BaseIcon.vue";
26
+
27
+ export default {
28
+ name: "DirectorModal",
29
+ components: {BaseIcon, DirectorCard},
30
+ props: {
31
+ show: {
32
+ type: Boolean,
33
+ default: true
34
+ },
35
+ bout: {
36
+ type: Object,
37
+ required: true
38
+ },
39
+ eventRules: {
40
+ type: Object,
41
+ required: true
42
+ },
43
+ hostingClubColors: {
44
+ type: Object,
45
+ required: true
46
+ },
47
+ ringName: {
48
+ type: String,
49
+ required: true
50
+ }
51
+ },
52
+ methods: {
53
+ close() {
54
+ this.$emit('update:closeModal', this.bout);
55
+ },
56
+ handleBoutChange(bout) {
57
+ this.$emit('update:bout', bout);
58
+ },
59
+ handleSubmitBout() {
60
+ this.$emit('submit:bout', this.bout);
61
+ }
62
+ }
63
+ };
64
+ </script>
@@ -0,0 +1,56 @@
1
+ import EditBoutModal from './EditBoutModal.vue';
2
+ import getPoolsWithBouts from "../../../../mocks/getPoolsWithBouts.js";
3
+ import eventRules from '../../../../mocks/eventRules.js';
4
+
5
+ export default {
6
+ title: 'Molecules/Modals/EditBoutModal',
7
+ component: EditBoutModal,
8
+ tags: ['autodocs'],
9
+ args: {
10
+ show: true,
11
+ bout: getPoolsWithBouts[1],
12
+ hostingClubColors: {
13
+ Color1: 'red',
14
+ Color2: 'blue'
15
+ },
16
+ eventRules: eventRules
17
+ },
18
+ argTypes: {
19
+ show: {
20
+ control: 'boolean'
21
+ },
22
+ bout: {
23
+ control: 'object'
24
+ },
25
+ hostingClubColors: {
26
+ control: 'object'
27
+ },
28
+ eventRules: {
29
+ control: 'array'
30
+ }
31
+ }
32
+ };
33
+
34
+ export const Default = {
35
+ args: {
36
+ show: true,
37
+ bout: getPoolsWithBouts[0],
38
+ hostingClubColors: {
39
+ Color1: 'red',
40
+ Color2: 'blue'
41
+ },
42
+ eventRules: eventRules
43
+ }
44
+ }
45
+
46
+ export const Hidden = {
47
+ args: {
48
+ show: true,
49
+ bout: getPoolsWithBouts[0],
50
+ hostingClubColors: {
51
+ Color1: 'red',
52
+ Color2: 'blue'
53
+ },
54
+ eventRules: eventRules
55
+ }
56
+ };
@@ -0,0 +1,57 @@
1
+ <template>
2
+ <transition
3
+ enter-active-class="transition-opacity duration-500"
4
+ enter-class="opacity-0"
5
+ enter-to-class="opacity-100"
6
+ leave-active-class="transition-opacity duration-500"
7
+ leave-class="opacity-100"
8
+ leave-to-class="opacity-0"
9
+ >
10
+ <div v-if="show" class="fixed inset-0 bg-secondary bg-opacity-75 flex items-center justify-center z-50"
11
+ @click="close">
12
+ <div class="w-1/2 min-w-[50rem] bg-neutral rounded-lg shadow-lg pb-6 px-2" @click.stop>
13
+ <div class="flex w-full justify-end mt-1">
14
+ <BaseIcon icon-name="fa-circle-xmark" size="lg" color="quaternary" hover="alarm" @click="close"/>
15
+ </div>
16
+ <EditBout :bout="bout" :hostingClubColors="hostingClubColors" :eventRules="eventRules"
17
+ @submit:bout="handleSubmitBout"/>
18
+ </div>
19
+ </div>
20
+ </transition>
21
+ </template>
22
+
23
+ <script>
24
+ import BaseIcon from "../../../Atoms/Icon/BaseIcon.vue";
25
+ import EditBout from "../../../Organisms/Cards/EditBout/EditBout.vue";
26
+
27
+ export default {
28
+ name: "EditBoutModal",
29
+ components: { BaseIcon, EditBout },
30
+ props: {
31
+ show: {
32
+ type: Boolean,
33
+ default: true
34
+ },
35
+ bout: {
36
+ type: Object,
37
+ required: true
38
+ },
39
+ eventRules: {
40
+ type: Object,
41
+ required: true
42
+ },
43
+ hostingClubColors: {
44
+ type: Object,
45
+ required: true
46
+ },
47
+ },
48
+ methods: {
49
+ close() {
50
+ this.$emit('update:closeModal', this.bout);
51
+ },
52
+ handleSubmitBout(bout2) {
53
+ this.$emit('submit:bout', bout2);
54
+ }
55
+ }
56
+ };
57
+ </script>
@@ -0,0 +1,81 @@
1
+ import BoutCard from './BoutCard.vue';
2
+ import getPoolsWithBouts from '../../../../mocks/getPoolsWithBouts.js';
3
+
4
+ export default {
5
+ title: 'Organisms/Cards/BoutCard',
6
+ component: BoutCard,
7
+ tags: ['autodocs'],
8
+ args: {
9
+ bout: getPoolsWithBouts[0],
10
+ isWaiting: false,
11
+ timerStatus: 'stopped',
12
+ hostingClubColors: {
13
+ Color1: 'red',
14
+ Color2: 'blue'
15
+ },
16
+ },
17
+ argTypes: {
18
+ bout: {
19
+ control: 'object'
20
+ },
21
+ isSkeleton: {
22
+ control: 'boolean'
23
+ },
24
+ timerStatus: {
25
+ control: 'text'
26
+ },
27
+ hostingClubColors: {
28
+ control: 'object'
29
+ },
30
+
31
+ }
32
+ };
33
+
34
+
35
+ export const Default = {
36
+ args: {
37
+ bout: getPoolsWithBouts[0],
38
+ isWaiting: false,
39
+ timerStatus: 'running',
40
+ hostingClubColors: {
41
+ Color1: 'red',
42
+ Color2: 'blue'
43
+ }
44
+ }
45
+ };
46
+
47
+ export const Scheduled = {
48
+ args: {
49
+ bout: getPoolsWithBouts[4],
50
+ isWaiting: false,
51
+ timerStatus: 'stopped',
52
+ hostingClubColors: {
53
+ Color1: 'red',
54
+ Color2: 'blue'
55
+ }
56
+ }
57
+ }
58
+
59
+ export const Completed = {
60
+ args: {
61
+ bout: getPoolsWithBouts[2],
62
+ isWaiting: false,
63
+ timerStatus: 'stopped',
64
+ hostingClubColors: {
65
+ Color1: 'red',
66
+ Color2: 'blue'
67
+ }
68
+ }
69
+ }
70
+
71
+ export const Skeleton = {
72
+ args: {
73
+ bout: getPoolsWithBouts[2],
74
+ isWaiting: true,
75
+ timerStatus: 'stopped',
76
+ hostingClubColors: {
77
+ Color1: 'red',
78
+ Color2: 'blue'
79
+ }
80
+ }
81
+ }
@@ -0,0 +1,212 @@
1
+ <template>
2
+ <section>
3
+ <div v-if="isWaiting" class="flex items-center justify-between rounded-lg w-full">
4
+ <!-- Fencer 1 -->
5
+ <div class="flex justify-between shadow-lg drop-shadow p-2 rounded-xl bg-poolBox w-5/12">
6
+ <div class="flex space-x-4 items-center">
7
+ <div>
8
+ <div :class="`w-4 h-4 rounded-full bg-${hostingClubColors.Color1} absolute top-10 left-11 `"></div>
9
+ <img :src="missingPortrait" alt="Portrait" class="w-12 h-12 rounded-full" />
10
+ </div>
11
+ <div>
12
+ <BaseText text="Waiting to be selected" size="md" color="primary" weight="bold" />
13
+ <BaseText text="starting soon" size="xs" color="quaternary" />
14
+ </div>
15
+ </div>
16
+ <BaseText text="" size="3xl" weight="bold" :class="`align-middle pr-3 pt-0.5`"/>
17
+ </div>
18
+
19
+ <!-- Timer -->
20
+ <div class="text-center mx-8"></div>
21
+
22
+ <!-- Fencer 2 -->
23
+ <div class="flex justify-between shadow-lg drop-shadow p-2 rounded-xl bg-poolBox w-5/12">
24
+ <div class="flex justify-end space-x-4 ml-4 w-full">
25
+ <div>
26
+ <BaseText text="Waiting to be selected" size="md" color="primary" weight="bold" class="text-right" />
27
+ <BaseText text="starting soon" size="xs" color="quaternary" class="text-right" />
28
+ </div>
29
+ <div>
30
+ <div :class="`w-4 h-4 rounded-full bg-${hostingClubColors.Color2} absolute top-10 right-12`"></div>
31
+ <img :src="missingPortrait" alt="Portrait" class="w-12 h-12 rounded-full" />
32
+ </div>
33
+ </div>
34
+ </div>
35
+ </div>
36
+
37
+ <!-- Custom Status -->
38
+ <div v-if="bout.customStatus && bout.Status !== 'Active'" class="text-left">
39
+ <BaseText :text="bout.customStatus" size="sm" color="primary"/>
40
+ </div>
41
+
42
+ <!-- Bout Card -->
43
+ <div v-if="!isWaiting" class="flex items-center justify-between rounded-lg">
44
+ <!-- Fencer 1 -->
45
+ <div class="flex justify-between shadow-lg drop-shadow p-2 rounded-xl bg-poolBox" :class="fencer1Class">
46
+ <div class="flex space-x-4 items-center">
47
+ <div>
48
+ <div :class="`w-4 h-4 rounded-full bg-${hostingClubColors.Color1} absolute top-10 left-11 `"></div>
49
+ <img :src="fencer1.portrait" alt="Portrait" class="w-12 h-12 rounded-full" />
50
+ </div>
51
+ <div>
52
+ <BaseText :text="fencer1.name" size="md" color="primary" weight="bold" />
53
+ <BaseText :text="fencer1.team" size="xs" color="quaternary" />
54
+ </div>
55
+ </div>
56
+ <BaseText :text="fencer1Score" size="3xl" weight="bold" :class="`align-middle pr-3 pt-0.5`"/>
57
+ </div>
58
+
59
+ <!-- Timer -->
60
+ <div v-if="bout.Status === 'Active'" class="text-center mx-8 ">
61
+ <p class="text-xl font-bold">{{ displayTime }}</p>
62
+ </div>
63
+
64
+ <!-- Fencer 2 -->
65
+ <div class="flex justify-between shadow-lg drop-shadow p-2 rounded-xl bg-poolBox" :class="fencer2Class">
66
+ <div class="flex space-x-4 justify-between w-full">
67
+ <BaseText :text="fencer2Score" size="3xl" weight="bold" :class="`align-middle pl-3 pt-0.5`"/>
68
+ <div class="w-full">
69
+ <BaseText :text="fencer2.name" size="md" color="primary" weight="bold" class="text-right" />
70
+ <BaseText :text="fencer2.team" size="xs" color="quaternary" class="text-right" />
71
+ </div>
72
+ <div class="w-20">
73
+ <div :class="`w-4 h-4 rounded-full bg-${hostingClubColors.Color2} absolute top-10 right-12`"></div>
74
+ <img :src="fencer2.portrait" alt="Portrait" class="w-12 h-12 rounded-full" />
75
+ </div>
76
+ </div>
77
+ </div>
78
+
79
+ <div v-if="bout.Status === 'Completed'" class="text-right pl-4">
80
+ <BaseButton label="Edit" size="sm" type="primary" @click="handleEditBout" class="w-12" />
81
+ </div>
82
+ <div v-if="bout.Status === 'Scheduled'" class="text-right pl-4">
83
+ <BaseButton label="Start" size="sm" type="primary" @click="handleStartBout" class="w-12" />
84
+ </div>
85
+
86
+ </div>
87
+ </section>
88
+ </template>
89
+
90
+ <script>
91
+ import missingPortrait from "../../../../assets/portrait1.png";
92
+ import BaseText from "../../../Atoms/Text/BaseText.vue";
93
+ import BaseButton from "../../../Molecules/Buttons/BaseButton/BaseButton.vue";
94
+
95
+ export default {
96
+ components: {BaseButton, BaseText},
97
+ props: {
98
+ bout: {
99
+ type: Object,
100
+ required: true
101
+ },
102
+ isWaiting: {
103
+ type: Boolean,
104
+ required: false,
105
+ default: false
106
+ },
107
+ timerStatus: {
108
+ type: String,
109
+ required: false,
110
+ default: 'stopped'
111
+ },
112
+ hostingClubColors: {
113
+ type: Object,
114
+ required: true
115
+ }
116
+ },
117
+ data() {
118
+ return {
119
+ remainingTime: this.bout.TimeLeft,
120
+ interval: null,
121
+ missingPortrait
122
+ };
123
+ },
124
+ mounted() {
125
+ if (this.timerStatus === 'running') {
126
+ this.startTimer();
127
+ }
128
+ },
129
+ beforeDestroy() {
130
+ this.stopTimer();
131
+ },
132
+ computed: {
133
+ fencer1() {
134
+ return {
135
+ portrait: this.bout.Person1.Images.length ? this.bout.Person1.Images[0].URL : this.missingPortrait,
136
+ name: this.bout.Person1.DisplayName,
137
+ team: this.bout.Person1.Club.Name,
138
+ score: this.bout.Score1
139
+ };
140
+ },
141
+ fencer2() {
142
+ return {
143
+ portrait: this.bout.Person2.Images.length ? this.bout.Person2.Images[0].URL : this.missingPortrait,
144
+ name: this.bout.Person2.DisplayName,
145
+ team: this.bout.Person2.Club.Name,
146
+ score: this.bout.Score2
147
+ };
148
+ },
149
+ fencer1Score() {
150
+ return this.bout.Status !== 'Scheduled' ? this.fencer1.score : '-';
151
+ },
152
+ fencer2Score() {
153
+ return this.bout.Status !== 'Scheduled' ? this.fencer2.score : '-';
154
+ },
155
+ displayTime() {
156
+ const minutes = Math.floor(this.remainingTime / 60).toString().padStart(2, '0');
157
+ const seconds = (this.remainingTime % 60).toString().padStart(2, '0');
158
+ return `${minutes}:${seconds}`;
159
+ },
160
+ fencer1Class() {
161
+ return {
162
+ 'w-5/12': this.bout.Status === 'Active',
163
+ 'w-full mr-4': this.bout.Status !== 'Active',
164
+ };
165
+ },
166
+ fencer2Class() {
167
+ return {
168
+ 'w-5/12': this.bout.Status === 'Active',
169
+ 'w-full ml-4': this.bout.Status !== 'Active',
170
+ };
171
+ }
172
+ },
173
+ watch: {
174
+ timerStatus(newStatus) {
175
+ if (newStatus === 'running') {
176
+ this.startTimer();
177
+ } else {
178
+ this.stopTimer();
179
+ }
180
+ },
181
+ bout: {
182
+ deep: true,
183
+ handler(newBout) {
184
+ this.remainingTime = newBout.TimeLeft;
185
+ newBout.TimerStatus === 'running' ? this.startTimer() : this.stopTimer();
186
+ }
187
+ }
188
+ },
189
+ methods: {
190
+ startTimer() {
191
+ if (this.interval) clearInterval(this.interval);
192
+ this.interval = setInterval(() => {
193
+ if (this.remainingTime > 0) {
194
+ this.remainingTime--;
195
+ } else {
196
+ this.stopTimer();
197
+ }
198
+ }, 1000);
199
+ },
200
+ stopTimer() {
201
+ if (this.interval) clearInterval(this.interval);
202
+ this.interval = null;
203
+ },
204
+ handleEditBout(){
205
+ this.$emit('action:editBout', this.bout);
206
+ },
207
+ handleStartBout() {
208
+ this.$emit('action:startBout', this.bout);
209
+ }
210
+ }
211
+ }
212
+ </script>
@@ -0,0 +1,34 @@
1
+ import DirectorCard from './DirectorCard.vue';
2
+ import eventRules from '../../../../mocks/eventRules.js';
3
+ import getPoolsWithBouts from "../../../../mocks/getPoolsWithBouts.js";
4
+
5
+ const hostingClubColors = {
6
+ Color1: 'red',
7
+ Color2: 'blue'
8
+ }
9
+
10
+ export default {
11
+ title: 'Organisms/Cards/DirectorCard',
12
+ component: DirectorCard,
13
+ tags: ['autodocs'],
14
+ args: {
15
+ eventRules: eventRules,
16
+ bout: getPoolsWithBouts[0],
17
+ hostingClubColors: hostingClubColors,
18
+ ringName: 'Pool 1 - Ring 1',
19
+ },
20
+ argTypes: {
21
+ eventRules: { control: 'object' },
22
+ bout: { control: 'object' },
23
+ hostingClubColors: { control: 'object' },
24
+ ringName: { control: 'string' },
25
+ },
26
+ };
27
+
28
+ export const Default = {
29
+ args: {
30
+ eventRules: eventRules,
31
+ bout: getPoolsWithBouts[0],
32
+ hostingClubColors: hostingClubColors
33
+ }
34
+ };
@@ -0,0 +1,100 @@
1
+ <template>
2
+ <section>
3
+ <ScoreBox :fencer1="true" :bout="localBout" :hostingClubColors="hostingClubColors" :maxScore="parseInt(maxPoints)" @update:Score="updateScore1"/>
4
+ <TimerBox v-if="showTimerBox" :ringName="ringName" :initialTime="parseInt(startTime)" @update:time="handleTimeChange" @update:timeChange="handleTimeStateChange"/>
5
+ <ScoreBox :fencer1="false" :bout="localBout" :hostingClubColors="hostingClubColors" :maxScore="parseInt(maxPoints)" @update:Score="updateScore2"/>
6
+ <div class="w-11/12 mt-5 mx-6">
7
+ <BaseButton label="Submit" type="grayAndBlue" :selected="showSubmit" @click="submitBout"/>
8
+ </div>
9
+ </section>
10
+ </template>
11
+
12
+ <script>
13
+ import ScoreBox from "../../../Molecules/Boxes/BoutBoxes/ScoreBox/ScoreBox.vue";
14
+ import TimerBox from "../../../Molecules/Boxes/BoutBoxes/TimerBox/TimerBox.vue";
15
+ import BaseButton from "../../../Molecules/Buttons/BaseButton/BaseButton.vue";
16
+
17
+ export default {
18
+ name: "DirectorCard",
19
+ components: {
20
+ BaseButton,
21
+ TimerBox,
22
+ ScoreBox
23
+ },
24
+ props: {
25
+ eventRules: {
26
+ type: Object,
27
+ required: true
28
+ },
29
+ bout: {
30
+ type: Object,
31
+ required: true
32
+ },
33
+ hostingClubColors: {
34
+ type: Object,
35
+ required: true
36
+ },
37
+ ringName: {
38
+ type: String,
39
+ required: true
40
+ }
41
+ },
42
+ data() {
43
+ return {
44
+ showSubmit: false,
45
+ localBout: { ...this.bout }
46
+ }
47
+ },
48
+ mounted() {
49
+ this.localBout.TimeLeft = this.startTime;
50
+ this.emitBout();
51
+ },
52
+ computed: {
53
+ showTimerBox() {
54
+ return this.eventRules.some(rule => rule.RuleName === "PoolTime") || this.eventRules.some(rule => rule.RuleName === "DETime");
55
+ },
56
+ startTime() {
57
+ if (this.localBout.DEBoutId) {
58
+ const rule = this.eventRules.find(rule => rule.RuleName === "DETime");
59
+ return rule ? parseInt(rule.RuleValue) : 90;
60
+ }
61
+ const rule = this.eventRules.find(rule => rule.RuleName === "PoolTime");
62
+ return rule ? parseInt(rule.RuleValue) : 90;
63
+ },
64
+ maxPoints() {
65
+ if (this.localBout.DEBoutId) {
66
+ const rule = this.eventRules.find(rule => rule.RuleName === "DEMaxPoints");
67
+ return rule ? parseInt(rule.RuleValue) : 7;
68
+ }
69
+ const rule = this.eventRules.find(rule => rule.RuleName === "PoolMaxPoints");
70
+ return rule ? parseInt(rule.RuleValue) : 7;
71
+ }
72
+ },
73
+ methods: {
74
+ handleTimeChange(time){
75
+ this.localBout.TimeLeft = time;
76
+ },
77
+ handleTimeStateChange(time) {
78
+ this.localBout.TimeLeft = time.time;
79
+ this.localBout.TimerStatus = time.running ? 'running' : 'stopped';
80
+ this.emitBout();
81
+ },
82
+ updateScore1(score) {
83
+ this.localBout.Score1 = score;
84
+ this.emitBout();
85
+ },
86
+ updateScore2(score) {
87
+ this.localBout.Score2 = score;
88
+ this.emitBout();
89
+ },
90
+ submitBout() {
91
+ if (this.showSubmit) this.$emit('submit:bout', this.localBout)
92
+ },
93
+ emitBout(){
94
+ if (this.localBout.Started === null) this.localBout.Started = new Date().toISOString();
95
+ this.showSubmit = this.localBout.Score1 === this.maxPoints || this.localBout.Score2 === this.maxPoints || this.localBout.TimeLeft === 0;
96
+ this.$emit('update:bout', this.localBout)
97
+ }
98
+ }
99
+ };
100
+ </script>