|
83 | 83 | </tr>
|
84 | 84 | </thead>
|
85 | 85 | <tbody>
|
86 |
| - <tr v-for="address in filteredAndSortedAddresses" :key="address.id"> |
| 86 | + <tr |
| 87 | + v-for="address in filteredAndSortedAddresses" |
| 88 | + :key="address.id + address.lat + address.lon" |
| 89 | + > |
87 | 90 | <td
|
88 | 91 | :style="{
|
89 | 92 | background:
|
@@ -203,41 +206,43 @@ function sortBy(key: SortKey) {
|
203 | 206 |
|
204 | 207 | // Filter and sort addresses based on the search query and selected sort column
|
205 | 208 | const filteredAndSortedAddresses = computed(() => {
|
206 |
| - return ( |
207 |
| - [...addressStore.addresses] |
208 |
| - // filter by category |
209 |
| - .filter((address) => { |
210 |
| - if (selectedIsophoneFilterIndex.value === 'all') { |
211 |
| - return true |
212 |
| - } |
213 |
| -
|
214 |
| - return ( |
215 |
| - address.isophoneLevelDay === selectedIsophoneFilterIndex.value.day || |
216 |
| - address.isophoneLevelNight === selectedIsophoneFilterIndex.value.night |
217 |
| - ) |
218 |
| - }) |
219 |
| - // filter by test input |
220 |
| - .filter((address) => { |
221 |
| - const searchLower = searchQuery.value.toLowerCase() |
222 |
| - return ( |
223 |
| - [address.street, address.housenumber, address.postcode, address.city] |
224 |
| - .join(' ') |
225 |
| - .toLowerCase() |
226 |
| - .includes(searchLower) || |
227 |
| - address.postcode?.toString().includes(searchLower) || |
228 |
| - address.street?.toLowerCase().includes(searchLower) || |
229 |
| - address.city?.toLowerCase().includes(searchLower) |
230 |
| - ) |
231 |
| - }) |
232 |
| - .sort((a, b) => { |
233 |
| - const aValue = a[sortKey.value] || '' |
234 |
| - const bValue = b[sortKey.value] || '' |
235 |
| -
|
236 |
| - if (aValue < bValue) return sortDirection.value === 'asc' ? -1 : 1 |
237 |
| - if (aValue > bValue) return sortDirection.value === 'asc' ? 1 : -1 |
238 |
| - return 0 |
239 |
| - }) |
240 |
| - ) |
| 209 | + const filteredAndSortedResult = [...addressStore.addresses] |
| 210 | + // filter by category |
| 211 | + .filter((address) => { |
| 212 | + if (selectedIsophoneFilterIndex.value === 'all') { |
| 213 | + return true |
| 214 | + } |
| 215 | +
|
| 216 | + return ( |
| 217 | + address.isophoneLevelDay === selectedIsophoneFilterIndex.value.day || |
| 218 | + address.isophoneLevelNight === selectedIsophoneFilterIndex.value.night |
| 219 | + ) |
| 220 | + }) |
| 221 | + // filter by test input |
| 222 | + /*.filter((address) => { |
| 223 | + const searchLower = searchQuery.value.toLowerCase() |
| 224 | + return ( |
| 225 | + [address.street, address.housenumber, address.postcode, address.city] |
| 226 | + .join(' ') |
| 227 | + .toLowerCase() |
| 228 | + .includes(searchLower) || |
| 229 | + address.postcode?.toString().includes(searchLower) || |
| 230 | + address.street?.toLowerCase().includes(searchLower) || |
| 231 | + address.city?.toLowerCase().includes(searchLower) |
| 232 | + ) |
| 233 | + }) |
| 234 | + .sort((a, b) => { |
| 235 | + const aValue = a[sortKey.value] || '' |
| 236 | + const bValue = b[sortKey.value] || '' |
| 237 | +
|
| 238 | + if (aValue < bValue) return sortDirection.value === 'asc' ? -1 : 1 |
| 239 | + if (aValue > bValue) return sortDirection.value === 'asc' ? 1 : -1 |
| 240 | + return 0 |
| 241 | + }) |
| 242 | +)*/ |
| 243 | +
|
| 244 | + console.log(filteredAndSortedResult) |
| 245 | + return filteredAndSortedResult |
241 | 246 | })
|
242 | 247 |
|
243 | 248 | function informPeople() {
|
|
0 commit comments