travis-web/app/components/settings-switch.coffee
2015-07-21 17:24:18 +02:00

22 lines
558 B
CoffeeScript

`import Ember from 'ember'`
SettingsSwitchComponent = Ember.Component.extend
tagName: 'a'
classNames: ['switch']
classNameBindings: ['active']
click: ->
return if @get('isSaving')
@set('isSaving', true)
@toggleProperty('active')
setting = {}
setting[@get('key')] = @get('active')
@get('repo').saveSettings(setting).then =>
@set('isSaving', false)
, =>
@set('isSaving', false)
Travis.flash(error: 'There was an error while saving settings. Please try again.')
`export default SettingsSwitchComponent`