@dcrackel/hematournamentui 1.0.712 → 1.0.714

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 (107) hide show
  1. package/.prettierignore +7 -7
  2. package/.storybook/main.js +3 -1
  3. package/README.md +42 -0
  4. package/dist/HemaTournamentUI-lib.es.js +6856 -6243
  5. package/dist/HemaTournamentUI-lib.umd.js +27 -27
  6. package/dist/hematournamentui-tailwind.css +79 -9
  7. package/package.json +96 -96
  8. package/prettier.config.js +16 -16
  9. package/src/index.js +43 -42
  10. package/src/main.js +1 -1
  11. package/src/mocks/getDEBouts-TableOf128.js +37 -37
  12. package/src/mocks/getDEBouts-TableOf64.js +35 -35
  13. package/src/stories/Atoms/Input/BaseInput.test.js +97 -97
  14. package/src/stories/Atoms/Input/BaseInput.vue +149 -149
  15. package/src/stories/Molecules/Indicators/MissingHemaRatingsId/MissingHemaRatingsId.stories.js +23 -23
  16. package/src/stories/Molecules/Indicators/MissingHemaRatingsId/MissingHemaRatingsId.vue +35 -35
  17. package/src/stories/Molecules/Indicators/RegistrationStatus/RegistrationStatus.vue +30 -30
  18. package/src/stories/Molecules/Menus/HoverActions/HoverActions.test.js +138 -0
  19. package/src/stories/Molecules/Menus/HoverActions/HoverActions.vue +212 -0
  20. package/src/stories/Molecules/Modals/BracketDirectorsModal/BracketDirectorsModal.stories.js +49 -0
  21. package/src/stories/Molecules/Modals/BracketDirectorsModal/BracketDirectorsModal.test.js +129 -0
  22. package/src/stories/Molecules/Modals/BracketDirectorsModal/BracketDirectorsModal.vue +165 -0
  23. package/src/stories/Molecules/Modals/DirectorModal/DirectorModal.stories.js +6 -0
  24. package/src/stories/Molecules/Modals/DirectorModal/DirectorModal.test.js +18 -18
  25. package/src/stories/Molecules/Modals/DirectorModal/DirectorModal.vue +1 -1
  26. package/src/stories/Organisms/Cards/BoutCard/BoutCard.vue +5 -1
  27. package/src/stories/Organisms/Cards/BoutCard/Variants/BoutCardActive/BoutCardActive.vue +19 -10
  28. package/src/stories/Organisms/Cards/BoutCard/Variants/BoutCardInactive/BoutCardInactive.vue +11 -7
  29. package/src/stories/Organisms/Cards/BracketDirectorAssignmentCard/BracketDirectorAssignmentCard.stories.js +42 -33
  30. package/src/stories/Organisms/Cards/BracketDirectorAssignmentCard/BracketDirectorAssignmentCard.test.js +76 -45
  31. package/src/stories/Organisms/Cards/BracketDirectorAssignmentCard/BracketDirectorAssignmentCard.vue +122 -103
  32. package/src/stories/Organisms/Cards/Director/DirectorCard.test.js +82 -0
  33. package/src/stories/Organisms/Cards/Director/DirectorCard.vue +32 -51
  34. package/src/stories/Organisms/Cards/EditBout/EditBout.test.js +51 -51
  35. package/src/stories/Organisms/Cards/EventCard/EventCard.test.js +106 -106
  36. package/src/stories/Organisms/Cards/FencerCard/FencerCard.vue +298 -298
  37. package/src/stories/Organisms/Cards/TableauBoutCard/TableauBoutCard.stories.js +77 -60
  38. package/src/stories/Organisms/Cards/TableauBoutCard/TableauBoutCard.test.js +144 -143
  39. package/src/stories/Organisms/Cards/TableauBoutCard/TableauBoutCard.vue +289 -256
  40. package/src/stories/Organisms/Cards/TableauFencerCard/TableauFencerCard.stories.js +69 -69
  41. package/src/stories/Organisms/Cards/TableauFencerCard/TableauFencerCard.vue +80 -80
  42. package/src/stories/Organisms/Cards/WaitlistFencerCard/WaitlistFencerCard.vue +153 -153
  43. package/src/stories/Organisms/ComplexInputs/DropDown/DropDownMenu.vue +4 -0
  44. package/src/stories/Organisms/ComplexInputs/ImageCropper/ImageCropper.stories.js +31 -31
  45. package/src/stories/Organisms/ComplexInputs/ImageCropper/ImageCropper.test.js +109 -109
  46. package/src/stories/Organisms/ComplexInputs/ImageCropper/ImageCropper.vue +192 -192
  47. package/src/stories/Organisms/Containers/Tableau/Tableau.stories.js +1 -0
  48. package/src/stories/Organisms/Containers/Tableau/Tableau.test.js +247 -204
  49. package/src/stories/Organisms/Containers/Tableau/Tableau.vue +89 -15
  50. package/src/stories/Organisms/Containers/Tableau/components/BracketDirectorAssignmentPanel.test.js +51 -29
  51. package/src/stories/Organisms/Containers/Tableau/components/BracketDirectorAssignmentPanel.vue +63 -46
  52. package/src/stories/Organisms/Containers/Tableau/components/TableauSvgOverlay.test.js +21 -21
  53. package/src/stories/Organisms/Containers/Tableau/components/TableauSvgOverlay.vue +39 -39
  54. package/src/stories/Organisms/Containers/Tableau/layout/TableauLayoutEngine.js +145 -145
  55. package/src/stories/Organisms/Containers/Tableau/layout/TableauLayoutEngine.test.js +64 -64
  56. package/src/stories/Organisms/Containers/Tableau/plannedAssignments.js +36 -57
  57. package/src/stories/Organisms/Containers/Tableau/plannedAssignments.test.js +101 -65
  58. package/src/stories/Organisms/Containers/TableauColumn/TableauColumn.vue +14 -1
  59. package/src/stories/Organisms/Wizards/EditEventWizard/BasicEventInfo/BasicEventInfo.stories.js +52 -52
  60. package/src/stories/Organisms/Wizards/EditEventWizard/BasicEventInfo/BasicEventInfo.vue +10 -3
  61. package/src/stories/Organisms/Wizards/EditEventWizard/DirectElimination/DirectElimination.vue +226 -226
  62. package/src/stories/Organisms/Wizards/EditEventWizard/DirectEliminationPromotion/DirectEliminationPromotion.vue +204 -204
  63. package/src/stories/Organisms/Wizards/EditEventWizard/EditEventWizard.stories.js +137 -137
  64. package/src/stories/Organisms/Wizards/EditEventWizard/EventCustomization/EventCustomization.vue +172 -172
  65. package/src/stories/Organisms/Wizards/EditEventWizard/PoolConfiguration/PoolConfiguration.vue +216 -216
  66. package/src/stories/Organisms/Wizards/EditEventWizard/PriceFields.test.js +79 -79
  67. package/src/stories/Organisms/Wizards/EditEventWizard/RuleSerialization.test.js +29 -29
  68. package/src/stories/Organisms/Wizards/EditEventWizard/WeaponSelection.test.js +138 -0
  69. package/src/stories/Templates/EventManagement/Bracket/Bracket.stories.js +149 -9
  70. package/src/stories/Templates/EventManagement/Bracket/Bracket.test.js +54 -2
  71. package/src/stories/Templates/EventManagement/Bracket/Bracket.vue +77 -8
  72. package/src/stories/Templates/EventManagement/Bracket/BracketDirectorAssignment.test.js +242 -0
  73. package/src/stories/Templates/EventManagement/Bracket/BracketMobile.test.js +131 -0
  74. package/src/stories/Templates/EventManagement/Bracket/BracketPlannedSuggestions.js +50 -39
  75. package/src/stories/Templates/EventManagement/Bracket/BracketStories.test.js +201 -0
  76. package/src/stories/Templates/EventManagement/Bracket/BracketStoryAssignments.js +93 -0
  77. package/src/stories/Templates/EventManagement/Bracket/BracketStoryAssignments.test.js +152 -0
  78. package/src/stories/Templates/EventManagement/Bracket/BracketStoryHarness.js +39 -39
  79. package/src/stories/Templates/EventManagement/Bracket/BracketStoryHarness.test.js +79 -79
  80. package/src/stories/Templates/EventManagement/EditEventInfo/EditEventInfo.stories.js +93 -93
  81. package/src/stories/Templates/EventManagement/EditEventInfo/EditEventInfo.vue +91 -91
  82. package/src/stories/Templates/EventManagement/PoolLive/PoolLive.test.js +121 -121
  83. package/src/stories/Templates/Menus/EditEventsTopMenu/EditEventsTopMenu.stories.js +9 -2
  84. package/src/stories/Templates/Menus/EditEventsTopMenu/EditEventsTopMenu.vue +5 -4
  85. package/src/stories/Templates/PersonManagement/Admin/Administration/Administration.stories.js +81 -81
  86. package/src/stories/Templates/PersonManagement/Admin/Administration/Administration.test.js +39 -39
  87. package/src/stories/Templates/PersonManagement/Admin/Administration/Administration.vue +101 -101
  88. package/src/stories/Templates/PersonManagement/Admin/FencerAdmin/FencerAdmin.stories.js +71 -71
  89. package/src/stories/Templates/PersonManagement/Admin/FencerAdmin/FencerAdmin.vue +86 -86
  90. package/src/stories/Templates/PersonManagement/Admin/MergeAccounts/MergeAccounts.stories.js +86 -86
  91. package/src/stories/Templates/PersonManagement/Admin/MergeAccounts/MergeAccounts.vue +247 -247
  92. package/src/stories/Templates/PersonManagement/Basic/BasicEdit.vue +170 -170
  93. package/src/stories/Templates/PersonManagement/PersonManagement.stories.js +156 -156
  94. package/src/stories/Templates/PersonManagement/PersonManagement.test.js +329 -329
  95. package/src/stories/Templates/PersonManagement/PersonManagement.vue +329 -329
  96. package/src/stories/Templates/PersonManagement/PersonManagementDraft.js +42 -42
  97. package/src/stories/Templates/TournamentManagement/TournamentManagement.stories.js +84 -84
  98. package/src/stories/Templates/TournamentManagement/TournamentManagement.test.js +114 -114
  99. package/src/stories/Templates/TournamentManagement/TournamentManagement.vue +363 -363
  100. package/src/stories/Templates/TournamentManagement/TournamentPageOne/TournamentPageOne.stories.js +116 -116
  101. package/src/stories/Templates/TournamentManagement/TournamentPageOne/TournamentPageOne.vue +307 -307
  102. package/src/stories/Util/Validations/PersonManagementValidations.js +45 -45
  103. package/src/stories/Util/Validations/PriceValidation.js +6 -6
  104. package/src/stories/Util/boutDirectorAssignment.js +46 -0
  105. package/src/stories/Util/bracketDirectors.js +86 -0
  106. package/src/stories/Util/registrationStatus.js +11 -11
  107. package/src/stories/Util/tabs.js +19 -47
@@ -1,86 +1,86 @@
1
- import MergeAccounts from './MergeAccounts.vue';
2
- import personsMock from '../../../../../mocks/personsMock.js';
3
- import peopleMock from '../../../../../mocks/personGetAllMock.js';
4
-
5
- export default {
6
- title: 'Templates/PersonManagement/Admin/MergeAccounts',
7
- component: MergeAccounts,
8
- tags: ['autodocs'],
9
- args: {
10
- person: personsMock[1],
11
- people: peopleMock
12
- },
13
- argTypes: {
14
- person: { control: { type: 'object' } },
15
- people: { control: { type: 'object' } },
16
- 'merge:merge': { action: 'merge:merge' }
17
- }
18
- };
19
-
20
- export const Default = {
21
- args: {
22
- person: personsMock[1],
23
- people: peopleMock
24
- }
25
- };
26
-
27
- export const EmptyResults = {
28
- args: {
29
- person: personsMock[1],
30
- people: []
31
- }
32
- };
33
-
34
- export const MissingRootDetails = {
35
- args: {
36
- person: {
37
- PersonId: 2001,
38
- DisplayName: '',
39
- FirstName: '',
40
- LastName: '',
41
- Club: null,
42
- PersonEmails: []
43
- },
44
- people: peopleMock
45
- }
46
- };
47
-
48
- export const SparsePeopleData = {
49
- args: {
50
- person: personsMock[1],
51
- people: [
52
- {
53
- PersonId: 2002,
54
- DisplayName: 'Missing Email',
55
- FirstName: 'Missing',
56
- LastName: 'Email',
57
- Club: {
58
- Name: 'Columbus United Fencing Club',
59
- ShortName: 'CUFC'
60
- },
61
- PersonEmails: []
62
- },
63
- {
64
- PersonId: 2003,
65
- DisplayName: 'Missing Club',
66
- FirstName: 'Missing',
67
- LastName: 'Club',
68
- Club: null,
69
- PersonEmails: [
70
- {
71
- EmailAddress: 'missing-club@example.com',
72
- IsPrimary: true
73
- }
74
- ]
75
- },
76
- {
77
- PersonId: 2004,
78
- DisplayName: 'No Optional Details',
79
- FirstName: '',
80
- LastName: '',
81
- Club: null,
82
- PersonEmails: []
83
- }
84
- ]
85
- }
86
- };
1
+ import MergeAccounts from './MergeAccounts.vue';
2
+ import personsMock from '../../../../../mocks/personsMock.js';
3
+ import peopleMock from '../../../../../mocks/personGetAllMock.js';
4
+
5
+ export default {
6
+ title: 'Templates/PersonManagement/Admin/MergeAccounts',
7
+ component: MergeAccounts,
8
+ tags: ['autodocs'],
9
+ args: {
10
+ person: personsMock[1],
11
+ people: peopleMock
12
+ },
13
+ argTypes: {
14
+ person: { control: { type: 'object' } },
15
+ people: { control: { type: 'object' } },
16
+ 'merge:merge': { action: 'merge:merge' }
17
+ }
18
+ };
19
+
20
+ export const Default = {
21
+ args: {
22
+ person: personsMock[1],
23
+ people: peopleMock
24
+ }
25
+ };
26
+
27
+ export const EmptyResults = {
28
+ args: {
29
+ person: personsMock[1],
30
+ people: []
31
+ }
32
+ };
33
+
34
+ export const MissingRootDetails = {
35
+ args: {
36
+ person: {
37
+ PersonId: 2001,
38
+ DisplayName: '',
39
+ FirstName: '',
40
+ LastName: '',
41
+ Club: null,
42
+ PersonEmails: []
43
+ },
44
+ people: peopleMock
45
+ }
46
+ };
47
+
48
+ export const SparsePeopleData = {
49
+ args: {
50
+ person: personsMock[1],
51
+ people: [
52
+ {
53
+ PersonId: 2002,
54
+ DisplayName: 'Missing Email',
55
+ FirstName: 'Missing',
56
+ LastName: 'Email',
57
+ Club: {
58
+ Name: 'Columbus United Fencing Club',
59
+ ShortName: 'CUFC'
60
+ },
61
+ PersonEmails: []
62
+ },
63
+ {
64
+ PersonId: 2003,
65
+ DisplayName: 'Missing Club',
66
+ FirstName: 'Missing',
67
+ LastName: 'Club',
68
+ Club: null,
69
+ PersonEmails: [
70
+ {
71
+ EmailAddress: 'missing-club@example.com',
72
+ IsPrimary: true
73
+ }
74
+ ]
75
+ },
76
+ {
77
+ PersonId: 2004,
78
+ DisplayName: 'No Optional Details',
79
+ FirstName: '',
80
+ LastName: '',
81
+ Club: null,
82
+ PersonEmails: []
83
+ }
84
+ ]
85
+ }
86
+ };
@@ -1,247 +1,247 @@
1
- <template>
2
- <section class="w-full">
3
- <div class="flex w-full flex-col gap-6 md:flex-row">
4
- <section class="border border-dropdownSelect rounded-lg p-4 bg-white md:w-1/2">
5
- <BaseText
6
- :text="`Merge into this account: ${person?.DisplayName || 'Root Account'}`"
7
- size="md"
8
- color="primary"
9
- />
10
-
11
- <div class="mt-3 space-y-2">
12
- <div class="text-sm text-quaternary">
13
- <span class="font-semibold text-primary">PersonId:</span> {{ rootPersonId }}
14
- </div>
15
- <div class="text-sm text-quaternary">
16
- <span class="font-semibold text-primary">Legal Name:</span> {{ legalName }}
17
- </div>
18
- <div class="text-sm text-quaternary">
19
- <span class="font-semibold text-primary">Club:</span> {{ clubName }}
20
- </div>
21
- <div class="text-sm text-quaternary">
22
- <span class="font-semibold text-primary">Email:</span> {{ primaryEmail }}
23
- </div>
24
- </div>
25
-
26
- <div class="mt-4 flex h-64 flex-col justify-between">
27
- <div class="min-h-0">
28
- <BaseText text="Accounts to merge in" size="sm" color="quaternary" weight="bold" />
29
- <div class="border-b border-dropdownSelect h-2"></div>
30
- <div v-if="selected.length === 0" class="mt-2 text-sm text-quaternary">None selected yet.</div>
31
- <div v-else class="mt-2 max-h-44 overflow-y-auto border border-dropdownSelect rounded-lg">
32
- <div
33
- v-for="p in selected"
34
- :key="p.PersonId"
35
- class="flex items-center justify-between px-3 py-2 border-b border-dropdownSelect last:border-b-0"
36
- >
37
- <div class="min-w-0">
38
- <div class="text-sm text-primary font-semibold truncate">
39
- {{ p.DisplayName }}
40
- <span class="text-xs text-quaternary font-normal">(#{{ p.PersonId }})</span>
41
- </div>
42
- <div class="text-xs text-quaternary truncate">
43
- {{ p.FirstName }} {{ p.LastName }}
44
- <span v-if="p?.Club?.Name">{{ personClubSuffix(p) }}</span>
45
- </div>
46
- </div>
47
-
48
- <BaseButton
49
- color="warn"
50
- label="Remove"
51
- size="xs"
52
- type="primary"
53
- @buttonClick="removeSelected(p.PersonId)"
54
- />
55
- </div>
56
- </div>
57
- </div>
58
-
59
- <div class="flex justify-end">
60
- <BaseButton
61
- color="warn"
62
- label="Merge Accounts Together"
63
- size="sm"
64
- type="primary"
65
- :disabled="!canMerge"
66
- @buttonClick="emitMergeAccounts"
67
- />
68
- </div>
69
- </div>
70
- </section>
71
-
72
- <section class="border border-dropdownSelect rounded-lg p-4 bg-white md:w-1/2">
73
- <BaseText text="Results" size="md" color="primary" />
74
-
75
- <div class="mt-4">
76
- <TitledInput
77
- title="Filter people"
78
- placeholder="Type name or club..."
79
- :inputValue="filterText"
80
- @update:value="filterText = $event"
81
- />
82
- <div class="text-xs text-quaternary mt-1">Filters Display Name, First/Last Name, or Club Name.</div>
83
- </div>
84
-
85
- <div class="mt-4 flex items-center justify-between text-xs text-quaternary">
86
- <span> Showing {{ filteredPeople.length }}{{ totalMatches > resultLimit ? '+' : '' }} results </span>
87
- <span v-if="totalMatches > resultLimit"> (limited to first {{ resultLimit }}) </span>
88
- </div>
89
-
90
- <div class="mt-2 border border-dropdownSelect rounded-lg h-64 overflow-y-auto">
91
- <div
92
- v-for="p in filteredPeople"
93
- :key="p.PersonId"
94
- class="flex items-center justify-between px-3 py-2 border-b border-dropdownSelect last:border-b-0"
95
- >
96
- <div class="min-w-0">
97
- <div class="text-sm text-primary font-semibold truncate">
98
- <span class="text-xs text-quaternary font-normal">(#{{ p.PersonId }})</span>
99
- {{ resultTitle(p) }}
100
- </div>
101
- <div class="text-xs text-quaternary truncate">
102
- {{ p.FirstName }} {{ p.LastName }}
103
- <span v-if="p?.Club?.Name">{{ personClubSuffix(p) }}</span>
104
- </div>
105
- </div>
106
-
107
- <BaseButton color="neutral" label="Add" size="xs" type="primary" @buttonClick="addSelected(p)" />
108
- </div>
109
-
110
- <div v-if="filteredPeople.length === 0" class="px-3 py-3 text-sm text-quaternary">No matches.</div>
111
- </div>
112
- </section>
113
- </div>
114
- </section>
115
- </template>
116
-
117
- <script>
118
- import BaseText from '../../../../Atoms/Text/BaseText.vue';
119
- import TitledInput from '../../../../Molecules/CombinationInputs/TitledInput/TitledInput.vue';
120
- import BaseButton from '../../../../Molecules/Buttons/BaseButton/BaseButton.vue';
121
-
122
- const getPersonSearchValues = person => {
123
- const searchablePerson = person || {};
124
- const club = searchablePerson.Club || {};
125
- return [
126
- searchablePerson.DisplayName,
127
- searchablePerson.FirstName,
128
- searchablePerson.LastName,
129
- club.Name,
130
- club.ShortName
131
- ];
132
- };
133
-
134
- const normalizeSearchValue = value => String(value || '').toLowerCase();
135
-
136
- const personMatchesQuery = (person, query) =>
137
- getPersonSearchValues(person).some(value => normalizeSearchValue(value).includes(query));
138
-
139
- export default {
140
- name: 'MergeAccounts',
141
- components: { BaseText, TitledInput, BaseButton },
142
- emits: ['merge:merge'],
143
- props: {
144
- person: { type: Object, required: true },
145
- people: { type: Array, required: true }
146
- },
147
- data() {
148
- return {
149
- filterText: '',
150
- selected: [],
151
- resultLimit: 200
152
- };
153
- },
154
- computed: {
155
- rootPersonId() {
156
- return this.person?.PersonId ?? '';
157
- },
158
- legalName() {
159
- const first = this.person?.FirstName || '';
160
- const last = this.person?.LastName || '';
161
- return `${first} ${last}`.trim() || '-';
162
- },
163
- clubName() {
164
- return this.person?.Club?.Name || '-';
165
- },
166
- primaryEmail() {
167
- const emails = this.person?.PersonEmails || [];
168
- const primary = emails.find(email => email.IsPrimary);
169
- return primary?.EmailAddress || '-';
170
- },
171
- selectedIds() {
172
- return new Set(this.selected.map(p => p.PersonId));
173
- },
174
- canMerge() {
175
- return this.selected.length > 0;
176
- },
177
- normalizedFilterText() {
178
- return (this.filterText || '').trim().toLowerCase();
179
- },
180
- candidatePeople() {
181
- return (this.people || []).filter(
182
- p => p && p.PersonId !== this.rootPersonId && !this.selectedIds.has(p.PersonId)
183
- );
184
- },
185
- matchingPeople() {
186
- const q = this.normalizedFilterText;
187
-
188
- if (!q) return this.candidatePeople;
189
-
190
- return this.candidatePeople.filter(p => this.matchesQuery(p, q));
191
- },
192
- totalMatches() {
193
- return this.matchingPeople.length;
194
- },
195
- filteredPeople() {
196
- return this.matchingPeople.slice(0, this.resultLimit);
197
- }
198
- },
199
- watch: {
200
- rootPersonId() {
201
- this.selected = [];
202
- },
203
- people() {
204
- this.removeUnavailableSelectedPeople();
205
- }
206
- },
207
- methods: {
208
- personClubSuffix(p) {
209
- return ` - ${p.Club.Name}`;
210
- },
211
- resultTitle(p) {
212
- const email = this.getPrimaryEmail(p);
213
-
214
- if (!email) return p.DisplayName || '';
215
-
216
- return `${p.DisplayName} - ${email}`;
217
- },
218
- getPrimaryEmail(p) {
219
- const emails = p?.PersonEmails || [];
220
- return emails.find(email => email.IsPrimary)?.EmailAddress || '';
221
- },
222
- matchesQuery(p, q) {
223
- return personMatchesQuery(p, q);
224
- },
225
- removeUnavailableSelectedPeople() {
226
- const availableIds = new Set((this.people || []).map(p => p?.PersonId));
227
- this.selected = this.selected.filter(p => availableIds.has(p.PersonId));
228
- },
229
- addSelected(p) {
230
- if (!p || p.PersonId === this.rootPersonId) return;
231
- if (this.selectedIds.has(p.PersonId)) return;
232
- this.selected = [...this.selected, p];
233
- },
234
- removeSelected(personId) {
235
- this.selected = this.selected.filter(p => p.PersonId !== personId);
236
- },
237
- emitMergeAccounts() {
238
- if (!this.canMerge) return;
239
-
240
- this.$emit('merge:merge', {
241
- rootPersonId: this.rootPersonId,
242
- mergePersonIds: this.selected.map(p => p.PersonId)
243
- });
244
- }
245
- }
246
- };
247
- </script>
1
+ <template>
2
+ <section class="w-full">
3
+ <div class="flex w-full flex-col gap-6 md:flex-row">
4
+ <section class="border border-dropdownSelect rounded-lg p-4 bg-white md:w-1/2">
5
+ <BaseText
6
+ :text="`Merge into this account: ${person?.DisplayName || 'Root Account'}`"
7
+ size="md"
8
+ color="primary"
9
+ />
10
+
11
+ <div class="mt-3 space-y-2">
12
+ <div class="text-sm text-quaternary">
13
+ <span class="font-semibold text-primary">PersonId:</span> {{ rootPersonId }}
14
+ </div>
15
+ <div class="text-sm text-quaternary">
16
+ <span class="font-semibold text-primary">Legal Name:</span> {{ legalName }}
17
+ </div>
18
+ <div class="text-sm text-quaternary">
19
+ <span class="font-semibold text-primary">Club:</span> {{ clubName }}
20
+ </div>
21
+ <div class="text-sm text-quaternary">
22
+ <span class="font-semibold text-primary">Email:</span> {{ primaryEmail }}
23
+ </div>
24
+ </div>
25
+
26
+ <div class="mt-4 flex h-64 flex-col justify-between">
27
+ <div class="min-h-0">
28
+ <BaseText text="Accounts to merge in" size="sm" color="quaternary" weight="bold" />
29
+ <div class="border-b border-dropdownSelect h-2"></div>
30
+ <div v-if="selected.length === 0" class="mt-2 text-sm text-quaternary">None selected yet.</div>
31
+ <div v-else class="mt-2 max-h-44 overflow-y-auto border border-dropdownSelect rounded-lg">
32
+ <div
33
+ v-for="p in selected"
34
+ :key="p.PersonId"
35
+ class="flex items-center justify-between px-3 py-2 border-b border-dropdownSelect last:border-b-0"
36
+ >
37
+ <div class="min-w-0">
38
+ <div class="text-sm text-primary font-semibold truncate">
39
+ {{ p.DisplayName }}
40
+ <span class="text-xs text-quaternary font-normal">(#{{ p.PersonId }})</span>
41
+ </div>
42
+ <div class="text-xs text-quaternary truncate">
43
+ {{ p.FirstName }} {{ p.LastName }}
44
+ <span v-if="p?.Club?.Name">{{ personClubSuffix(p) }}</span>
45
+ </div>
46
+ </div>
47
+
48
+ <BaseButton
49
+ color="warn"
50
+ label="Remove"
51
+ size="xs"
52
+ type="primary"
53
+ @buttonClick="removeSelected(p.PersonId)"
54
+ />
55
+ </div>
56
+ </div>
57
+ </div>
58
+
59
+ <div class="flex justify-end">
60
+ <BaseButton
61
+ color="warn"
62
+ label="Merge Accounts Together"
63
+ size="sm"
64
+ type="primary"
65
+ :disabled="!canMerge"
66
+ @buttonClick="emitMergeAccounts"
67
+ />
68
+ </div>
69
+ </div>
70
+ </section>
71
+
72
+ <section class="border border-dropdownSelect rounded-lg p-4 bg-white md:w-1/2">
73
+ <BaseText text="Results" size="md" color="primary" />
74
+
75
+ <div class="mt-4">
76
+ <TitledInput
77
+ title="Filter people"
78
+ placeholder="Type name or club..."
79
+ :inputValue="filterText"
80
+ @update:value="filterText = $event"
81
+ />
82
+ <div class="text-xs text-quaternary mt-1">Filters Display Name, First/Last Name, or Club Name.</div>
83
+ </div>
84
+
85
+ <div class="mt-4 flex items-center justify-between text-xs text-quaternary">
86
+ <span> Showing {{ filteredPeople.length }}{{ totalMatches > resultLimit ? '+' : '' }} results </span>
87
+ <span v-if="totalMatches > resultLimit"> (limited to first {{ resultLimit }}) </span>
88
+ </div>
89
+
90
+ <div class="mt-2 border border-dropdownSelect rounded-lg h-64 overflow-y-auto">
91
+ <div
92
+ v-for="p in filteredPeople"
93
+ :key="p.PersonId"
94
+ class="flex items-center justify-between px-3 py-2 border-b border-dropdownSelect last:border-b-0"
95
+ >
96
+ <div class="min-w-0">
97
+ <div class="text-sm text-primary font-semibold truncate">
98
+ <span class="text-xs text-quaternary font-normal">(#{{ p.PersonId }})</span>
99
+ {{ resultTitle(p) }}
100
+ </div>
101
+ <div class="text-xs text-quaternary truncate">
102
+ {{ p.FirstName }} {{ p.LastName }}
103
+ <span v-if="p?.Club?.Name">{{ personClubSuffix(p) }}</span>
104
+ </div>
105
+ </div>
106
+
107
+ <BaseButton color="neutral" label="Add" size="xs" type="primary" @buttonClick="addSelected(p)" />
108
+ </div>
109
+
110
+ <div v-if="filteredPeople.length === 0" class="px-3 py-3 text-sm text-quaternary">No matches.</div>
111
+ </div>
112
+ </section>
113
+ </div>
114
+ </section>
115
+ </template>
116
+
117
+ <script>
118
+ import BaseText from '../../../../Atoms/Text/BaseText.vue';
119
+ import TitledInput from '../../../../Molecules/CombinationInputs/TitledInput/TitledInput.vue';
120
+ import BaseButton from '../../../../Molecules/Buttons/BaseButton/BaseButton.vue';
121
+
122
+ const getPersonSearchValues = person => {
123
+ const searchablePerson = person || {};
124
+ const club = searchablePerson.Club || {};
125
+ return [
126
+ searchablePerson.DisplayName,
127
+ searchablePerson.FirstName,
128
+ searchablePerson.LastName,
129
+ club.Name,
130
+ club.ShortName
131
+ ];
132
+ };
133
+
134
+ const normalizeSearchValue = value => String(value || '').toLowerCase();
135
+
136
+ const personMatchesQuery = (person, query) =>
137
+ getPersonSearchValues(person).some(value => normalizeSearchValue(value).includes(query));
138
+
139
+ export default {
140
+ name: 'MergeAccounts',
141
+ components: { BaseText, TitledInput, BaseButton },
142
+ emits: ['merge:merge'],
143
+ props: {
144
+ person: { type: Object, required: true },
145
+ people: { type: Array, required: true }
146
+ },
147
+ data() {
148
+ return {
149
+ filterText: '',
150
+ selected: [],
151
+ resultLimit: 200
152
+ };
153
+ },
154
+ computed: {
155
+ rootPersonId() {
156
+ return this.person?.PersonId ?? '';
157
+ },
158
+ legalName() {
159
+ const first = this.person?.FirstName || '';
160
+ const last = this.person?.LastName || '';
161
+ return `${first} ${last}`.trim() || '-';
162
+ },
163
+ clubName() {
164
+ return this.person?.Club?.Name || '-';
165
+ },
166
+ primaryEmail() {
167
+ const emails = this.person?.PersonEmails || [];
168
+ const primary = emails.find(email => email.IsPrimary);
169
+ return primary?.EmailAddress || '-';
170
+ },
171
+ selectedIds() {
172
+ return new Set(this.selected.map(p => p.PersonId));
173
+ },
174
+ canMerge() {
175
+ return this.selected.length > 0;
176
+ },
177
+ normalizedFilterText() {
178
+ return (this.filterText || '').trim().toLowerCase();
179
+ },
180
+ candidatePeople() {
181
+ return (this.people || []).filter(
182
+ p => p && p.PersonId !== this.rootPersonId && !this.selectedIds.has(p.PersonId)
183
+ );
184
+ },
185
+ matchingPeople() {
186
+ const q = this.normalizedFilterText;
187
+
188
+ if (!q) return this.candidatePeople;
189
+
190
+ return this.candidatePeople.filter(p => this.matchesQuery(p, q));
191
+ },
192
+ totalMatches() {
193
+ return this.matchingPeople.length;
194
+ },
195
+ filteredPeople() {
196
+ return this.matchingPeople.slice(0, this.resultLimit);
197
+ }
198
+ },
199
+ watch: {
200
+ rootPersonId() {
201
+ this.selected = [];
202
+ },
203
+ people() {
204
+ this.removeUnavailableSelectedPeople();
205
+ }
206
+ },
207
+ methods: {
208
+ personClubSuffix(p) {
209
+ return ` - ${p.Club.Name}`;
210
+ },
211
+ resultTitle(p) {
212
+ const email = this.getPrimaryEmail(p);
213
+
214
+ if (!email) return p.DisplayName || '';
215
+
216
+ return `${p.DisplayName} - ${email}`;
217
+ },
218
+ getPrimaryEmail(p) {
219
+ const emails = p?.PersonEmails || [];
220
+ return emails.find(email => email.IsPrimary)?.EmailAddress || '';
221
+ },
222
+ matchesQuery(p, q) {
223
+ return personMatchesQuery(p, q);
224
+ },
225
+ removeUnavailableSelectedPeople() {
226
+ const availableIds = new Set((this.people || []).map(p => p?.PersonId));
227
+ this.selected = this.selected.filter(p => availableIds.has(p.PersonId));
228
+ },
229
+ addSelected(p) {
230
+ if (!p || p.PersonId === this.rootPersonId) return;
231
+ if (this.selectedIds.has(p.PersonId)) return;
232
+ this.selected = [...this.selected, p];
233
+ },
234
+ removeSelected(personId) {
235
+ this.selected = this.selected.filter(p => p.PersonId !== personId);
236
+ },
237
+ emitMergeAccounts() {
238
+ if (!this.canMerge) return;
239
+
240
+ this.$emit('merge:merge', {
241
+ rootPersonId: this.rootPersonId,
242
+ mergePersonIds: this.selected.map(p => p.PersonId)
243
+ });
244
+ }
245
+ }
246
+ };
247
+ </script>