@dcrackel/hematournamentui 1.0.709 → 1.0.711

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 (24) hide show
  1. package/README.md +16 -0
  2. package/dist/HemaTournamentUI-lib.es.js +4343 -4086
  3. package/dist/HemaTournamentUI-lib.umd.js +27 -27
  4. package/dist/hematournamentui-tailwind.css +3 -0
  5. package/package.json +1 -1
  6. package/src/stories/Organisms/Wizards/EditEventWizard/BasicEventInfo/BasicEventInfo.stories.js +48 -41
  7. package/src/stories/Organisms/Wizards/EditEventWizard/BasicEventInfo/BasicEventInfo.vue +227 -206
  8. package/src/stories/Organisms/Wizards/EditEventWizard/DirectElimination/DirectElimination.vue +226 -225
  9. package/src/stories/Organisms/Wizards/EditEventWizard/DirectEliminationPromotion/DirectEliminationPromotion.vue +204 -204
  10. package/src/stories/Organisms/Wizards/EditEventWizard/EditEventWizard.stories.js +133 -91
  11. package/src/stories/Organisms/Wizards/EditEventWizard/EditEventWizard.test.js +191 -0
  12. package/src/stories/Organisms/Wizards/EditEventWizard/EditEventWizard.vue +366 -309
  13. package/src/stories/Organisms/Wizards/EditEventWizard/EventCustomization/EventCustomization.vue +172 -171
  14. package/src/stories/Organisms/Wizards/EditEventWizard/PoolConfiguration/PoolConfiguration.vue +216 -215
  15. package/src/stories/Organisms/Wizards/EditEventWizard/PriceFields.test.js +79 -0
  16. package/src/stories/Templates/EventManagement/EditEventInfo/EditEventInfo.stories.js +93 -52
  17. package/src/stories/Templates/EventManagement/EditEventInfo/EditEventInfo.vue +91 -75
  18. package/src/stories/Templates/TournamentManagement/TournamentManagement.stories.js +84 -83
  19. package/src/stories/Templates/TournamentManagement/TournamentManagement.test.js +114 -0
  20. package/src/stories/Templates/TournamentManagement/TournamentManagement.vue +363 -360
  21. package/src/stories/Templates/TournamentManagement/TournamentPageOne/TournamentPageOne.stories.js +116 -113
  22. package/src/stories/Templates/TournamentManagement/TournamentPageOne/TournamentPageOne.vue +307 -280
  23. package/src/stories/Util/Validations/PriceValidation.js +6 -0
  24. package/src/stories/Util/Validations/TournamentFieldsValidations.js +4 -0
@@ -1,75 +1,91 @@
1
- <template>
2
- <section>
3
- <EditEventsTopMenu :currentTab="'Edit'" :tabs="tabs(userLevel, isMobile)" @tabMenuClick="handleTabMenuClick" />
4
-
5
- <div class="w-full flex flex-row justify-center mt-3">
6
- <EditEventWizard
7
- :event="event"
8
- :rules="rules"
9
- :weapons="weapons"
10
- :userLevel="userLevel"
11
- @update:submit="handleSubmit"
12
- />
13
- </div>
14
- </section>
15
- </template>
16
-
17
- <script>
18
- import EditEventsTopMenu from '../../Menus/EditEventsTopMenu/EditEventsTopMenu.vue';
19
- import EditEventWizard from '../../../Organisms/Wizards/EditEventWizard/EditEventWizard.vue';
20
- import { tabs } from '../../../Util/tabs.js';
21
-
22
- export default {
23
- emits: ['tab:menu-click', 'update:submit'],
24
- components: {
25
- EditEventWizard,
26
- EditEventsTopMenu
27
- },
28
- props: {
29
- event: {
30
- type: Object,
31
- required: true
32
- },
33
- weapons: {
34
- type: Array,
35
- required: true
36
- },
37
- rules: {
38
- type: Array,
39
- required: true
40
- },
41
- userLevel: {
42
- type: String,
43
- default: 'Club'
44
- }
45
- },
46
- data() {
47
- return {
48
- tabs,
49
- windowWidth: window.innerWidth
50
- };
51
- },
52
- mounted() {
53
- window.addEventListener('resize', this.handleResize);
54
- },
55
- beforeUnmount() {
56
- window.removeEventListener('resize', this.handleResize);
57
- },
58
- computed: {
59
- isMobile() {
60
- return this.windowWidth <= 748;
61
- }
62
- },
63
- methods: {
64
- handleTabMenuClick(value) {
65
- this.$emit('tab:menu-click', value);
66
- },
67
- handleSubmit(value) {
68
- this.$emit('update:submit', value);
69
- },
70
- handleResize() {
71
- this.windowWidth = window.innerWidth;
72
- }
73
- }
74
- };
75
- </script>
1
+ <template>
2
+ <section>
3
+ <EditEventsTopMenu :currentTab="'Edit'" :tabs="tabs(userLevel, isMobile)" @tabMenuClick="handleTabMenuClick" />
4
+
5
+ <div class="w-full flex flex-row justify-center mt-3">
6
+ <EditEventWizard
7
+ :event="event"
8
+ :rules="rules"
9
+ :weapons="weapons"
10
+ :userLevel="userLevel"
11
+ :editMode="editMode"
12
+ :step="step"
13
+ :saving="saving"
14
+ :saveError="saveError"
15
+ :saveNotice="saveNotice"
16
+ @save:step="$emit('save:step', $event)"
17
+ @navigate:step="$emit('navigate:step', $event)"
18
+ @update:dirty="$emit('update:dirty', $event)"
19
+ @update:cancel="$emit('update:cancel')"
20
+ @update:submit="handleSubmit"
21
+ />
22
+ </div>
23
+ </section>
24
+ </template>
25
+
26
+ <script>
27
+ import EditEventsTopMenu from '../../Menus/EditEventsTopMenu/EditEventsTopMenu.vue';
28
+ import EditEventWizard from '../../../Organisms/Wizards/EditEventWizard/EditEventWizard.vue';
29
+ import { tabs } from '../../../Util/tabs.js';
30
+
31
+ export default {
32
+ emits: ['tab:menu-click', 'update:submit', 'save:step', 'navigate:step', 'update:dirty', 'update:cancel'],
33
+ components: {
34
+ EditEventWizard,
35
+ EditEventsTopMenu
36
+ },
37
+ props: {
38
+ editMode: { type: Boolean, default: false },
39
+ step: { type: Number, default: 1 },
40
+ saving: { type: Boolean, default: false },
41
+ saveError: { type: String, default: '' },
42
+ saveNotice: { type: String, default: '' },
43
+
44
+ event: {
45
+ type: Object,
46
+ required: true
47
+ },
48
+ weapons: {
49
+ type: Array,
50
+ required: true
51
+ },
52
+ rules: {
53
+ type: Array,
54
+ required: true
55
+ },
56
+ userLevel: {
57
+ type: String,
58
+ default: 'Club'
59
+ }
60
+ },
61
+ data() {
62
+ return {
63
+ tabs,
64
+ windowWidth: window.innerWidth
65
+ };
66
+ },
67
+ mounted() {
68
+ window.addEventListener('resize', this.handleResize);
69
+ },
70
+ beforeUnmount() {
71
+ window.removeEventListener('resize', this.handleResize);
72
+ },
73
+ computed: {
74
+ isMobile() {
75
+ return this.windowWidth <= 748;
76
+ }
77
+ },
78
+ methods: {
79
+ handleTabMenuClick(value) {
80
+ if (this.saving) return;
81
+ this.$emit('tab:menu-click', value);
82
+ },
83
+ handleSubmit(value) {
84
+ this.$emit('update:submit', value);
85
+ },
86
+ handleResize() {
87
+ this.windowWidth = window.innerWidth;
88
+ }
89
+ }
90
+ };
91
+ </script>
@@ -1,83 +1,84 @@
1
- import TournamentManagement from './TournamentManagement.vue';
2
- import mockLocation from '../../../mocks/locationMock.js';
3
- import mockPersons from '../../../mocks/personsMock.js';
4
- import mockTournaments from '../../../mocks/tournamentMock.js';
5
-
6
- const existingTournament = {
7
- ...mockTournaments[0],
8
- HostedOnM2: true,
9
- ResultsEnabled: false,
10
- Visibility: 'Open',
11
- WaiverScope: 'None'
12
- };
13
-
14
- export default {
15
- title: 'Templates/TournamentManagement',
16
- component: TournamentManagement,
17
- tags: ['autodocs'],
18
- args: {
19
- tournament: existingTournament,
20
- locations: mockLocation,
21
- persons: mockPersons,
22
- uploadImageName: 'tournament-test',
23
- uploadServer: 'http://localhost:3000/api/upload/',
24
- imageServer: 'https://meyersquaredimages.com/uploads/',
25
- showTab: 'Basic',
26
- userLevel: 'Club',
27
- submitButtonLabel: 'Save'
28
- },
29
- argTypes: {
30
- tournament: {
31
- control: { type: 'object' }
32
- },
33
- locations: {
34
- control: { type: 'object' }
35
- },
36
- persons: {
37
- control: { type: 'object' }
38
- },
39
- showTab: {
40
- control: { type: 'text' }
41
- },
42
- userLevel: {
43
- control: { type: 'text' }
44
- },
45
- submitButtonLabel: {
46
- control: { type: 'text' }
47
- }
48
- }
49
- };
50
-
51
- export const Default = {
52
- args: {
53
- tournament: existingTournament,
54
- locations: mockLocation,
55
- persons: mockPersons
56
- }
57
- };
58
-
59
- export const EmptyTournament = {
60
- args: {
61
- tournament: {},
62
- locations: mockLocation,
63
- persons: mockPersons
64
- }
65
- };
66
-
67
- export const StartOnDetails = {
68
- args: {
69
- tournament: existingTournament,
70
- locations: mockLocation,
71
- persons: mockPersons,
72
- showTab: 'Hosting'
73
- }
74
- };
75
-
76
- export const Saving = {
77
- args: {
78
- tournament: existingTournament,
79
- locations: mockLocation,
80
- persons: mockPersons,
81
- submitButtonLabel: 'Saving...'
82
- }
83
- };
1
+ import TournamentManagement from './TournamentManagement.vue';
2
+ import mockLocation from '../../../mocks/locationMock.js';
3
+ import mockPersons from '../../../mocks/personsMock.js';
4
+ import mockTournaments from '../../../mocks/tournamentMock.js';
5
+
6
+ const existingTournament = {
7
+ ...mockTournaments[0],
8
+ BasePrice: 75.5,
9
+ HostedOnM2: true,
10
+ ResultsEnabled: false,
11
+ Visibility: 'Open',
12
+ WaiverScope: 'None'
13
+ };
14
+
15
+ export default {
16
+ title: 'Templates/TournamentManagement',
17
+ component: TournamentManagement,
18
+ tags: ['autodocs'],
19
+ args: {
20
+ tournament: existingTournament,
21
+ locations: mockLocation,
22
+ persons: mockPersons,
23
+ uploadImageName: 'tournament-test',
24
+ uploadServer: 'http://localhost:3000/api/upload/',
25
+ imageServer: 'https://meyersquaredimages.com/uploads/',
26
+ showTab: 'Basic',
27
+ userLevel: 'Club',
28
+ submitButtonLabel: 'Save'
29
+ },
30
+ argTypes: {
31
+ tournament: {
32
+ control: { type: 'object' }
33
+ },
34
+ locations: {
35
+ control: { type: 'object' }
36
+ },
37
+ persons: {
38
+ control: { type: 'object' }
39
+ },
40
+ showTab: {
41
+ control: { type: 'text' }
42
+ },
43
+ userLevel: {
44
+ control: { type: 'text' }
45
+ },
46
+ submitButtonLabel: {
47
+ control: { type: 'text' }
48
+ }
49
+ }
50
+ };
51
+
52
+ export const Default = {
53
+ args: {
54
+ tournament: existingTournament,
55
+ locations: mockLocation,
56
+ persons: mockPersons
57
+ }
58
+ };
59
+
60
+ export const EmptyTournament = {
61
+ args: {
62
+ tournament: {},
63
+ locations: mockLocation,
64
+ persons: mockPersons
65
+ }
66
+ };
67
+
68
+ export const StartOnDetails = {
69
+ args: {
70
+ tournament: existingTournament,
71
+ locations: mockLocation,
72
+ persons: mockPersons,
73
+ showTab: 'Hosting'
74
+ }
75
+ };
76
+
77
+ export const Saving = {
78
+ args: {
79
+ tournament: existingTournament,
80
+ locations: mockLocation,
81
+ persons: mockPersons,
82
+ submitButtonLabel: 'Saving...'
83
+ }
84
+ };
@@ -0,0 +1,114 @@
1
+ import { afterEach, describe, expect, it } from 'vitest';
2
+ import { mount } from '@vue/test-utils';
3
+ import TournamentManagement from './TournamentManagement.vue';
4
+ import TitledInput from '../../Molecules/CombinationInputs/TitledInput/TitledInput.vue';
5
+
6
+ const wrappers = [];
7
+ afterEach(() => wrappers.splice(0).forEach(wrapper => wrapper.unmount()));
8
+
9
+ function mountTournament(tournament = {}) {
10
+ const wrapper = mount(TournamentManagement, {
11
+ props: { tournament, locations: [], persons: [] },
12
+ global: {
13
+ stubs: {
14
+ EditEventsTopMenu: true,
15
+ TournamentPageTwo: true,
16
+ ImageCropper: true,
17
+ FindLocation: true,
18
+ FindPerson: true,
19
+ DatePicker: true,
20
+ TextBoxEditor: true
21
+ }
22
+ }
23
+ });
24
+ wrappers.push(wrapper);
25
+ return wrapper;
26
+ }
27
+
28
+ function priceField(wrapper) {
29
+ return wrapper.findAllComponents(TitledInput).find(field => field.props('title').startsWith('Base Price'));
30
+ }
31
+
32
+ function existingTournament(BasePrice) {
33
+ return { Name: 'Test Tournament', Address: { Name: 'Test Venue' }, BasePrice };
34
+ }
35
+
36
+ describe('tournament base price', () => {
37
+ it.each([
38
+ [45, '45.00'],
39
+ ['45', '45.00'],
40
+ [45.5, '45.50'],
41
+ ['45.5', '45.50']
42
+ ])('displays a saved base price of %s as %s', async (value, display) => {
43
+ const wrapper = mountTournament(existingTournament(value));
44
+ await wrapper.vm.$nextTick();
45
+ expect(priceField(wrapper).find('input').element.value).toBe(display);
46
+ });
47
+
48
+ it('formats an entered price on blur and preserves the numeric submit payload', async () => {
49
+ const wrapper = mountTournament();
50
+ await wrapper.vm.$nextTick();
51
+ wrapper.vm.updateTournament({ Name: 'Test Tournament', Address: { Name: 'Test Venue' } });
52
+ const input = priceField(wrapper).find('input');
53
+ await input.setValue('45.');
54
+ expect(input.element.value).toBe('45.');
55
+ await input.setValue('45');
56
+ await input.trigger('focusout');
57
+ expect(input.element.value).toBe('45.00');
58
+ wrapper.vm.handleSubmit();
59
+ expect(wrapper.emitted('submit:tournament')[0][0].BasePrice).toBe(45);
60
+ });
61
+
62
+ it('retains decimal typing and submits the base price from a new tournament', async () => {
63
+ const wrapper = mountTournament();
64
+ await wrapper.vm.$nextTick();
65
+ expect(priceField(wrapper).find('input').element.value).toBe('');
66
+ expect(priceField(wrapper).find('input').attributes('placeholder')).toBe('0.00');
67
+ wrapper.vm.updateTournament({ Name: 'Test Tournament', Address: { Name: 'Test Venue' } });
68
+ const input = priceField(wrapper).find('input');
69
+ await input.setValue('75.');
70
+ expect(input.element.value).toBe('75.');
71
+ await input.setValue('75.50');
72
+ wrapper.vm.handleNext();
73
+ await wrapper.vm.$nextTick();
74
+ expect(wrapper.vm.currentTab).toBe('Hosting');
75
+ wrapper.vm.handleSubmit();
76
+ expect(wrapper.emitted('submit:tournament')[0][0].BasePrice).toBe(75.5);
77
+ });
78
+
79
+ it('edits saved prices without mutating props and reconciles parent updates', async () => {
80
+ const tournament = existingTournament(50.25);
81
+ const wrapper = mountTournament(tournament);
82
+ await wrapper.vm.$nextTick();
83
+ expect(priceField(wrapper).find('input').element.value).toBe('50.25');
84
+ await priceField(wrapper).find('input').setValue('80.75');
85
+ wrapper.vm.handleSubmit();
86
+ expect(wrapper.emitted('submit:tournament')[0][0].BasePrice).toBe(80.75);
87
+ expect(tournament.BasePrice).toBe(50.25);
88
+ await wrapper.setProps({ tournament: existingTournament(0) });
89
+ expect(priceField(wrapper).find('input').element.value).toBe('0.00');
90
+ });
91
+
92
+ it.each([undefined, null, 0])('allows free tournaments with an initial price of %s', async value => {
93
+ const wrapper = mountTournament(existingTournament(value));
94
+ await wrapper.vm.$nextTick();
95
+ expect(priceField(wrapper).find('input').element.value).toBe(value == null ? '' : '0.00');
96
+ expect(priceField(wrapper).find('input').attributes('placeholder')).toBe('0.00');
97
+ await priceField(wrapper).find('input').setValue('');
98
+ wrapper.vm.handleSubmit();
99
+ expect(wrapper.emitted('submit:tournament')[0][0].BasePrice).toBe(0);
100
+ });
101
+
102
+ it.each(['-5', 'invalid', 'Infinity'])('rejects invalid price %s and recovers after correction', async value => {
103
+ const wrapper = mountTournament(existingTournament(10));
104
+ await wrapper.vm.$nextTick();
105
+ await priceField(wrapper).find('input').setValue(value);
106
+ wrapper.vm.handleSubmit();
107
+ await wrapper.vm.$nextTick();
108
+ expect(wrapper.emitted('submit:tournament')).toBeUndefined();
109
+ expect(priceField(wrapper).props('invalid')).toBe(true);
110
+ await priceField(wrapper).find('input').setValue('0');
111
+ wrapper.vm.handleSubmit();
112
+ expect(wrapper.emitted('submit:tournament')[0][0].BasePrice).toBe(0);
113
+ });
114
+ });