# @cjsx React.DOM
$ = require('jquery')
React = require('react/addons')
Modal = require('react-bootstrap/lib/Modal')
Button = require('react-bootstrap/lib/Button')
module.exports = React.createClass
mixins: [React.addons.LinkedStateMixin]
displayName: 'EditTag'
getInitialState: ()->
updating: false
name: @props.tag.get('name')
errors: false
shaking: false
onChangeName: (event)->
@setState name: event.target.value
onClickOk: (event)->
event.preventDefault()
@setState updating: true
attributes = {new_name: @state.name}
@props.tag.save attributes,
success: ()=>
@props.tag.set 'name', @state.name
@props.onRequestHide()
error: (model, response, options)=>
@setState errors: response.responseJSON.tag.errors
@setState updating: false
@setState shaking: true
setTimeout (=> @setState shaking: false), 300
render: ->