Commit 61f021ef authored by Evren Kutar's avatar Evren Kutar

Merge branch 'Feature/#114/PersonelEkleListele'

parents 3cca2209 69e56e4f
#Zaerp User Interface #Zaerp User Interface
##Get Ready For Development ##Get Ready For Development
1. Get Repo `git clone git@github.com:zetaops/zaerp-ui.git` 1. Get Repo `git clone git@github.com:zetaops/ulakbus-ui.git`
*if you are not familiar with git follow these guides:* *if you are not familiar with git follow these guides:*
- https://git-scm.com/doc - https://git-scm.com/doc
......
...@@ -62,7 +62,35 @@ var app = angular.module( ...@@ -62,7 +62,35 @@ var app = angular.module(
sessionTimeout: 'auth-session-timeout', sessionTimeout: 'auth-session-timeout',
notAuthenticated: 'auth-not-authenticated', notAuthenticated: 'auth-not-authenticated',
notAuthorized: 'auth-not-authorized' notAuthorized: 'auth-not-authorized'
}); }).
/**
* Directive to highlight current menu item
*/
// todo: not working properly, get it done!
directive('activeLink', ['$location', function($location) {
return {
restrict: 'A',
link: function($scope, $element, $attrs) {
var clazz = $attrs.activeLink;
var path = $location.path();
path = path //hack because path does not
// return including hashbang
$scope.location = $location;
$scope.$watch('location.path()', function(newPath) {
if (path === newPath) {
console.log(path, newPath);
$element.addClass(clazz);
} else {
console.log(path, newPath);
$element.removeClass(clazz);
}
});
}
};
}]);
// test the code with strict di mode to see if it works when minified // test the code with strict di mode to see if it works when minified
//angular.bootstrap(document, ['zaerp'], { //angular.bootstrap(document, ['zaerp'], {
......
...@@ -66,8 +66,23 @@ app.config(['$routeProvider', function ($routeProvider) { ...@@ -66,8 +66,23 @@ app.config(['$routeProvider', function ($routeProvider) {
}] }]
} }
}) })
.when('/student/:id', {
templateUrl: 'components/student/student_list_template.html',
controller: 'StudentShowCtrl',
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', { .when('/staff/add', {
templateUrl: 'components/staff/staff_add_template.html', templateUrl: 'components/staff/templates/add.html',
controller: 'StaffAddCtrl', controller: 'StaffAddCtrl',
resolve: { resolve: {
loadMyCtrl: ['$ocLazyLoad', function ($ocLazyLoad) { loadMyCtrl: ['$ocLazyLoad', function ($ocLazyLoad) {
...@@ -82,11 +97,11 @@ app.config(['$routeProvider', function ($routeProvider) { ...@@ -82,11 +97,11 @@ app.config(['$routeProvider', function ($routeProvider) {
} }
}) })
.when('/staff/edit/:id', { .when('/staff/edit/:id', {
templateUrl: 'components/staff/staff_add_template.html', templateUrl: 'components/staff/templates/edit.html',
controller: 'StudentEditCtrl', controller: 'StaffEditCtrl',
resolve: { resolve: {
loadMyCtrl: ['$ocLazyLoad', function ($ocLazyLoad) { loadMyCtrl: ['$ocLazyLoad', function ($ocLazyLoad) {
return $ocLazyLoad.load('components/student/student_controller.js'); return $ocLazyLoad.load('components/staff/staff_controller.js');
}], }],
loadMyService: ['$ocLazyLoad', function ($ocLazyLoad) { loadMyService: ['$ocLazyLoad', function ($ocLazyLoad) {
return $ocLazyLoad.load('zetalib/forms/form_service.js'); return $ocLazyLoad.load('zetalib/forms/form_service.js');
...@@ -97,7 +112,7 @@ app.config(['$routeProvider', function ($routeProvider) { ...@@ -97,7 +112,7 @@ app.config(['$routeProvider', function ($routeProvider) {
} }
}) })
.when('/staffs', { .when('/staffs', {
templateUrl: 'components/staff/staff_list_template.html', templateUrl: 'components/staff/templates/list.html',
controller: 'StaffListCtrl', controller: 'StaffListCtrl',
resolve: { resolve: {
loadMyCtrl: ['$ocLazyLoad', function ($ocLazyLoad) { loadMyCtrl: ['$ocLazyLoad', function ($ocLazyLoad) {
...@@ -111,6 +126,21 @@ app.config(['$routeProvider', function ($routeProvider) { ...@@ -111,6 +126,21 @@ app.config(['$routeProvider', function ($routeProvider) {
}] }]
} }
}) })
.when('/staff/:id', {
templateUrl: 'components/staff/templates/show.html',
controller: 'StaffShowCtrl',
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');
}],
loadMyService2: ['$ocLazyLoad', function ($ocLazyLoad) {
return $ocLazyLoad.load('zetalib/general.js');
}]
}
})
.when('/input_types', { .when('/input_types', {
templateUrl: 'components/types/types_template.html', templateUrl: 'components/types/types_template.html',
controller: 'TypeCtrl', controller: 'TypeCtrl',
...@@ -144,27 +174,4 @@ app.config(['$routeProvider', function ($routeProvider) { ...@@ -144,27 +174,4 @@ app.config(['$routeProvider', function ($routeProvider) {
} }
} }
}); });
}).config(['$httpProvider', function ($httpProvider) { });
/** \ No newline at end of file
* the interceptor for all requests to check response
* 4xx - 5xx errors will be handled here
*/
$httpProvider.interceptors.push(function ($q) {
return {
'response': function (response) {
//Will only be called for HTTP up to 300
return response;
},
'responseError': function (rejection) {
// if unauthorized then redirect to login page
if(rejection.status === 400) {
location.reload();
}
if(rejection.status === 401) {
location.path('#/login');
}
return $q.reject(rejection);
}
};
});
}]);
\ No newline at end of file
...@@ -40,7 +40,7 @@ staff.controller('StaffAddCtrl', function ($scope, $http, $log, Generator, $rout ...@@ -40,7 +40,7 @@ staff.controller('StaffAddCtrl', function ($scope, $http, $log, Generator, $rout
}); });
staff.controller('StaffEditCtrl', function ($scope, $http, $log, Generator, $routeParams) { staff.controller('StaffEditCtrl', function ($scope, $http, $log, Generator, $routeParams) {
Generator.get_form('add_staff', $routeParams.id).then(function (d) { Generator.get_form('edit_staff', {id: $routeParams.id}).then(function (d) {
$scope.schema = d.schema; $scope.schema = d.schema;
$scope.form = d.form; $scope.form = d.form;
$scope.model = d.model ? d.model : {}; $scope.model = d.model ? d.model : {};
...@@ -70,4 +70,13 @@ staff.controller('StaffListCtrl', function($scope, $http){ ...@@ -70,4 +70,13 @@ staff.controller('StaffListCtrl', function($scope, $http){
$http.get('http://127.0.0.1:3000/api/list_staff').then(function(res){ $http.get('http://127.0.0.1:3000/api/list_staff').then(function(res){
$scope.staffs = res.data; $scope.staffs = res.data;
}) })
});
/**
* Staff Show Controller
*/
staff.controller('StaffShowCtrl', function($scope, $http, $routeParams){
$http.get('http://127.0.0.1:3000/api/list_staff/').then(function(res){
$scope.staff = res.data[0];
})
}); });
\ 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
<table class="table table-bordered"> <table class="table table-bordered table-responsive">
<thead> <thead>
<tr> <tr>
<th>name</th>
<th ng-repeat="(key,value) in staffs[0]">{{ key }}</th> <th ng-repeat="(key,value) in staffs[0]">{{ key }}</th>
<th>action</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr ng-repeat="staff in staffs"> <tr ng-repeat="staff in staffs">
<td><a ng-href="#/staff/{{staff.id}}">{{staff.name}}</a></td>
<td ng-repeat="(key,value) in staff">{{value}}</td> <td ng-repeat="(key,value) in staff">{{value}}</td>
<td><a ng-href="#/s/edit/{{staff.id}}">Edit</a></td> <td><a ng-href="#/staff/edit/{{staff.id}}">Edit</a></td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
\ No newline at end of file
<p ng-repeat="(key, value) in staff"><span class="col-md-3">{{ key }}:</span>{{
value}}</p>
\ No newline at end of file
...@@ -48,9 +48,11 @@ ...@@ -48,9 +48,11 @@
<div class="row"> <div class="row">
<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="#/student/add">New Student</a></li> <li active-link="active"><a href="#/students">Students</a></li>
<li><a href="#/staff/add">New Staff</a></li> <li active-link="active"><a href="#/student/add">New Student</a></li>
<li><a href="#/input_types">Types</a></li> <li active-link="active"><a href="#/staffs">Staffs</a></li>
<li active-link="active"><a href="#/staff/add">New Staff</a></li>
<li active-link="active"><a href="#/input_types">Types</a></li>
</ul> </ul>
</div> </div>
...@@ -82,6 +84,7 @@ ...@@ -82,6 +84,7 @@
<script type="text/javascript" src="bower_components/angular-schema-form/dist/bootstrap-decorator.min.js"></script> <script type="text/javascript" src="bower_components/angular-schema-form/dist/bootstrap-decorator.min.js"></script>
<script src="app.js"></script> <script src="app.js"></script>
<script src="zetalib/interceptors.js"></script>
<script src="app_routes.js"></script> <script src="app_routes.js"></script>
<!--<script src="zlib/general.js"></script>--> <!--<script src="zlib/general.js"></script>-->
......
/**
* Copyright (C) 2015 ZetaOps Inc.
*
* This file is licensed under the GNU General Public License v3
* (GPLv3). See LICENSE.txt for details.
*/
app.config(['$httpProvider', function ($httpProvider) {
/**
* the interceptor for all requests to check response
* 4xx - 5xx errors will be handled here
*/
$httpProvider.interceptors.push(function ($q) {
return {
'response': function (response) {
//Will only be called for HTTP up to 300
return response;
},
'responseError': function (rejection) {
// if unauthorized then redirect to login page
if(rejection.status === 400) {
location.reload();
}
if(rejection.status === 401) {
location.path('#/login');
}
return $q.reject(rejection);
}
};
});
}]);
\ No newline at end of file
...@@ -10,7 +10,7 @@ var login = new fake.Resource("login") ...@@ -10,7 +10,7 @@ var login = new fake.Resource("login")
success: true success: true
}); });
var form = new fake.Resource("add_student") var add_student = new fake.Resource("add_student")
.add({ .add({
schema: { schema: {
title: "Add Student", title: "Add Student",
...@@ -43,7 +43,7 @@ var form = new fake.Resource("add_student") ...@@ -43,7 +43,7 @@ var form = new fake.Resource("add_student")
} }
}); });
var form2 = new fake.Resource("add_staff") var add_staff = new fake.Resource("add_staff")
.add({ .add({
schema: { schema: {
title: "Add Staff", title: "Add Staff",
...@@ -73,6 +73,40 @@ var form2 = new fake.Resource("add_staff") ...@@ -73,6 +73,40 @@ var form2 = new fake.Resource("add_staff")
] ]
}); });
var edit_staff = new fake.Resource("edit_staff")
.add({
schema: {
title: "Edit 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"
],
model: {
name: "evren kutar",
email: "evren@zetaops.io"
}
});
var student = new fake.Resource("list_student") var student = new fake.Resource("list_student")
.add({ .add({
'deleted': false, 'deleted': false,
...@@ -278,9 +312,10 @@ var types = new fake.Resource("input_types") ...@@ -278,9 +312,10 @@ var types = new fake.Resource("input_types")
var server = new fake.Server() var server = new fake.Server()
.register(login) .register(login)
.register(form) .register(add_student)
.register(student) .register(student)
.register(staff) .register(staff)
.register(form2) .register(add_staff)
.register(edit_staff)
.register(types) .register(types)
.listen(3000); .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