2014-11-28 20:49:41 -05:00
|
|
|
RootView = require 'views/core/RootView'
|
2014-01-03 13:32:13 -05:00
|
|
|
template = require 'templates/cla'
|
2014-11-28 20:49:41 -05:00
|
|
|
{me} = require 'core/auth'
|
2014-01-03 13:32:13 -05:00
|
|
|
|
2014-07-17 20:16:32 -04:00
|
|
|
module.exports = class CLAView extends RootView
|
2014-06-30 22:16:26 -04:00
|
|
|
id: 'cla-view'
|
2014-01-03 13:32:13 -05:00
|
|
|
template: template
|
2014-01-04 18:49:13 -05:00
|
|
|
|
2014-01-03 13:32:13 -05:00
|
|
|
events:
|
|
|
|
'click #agreement-button': 'onAgree'
|
2014-01-04 18:49:13 -05:00
|
|
|
|
2014-01-03 13:32:13 -05:00
|
|
|
getRenderData: ->
|
|
|
|
c = super()
|
|
|
|
c.signedOn = moment(me.get('signedCLA')).format('LLLL') if me.get('signedCLA')
|
|
|
|
c
|
2014-01-04 18:49:13 -05:00
|
|
|
|
2014-01-03 13:32:13 -05:00
|
|
|
onAgree: ->
|
2014-01-04 18:49:13 -05:00
|
|
|
@$el.find('#agreement-button').prop('disabled', true).text('Saving')
|
2014-01-03 13:32:13 -05:00
|
|
|
$.ajax({
|
2014-06-30 22:16:26 -04:00
|
|
|
url: '/db/user/me/agreeToCLA'
|
|
|
|
data: {'githubUsername': @$el.find('#github-username').val()}
|
2014-01-03 13:32:13 -05:00
|
|
|
method: 'POST'
|
|
|
|
success: @onAgreeSucceeded
|
|
|
|
error: @onAgreeFailed
|
|
|
|
})
|
2014-01-04 18:49:13 -05:00
|
|
|
|
2014-01-03 13:32:13 -05:00
|
|
|
onAgreeSucceeded: =>
|
|
|
|
@$el.find('#agreement-button').text('Success')
|
|
|
|
|
|
|
|
onAgreeFailed: =>
|
2014-01-04 18:49:13 -05:00
|
|
|
@$el.find('#agreement-button').text('Failed')
|