|
26 | 26 | ref: ShowMore,
|
27 | 27 | props: {
|
28 | 28 | group,
|
29 |
| - handleSave, |
| 29 | + handleApply, |
30 | 30 | handleCancel
|
31 | 31 | }
|
32 | 32 | }
|
|
45 | 45 |
|
46 | 46 | const modalStore = getModalStore();
|
47 | 47 |
|
48 |
| - const handleSave = (group: SelectedFacetGroup) => { |
| 48 | + const handleApply = (group: SelectedFacetGroup) => { |
49 | 49 | const { name: groupName, children } = group;
|
50 | 50 |
|
51 | 51 | dispatch('showMoreOpenChange', {
|
|
110 | 110 | changed.length && dispatch('facetSelect', changed);
|
111 | 111 | };
|
112 | 112 |
|
113 |
| - // Keeping the sorting function, but stays unused for now |
114 | 113 | const sortOptions = () => {
|
115 |
| - // Sort facets in a descending order if count exits, or sort alphabetically |
| 114 | + // Sort facets in a descending order if count exits |
116 | 115 | Object.keys(selected).forEach((group) => {
|
117 | 116 | const checked = Object.keys(selected[group].children)
|
118 | 117 | .filter((item) => selected[group].children[item].selected)
|
|
121 | 120 | if (a.count != undefined && b.count != undefined) {
|
122 | 121 | return b.count - a.count;
|
123 | 122 | }
|
124 |
| - return a.displayName.localeCompare(b.displayName); |
| 123 | + return 0; |
125 | 124 | })
|
126 | 125 | .map((item) => item.name);
|
127 | 126 |
|
128 |
| - const unchecked = Object.keys(selected[group].children).filter( |
129 |
| - (item) => !checked.includes(item) |
130 |
| - ); |
| 127 | + const unchecked = Object.keys(selected[group].children) |
| 128 | + .filter((item) => !checked.includes(item)) |
| 129 | + .map((item) => selected[group].children[item]) |
| 130 | + .sort((a, b) => { |
| 131 | + if (a.count != undefined && b.count != undefined) { |
| 132 | + return b.count - a.count; |
| 133 | + } |
| 134 | + return 0; |
| 135 | + }) |
| 136 | + .map((item) => item.name); |
131 | 137 |
|
132 | 138 | const groupIndex = displayedGroups.findIndex((g) => g.name === group);
|
133 | 139 |
|
|
172 | 178 | });
|
173 | 179 |
|
174 | 180 | $: displayedGroups = structuredClone($groups);
|
175 |
| - $: selectedItems, mapSelected('items'); // sortOptions(); // Sorting is not used for now |
| 181 | + $: selectedItems, mapSelected('items'), sortOptions(); |
176 | 182 | $: selectedGroups, mapSelected('groups');
|
177 | 183 | </script>
|
178 | 184 |
|
|
186 | 192 | bind:checked={selectedGroups[group.name]}
|
187 | 193 | bind:group={selectedGroups}
|
188 | 194 | >
|
189 |
| - <p class="font-semibold"> |
| 195 | + <p class="font-semibold whitespace-nowrap"> |
190 | 196 | {group.displayName}{group.count !== undefined ? ` (${group.count})` : ''}
|
191 | 197 | </p>
|
192 | 198 |
|
|
204 | 210 | selection
|
205 | 211 | multiple
|
206 | 212 | >
|
207 |
| - <p>{item.displayName} ({item.count})</p> |
| 213 | + <div class="flex gap-2"> |
| 214 | + <p class="w-max grow truncate"> |
| 215 | + <span title={item.displayName}>{item.displayName}</span> |
| 216 | + </p> |
| 217 | + <span>({item.count})</span> |
| 218 | + </div> |
208 | 219 | </TreeViewItem>
|
209 | 220 | {/each}
|
210 | 221 | <!-- Trigger for the Modal to view all options -->
|
|
226 | 237 | selection
|
227 | 238 | multiple
|
228 | 239 | >
|
229 |
| - <p>{item.displayName} ({item.count})</p> |
| 240 | + <div class="flex gap-2"> |
| 241 | + <p class="w-max grow truncate"> |
| 242 | + <span title={item.displayName}>{item.displayName}</span> |
| 243 | + </p> |
| 244 | + <span>({item.count})</span> |
| 245 | + </div> |
230 | 246 | </TreeViewItem>
|
231 | 247 | {/each}
|
232 | 248 | {/if}
|
|
0 commit comments