Commit c0132eb9 authored by Evren Kutar's avatar Evren Kutar

handling login submit (fake url)

parent 9dcb244f
<div ng-app="zaerp.login">
<div class="starter-template" ng-controller="LoginCtrl">
<h1>Zaerp Login Form</h1>
<form sf-schema="schema" sf-form="form" sf-model="model"></form>
<form name="loginForm" sf-schema="schema" sf-form="form" sf-model="model" ng-submit="onSubmit(loginForm)"></form>
</div>
<hr/>
......
'use strict';
// TODO: password field fix
angular.module('zaerp.login', ['ngRoute', 'schemaForm'])
.config(['$routeProvider', function ($routeProvider) {
......@@ -8,7 +11,7 @@ angular.module('zaerp.login', ['ngRoute', 'schemaForm'])
controller: 'LoginCtrl'
});
}])
.controller('LoginCtrl', function ($scope) {
.controller('LoginCtrl', function ($scope, $http) {
$scope.schema =
{
title: "Login",
......@@ -16,13 +19,11 @@ angular.module('zaerp.login', ['ngRoute', 'schemaForm'])
properties: {
email: {
type: "string",
title: "Email",
pattern: "^[A-Z]"
title: "Email"
},
pass: {
type: "string",
title: "Password",
pattern: "^[A-Z]"
title: "Password"
},
remember: {
type: "boolean",
......@@ -36,7 +37,7 @@ angular.module('zaerp.login', ['ngRoute', 'schemaForm'])
},
required: ["email", "pass", "who"]
};
$scope.fields = ["email", "pass", "who", "remember"];
//$scope.fields = ["email", "pass", "who", "remember"];
$scope.model = {
email: "user@example.com",
remember: false
......@@ -48,4 +49,19 @@ angular.module('zaerp.login', ['ngRoute', 'schemaForm'])
title: "Save"
}
];
$scope.onSubmit = function(form){
$scope.$broadcast('schemaFormValidate');
if (form.$valid){
$http.post('http://127.0.0.1:8000/login', form).
success(function(data, status, headers, config){
console.log(data);
}).
error(function(data, status, headers, config){
console.log("form submit failed: "+status);
});
}
else {
console.log("not valid");
}
}
});
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment