Commit bae33140 authored by Evren Kutar's avatar Evren Kutar

implement student functions for staff,

add routes,
change fake api server
parent ca6e98f8
......@@ -21,7 +21,7 @@ app.config(['$routeProvider', function ($routeProvider) {
}]
}
})
.when('/s/add', {
.when('/student/add', {
templateUrl: 'components/student/student_add_template.html',
controller: 'StudentAddEditCtrl',
resolve: {
......@@ -36,7 +36,7 @@ app.config(['$routeProvider', function ($routeProvider) {
}]
}
})
.when('/s/edit/:id', {
.when('/student/edit/:id', {
templateUrl: 'components/student/student_add_template.html',
controller: 'StudentAddEditCtrl',
resolve: {
......@@ -66,25 +66,49 @@ app.config(['$routeProvider', function ($routeProvider) {
}]
}
})
.when('/staff/add', {
templateUrl: 'components/staff/staff_add_template.html',
controller: 'StaffCtrl',
resolve: {
loadMyCtrl: ['$ocLazyLoad', function ($ocLazyLoad) {
return $ocLazyLoad.load('components/staff/staff_controller.js');
}],
loadMyService: ['$ocLazyLoad', function ($ocLazyLoad) {
return $ocLazyLoad.load('zetalib/forms/form_service.js');
}]
}
})
.when('/input_types', {
templateUrl: 'components/types/types_template.html',
controller: 'TypeCtrl',
resolve: {
loadMyCtrl: ['$ocLazyLoad', function ($ocLazyLoad) {
return $ocLazyLoad.load('components/types/types_controller.js');
}],
loadMyService: ['$ocLazyLoad', function ($ocLazyLoad) {
return $ocLazyLoad.load('zetalib/forms/form_service.js');
}]
}
})
.otherwise({redirectTo: '/dashboard'});
}]).run(function ($rootScope, $location, $cookies) {
/**
* todo: below session id is temporary session_id
* the login logic will be finished when backend complete
*
*/
/**
* todo: below session id is temporary session_id
* the login logic will be finished when backend complete
*
*/
var sessionId = $cookies.get('session');
$rootScope.loggedInUser = sessionId ? true : false;
$rootScope.$on("$routeChangeStart", function (event, next, current) {
if ($rootScope.loggedInUser == null) {
// no logged user, redirect to /login
if (next.templateUrl === "login/login.html") {
console.log("test log to login");
} else {
console.log("test log logged");
$location.path("/login");
}
var sessionId = $cookies.get('session');
$rootScope.loggedInUser = sessionId ? true : false;
$rootScope.$on("$routeChangeStart", function (event, next, current) {
if ($rootScope.loggedInUser == null) {
// no logged user, redirect to /login
if (next.templateUrl === "login/login.html") {
console.log("test log to login");
} else {
console.log("test log logged");
$location.path("/login");
}
});
});
\ No newline at end of file
}
});
});
\ No newline at end of file
<div ng-app="zaerp.staff.add">
<div class="col-md-6">
<h1>{{ schema.title }}</h1>
<form name="formgenerated" sf-schema="schema" sf-form="form" sf-model="model" ng-submit="onSubmit(formgenerated)"></form>
</div>
</div>
\ No newline at end of file
/**
* Created by erkanderon on 18.06.2015.
*/
'use strict';
var staff = angular.module('zaerp.staff.add',['ngRoute','schemaForm', 'formService']);
/* StaffCtrl is a controller
which provide a form with form generator.
*/
staff.controller('StaffCtrl', function($scope, $http, $log, Generator, $routeParams){
Generator.get_form('add_staff', $routeParams).then(function(d){
$scope.schema = d.schema;
$scope.form = d.form;
$scope.model = d.model ? d.model : {};
$scope.form[0].$asyncValidators = Generator.asyncValidators;
$scope.form.push(
{
type: "submit",
title: "Save"
}
);
});
$scope.onSubmit = function(form){
$scope.$broadcast('schemaFormValidate');
if (form.$valid) {
// todo: implement form diff here
$log.info($scope);
}
}
});
\ No newline at end of file
/**
* Created by erkanderon on 19.06.2015.
*/
'use strict';
var staff = angular.module('zaerp.types',['ngRoute','schemaForm', 'formService']);
staff.controller('TypeCtrl', function($scope, $http, $log, Generator, $routeParams){
Generator.get_form('input_types', $routeParams).then(function(d){
$scope.congressFilter = "Choice";
$scope.schema = d.schema;
$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;
// add submit button to the form todo: move this to form service
$scope.form.push(
{
type: "submit",
title: "Save"
}
);
});
$scope.onSubmit = function (form) {
$scope.$broadcast('schemaFormValidate');
if (form.$valid) {
// todo: implement form diff here
$log.info($scope);
}
}
});
\ No newline at end of file
<div ng-app="zaerp.types">
<div class="col-md-6">
<h1>{{ schema.title }}</h1>
<form name="formgenerated" sf-schema="schema" sf-form="form" sf-model="model" ng-submit="onSubmit(formgenerated)"></form>
</div>
</div>
\ No newline at end of file
......@@ -51,21 +51,9 @@
<div class="col-sm-3 col-md-2 sidebar">
<ul class="nav nav-sidebar">
<li class="active"><a href="#">Overview <span class="sr-only">(current)</span></a></li>
<li><a href="#/student_add">New Student</a></li>
<li><a href="#">Analytics</a></li>
<li><a href="#">Export</a></li>
</ul>
<ul class="nav nav-sidebar">
<li><a href="">Nav item</a></li>
<li><a href="">Nav item again</a></li>
<li><a href="">One more nav</a></li>
<li><a href="">Another nav item</a></li>
<li><a href="">More navigation</a></li>
</ul>
<ul class="nav nav-sidebar">
<li><a href="">Nav item again</a></li>
<li><a href="">One more nav</a></li>
<li><a href="">Another nav item</a></li>
<li><a href="#/student/add">New Student</a></li>
<li><a href="#/staff/add">New Staff</a></li>
<li><a href="#/input_types">Types</a></li>
</ul>
</div>
......
......@@ -43,48 +43,183 @@ var form = new fake.Resource("add_student")
}
});
var form2 = new fake.Resource("add_staff")
.add({
schema: {
title: "Add Staff",
type: "object",
properties: {
name: {
type: "string",
title: "Name"
},
email: {
type: "email",
title: "Email"
}
},
required: ["email", "name"]
},
form: [
{
key: "email",
type: "email",
validationMessages: {
'emailNotValid': 'Email is not valid!'
}
},
"name"
]
});
var student = new fake.Resource("list_student")
.add({'deleted': false,
.add({
'deleted': false,
'archived': false,
'auth_info': {'email': 'suuper@suup.com',
'auth_info': {
'email': 'suuper@suup.com',
'password': '123',
'username': 'foo_user'},
'username': 'foo_user'
},
'bio': 'Lorem impsum dolar sit amet falan filan',
'join_date': '2015-05-16T00:00:00Z',
'lectures': [{'attendance': [{'attended': false,
'date': '2015-05-09T00:00:00Z',
'hour': 2},
{'attended': true,
'date': '2015-05-10T00:00:00Z',
'hour': 4}],
'lectures': [{
'attendance': [{
'attended': false,
'date': '2015-05-09T00:00:00Z',
'hour': 2
},
{
'attended': true,
'date': '2015-05-10T00:00:00Z',
'hour': 4
}],
'code': 'math101',
'credit': 4,
'exams': [
{'date': '2015-05-11T00:00:00Z', 'point': 65,
'type': 'Q'}],
{
'date': '2015-05-11T00:00:00Z', 'point': 65,
'type': 'Q'
}],
'name': 'Introduction to Math',
'node_in_list_node': {'foo': 'FOOOO'}},
{'attendance': [{'attended': false,
'date': '2015-05-13T00:00:00Z',
'hour': 2},
{'attended': true,
'date': '2015-05-14T00:00:00Z',
'hour': 4}],
'node_in_list_node': {'foo': 'FOOOO'}
},
{
'attendance': [{
'attended': false,
'date': '2015-05-13T00:00:00Z',
'hour': 2
},
{
'attended': true,
'date': '2015-05-14T00:00:00Z',
'hour': 4
}],
'code': 'rock101',
'credit': 10,
'exams': [
{'date': '2015-05-15T00:00:00Z', 'point': 65,
'type': 'Q'}],
{
'date': '2015-05-15T00:00:00Z', 'point': 65,
'type': 'Q'
}],
'name': 'Introduction to Rocking',
'node_in_list_node': {'foo': 'FOOOO'}}],
'node_in_list_node': {'foo': 'FOOOO'}
}],
'name': 'Jack',
'number': '20300344',
'pno': '2343243433',
'surname': 'Black',
'timestamp': null});
'timestamp': null
});
var types = new fake.Resource("input_types")
.add({
schema: {
title: "Input Types",
type: "object",
properties: {
name: {
type: "string",
title: "Name"
},
email: {
type: "email",
title: "Email"
}
},
required: ["email", "name", "select"]
},
form: [
{
key: "email",
type: "email",
validationMessages: {
'emailNotValid': 'Email is not valid!'
}
},
{
key: "comment",
type: "textarea",
placeholder: "Make a Comment"
},
{
type: "submit",
title: "OK"
},
{
type: "select",
titleMap: [
{value: "yes", name: "Choice 1"},
{value: "no", name: "Choice 2"}
]
},
{
key: "textarea",
type: "password",
title: "Password"
},
{
key: "choice",
type: "radiobuttons",
titleMap: [
{value: "one", name: "One"},
{value: "two", name: "More..."}
]
},
{
key: "checkbox",
type: "checkboxes",
"titleMap": [
{
"value": "a",
"name": "A"
},
{
"value": "b",
"name": "B"
},
{
"value": "c",
"name": "C"
}
]
},
"checkbox",
"name"
]
});
var server = new fake.Server()
.register(login)
.register(form)
.register(student)
.register(form2)
.register(types)
.listen(3000);
\ 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