@dcrackel/hematournamentui 1.0.711 → 1.0.712
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.
- package/README.md +152 -148
- package/dist/HemaTournamentUI-lib.es.js +4150 -4039
- package/dist/HemaTournamentUI-lib.umd.js +27 -27
- package/dist/hematournamentui-tailwind.css +11 -0
- package/package.json +1 -1
- package/src/stories/Molecules/Indicators/RegistrationStatus/RegistrationStatus.vue +30 -0
- package/src/stories/Organisms/Cards/EventCard/EventCard.stories.js +41 -1
- package/src/stories/Organisms/Cards/EventCard/EventCard.test.js +106 -0
- package/src/stories/Organisms/Cards/EventCard/EventCard.vue +62 -30
- package/src/stories/Organisms/Cards/FencerCard/FencerCard.vue +1 -1
- package/src/stories/Organisms/Headers/AttendanceSummary/AttendanceSummary.vue +12 -5
- package/src/stories/Organisms/Wizards/EditEventWizard/BasicEventInfo/BasicEventInfo.stories.js +4 -0
- package/src/stories/Organisms/Wizards/EditEventWizard/BasicEventInfo/BasicEventInfo.vue +249 -227
- package/src/stories/Organisms/Wizards/EditEventWizard/EditEventWizard.stories.js +4 -0
- package/src/stories/Organisms/Wizards/EditEventWizard/EditEventWizard.test.js +221 -191
- package/src/stories/Organisms/Wizards/EditEventWizard/EditEventWizard.vue +372 -366
- package/src/stories/Organisms/Wizards/EditEventWizard/RuleSerialization.test.js +29 -0
- package/src/stories/Templates/EventManagement/EventAttendance/EventAttendance.stories.js +31 -1
- package/src/stories/Templates/TournamentManagement/ListEvents/ListEvents.stories.js +58 -45
- package/src/stories/Util/registrationStatus.js +11 -0
|
@@ -1,366 +1,372 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="p-4" :class="{ 'max-h-screen overflow-y-auto': !editMode }">
|
|
3
|
-
<fieldset :key="draftVersion" :disabled="saving" :inert="saving" :aria-busy="saving" class="min-w-0 border-0 p-0">
|
|
4
|
-
<BasicEventInfo
|
|
5
|
-
v-if="currentStep === 1"
|
|
6
|
-
:eventConfig="eventConfig"
|
|
7
|
-
:weapons="weapons"
|
|
8
|
-
:validation="validation"
|
|
9
|
-
:steps="steps"
|
|
10
|
-
:currentStep="currentStep - 1"
|
|
11
|
-
:nextButtonLabel="nextButtonLabel"
|
|
12
|
-
:userLevel="userLevel"
|
|
13
|
-
@update="handleValueChange"
|
|
14
|
-
@update:back="handleCancel"
|
|
15
|
-
@update:next="handleUpdate"
|
|
16
|
-
/>
|
|
17
|
-
<EventCustomization
|
|
18
|
-
v-if="currentStep === 2"
|
|
19
|
-
:eventConfig="eventConfig"
|
|
20
|
-
:steps="steps"
|
|
21
|
-
:currentStep="currentStep - 1"
|
|
22
|
-
:nextButtonLabel="nextButtonLabel"
|
|
23
|
-
@update="handleValueChange"
|
|
24
|
-
@update:back="handleBack"
|
|
25
|
-
@update:next="handleUpdate"
|
|
26
|
-
/>
|
|
27
|
-
<PoolConfiguration
|
|
28
|
-
v-if="currentStep === 3"
|
|
29
|
-
:eventConfig="eventConfig"
|
|
30
|
-
:seedWithOptions="seedWithOptions"
|
|
31
|
-
:validation="validation"
|
|
32
|
-
:steps="steps"
|
|
33
|
-
:currentStep="currentStep - 1"
|
|
34
|
-
:nextButtonLabel="nextButtonLabel"
|
|
35
|
-
@update="handleValueChange"
|
|
36
|
-
@update:back="handleBack"
|
|
37
|
-
@update:next="handleUpdate"
|
|
38
|
-
/>
|
|
39
|
-
<DirectEliminationPromotion
|
|
40
|
-
v-if="currentStep === 4"
|
|
41
|
-
:eventConfig="eventConfig"
|
|
42
|
-
:validation="validation"
|
|
43
|
-
:steps="steps"
|
|
44
|
-
:currentStep="currentStep - 1"
|
|
45
|
-
:nextButtonLabel="nextButtonLabel"
|
|
46
|
-
@update="handleValueChange"
|
|
47
|
-
@update:DEPromotionType="handleDEPromotionType"
|
|
48
|
-
@update:back="handleBack"
|
|
49
|
-
@update:next="handleUpdate"
|
|
50
|
-
/>
|
|
51
|
-
<DirectElimination
|
|
52
|
-
v-if="currentStep === 5"
|
|
53
|
-
:eventConfig="eventConfig"
|
|
54
|
-
:validation="validation"
|
|
55
|
-
:steps="steps"
|
|
56
|
-
:currentStep="currentStep - 1"
|
|
57
|
-
:nextButtonLabel="nextButtonLabel"
|
|
58
|
-
:DEFormats="DEFormats"
|
|
59
|
-
@update="handleValueChange"
|
|
60
|
-
@update:back="handleBack"
|
|
61
|
-
@update:submit="handleSubmit"
|
|
62
|
-
/>
|
|
63
|
-
</fieldset>
|
|
64
|
-
<p role="status" aria-live="polite" aria-atomic="true" class="mt-3 min-h-5 text-sm text-primaryHighlight">
|
|
65
|
-
{{ saving ? 'Saving changes…' : saveNotice }}
|
|
66
|
-
</p>
|
|
67
|
-
<p v-if="saveError" role="alert" class="mt-2 text-sm text-alarm">{{ saveError }}</p>
|
|
68
|
-
</div>
|
|
69
|
-
</template>
|
|
70
|
-
|
|
71
|
-
<script>
|
|
72
|
-
import BasicEventInfo from './BasicEventInfo/BasicEventInfo.vue';
|
|
73
|
-
import { validatePrice } from '../../../Util/Validations/PriceValidation.js';
|
|
74
|
-
import PoolConfiguration from './PoolConfiguration/PoolConfiguration.vue';
|
|
75
|
-
import DirectElimination from './DirectElimination/DirectElimination.vue';
|
|
76
|
-
import BaseButton from '../../../Molecules/Buttons/BaseButton/BaseButton.vue';
|
|
77
|
-
import StepIndicator from '../../../Molecules/StepIndicator/BaseStepIndicator/StepIndicator.vue';
|
|
78
|
-
import DirectEliminationPromotion from './DirectEliminationPromotion/DirectEliminationPromotion.vue';
|
|
79
|
-
import EventCustomization from '../../..//Organisms/Wizards/EditEventWizard/EventCustomization/EventCustomization.vue';
|
|
80
|
-
|
|
81
|
-
const ruleValueIsTrue = (rule, fallbackField) =>
|
|
82
|
-
rule.RuleValue === 'true' || rule.RuleValue === true || rule[fallbackField] === true;
|
|
83
|
-
|
|
84
|
-
const rulePatchCreators = {
|
|
85
|
-
1: rule => ({ poolTime: rule.RuleValue, poolTimer: true }),
|
|
86
|
-
2: rule => ({ poolMaxPoints: rule.RuleValue, poolMax: true }),
|
|
87
|
-
3: rule => ({ DETime: rule.RuleValue, DETimer: true }),
|
|
88
|
-
4: rule => ({ DEMaxPoints: rule.RuleValue, DEMax: true }),
|
|
89
|
-
5: rule => ({ thirdPlaceBout: ruleValueIsTrue(rule, 'thirdPlaceBout') }),
|
|
90
|
-
6: rule => ({ boutCount: rule.RuleValue, boutCounter: true }),
|
|
91
|
-
7: rule => ({ DEBoutCount: rule.RuleValue, DEBoutCounter: true }),
|
|
92
|
-
9: rule => ({ DEPromotionOrder: rule.RuleValue.split(',') }),
|
|
93
|
-
10: rule => ({ DEPromotionAmount: rule.RuleValue }),
|
|
94
|
-
11: rule => ({ seedWith: rule.RuleValue }),
|
|
95
|
-
14: rule => ({ CutOffNumber: rule.RuleValue }),
|
|
96
|
-
15: rule => ({ DEType: rule.RuleValue }),
|
|
97
|
-
16: rule => ({ PoolScoreDirection: ruleValueIsTrue(rule, 'PoolScoreDirection') }),
|
|
98
|
-
17: rule => ({ DEPromoteBy: rule.RuleValue }),
|
|
99
|
-
19: rule => ({ CountHandshots: ruleValueIsTrue(rule, 'CountHandshots') }),
|
|
100
|
-
20: rule => ({ CountDoubles: ruleValueIsTrue(rule, 'CountDoubles') }),
|
|
101
|
-
21: rule => ({ PenaltiesReset: ruleValueIsTrue(rule, 'PenaltiesReset') }),
|
|
102
|
-
22: rule => ({ IncludeInRatings: ruleValueIsTrue(rule, 'IncludeInRatings') })
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
const createRulePatch = rule => (rulePatchCreators[rule.RuleId] || (() => ({})))(rule);
|
|
106
|
-
|
|
107
|
-
const applyRulesToEventConfig = (eventConfig, rules) =>
|
|
108
|
-
rules.reduce((currentConfig, rule) => ({ ...currentConfig, ...createRulePatch(rule) }), { ...eventConfig });
|
|
109
|
-
|
|
110
|
-
const cloneEvent = event => ({
|
|
111
|
-
...(event || {}),
|
|
112
|
-
rules: Array.isArray(event?.rules) ? event.rules.map(rule => ({ ...rule })) : []
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
const createEventConfig = event => ({
|
|
116
|
-
EventName: event.EventName,
|
|
117
|
-
EventPrice: event.EventPrice ?? '',
|
|
118
|
-
Date: event.startDate ?? event.Date,
|
|
119
|
-
StartTime: event.startTime ?? event.StartTime,
|
|
120
|
-
NumberOfRings: event.NumberOfRings,
|
|
121
|
-
WeaponId: event.WeaponId,
|
|
122
|
-
seedWith: 'M2 - MeyerSquared',
|
|
123
|
-
CutOffNumber: undefined,
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
{ link:
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
{ text: '
|
|
205
|
-
{ text: '
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
{ name: '
|
|
210
|
-
{ name: '
|
|
211
|
-
{ name: '
|
|
212
|
-
{ name: '
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
return this.currentStep === 5 ? '
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
this.
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
this.
|
|
241
|
-
this.
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
this.
|
|
250
|
-
this.
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
this.
|
|
285
|
-
|
|
286
|
-
if (!this.
|
|
287
|
-
if (this.
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
if (this.
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
.filter(
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
}
|
|
366
|
-
|
|
1
|
+
<template>
|
|
2
|
+
<div class="p-4" :class="{ 'max-h-screen overflow-y-auto': !editMode }">
|
|
3
|
+
<fieldset :key="draftVersion" :disabled="saving" :inert="saving" :aria-busy="saving" class="min-w-0 border-0 p-0">
|
|
4
|
+
<BasicEventInfo
|
|
5
|
+
v-if="currentStep === 1"
|
|
6
|
+
:eventConfig="eventConfig"
|
|
7
|
+
:weapons="weapons"
|
|
8
|
+
:validation="validation"
|
|
9
|
+
:steps="steps"
|
|
10
|
+
:currentStep="currentStep - 1"
|
|
11
|
+
:nextButtonLabel="nextButtonLabel"
|
|
12
|
+
:userLevel="userLevel"
|
|
13
|
+
@update="handleValueChange"
|
|
14
|
+
@update:back="handleCancel"
|
|
15
|
+
@update:next="handleUpdate"
|
|
16
|
+
/>
|
|
17
|
+
<EventCustomization
|
|
18
|
+
v-if="currentStep === 2"
|
|
19
|
+
:eventConfig="eventConfig"
|
|
20
|
+
:steps="steps"
|
|
21
|
+
:currentStep="currentStep - 1"
|
|
22
|
+
:nextButtonLabel="nextButtonLabel"
|
|
23
|
+
@update="handleValueChange"
|
|
24
|
+
@update:back="handleBack"
|
|
25
|
+
@update:next="handleUpdate"
|
|
26
|
+
/>
|
|
27
|
+
<PoolConfiguration
|
|
28
|
+
v-if="currentStep === 3"
|
|
29
|
+
:eventConfig="eventConfig"
|
|
30
|
+
:seedWithOptions="seedWithOptions"
|
|
31
|
+
:validation="validation"
|
|
32
|
+
:steps="steps"
|
|
33
|
+
:currentStep="currentStep - 1"
|
|
34
|
+
:nextButtonLabel="nextButtonLabel"
|
|
35
|
+
@update="handleValueChange"
|
|
36
|
+
@update:back="handleBack"
|
|
37
|
+
@update:next="handleUpdate"
|
|
38
|
+
/>
|
|
39
|
+
<DirectEliminationPromotion
|
|
40
|
+
v-if="currentStep === 4"
|
|
41
|
+
:eventConfig="eventConfig"
|
|
42
|
+
:validation="validation"
|
|
43
|
+
:steps="steps"
|
|
44
|
+
:currentStep="currentStep - 1"
|
|
45
|
+
:nextButtonLabel="nextButtonLabel"
|
|
46
|
+
@update="handleValueChange"
|
|
47
|
+
@update:DEPromotionType="handleDEPromotionType"
|
|
48
|
+
@update:back="handleBack"
|
|
49
|
+
@update:next="handleUpdate"
|
|
50
|
+
/>
|
|
51
|
+
<DirectElimination
|
|
52
|
+
v-if="currentStep === 5"
|
|
53
|
+
:eventConfig="eventConfig"
|
|
54
|
+
:validation="validation"
|
|
55
|
+
:steps="steps"
|
|
56
|
+
:currentStep="currentStep - 1"
|
|
57
|
+
:nextButtonLabel="nextButtonLabel"
|
|
58
|
+
:DEFormats="DEFormats"
|
|
59
|
+
@update="handleValueChange"
|
|
60
|
+
@update:back="handleBack"
|
|
61
|
+
@update:submit="handleSubmit"
|
|
62
|
+
/>
|
|
63
|
+
</fieldset>
|
|
64
|
+
<p role="status" aria-live="polite" aria-atomic="true" class="mt-3 min-h-5 text-sm text-primaryHighlight">
|
|
65
|
+
{{ saving ? 'Saving changes…' : saveNotice }}
|
|
66
|
+
</p>
|
|
67
|
+
<p v-if="saveError" role="alert" class="mt-2 text-sm text-alarm">{{ saveError }}</p>
|
|
68
|
+
</div>
|
|
69
|
+
</template>
|
|
70
|
+
|
|
71
|
+
<script>
|
|
72
|
+
import BasicEventInfo from './BasicEventInfo/BasicEventInfo.vue';
|
|
73
|
+
import { validatePrice } from '../../../Util/Validations/PriceValidation.js';
|
|
74
|
+
import PoolConfiguration from './PoolConfiguration/PoolConfiguration.vue';
|
|
75
|
+
import DirectElimination from './DirectElimination/DirectElimination.vue';
|
|
76
|
+
import BaseButton from '../../../Molecules/Buttons/BaseButton/BaseButton.vue';
|
|
77
|
+
import StepIndicator from '../../../Molecules/StepIndicator/BaseStepIndicator/StepIndicator.vue';
|
|
78
|
+
import DirectEliminationPromotion from './DirectEliminationPromotion/DirectEliminationPromotion.vue';
|
|
79
|
+
import EventCustomization from '../../..//Organisms/Wizards/EditEventWizard/EventCustomization/EventCustomization.vue';
|
|
80
|
+
|
|
81
|
+
const ruleValueIsTrue = (rule, fallbackField) =>
|
|
82
|
+
rule.RuleValue === 'true' || rule.RuleValue === true || rule[fallbackField] === true;
|
|
83
|
+
|
|
84
|
+
const rulePatchCreators = {
|
|
85
|
+
1: rule => ({ poolTime: rule.RuleValue, poolTimer: true }),
|
|
86
|
+
2: rule => ({ poolMaxPoints: rule.RuleValue, poolMax: true }),
|
|
87
|
+
3: rule => ({ DETime: rule.RuleValue, DETimer: true }),
|
|
88
|
+
4: rule => ({ DEMaxPoints: rule.RuleValue, DEMax: true }),
|
|
89
|
+
5: rule => ({ thirdPlaceBout: ruleValueIsTrue(rule, 'thirdPlaceBout') }),
|
|
90
|
+
6: rule => ({ boutCount: rule.RuleValue, boutCounter: true }),
|
|
91
|
+
7: rule => ({ DEBoutCount: rule.RuleValue, DEBoutCounter: true }),
|
|
92
|
+
9: rule => ({ DEPromotionOrder: rule.RuleValue.split(',') }),
|
|
93
|
+
10: rule => ({ DEPromotionAmount: rule.RuleValue }),
|
|
94
|
+
11: rule => ({ seedWith: rule.RuleValue }),
|
|
95
|
+
14: rule => ({ CutOffNumber: rule.RuleValue }),
|
|
96
|
+
15: rule => ({ DEType: rule.RuleValue }),
|
|
97
|
+
16: rule => ({ PoolScoreDirection: ruleValueIsTrue(rule, 'PoolScoreDirection') }),
|
|
98
|
+
17: rule => ({ DEPromoteBy: rule.RuleValue }),
|
|
99
|
+
19: rule => ({ CountHandshots: ruleValueIsTrue(rule, 'CountHandshots') }),
|
|
100
|
+
20: rule => ({ CountDoubles: ruleValueIsTrue(rule, 'CountDoubles') }),
|
|
101
|
+
21: rule => ({ PenaltiesReset: ruleValueIsTrue(rule, 'PenaltiesReset') }),
|
|
102
|
+
22: rule => ({ IncludeInRatings: ruleValueIsTrue(rule, 'IncludeInRatings') })
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
const createRulePatch = rule => (rulePatchCreators[rule.RuleId] || (() => ({})))(rule);
|
|
106
|
+
|
|
107
|
+
const applyRulesToEventConfig = (eventConfig, rules) =>
|
|
108
|
+
rules.reduce((currentConfig, rule) => ({ ...currentConfig, ...createRulePatch(rule) }), { ...eventConfig });
|
|
109
|
+
|
|
110
|
+
const cloneEvent = event => ({
|
|
111
|
+
...(event || {}),
|
|
112
|
+
rules: Array.isArray(event?.rules) ? event.rules.map(rule => ({ ...rule })) : []
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
const createEventConfig = event => ({
|
|
116
|
+
EventName: event.EventName,
|
|
117
|
+
EventPrice: event.EventPrice ?? '',
|
|
118
|
+
Date: event.startDate ?? event.Date,
|
|
119
|
+
StartTime: event.startTime ?? event.StartTime,
|
|
120
|
+
NumberOfRings: event.NumberOfRings,
|
|
121
|
+
WeaponId: event.WeaponId,
|
|
122
|
+
seedWith: 'M2 - MeyerSquared',
|
|
123
|
+
CutOffNumber: undefined,
|
|
124
|
+
WaitlistEnabled: event.WaitlistEnabled ?? true,
|
|
125
|
+
boutCounter: false,
|
|
126
|
+
boutCount: 5,
|
|
127
|
+
poolTimer: false,
|
|
128
|
+
poolMax: false,
|
|
129
|
+
DEMax: false,
|
|
130
|
+
thirdPlaceBout: false,
|
|
131
|
+
poolTime: 180,
|
|
132
|
+
poolMaxPoints: 7,
|
|
133
|
+
PoolScoreDirection: true,
|
|
134
|
+
DETimer: false,
|
|
135
|
+
DETime: 180,
|
|
136
|
+
DEBoutCounter: false,
|
|
137
|
+
DEBoutCount: 7,
|
|
138
|
+
DEMaxPoints: 12,
|
|
139
|
+
DEPromotionAmount: '100%',
|
|
140
|
+
DEPromotionOrder: ['Win Percent', 'Win Count', 'Indicator', 'Points Scored'],
|
|
141
|
+
DEPromoteBy: 'Percent',
|
|
142
|
+
DEType: 'single',
|
|
143
|
+
CountHandshots: false,
|
|
144
|
+
CountDoubles: false,
|
|
145
|
+
PenaltiesReset: true,
|
|
146
|
+
IncludeInRatings: event.IncludeInRatings ?? true
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
export default {
|
|
150
|
+
name: 'EditEventWizard',
|
|
151
|
+
components: {
|
|
152
|
+
EventCustomization,
|
|
153
|
+
DirectEliminationPromotion,
|
|
154
|
+
StepIndicator,
|
|
155
|
+
BasicEventInfo,
|
|
156
|
+
PoolConfiguration,
|
|
157
|
+
DirectElimination,
|
|
158
|
+
BaseButton
|
|
159
|
+
},
|
|
160
|
+
emits: ['update:submit', 'update:cancel', 'save:step', 'navigate:step', 'update:dirty'],
|
|
161
|
+
props: {
|
|
162
|
+
editMode: { type: Boolean, default: false },
|
|
163
|
+
step: { type: Number, default: 1 },
|
|
164
|
+
saving: { type: Boolean, default: false },
|
|
165
|
+
saveError: { type: String, default: '' },
|
|
166
|
+
saveNotice: { type: String, default: '' },
|
|
167
|
+
|
|
168
|
+
event: {
|
|
169
|
+
type: Object
|
|
170
|
+
},
|
|
171
|
+
weapons: {
|
|
172
|
+
type: Array,
|
|
173
|
+
required: true
|
|
174
|
+
},
|
|
175
|
+
saveButtonLabel: {
|
|
176
|
+
type: String,
|
|
177
|
+
default: 'Save'
|
|
178
|
+
},
|
|
179
|
+
DEFormats: {
|
|
180
|
+
type: Array,
|
|
181
|
+
default: () => [
|
|
182
|
+
{ link: 1, text: 'Single Elimination' },
|
|
183
|
+
{ link: 2, text: 'Double Elimination' }
|
|
184
|
+
]
|
|
185
|
+
},
|
|
186
|
+
userLevel: {
|
|
187
|
+
type: String,
|
|
188
|
+
default: 'Club'
|
|
189
|
+
}
|
|
190
|
+
},
|
|
191
|
+
data() {
|
|
192
|
+
return {
|
|
193
|
+
currentStep: this.step,
|
|
194
|
+
localEvent: cloneEvent(this.event),
|
|
195
|
+
hasClickedNext: false,
|
|
196
|
+
validation: {
|
|
197
|
+
EventName: { invalid: false, message: '' },
|
|
198
|
+
EventPrice: { invalid: false, message: '' }
|
|
199
|
+
},
|
|
200
|
+
eventConfig: createEventConfig(this.event),
|
|
201
|
+
savedDraft: '',
|
|
202
|
+
draftVersion: 0,
|
|
203
|
+
seedWithOptions: [
|
|
204
|
+
{ text: 'M2 - MeyerSquared', link: 'M2' },
|
|
205
|
+
{ text: 'HR - Hema Rating', link: 'HR' },
|
|
206
|
+
{ text: 'Manual', link: 'MN' }
|
|
207
|
+
],
|
|
208
|
+
steps: [
|
|
209
|
+
{ name: 'Basic Info', icon: 'fa-circle-info' },
|
|
210
|
+
{ name: 'Customization', icon: 'fa-star' },
|
|
211
|
+
{ name: 'Pool Setup', icon: 'fa-table-columns' },
|
|
212
|
+
{ name: 'DE Promotion', icon: 'fa-list' },
|
|
213
|
+
{ name: 'Direct Elimination', icon: 'fa-diagram-sankey' }
|
|
214
|
+
]
|
|
215
|
+
};
|
|
216
|
+
},
|
|
217
|
+
computed: {
|
|
218
|
+
nextButtonLabel() {
|
|
219
|
+
if (!this.editMode) return this.currentStep === 5 ? 'Submit' : 'Next';
|
|
220
|
+
return this.currentStep === 5 ? 'Save' : 'Save and Continue';
|
|
221
|
+
}
|
|
222
|
+
},
|
|
223
|
+
mounted() {
|
|
224
|
+
this.resetDraft();
|
|
225
|
+
},
|
|
226
|
+
watch: {
|
|
227
|
+
event() {
|
|
228
|
+
this.resetDraft();
|
|
229
|
+
},
|
|
230
|
+
step(value) {
|
|
231
|
+
if (Number.isInteger(value) && value >= 1 && value <= this.steps.length) this.currentStep = value;
|
|
232
|
+
}
|
|
233
|
+
},
|
|
234
|
+
methods: {
|
|
235
|
+
resetDraft() {
|
|
236
|
+
this.localEvent = cloneEvent(this.event);
|
|
237
|
+
this.eventConfig = applyRulesToEventConfig(createEventConfig(this.event), this.localEvent.rules);
|
|
238
|
+
if (typeof this.event.IncludeInRatings === 'boolean')
|
|
239
|
+
this.eventConfig.IncludeInRatings = this.event.IncludeInRatings;
|
|
240
|
+
this.savedDraft = JSON.stringify(this.eventConfig);
|
|
241
|
+
this.draftVersion += 1;
|
|
242
|
+
this.publishDirtyState();
|
|
243
|
+
},
|
|
244
|
+
publishDirtyState() {
|
|
245
|
+
if (this.editMode) this.$emit('update:dirty', JSON.stringify(this.eventConfig) !== this.savedDraft);
|
|
246
|
+
},
|
|
247
|
+
handleValueChange(change) {
|
|
248
|
+
if (this.saving) return;
|
|
249
|
+
this.eventConfig = { ...this.eventConfig, ...change };
|
|
250
|
+
this.localEvent = { ...this.localEvent, ...change };
|
|
251
|
+
this.publishDirtyState();
|
|
252
|
+
if (this.hasClickedNext) this.validateAll();
|
|
253
|
+
},
|
|
254
|
+
handleDEPromotionType(value) {
|
|
255
|
+
this.handleValueChange({ DEPromoteBy: value });
|
|
256
|
+
},
|
|
257
|
+
validateAll() {
|
|
258
|
+
let isValid = true;
|
|
259
|
+
this.validation.EventPrice = validatePrice(this.eventConfig.EventPrice);
|
|
260
|
+
const forbiddenChars = /[\/\\'"=:*<>|?&!@#$%^(){}[\]]/g;
|
|
261
|
+
|
|
262
|
+
if (!this.eventConfig.EventName || this.eventConfig.EventName.trim().length < 4) {
|
|
263
|
+
this.validation.EventName = {
|
|
264
|
+
invalid: true,
|
|
265
|
+
message: 'Event Name must be at least 3 characters long.'
|
|
266
|
+
};
|
|
267
|
+
isValid = false;
|
|
268
|
+
return isValid;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
if (forbiddenChars.test(this.eventConfig.EventName)) {
|
|
272
|
+
this.validation.EventName = {
|
|
273
|
+
invalid: true,
|
|
274
|
+
message: 'Event Name contains invalid characters.'
|
|
275
|
+
};
|
|
276
|
+
isValid = false;
|
|
277
|
+
return isValid;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
this.validation.EventName = { invalid: false, message: '' };
|
|
281
|
+
return !this.validation.EventPrice.invalid;
|
|
282
|
+
},
|
|
283
|
+
handleUpdate(eventConfig = {}) {
|
|
284
|
+
if (this.saving) return;
|
|
285
|
+
this.hasClickedNext = true;
|
|
286
|
+
if (!this.editMode) this.eventConfig = { ...this.eventConfig, ...eventConfig };
|
|
287
|
+
if (!this.validateAll()) return;
|
|
288
|
+
if (this.editMode) {
|
|
289
|
+
this.requestStepSave();
|
|
290
|
+
return;
|
|
291
|
+
}
|
|
292
|
+
this.currentStep += 1;
|
|
293
|
+
},
|
|
294
|
+
handleBack() {
|
|
295
|
+
if (this.saving) return;
|
|
296
|
+
if (this.editMode) {
|
|
297
|
+
this.$emit('navigate:step', this.currentStep - 1);
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
this.currentStep -= 1;
|
|
301
|
+
},
|
|
302
|
+
convertEventConfigToRules(eventConfig) {
|
|
303
|
+
const mapping = {
|
|
304
|
+
poolTime: { RuleId: 1, RuleName: 'PoolTime', Context: 'pool', dependsOn: 'poolTimer' },
|
|
305
|
+
poolMaxPoints: { RuleId: 2, RuleName: 'PoolMaxPoints', Context: 'pool', dependsOn: 'poolMax' },
|
|
306
|
+
DETime: { RuleId: 3, RuleName: 'DETime', Context: 'de', dependsOn: 'DETimer' },
|
|
307
|
+
DEMaxPoints: { RuleId: 4, RuleName: 'DEMaxPoints', Context: 'de', dependsOn: 'DEMax' },
|
|
308
|
+
thirdPlaceBout: { RuleId: 5, RuleName: 'DE3rdFenceOff', Context: 'de' },
|
|
309
|
+
boutCount: { RuleId: 6, RuleName: 'PoolNumOfPasses', Context: 'pool', dependsOn: 'boutCounter' },
|
|
310
|
+
DEBoutCount: { RuleId: 7, RuleName: 'DENumOfPasses', Context: 'de', dependsOn: 'DEBoutCounter' },
|
|
311
|
+
DEPromotionAmount: { RuleId: 10, RuleName: 'DENumOfPromotion', Context: 'de' },
|
|
312
|
+
DEPromotionOrder: { RuleId: 9, RuleName: 'DEPromotionOrder', Context: 'de' },
|
|
313
|
+
seedWith: { RuleId: 11, RuleName: 'PoolSeeding', Context: 'pool' },
|
|
314
|
+
CutOffNumber: { RuleId: 14, RuleName: 'CutOffNumber', Context: 'event' },
|
|
315
|
+
DEType: { RuleId: 15, RuleName: 'DEType', Context: 'de' },
|
|
316
|
+
PoolScoreDirection: { RuleId: 16, RuleName: 'PoolScoreDirection', Context: 'de' },
|
|
317
|
+
DEPromoteBy: { RuleId: 17, RuleName: 'DEPromoteBy', Context: 'de' },
|
|
318
|
+
CountHandshots: { RuleId: 19, RuleName: 'CountHandshots', Context: 'event' },
|
|
319
|
+
CountDoubles: { RuleId: 20, RuleName: 'CountDoubles', Context: 'event' },
|
|
320
|
+
PenaltiesReset: { RuleId: 21, RuleName: 'PenaltiesReset', Context: 'event' },
|
|
321
|
+
IncludeInRatings: { RuleId: 22, RuleName: 'IncludeInRatings', Context: 'event', onlyWhenExisting: true }
|
|
322
|
+
};
|
|
323
|
+
|
|
324
|
+
return Object.entries(eventConfig)
|
|
325
|
+
.filter(([key, value]) => mapping[key] && value !== undefined)
|
|
326
|
+
.filter(
|
|
327
|
+
([key]) =>
|
|
328
|
+
!mapping[key].onlyWhenExisting ||
|
|
329
|
+
this.localEvent.rules.some(rule => Number(rule.RuleId) === mapping[key].RuleId)
|
|
330
|
+
)
|
|
331
|
+
.filter(([key]) => {
|
|
332
|
+
const dependency = mapping[key].dependsOn;
|
|
333
|
+
return !dependency || eventConfig[dependency];
|
|
334
|
+
})
|
|
335
|
+
.map(([key, value]) => ({
|
|
336
|
+
RuleId: mapping[key].RuleId,
|
|
337
|
+
RuleName: mapping[key].RuleName,
|
|
338
|
+
RuleValue: this.serializeRuleValue(value),
|
|
339
|
+
Context: mapping[key].Context
|
|
340
|
+
}));
|
|
341
|
+
},
|
|
342
|
+
serializeRuleValue(value) {
|
|
343
|
+
if (Array.isArray(value)) return value.join(',');
|
|
344
|
+
const isDropdownOption = value !== null && typeof value === 'object';
|
|
345
|
+
return String(isDropdownOption ? (value.link ?? value.text ?? '') : value);
|
|
346
|
+
},
|
|
347
|
+
buildEventPayload() {
|
|
348
|
+
return {
|
|
349
|
+
...cloneEvent(this.localEvent),
|
|
350
|
+
...this.eventConfig,
|
|
351
|
+
EventPrice: Number(this.eventConfig.EventPrice),
|
|
352
|
+
rules: this.convertEventConfigToRules(this.eventConfig)
|
|
353
|
+
};
|
|
354
|
+
},
|
|
355
|
+
requestStepSave() {
|
|
356
|
+
this.$emit('save:step', { event: this.buildEventPayload(), step: this.currentStep });
|
|
357
|
+
},
|
|
358
|
+
handleSubmit() {
|
|
359
|
+
if (this.saving || !this.validateAll()) return;
|
|
360
|
+
if (this.editMode) {
|
|
361
|
+
this.requestStepSave();
|
|
362
|
+
return;
|
|
363
|
+
}
|
|
364
|
+
this.$emit('update:submit', this.buildEventPayload());
|
|
365
|
+
},
|
|
366
|
+
handleCancel() {
|
|
367
|
+
if (this.saving) return;
|
|
368
|
+
this.$emit('update:cancel');
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
};
|
|
372
|
+
</script>
|