Commit c0132eb9 authored by Evren Kutar's avatar Evren Kutar

handling login submit (fake url)

parent 9dcb244f
<div ng-app="zaerp.login"> <div ng-app="zaerp.login">
<div class="starter-template" ng-controller="LoginCtrl"> <div class="starter-template" ng-controller="LoginCtrl">
<h1>Zaerp Login Form</h1> <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> </div>
<hr/> <hr/>
......
'use strict'; 'use strict';
// TODO: password field fix
angular.module('zaerp.login', ['ngRoute', 'schemaForm']) angular.module('zaerp.login', ['ngRoute', 'schemaForm'])
.config(['$routeProvider', function ($routeProvider) { .config(['$routeProvider', function ($routeProvider) {
...@@ -8,7 +11,7 @@ angular.module('zaerp.login', ['ngRoute', 'schemaForm']) ...@@ -8,7 +11,7 @@ angular.module('zaerp.login', ['ngRoute', 'schemaForm'])
controller: 'LoginCtrl' controller: 'LoginCtrl'
}); });
}]) }])
.controller('LoginCtrl', function ($scope) { .controller('LoginCtrl', function ($scope, $http) {
$scope.schema = $scope.schema =
{ {
title: "Login", title: "Login",
...@@ -16,13 +19,11 @@ angular.module('zaerp.login', ['ngRoute', 'schemaForm']) ...@@ -16,13 +19,11 @@ angular.module('zaerp.login', ['ngRoute', 'schemaForm'])
properties: { properties: {
email: { email: {
type: "string", type: "string",
title: "Email", title: "Email"
pattern: "^[A-Z]"
}, },
pass: { pass: {
type: "string", type: "string",
title: "Password", title: "Password"
pattern: "^[A-Z]"
}, },
remember: { remember: {
type: "boolean", type: "boolean",
...@@ -36,7 +37,7 @@ angular.module('zaerp.login', ['ngRoute', 'schemaForm']) ...@@ -36,7 +37,7 @@ angular.module('zaerp.login', ['ngRoute', 'schemaForm'])
}, },
required: ["email", "pass", "who"] required: ["email", "pass", "who"]
}; };
$scope.fields = ["email", "pass", "who", "remember"]; //$scope.fields = ["email", "pass", "who", "remember"];
$scope.model = { $scope.model = {
email: "user@example.com", email: "user@example.com",
remember: false remember: false
...@@ -48,4 +49,19 @@ angular.module('zaerp.login', ['ngRoute', 'schemaForm']) ...@@ -48,4 +49,19 @@ angular.module('zaerp.login', ['ngRoute', 'schemaForm'])
title: "Save" 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