Commit 02054713 authored by Evren Kutar's avatar Evren Kutar

restructure application phase 3

parent a2f2b34d
app.config(['$routeProvider', function ($routeProvider) {
$routeProvider
.when('/login', {
templateUrl: 'login/login.html',
templateUrl: 'components/login/login.html',
controller: 'LoginCtrl',
resolve: {
loadMyCtrl: ['$ocLazyLoad', function ($ocLazyLoad) {
return $ocLazyLoad.load('login/login.js');
return $ocLazyLoad.load('components/auth/auth_controller.js');
}],
loadMyService: ['$ocLazyLoad', function ($ocLazyLoad) {
return $ocLazyLoad.load('login/login_service.js');
return $ocLazyLoad.load('components/auth/auth_service.js');
}]
}
})
.when('/dashboard', {
templateUrl: 'dashboard/dashboard.html',
templateUrl: 'components/dashboard/dashboard.html',
controller: 'DashCtrl',
resolve: {
loadMyCtrl: ['$ocLazyLoad', function ($ocLazyLoad) {
return $ocLazyLoad.load('dashboard/dashboard.js');
return $ocLazyLoad.load('components/dashboard/dashboard.js');
}]
}
})
.when('/student_add', {
templateUrl: 'student/student_add_template.html',
templateUrl: 'components/student/student_add_template.html',
controller: 'StudentAddCtrl',
resolve: {
loadMyCtrl: ['$ocLazyLoad', function ($ocLazyLoad) {
return $ocLazyLoad.load('student/student_add.js');
return $ocLazyLoad.load('components/student/student_add.js');
}],
loadMyService: ['$ocLazyLoad', function ($ocLazyLoad) {
return $ocLazyLoad.load('forms/form_service.js');
return $ocLazyLoad.load('zetalib/forms/form_service.js');
}]
}
})
......
......@@ -11,8 +11,8 @@
// TODO: password hash or not??
// TODO: who field can be removed??
var login = angular.module('zaerp.login', ['ngRoute', 'schemaForm', 'ngCookies']);
login.controller('LoginCtrl', function ($scope, $q, $timeout, LoginService) {
var auth = angular.module('zaerp.auth', ['ngRoute', 'schemaForm', 'ngCookies']);
auth.controller('LoginCtrl', function ($scope, $q, $timeout, LoginService) {
$scope.schema =
{
title: "Login",
......
/**
* Created by Evren Kutar on 18/05/15.
*/
angular.module('zaerp.login.directives', [])
/**
* Simple directive to check password equality
*
* usage:
* <input type="password" ng-model="password" password-match="password2">
* <input type="password" ng-model="password2">
*/
.directive('passwordMatch', function () {
return {
restrict: 'A',
scope: false,
require: 'ngModel',
link: function (scope, elem, attrs, controller) {
var checker = function () {
// get the value of the first password
var pwd = scope.$eval(attrs.ngModel);
// get the value of the other password
var pwd2 = scope.$eval(attrs.passwordMatch);
return pwd === pwd2;
};
scope.$watch(checker, function (pwdMatch) {
controller.$setValidity('match', pwdMatch);
});
}
};
})
/**
* Directive to manage valid/invalid states of remote-validated Data.
* It stores an internal array of values declared invalid by the server.
* Generates the form error specified in case the user re-types the same invalid values,
* clears the errors in case the user changes the ngModel.
*
* usage:
* <input type="email" ng-model="email" remote-validated="used">
*
* NOTE: Your controllers have to make the field invalid in case *your* server says so.
*/
.directive('remoteValidated', function () {
return {
restrict: 'A',
scope: false,
require: 'ngModel',
link: function (scope, elem, attrs, controller) {
var invalidItems = [];
scope.$watch(attrs.ngModel, function (newValue, oldValue) {
if (newValue) {
// Check the array of already-bad items
if (invalidItems.indexOf(newValue) !== -1) {
return controller.$setValidity(attrs.remoteValidated, false);
}
// When the model changes, it checks if the previous value was
// triggering the error from server-side
if (controller.$error[attrs.remoteValidated]) {
invalidItems.push(oldValue);
}
controller.$setValidity(attrs.remoteValidated, true);
}
});
}
};
});
<div ng-app="zaerp.test">
<div class="starter-template">
<h1>Add Student</h1>
<div>{{ form }}</div>
</div>
</div>
\ No newline at end of file
'use strict';
var testform = angular.module('zaerp.', ['ngRoute', 'schemaForm', 'formGenerator']);
testform.controller('RecordCtrl', function($scope, $http, $timeout, $log, Generator, RESTURL){
$scope.form = Generator.generate('add_student', '');
$log.info($scope.form);
$http.get(RESTURL.url + 'add_student').then(function(res){
$log.info(res.data);
});
});
\ 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