Skip to content

Commit

Permalink
[#2379] Cleaned up notification code + improved login form
Browse files Browse the repository at this point in the history
  • Loading branch information
jiromaykin committed Jul 8, 2024
1 parent 7ec3285 commit 7e2d154
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions src/open_inwoner/js/components/notifications/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,24 +100,28 @@ export class Notification {
*/
reorderNotifications() {
// Select the parent container, in order to re-index its children
// for both Notifications.html as well as for Error.html
const notificationsContainer = document.querySelector('.notifications')
const notifications = Array.from(
// Get first matching element in the document
notificationsContainer.querySelectorAll(Notification.selector)
)

// Re-indexing the NodeList: Sort children/notifications (siblings) based on type order
notifications.sort((a, b) => {
const typeA = getTypeOrderIndex(a)
const typeB = getTypeOrderIndex(b)
return typeA - typeB
})
if (notificationsContainer) {
const notifications = Array.from(
// Get first matching element in the document
notificationsContainer.querySelectorAll(Notification.selector)
)

// Re-indexing the NodeList: Sort notifications (children/siblings) based on type order
notifications.sort((a, b) => {
const typeA = getTypeOrderIndex(a)
const typeB = getTypeOrderIndex(b)
return typeA - typeB
})

// Re-append sorted notifications to parent container
notifications.forEach((notification) =>
notificationsContainer.appendChild(notification)
)
// Re-append sorted notifications to parent container
notifications.forEach((notification) =>
notificationsContainer.appendChild(notification)
)
} else {
return
}
}
}

Expand Down

0 comments on commit 7e2d154

Please sign in to comment.