Created
December 21, 2010 00:17
-
-
Save sprite2005/749280 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class LoginFormComponent < Netzke::Base | |
js_base_class "Ext.form.FormPanel" | |
def configuration | |
super.merge({ | |
:items => [{ | |
:xtype => :fieldset, | |
:title => 'Login Form', | |
:items => [ | |
{ | |
:xtype => :emailfield, | |
:name => :email, | |
:label => 'Email' | |
}, | |
{ | |
:xtype => :passwordfield, | |
:name => :password, | |
:label => 'Password' | |
}] | |
}, | |
{ | |
:xtype => :button, | |
:text => 'Login', | |
:handler => :do_login, | |
} | |
] | |
}) | |
end | |
js_method :do_login, <<-JS | |
function() | |
{ | |
Ext.Ajax.request({ | |
url: '/users/sign_in', | |
method: 'post', | |
params: { email: this.getValues().email, password : this.getValues().password }, | |
failure : function(response){ | |
data = Ext.decode(response.responseText); | |
Ext.Msg.alert('Login Error', data.errorMessage, Ext.emptyFn); | |
}, | |
success: function(response, opts) { | |
data = Ext.decode(response.responseText); | |
if (data.errors != null) | |
{ | |
Ext.Msg.alert('Login Error', data.errors.reason, Ext.emptyFn); | |
} else { | |
Ext.Msg.alert('Login Ok', "Ok", Ext.emptyFn); | |
} | |
} | |
}); | |
} | |
JS | |
endpoint :new_user_session do |params| | |
logger.info "Called new user session" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment