Commit 9afb4586 authored by Evren Kutar's avatar Evren Kutar

new link on index page & bower.json edit

parent 712c7ddf
...@@ -23,7 +23,7 @@ app.config(['$routeProvider', function ($routeProvider) { ...@@ -23,7 +23,7 @@ app.config(['$routeProvider', function ($routeProvider) {
}) })
.when('/student_add', { .when('/student_add', {
templateUrl: 'components/student/student_add_template.html', templateUrl: 'components/student/student_add_template.html',
controller: 'StudentAddCtrl', controller: 'StudentAddEditCtrl',
resolve: { resolve: {
loadMyCtrl: ['$ocLazyLoad', function ($ocLazyLoad) { loadMyCtrl: ['$ocLazyLoad', function ($ocLazyLoad) {
return $ocLazyLoad.load('components/student/student_controller.js'); return $ocLazyLoad.load('components/student/student_controller.js');
......
...@@ -18,11 +18,15 @@ var student = angular.module('zaerp.student.add', ['ngRoute', 'schemaForm', 'for ...@@ -18,11 +18,15 @@ var student = angular.module('zaerp.student.add', ['ngRoute', 'schemaForm', 'for
* to add student, provide form with form generator * to add student, provide form with form generator
*/ */
student.controller('StudentAddCtrl', function($scope, $http, $log, Generator, $routeParams){ student.controller('StudentAddEditCtrl', function($scope, $http, $log, Generator, $routeParams){
Generator.get_form('add_student', $routeParams).then(function(d){ Generator.get_form('add_student', $routeParams).then(function(d){
$scope.schema = d.schema; $scope.schema = d.schema;
$scope.form = d.form; $scope.form = d.form;
// model is the init data of the form or in edit templates
$scope.model = {};
// for email validation add asyncvalidator
$scope.form[0].$asyncValidators = Generator.asyncValidators; $scope.form[0].$asyncValidators = Generator.asyncValidators;
// add submit button to the form todo: move this to form service
$scope.form.push( $scope.form.push(
{ {
type: "submit", type: "submit",
...@@ -33,10 +37,8 @@ student.controller('StudentAddCtrl', function($scope, $http, $log, Generator, $r ...@@ -33,10 +37,8 @@ student.controller('StudentAddCtrl', function($scope, $http, $log, Generator, $r
$scope.onSubmit = function (form) { $scope.onSubmit = function (form) {
$scope.$broadcast('schemaFormValidate'); $scope.$broadcast('schemaFormValidate');
if (form.$valid) { if (form.$valid) {
$log.info(form); // todo: implement form diff here
} $log.info($scope);
else {
$log.info("not valid");
} }
} }
}); });
\ No newline at end of file
...@@ -51,7 +51,7 @@ ...@@ -51,7 +51,7 @@
<div class="col-sm-3 col-md-2 sidebar"> <div class="col-sm-3 col-md-2 sidebar">
<ul class="nav nav-sidebar"> <ul class="nav nav-sidebar">
<li class="active"><a href="#">Overview <span class="sr-only">(current)</span></a></li> <li class="active"><a href="#">Overview <span class="sr-only">(current)</span></a></li>
<li><a href="#">Reports</a></li> <li><a href="#/student_add">New Student</a></li>
<li><a href="#">Analytics</a></li> <li><a href="#">Analytics</a></li>
<li><a href="#">Export</a></li> <li><a href="#">Export</a></li>
</ul> </ul>
......
...@@ -53,5 +53,12 @@ form_generator.factory('Generator', function ($http, $q, $timeout, RESTURL) { ...@@ -53,5 +53,12 @@ form_generator.factory('Generator', function ($http, $q, $timeout, RESTURL) {
return deferred.promise; return deferred.promise;
} }
}; };
generator.submit = function (form, $scope, $log) {
$scope.$broadcast('schemaFormValidate');
if (form.$valid) {
// todo: implement form diff here
$log.info($scope.model);
}
};
return generator; return generator;
}); });
\ No newline at end of file
{ {
"name": "angular-seed", "name": "zaerp-ui",
"description": "A starter project for AngularJS", "description": "UI project for ZAERP",
"version": "0.0.0", "version": "0.0.1",
"homepage": "https://github.com/angular/angular-seed", "homepage": "https://github.com/zetaops/zaerp-ui",
"license": "MIT", "license": "GPL",
"private": true, "private": false,
"dependencies": { "dependencies": {
"angular": "1.4.x", "angular": "1.4.x",
"angular-mocks": "1.4.x", "angular-mocks": "1.4.x",
......
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