Files
gitlabhq/app/assets/javascripts/notifications_dropdown.js.coffee
T
Jacob SchatzandRobert Speicher 605e122952 Merge branch 'notification-dropdown-active-fix' into 'master'
Fixed issue with notification dropdown not updating active

## What does this MR do?

This fixes an issue where the notification dropdown wouldn't correctly update the selected notification type in the dropdown. I've also added a spinner to show the action is happening & removed the flash message for success.

## What are the relevant issue numbers?

Closes #18480 

## Screenshots (if relevant)

![notifications](/uploads/5ed5055d180c12450cea77543ae5f44e/notifications.gif)

See merge request !4615
2016-06-21 11:52:06 -04:00

26 lines
958 B
CoffeeScript

class @NotificationsDropdown
constructor: ->
$(document)
.off 'click', '.update-notification'
.on 'click', '.update-notification', (e) ->
e.preventDefault()
return if $(this).is('.is-active') and $(this).data('notification-level') is 'custom'
notificationLevel = $(@).data 'notification-level'
label = $(@).data 'notification-title'
form = $(this).parents('.notification-form:first')
form.find('.js-notification-loading').toggleClass 'fa-bell fa-spin fa-spinner'
form.find('#notification_setting_level').val(notificationLevel)
form.submit()
$(document)
.off 'ajax:success', '.notification-form'
.on 'ajax:success', '.notification-form', (e, data) ->
if data.saved
$(e.currentTarget)
.closest('.notification-dropdown')
.replaceWith(data.html)
else
new Flash('Failed to save new settings', 'alert')