gitlab-org--gitlab-foss/app/assets/javascripts/notifications_dropdown.js.coffee
Phil Hughes a4d4a7e635 Fixed issue with notification dropdownn not updating active
Changes bell icon to spinner to show the action is happening
Removed the flash message

Closes #18480
2016-06-21 08:35:11 +01:00

25 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')