Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
U
ulakbus-ui
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ulakbus
ulakbus-ui
Commits
2e9198c7
Commit
2e9198c7
authored
Jun 30, 2015
by
Evren Kutar
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'Feature/#114/PersonelEkleListele'
parents
2320c175
6dcf7631
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
388 additions
and
50 deletions
+388
-50
app_routes.js
app/app_routes.js
+74
-20
staff_add_template.html
app/components/staff/staff_add_template.html
+7
-0
staff_controller.js
app/components/staff/staff_controller.js
+41
-0
student_controller.js
app/components/student/student_controller.js
+20
-9
student_list_template.html
app/components/student/student_list_template.html
+13
-0
types_controller.js
app/components/types/types_controller.js
+43
-0
types_template.html
app/components/types/types_template.html
+6
-0
index.html
app/index.html
+3
-15
form_service.js
app/zetalib/forms/form_service.js
+5
-6
fake_rest_server.js
fake_rest_server.js
+176
-0
No files found.
app/app_routes.js
View file @
2e9198c7
...
...
@@ -21,7 +21,7 @@ app.config(['$routeProvider', function ($routeProvider) {
}]
}
})
.
when
(
'/student
_
add'
,
{
.
when
(
'/student
/
add'
,
{
templateUrl
:
'components/student/student_add_template.html'
,
controller
:
'StudentAddEditCtrl'
,
resolve
:
{
...
...
@@ -36,25 +36,79 @@ app.config(['$routeProvider', function ($routeProvider) {
}]
}
})
.
when
(
'/student/edit/:id'
,
{
templateUrl
:
'components/student/student_add_template.html'
,
controller
:
'StudentAddEditCtrl'
,
resolve
:
{
loadMyCtrl
:
[
'$ocLazyLoad'
,
function
(
$ocLazyLoad
)
{
return
$ocLazyLoad
.
load
(
'components/student/student_controller.js'
);
}],
loadMyService
:
[
'$ocLazyLoad'
,
function
(
$ocLazyLoad
)
{
return
$ocLazyLoad
.
load
(
'zetalib/forms/form_service.js'
);
}],
loadMyService2
:
[
'$ocLazyLoad'
,
function
(
$ocLazyLoad
)
{
return
$ocLazyLoad
.
load
(
'zetalib/general.js'
);
}]
}
})
.
when
(
'/students'
,
{
templateUrl
:
'components/student/student_list_template.html'
,
controller
:
'StudentListCtrl'
,
resolve
:
{
loadMyCtrl
:
[
'$ocLazyLoad'
,
function
(
$ocLazyLoad
)
{
return
$ocLazyLoad
.
load
(
'components/student/student_controller.js'
);
}],
loadMyService
:
[
'$ocLazyLoad'
,
function
(
$ocLazyLoad
)
{
return
$ocLazyLoad
.
load
(
'zetalib/forms/form_service.js'
);
}],
loadMyService2
:
[
'$ocLazyLoad'
,
function
(
$ocLazyLoad
)
{
return
$ocLazyLoad
.
load
(
'zetalib/general.js'
);
}]
}
})
.
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"
);
}
}
});
});
\ No newline at end of file
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
app/components/staff/staff_add_template.html
0 → 100644
View file @
2e9198c7
<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
app/components/staff/staff_controller.js
0 → 100644
View file @
2e9198c7
/**
* Copyright (C) 2015 ZetaOps Inc.
*
* This file is licensed under the GNU General Public License v3
* (GPLv3). See LICENSE.txt for details.
*/
'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
app/components/student/student_controller.js
View file @
2e9198c7
...
...
@@ -14,8 +14,8 @@
var
student
=
angular
.
module
(
'zaerp.student.add'
,
[
'ngRoute'
,
'schemaForm'
,
'formService'
,
'general'
]);
/**
* StudentAddCtrl
* to add student, provide form with form generator
* StudentAdd
Edit
Ctrl
* to add
or edit
student, provide form with form generator
*/
student
.
controller
(
'StudentAddEditCtrl'
,
function
(
$scope
,
$http
,
$log
,
Generator
,
$routeParams
){
...
...
@@ -23,7 +23,7 @@ student.controller('StudentAddEditCtrl', function($scope, $http, $log, Generator
$scope
.
schema
=
d
.
schema
;
$scope
.
form
=
d
.
form
;
// model is the init data of the form or in edit templates
$scope
.
model
=
d
.
model
;
$scope
.
model
=
d
.
model
?
d
.
model
:
{}
;
$scope
.
initialModel
=
angular
.
copy
(
d
.
model
);
// for email validation add asyncvalidator
$scope
.
form
[
0
].
$asyncValidators
=
Generator
.
asyncValidators
;
...
...
@@ -35,11 +35,22 @@ student.controller('StudentAddEditCtrl', function($scope, $http, $log, Generator
}
);
});
$scope
.
onSubmit
=
function
(
form
)
{
$scope
.
$broadcast
(
'schemaFormValidate'
);
if
(
form
.
$valid
)
{
$scope
.
onSubmit
=
Generator
.
submit
(
$scope
);
//
$scope.$broadcast('schemaFormValidate');
//
if (form.$valid) {
// todo: implement form diff here
$log
.
info
(
$scope
.
initialModel
,
$scope
.
model
);
}
}
//Generator.submit($scope);
//$log.info($scope.initialModel, $scope.model);
//}
//}
});
/**
* Student List Controller
*/
student
.
controller
(
'StudentListCtrl'
,
function
(
$scope
,
$http
){
$http
.
get
(
'http://127.0.0.1:3000/api/list_student'
).
then
(
function
(
res
){
$scope
.
students
=
res
.
data
;
})
});
\ No newline at end of file
app/components/student/student_list_template.html
0 → 100644
View file @
2e9198c7
<table
class=
"table table-bordered"
>
<thead>
<tr>
<th
ng-repeat=
"(key,value) in students[0]"
>
{{ key }}
</th>
</tr>
</thead>
<tbody>
<tr
ng-repeat=
"student in students"
>
<td
ng-repeat=
"(key,value) in student"
>
{{value}}
</td>
<td><a
ng-href=
"#/s/edit/{{student.id}}"
>
Edit
</a></td>
</tr>
</tbody>
</table>
\ No newline at end of file
app/components/types/types_controller.js
0 → 100644
View file @
2e9198c7
/**
* Copyright (C) 2015 ZetaOps Inc.
*
* This file is licensed under the GNU General Public License v3
* (GPLv3). See LICENSE.txt for details.
*/
'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
app/components/types/types_template.html
0 → 100644
View file @
2e9198c7
<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
app/index.html
View file @
2e9198c7
...
...
@@ -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>
...
...
app/zetalib/forms/form_service.js
View file @
2e9198c7
...
...
@@ -7,7 +7,7 @@
var
form_generator
=
angular
.
module
(
'formService'
,
[]);
form_generator
.
factory
(
'Generator'
,
function
(
$http
,
$q
,
$timeout
,
RESTURL
)
{
form_generator
.
factory
(
'Generator'
,
function
(
$http
,
$q
,
$
log
,
$
timeout
,
RESTURL
)
{
var
generator
=
{};
generator
.
generate
=
function
(
modelObject
)
{
return
generator
.
group
(
modelObject
);
...
...
@@ -54,12 +54,11 @@ form_generator.factory('Generator', function ($http, $q, $timeout, RESTURL) {
return
deferred
.
promise
;
}
};
generator
.
submit
=
function
(
form
,
$scope
,
$log
)
{
generator
.
submit
=
function
(
$scope
)
{
$scope
.
$broadcast
(
'schemaFormValidate'
);
if
(
form
.
$valid
)
{
// todo: implement form diff here
$log
.
info
(
$scope
.
model
);
}
//if ($scope.form.$valid) {
$http
.
post
(
'http://127.0.0.1:3000/api/add_student'
,
$scope
.
model
).
then
(
function
(
res
){
$log
.
info
(
res
);});
//}
};
return
generator
;
});
\ No newline at end of file
fake_rest_server.js
View file @
2e9198c7
...
...
@@ -43,7 +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
,
'archived'
:
false
,
'auth_info'
:
{
'email'
:
'suuper@suup.com'
,
'password'
:
'123'
,
'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
}],
'code'
:
'math101'
,
'credit'
:
4
,
'exams'
:
[
{
'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
}],
'code'
:
'rock101'
,
'credit'
:
10
,
'exams'
:
[
{
'date'
:
'2015-05-15T00:00:00Z'
,
'point'
:
65
,
'type'
:
'Q'
}],
'name'
:
'Introduction to Rocking'
,
'node_in_list_node'
:
{
'foo'
:
'FOOOO'
}
}],
'name'
:
'Jack'
,
'number'
:
'20300344'
,
'pno'
:
'2343243433'
,
'surname'
:
'Black'
,
'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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment