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
5249a046
Commit
5249a046
authored
Oct 06, 2015
by
Evren Kutar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix tests for coverage and some linter fixes for javascript
parent
11f317c5
Changes
27
Hide whitespace changes
Inline
Side-by-side
Showing
27 changed files
with
300 additions
and
599 deletions
+300
-599
Gruntfile.js
Gruntfile.js
+1
-1
app.js
app/app.js
+1
-1
auth_service.js
app/components/auth/auth_service.js
+5
-22
auth_test.js
app/components/auth/auth_test.js
+16
-15
login_form_helpers.js
app/components/auth/login_form_helpers.js
+0
-66
crud_controller_test.js
app/components/crud/crud_controller_test.js
+27
-1
dashboard_controller.js
app/components/dashboard/dashboard_controller.js
+3
-3
dashboard_test.js
app/components/dashboard/dashboard_test.js
+34
-1
personelinfo.html
app/components/personelinfo/personelinfo.html
+0
-160
pinfo_controller.js
app/components/personelinfo/pinfo_controller.js
+0
-16
staff_controller.js
app/components/staff/staff_controller.js
+0
-81
staff_controller_test.js
app/components/staff/staff_controller_test.js
+0
-35
add.html
app/components/staff/templates/add.html
+0
-3
edit.html
app/components/staff/templates/edit.html
+0
-6
list.html
app/components/staff/templates/list.html
+0
-19
show.html
app/components/staff/templates/show.html
+0
-2
student_add_template.html
app/components/student/student_add_template.html
+0
-6
student_controller.js
app/components/student/student_controller.js
+0
-54
student_list_template.html
app/components/student/student_list_template.html
+0
-13
types_controller.js
app/components/types/types_controller.js
+0
-43
types_template.html
app/components/types/types_template.html
+0
-6
version.js
app/components/version/version.js
+1
-1
version_test.js
app/components/version/version_test.js
+1
-1
index.html
app/index.html
+2
-2
form_service.js
app/zetalib/forms/form_service.js
+36
-39
form_service_test.js
app/zetalib/forms/form_service_test.js
+158
-1
karma.conf.js
karma.conf.js
+15
-1
No files found.
Gruntfile.js
View file @
5249a046
...
@@ -329,6 +329,6 @@ module.exports = function (grunt) {
...
@@ -329,6 +329,6 @@ module.exports = function (grunt) {
'preprocess:prod_branch'
,
'preprocess:prod_branch'
,
'html2js:prod_branch'
,
'html2js:prod_branch'
,
'uglify:branch'
'uglify:branch'
])
])
;
});
});
};
};
\ No newline at end of file
app/app.js
View file @
5249a046
...
@@ -24,7 +24,7 @@ var app = angular.module(
...
@@ -24,7 +24,7 @@ var app = angular.module(
'ulakbus.version'
,
'ulakbus.version'
,
'schemaForm'
,
'schemaForm'
,
'gettext'
,
'gettext'
,
//'templates-dev
',
'ulakbus.uitemplates
'
,
]).
]).
/**
/**
* RESTURL is the url of rest api to talk
* RESTURL is the url of rest api to talk
...
...
app/components/auth/auth_service.js
View file @
5249a046
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
// TODO: login url change with correct one
// TODO: login url change with correct one
auth
.
factory
(
'LoginService'
,
function
(
$http
,
$rootScope
,
$location
,
$log
,
$cookies
,
$window
,
Session
,
RESTURL
)
{
auth
.
factory
(
'LoginService'
,
function
(
$http
,
$rootScope
,
$location
,
$log
,
Session
,
RESTURL
)
{
var
loginService
=
{};
var
loginService
=
{};
loginService
.
login
=
function
(
url
,
credentials
)
{
loginService
.
login
=
function
(
url
,
credentials
)
{
...
@@ -22,35 +22,18 @@ auth.factory('LoginService', function ($http, $rootScope, $location, $log, $cook
...
@@ -22,35 +22,18 @@ auth.factory('LoginService', function ($http, $rootScope, $location, $log, $cook
$rootScope
.
loggedInUser
=
true
;
$rootScope
.
loggedInUser
=
true
;
})
})
.
error
(
function
(
data
,
status
,
headers
,
config
)
{
.
error
(
function
(
data
,
status
,
headers
,
config
)
{
// Erase the token if the user fails to log in
//delete $window.sessionStorage.token;
// Handle login errors here
// Handle login errors here
return
data
;
return
data
;
});
});
//.then(function (res) {
// $log.info(res.data[0]);
// res.data = res.data[0];
// if (res.data.success) {
// $rootScope.loggedInUser = true;
// $location.path("/dashboard");
// var session = Session.create(res.data.id, res.data.user.id,
// res.data.user.role);
// $log.info(session);
// $cookies.put('sessionId', 123456);
// console.log($cookies.getAll());
// return res.data.user;
// }
//});
};
};
loginService
.
logout
=
function
()
{
loginService
.
logout
=
function
()
{
console
.
log
(
"logout"
);
$log
.
info
(
"logout"
);
$http
.
post
(
RESTURL
.
url
+
'logout'
,
{}).
then
(
function
()
{
return
$http
.
post
(
RESTURL
.
url
+
'logout'
,
{}).
success
(
function
(
data
)
{
$rootScope
.
loggedInUser
=
false
;
$rootScope
.
loggedInUser
=
false
;
$location
.
path
(
"/login"
);
$location
.
path
(
"/login"
);
});
});
console
.
log
(
"loggedout"
);
$log
.
info
(
"loggedout"
);
};
};
...
...
app/components/auth/auth_test.js
View file @
5249a046
...
@@ -7,8 +7,6 @@
...
@@ -7,8 +7,6 @@
'use strict'
;
'use strict'
;
// TODO: fill up the test cases correctly
describe
(
'ulakbus.auth module'
,
function
()
{
describe
(
'ulakbus.auth module'
,
function
()
{
// load dependencies of modules e.g REST_URL
// load dependencies of modules e.g REST_URL
...
@@ -54,7 +52,7 @@ describe('ulakbus.auth module', function () {
...
@@ -54,7 +52,7 @@ describe('ulakbus.auth module', function () {
}])
}])
);
);
it
(
'ensures user can log in'
,
function
()
{
it
(
'ensures user can log in'
,
function
(
LoginService
,
$httpBackend
,
RESTURL
)
{
// todo: after backend api ready implement this
// todo: after backend api ready implement this
});
});
...
@@ -85,19 +83,22 @@ describe('ulakbus.auth module', function () {
...
@@ -85,19 +83,22 @@ describe('ulakbus.auth module', function () {
})
})
);
);
// todo: test in case of 401 reload
it
(
'should logout'
,
inject
(
function
(
LoginService
,
$httpBackend
,
$location
,
RESTURL
)
{
//it('unauthorized 401 should redirect to login',
// use httpBackend to imitate login api
// inject(function ($httpBackend, $http, $location, $window) {
//
$httpBackend
.
expectPOST
(
RESTURL
.
url
+
'logout'
,
{})
// $httpBackend.whenGET('http://127.0.0.1:8000/#/dashboard').respond(401, '');
.
respond
(
200
,
{
//
is_login
:
false
// $http.get('http://127.0.0.1:8000/#/dashboard');
});
// expect($window.location == '/#/login');
//
// $httpBackend.flush();
// })
//);
LoginService
.
logout
().
success
(
function
(
data
)
{
expect
(
data
.
is_login
).
toBe
(
false
);
});
$httpBackend
.
flush
();
})
);
});
});
});
});
\ No newline at end of file
app/components/auth/login_form_helpers.js
deleted
100644 → 0
View file @
11f317c5
/**
* Created by Evren Kutar on 18/05/15.
*/
angular
.
module
(
'ulakbus.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
);
}
});
}
};
});
app/components/crud/crud_controller_test.js
View file @
5249a046
...
@@ -26,10 +26,36 @@ describe('crud controller module', function () {
...
@@ -26,10 +26,36 @@ describe('crud controller module', function () {
});
});
});
});
describe
(
'crud add controller'
,
function
()
{
// todo: chack if needed for these tests
// describe('crud list controller', function() {
// it('should get list', function() {
// var $scope = {};
// var controller = $controller('CRUDListCtrl', { $scope: $scope });
// expect($scope).not.toEqual(null);
// });
// });
// describe('crud show controller', function() {
// it('should get single item', function() {
// var $scope = {};
// var controller = $controller('CRUDShowCtrl', { $scope: $scope });
// expect($scope).not.toEqual(null);
// });
// });
describe
(
'crud controller'
,
function
()
{
it
(
'should have CRUDAddEditCtrl'
,
inject
(
function
(
$controller
)
{
it
(
'should have CRUDAddEditCtrl'
,
inject
(
function
(
$controller
)
{
expect
(
$controller
).
toBeDefined
();
expect
(
$controller
).
toBeDefined
();
}));
}));
it
(
'should have CRUDListCtrl'
,
inject
(
function
(
$controller
)
{
expect
(
$controller
).
toBeDefined
();
}));
it
(
'should have CRUDShowCtrl'
,
inject
(
function
(
$controller
)
{
expect
(
$controller
).
toBeDefined
();
}));
});
});
});
});
\ No newline at end of file
app/components/dashboard/dashboard_controller.js
View file @
5249a046
...
@@ -11,8 +11,8 @@
...
@@ -11,8 +11,8 @@
angular
.
module
(
'ulakbus.dashboard'
,
[
'ngRoute'
])
angular
.
module
(
'ulakbus.dashboard'
,
[
'ngRoute'
])
.
controller
(
'DashCtrl'
,
function
(
$scope
,
$rootScope
,
$location
)
{
.
controller
(
'DashCtrl'
,
function
(
$scope
,
$rootScope
)
{
$scope
.
section
=
function
(
section_index
)
{
$scope
.
section
=
function
(
section_index
)
{
$rootScope
.
section
=
section_index
;
$rootScope
.
section
=
section_index
;
}
}
;
});
});
\ No newline at end of file
app/components/dashboard/dashboard_test.js
View file @
5249a046
...
@@ -3,4 +3,37 @@
...
@@ -3,4 +3,37 @@
*
*
* This file is licensed under the GNU General Public License v3
* This file is licensed under the GNU General Public License v3
* (GPLv3). See LICENSE.txt for details.
* (GPLv3). See LICENSE.txt for details.
*/
*/
\ No newline at end of file
'use strict'
;
describe
(
'dashboard controller module'
,
function
()
{
beforeEach
(
module
(
'ulakbus'
));
beforeEach
(
module
(
'ulakbus.dashboard'
));
var
$controller
;
beforeEach
(
inject
(
function
(
_$controller_
)
{
$controller
=
_$controller_
;
}));
var
$rootScope
;
beforeEach
(
inject
(
function
(
_$rootScope_
)
{
$rootScope
=
_$rootScope_
;
}));
describe
(
'dashboard controller'
,
function
()
{
it
(
'should define DashCtrl'
,
inject
(
function
(
$controller
)
{
expect
(
$controller
).
toBeDefined
();
}));
it
(
'should define section'
,
function
()
{
var
$scope
=
{};
var
controller
=
$controller
(
'DashCtrl'
,
{
$scope
:
$scope
});
$scope
.
section
(
'test_section'
);
expect
(
$rootScope
.
section
).
toBe
(
'test_section'
);
});
});
});
\ No newline at end of file
app/components/personelinfo/personelinfo.html
deleted
100644 → 0
View file @
11f317c5
<div
ng-app=
"ulakbus.personelinfo"
>
<div
class=
"starter-template"
>
<div
class=
"personnel-info-container"
>
<div
class=
"personnel-info-left"
>
<div
class=
"generic-profile-picture"
>
<img
src=
"../../img/sample-profile-pic.jpg"
/>
</div>
<ul>
<li>
Gökhan Boranalp
</li>
<li>
Pozisyon
</li>
<li><i
class=
"fa fa-phone"
></i>
(+90) 123 456 7890
</li>
<li><i
class=
"fa fa-envelope"
></i>
samplemail@mail.com
</li>
<li><i
class=
"fa fa-map-marker"
></i>
Gülbahçe Mah. İzmir Teknoloji Geliştirme Bölgesi A9 Blok 215/A IYTE Campus, URLA/IZMIR
</li></li>
</ul>
</div>
<!-- end of personnel-info-left -->
<div
class=
"personnel-info-right"
>
<div
class=
"info-block"
>
<div
class=
"info-block-header"
>
<h2>
Kişisel Bilgiler
</h2>
</div>
<!-- end of info-block-header -->
<div
class=
"info-block-body"
>
<dl
class=
"dl-horizontal"
>
<dt>
Ad Soyad
</dt>
<dd>
Gökhan Boranalp
</dd>
</dl>
<dl
class=
"dl-horizontal"
>
<dt>
Cinsiyet
</dt>
<dd>
Erkek
</dd>
</dl>
<dl
class=
"dl-horizontal"
>
<dt>
Doğum Tarihi
</dt>
<dd>
23/06/1970
</dd>
</dl>
<dl
class=
"dl-horizontal"
>
<dt>
İkamet Adresi
</dt>
<dd>
Gülbahçe Mah. İzmir Teknoloji Geliştirme Bölgesi A9 Blok 215/A IYTE Campus, URLA/IZMIR
</dd>
</dl>
</div>
<!-- end of info-block-body -->
</div>
<!-- end of info block -->
<div
class=
"info-block"
>
<div
class=
"info-block-header"
>
<h2>
İletişim Bilgileri
</h2>
</div>
<!-- end of info-block-header -->
<div
class=
"info-block-body"
>
<dl
class=
"dl-horizontal"
>
<dt>
Ev Telefonu
</dt>
<dd>
-
</dd>
</dl>
<dl
class=
"dl-horizontal"
>
<dt>
Cep Telefonu
</dt>
<dd>
(+90) 123 456 7890
</dd>
</dl>
<dl
class=
"dl-horizontal"
>
<dt>
Mail Adresi
</dt>
<dd>
gokhan@zetaops.io
</dd>
</dl>
<dl
class=
"dl-horizontal"
>
<dt>
Diğer Mail Adresi
</dt>
<dd>
-
</dd>
</dl>
</div>
<!-- end of info-block-body -->
</div>
<!-- end of info block -->
</div>
<!-- personnel-info-left -->
</div>
<!-- end of personnel-info-container -->
<div
class=
"personnel-info-container personnel-info-edit"
>
<div
class=
"personnel-info-left"
>
<div
class=
"generic-profile-picture"
>
<img
src=
"../../img/sample-profile-pic.jpg"
/>
</div>
<div
style=
"margin-top:10px; text-align:center;"
>
<button
type=
"button"
class=
"btn btn-primary"
>
Değiştir
</button>
<button
type=
"button"
class=
"btn btn-danger"
>
Sil
</button>
</div>
</div>
<!-- end of personnel-info-left -->
<div
class=
"personnel-info-right"
>
<div
class=
"info-block"
>
<div
class=
"info-block-header"
>
<h2>
Kişisel Bilgiler
</h2>
</div>
<!-- end of info-block-header -->
<div
class=
"info-block-body"
>
<dl
class=
"dl-horizontal"
>
<dt>
Ad Soyad
</dt>
<dd><input
type=
"text"
class=
"form-control"
placeholder=
"Gökhan Boranalp"
></dd>
</dl>
<dl
class=
"dl-horizontal"
>
<dt>
Pozisyon
</dt>
<dd><input
type=
"text"
class=
"form-control"
placeholder=
"Pozisyon"
></dd>
</dl>
<dl
class=
"dl-horizontal"
>
<dt>
Cinsiyet
</dt>
<dd>
<select
class=
"form-control"
>
<option
value=
"male"
>
Erkek
</option>
<option
value=
"female"
>
Kadın
</option>
</select>
</dd>
</dl>
<dl
class=
"dl-horizontal"
>
<dt>
Doğum Tarihi
</dt>
<dd>
<input
type=
"text"
class=
"form-control"
placeholder=
"Angular JS - Bootstrap Date Picker Eklenecek"
>
</dd>
</dl>
<dl
class=
"dl-horizontal"
>
<dt>
İkamet Adresi
</dt>
<dd><input
type=
"text"
class=
"form-control"
placeholder=
"Gülbahçe Mah. İzmir Teknoloji Geliştirme Bölgesi A9 Blok 215/A IYTE Campus, URLA/IZMIR"
></dd>
</dl>
</div>
<!-- end of info-block-body -->
</div>
<!-- end of info block -->
<div
class=
"info-block"
>
<div
class=
"info-block-header"
>
<h2>
İletişim Bilgileri
</h2>
</div>
<!-- end of info-block-header -->
<div
class=
"info-block-body"
>
<dl
class=
"dl-horizontal"
>
<dt>
Ev Telefonu
</dt>
<dd><input
type=
"text"
class=
"form-control"
placeholder=
""
></dd>
</dl>
<dl
class=
"dl-horizontal"
>
<dt>
Cep Telefonu
</dt>
<dd><input
type=
"text"
class=
"form-control"
placeholder=
"(+90) 123 456 7890 (Phone number mask uygulanacak)"
></dd>
</dl>
<dl
class=
"dl-horizontal"
>
<dt>
Mail Adresi
</dt>
<dd><input
type=
"text"
class=
"form-control"
placeholder=
"gokhan@zetaops.io"
></dd>
</dl>
<dl
class=
"dl-horizontal"
>
<dt>
Diğer Mail Adresi
</dt>
<dd><input
type=
"text"
class=
"form-control"
placeholder=
""
></dd>
</dl>
</div>
<!-- end of info-block-body -->
</div>
<!-- end of info block -->
</div>
<!-- personnel-info-left -->
</div>
<!-- end of personnel-info-container -->
</div>
</div>
\ No newline at end of file
app/components/personelinfo/pinfo_controller.js
deleted
100644 → 0
View file @
11f317c5
/**
* Copyright (C) 2015 ZetaOps Inc.
*
* This file is licensed under the GNU General Public License v3
* (GPLv3). See LICENSE.txt for details.
*/
'use strict'
;
// TODO: clean console log items
angular
.
module
(
'ulakbus.pinfo'
,
[
'ngRoute'
])
.
controller
(
'PCtrl'
,
function
(
$scope
)
{
$scope
.
testData
=
"<h1>This is main Dashboard</h1>"
;
});
\ No newline at end of file
app/components/staff/staff_controller.js
deleted
100644 → 0
View file @
11f317c5
/**
* 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
(
'ulakbus.staff'
,
[
'ngRoute'
,
'schemaForm'
,
'formService'
,
'ui.bootstrap'
]);
/**
* StaffAddEditCtrl is a controller
* which provide a form with form generator.
*/
staff
.
controller
(
'StaffAddEditCtrl'
,
function
(
$scope
,
$rootScope
,
$location
,
$http
,
$log
,
$modal
,
Generator
,
$routeParams
)
{
$scope
.
url
=
'personel_duzenle_basitlestirilmis'
;
$scope
.
form_params
=
{};
if
(
$routeParams
.
id
)
{
$scope
.
form_params
[
'object_id'
]
=
$routeParams
.
id
;
$scope
.
form_params
[
'cmd'
]
=
'edit_object'
;
}
else
{
$scope
.
form_params
[
'cmd'
]
=
'add_object'
;
}
// to start in certain part of the workflow use clear_wf=1
$scope
.
form_params
[
'clear_wf'
]
=
1
;
// get form with generator
Generator
.
get_form
(
$scope
);
$scope
.
onSubmit
=
function
(
form
)
{
$scope
.
$broadcast
(
'schemaFormValidate'
);
if
(
form
.
$valid
)
{
Generator
.
submit
(
$scope
)
.
success
(
function
(
data
){
$location
.
path
(
"/staffs"
);
})
.
error
(
function
(
data
){
$scope
.
message
=
data
.
title
;
});
}
};
});
// todo: for single point of failure code a "get item" service and use it to
// retrieve list and single item
/**
* Staff List Controller
*/
staff
.
controller
(
'StaffListCtrl'
,
function
(
$scope
,
$rootScope
,
Generator
)
{
$scope
.
url
=
'personel_duzenle_basitlestirilmis'
;
$scope
.
form_params
=
{
"clear_wf"
:
1
};
// call generator's get_list func
Generator
.
get_list
(
$scope
)
.
then
(
function
(
res
)
{
var
data
=
res
.
data
.
employees
;
for
(
var
item
in
data
){
delete
data
[
item
].
data
[
'deleted'
];
delete
data
[
item
].
data
[
'timestamp'
];
}
$scope
.
staffs
=
data
;
});
});
/**
* Staff Show Controller
*/
staff
.
controller
(
'StaffShowCtrl'
,
function
(
$scope
,
$rootScope
,
Generator
,
$routeParams
)
{
$scope
.
url
=
'personel_duzenle_basitlestirilmis'
;
$scope
.
form_params
=
{
"object_id"
:
$routeParams
.
id
,
"clear_wf"
:
1
};
// call generator's get_single_itemfunc
Generator
.
get_single_item
(
$scope
).
then
(
function
(
res
)
{
$scope
.
staff
=
res
.
data
.
employees
[
0
].
data
;
})
});
\ No newline at end of file
app/components/staff/staff_controller_test.js
deleted
100644 → 0
View file @
11f317c5
/**
* Copyright (C) 2015 ZetaOps Inc.
*
* This file is licensed under the GNU General Public License v3
* (GPLv3). See LICENSE.txt for details.
*/
'use strict'
;
describe
(
'staff controller module'
,
function
()
{
beforeEach
(
module
(
'ulakbus'
));
beforeEach
(
module
(
'ulakbus.staff'
));
var
$controller
;
beforeEach
(
inject
(
function
(
_$controller_
)
{
$controller
=
_$controller_
;
}));
describe
(
'staff add controller'
,
function
()
{
it
(
'should get form'
,
function
()
{
var
$scope
=
{};
var
controller
=
$controller
(
'StaffAddEditCtrl'
,
{
$scope
:
$scope
});
expect
(
$scope
).
not
.
toEqual
(
null
);
});
});
describe
(
'staff add controller'
,
function
()
{
it
(
'should have StaffAddEditCtrl'
,
inject
(
function
(
$controller
)
{
expect
(
$controller
).
toBeDefined
();
}));
});
});
\ No newline at end of file
app/components/staff/templates/add.html
deleted
100644 → 0
View file @
11f317c5
<div
ng-app=
"ulakbus.staff"
>
<ng-include
src=
"'shared/templates/add.html'"
></ng-include>
</div>
\ No newline at end of file
app/components/staff/templates/edit.html
deleted
100644 → 0
View file @
11f317c5
<div
ng-app=
"ulakbus.staff"
>
<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/templates/list.html
deleted
100644 → 0
View file @
11f317c5
<table
class=
"table table-bordered table-responsive"
>
<thead>
<tr>
<!--<th>{{ staffs[0].key }}</th>-->
<th
ng-repeat=
"(key,value) in staffs[0].data"
>
{{ key }}
</th>
<th>
action
</th>
</tr>
</thead>
<tbody>
<tr
ng-repeat=
"staff in staffs"
>
<!--<td><a ng-href="#/staff/{{staff.id}}">{{staff.name}}</a></td>-->
<td
ng-repeat=
"(key,value) in staff.data"
>
{{value}}
</td>
<td>
<a
ng-href=
"#/staff/edit/{{staff.key}}"
>
Edit
</a><br>
<a
ng-href=
"#/staff/{{staff.key}}"
>
Show
</a>
</td>
</tr>
</tbody>
</table>
\ No newline at end of file
app/components/staff/templates/show.html
deleted
100644 → 0
View file @
11f317c5
<p
ng-repeat=
"(key, value) in staff"
><span
class=
"col-md-3"
>
{{ key }}:
</span>
{{
value}}
</p>
\ No newline at end of file
app/components/student/student_add_template.html
deleted
100644 → 0
View file @
11f317c5
<div
ng-app=
"ulakbus.student"
>
<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/student/student_controller.js
deleted
100644 → 0
View file @
11f317c5
/**
* Copyright (C) 2015 ZetaOps Inc.
*
* This file is licensed under the GNU General Public License v3
* (GPLv3). See LICENSE.txt for details.
*/
'use strict'
;
/**
* student module is base module object for student operations
*/
var
student
=
angular
.
module
(
'ulakbus.student'
,
[
'ngRoute'
,
'schemaForm'
,
'formService'
,
'general'
]);
/**
* StudentAddEditCtrl
* to add or edit student, provide form with form generator
*/
student
.
controller
(
'StudentAddEditCtrl'
,
function
(
$scope
,
$http
,
$log
,
Generator
,
$routeParams
){
Generator
.
get_form
(
'add_student'
,
$routeParams
).
then
(
function
(
d
){
$scope
.
schema
=
d
.
schema
;
$scope
.
form
=
d
.
form
;
// model is the init data of the form or in edit templates
$scope
.
model
=
d
.
model
?
d
.
model
:
{};
$scope
.
initialModel
=
angular
.
copy
(
d
.
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
)
{
Generator
.
submit
(
'add_staff'
,
$scope
);
}
}
});
/**
* 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
deleted
100644 → 0
View file @
11f317c5
<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
deleted
100644 → 0
View file @
11f317c5
/**
* 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
(
'ulakbus.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
deleted
100644 → 0
View file @
11f317c5
<div
ng-app=
"ulakbus.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/components/version/version.js
View file @
5249a046
...
@@ -5,4 +5,4 @@ angular.module('ulakbus.version', [
...
@@ -5,4 +5,4 @@ angular.module('ulakbus.version', [
'ulakbus.version.version-directive'
'ulakbus.version.version-directive'
])
])
.
value
(
'version'
,
'0.
3
.0'
);
.
value
(
'version'
,
'0.
1
.0'
);
app/components/version/version_test.js
View file @
5249a046
...
@@ -5,7 +5,7 @@ describe('ulakbus.version module', function() {
...
@@ -5,7 +5,7 @@ describe('ulakbus.version module', function() {
describe
(
'version service'
,
function
()
{
describe
(
'version service'
,
function
()
{
it
(
'should return current version'
,
inject
(
function
(
version
)
{
it
(
'should return current version'
,
inject
(
function
(
version
)
{
expect
(
version
).
toEqual
(
'0.
3
'
);
expect
(
version
).
toEqual
(
'0.
1.0
'
);
}));
}));
});
});
});
});
app/index.html
View file @
5249a046
...
@@ -99,8 +99,8 @@
...
@@ -99,8 +99,8 @@
<script
src=
"components/auth/auth_service.js"
></script>
<script
src=
"components/auth/auth_service.js"
></script>
<script
src=
"components/dashboard/dashboard_controller.js"
></script>
<script
src=
"components/dashboard/dashboard_controller.js"
></script>
<script
src=
"components/crud/crud_controller.js"
></script>
<script
src=
"components/crud/crud_controller.js"
></script>
<script
src=
"components/
staff/staff_controller
.js"
></script>
<script
src=
"components/
uitemplates/uitemplates
.js"
></script>
<
script
src=
"components/student/student_controller.js"
></script
>
<
!--<script src="components/student/student_controller.js"></script>--
>
<script
src=
"components/version/interpolate-filter.js"
></script>
<script
src=
"components/version/interpolate-filter.js"
></script>
<script
src=
"components/version/version-directive.js"
></script>
<script
src=
"components/version/version-directive.js"
></script>
<script
src=
"components/version/version.js"
></script>
<script
src=
"components/version/version.js"
></script>
...
...
app/zetalib/forms/form_service.js
View file @
5249a046
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
var
form_generator
=
angular
.
module
(
'formService'
,
[
'general'
]);
var
form_generator
=
angular
.
module
(
'formService'
,
[
'general'
]);
form_generator
.
factory
(
'Generator'
,
function
(
$http
,
$q
,
$
log
,
$location
,
$modal
,
$
timeout
,
RESTURL
,
FormDiff
,
$rootScope
)
{
form_generator
.
factory
(
'Generator'
,
function
(
$http
,
$q
,
$timeout
,
RESTURL
,
FormDiff
,
$rootScope
)
{
var
generator
=
{};
var
generator
=
{};
generator
.
makeUrl
=
function
(
url
)
{
generator
.
makeUrl
=
function
(
url
)
{
return
RESTURL
.
url
+
url
;
return
RESTURL
.
url
+
url
;
...
@@ -35,7 +35,7 @@ form_generator.factory('Generator', function ($http, $q, $log, $location, $modal
...
@@ -35,7 +35,7 @@ form_generator.factory('Generator', function ($http, $q, $log, $location, $modal
generator
.
prepareFormItems
(
scope
);
generator
.
prepareFormItems
(
scope
);
scope
.
object_id
=
scope
.
form_params
[
'object_id'
]
;
scope
.
object_id
=
scope
.
form_params
.
object_id
;
// showSaveButton is used for to show or not to show save button on top of the page
// showSaveButton is used for to show or not to show save button on top of the page
// here change to true because the view retrieves form from api
// here change to true because the view retrieves form from api
...
@@ -53,32 +53,29 @@ form_generator.factory('Generator', function ($http, $q, $log, $location, $modal
...
@@ -53,32 +53,29 @@ form_generator.factory('Generator', function ($http, $q, $log, $location, $modal
angular
.
forEach
(
scope
.
schema
.
properties
,
function
(
k
,
v
)
{
angular
.
forEach
(
scope
.
schema
.
properties
,
function
(
k
,
v
)
{
// check if type is date and if type date found change it to string
// check if type is date and if type date found change it to string
if
(
k
.
type
==
'date'
)
{
if
(
k
.
type
==
=
'date'
)
{
k
.
type
=
'string'
;
k
.
type
=
'string'
;
scope
.
model
[
v
]
=
generator
.
dateformatter
(
scope
.
model
[
v
]);
scope
.
model
[
v
]
=
generator
.
dateformatter
(
scope
.
model
[
v
]);
// seek for datepicker field and initialize datepicker
$timeout
(
function
()
{
//scope.$watch($('#' + v), function () {
jQuery
(
'#'
+
v
).
datepicker
({
$timeout
(
function
()
{
changeMonth
:
true
,
jQuery
(
'#'
+
v
).
datepicker
({
changeYear
:
true
,
changeMonth
:
true
,
dateFormat
:
"dd.mm.yy"
,
changeYear
:
true
,
onSelect
:
function
(
date
)
{
dateFormat
:
"dd.mm.yy"
,
scope
.
model
[
v
]
=
date
;
onSelect
:
function
(
date
)
{
}
scope
.
model
[
v
]
=
date
;
}
});
});
});
//
});
});
}
}
if
(
k
.
type
==
'int'
||
k
.
type
==
'float'
)
{
if
(
k
.
type
==
=
'int'
||
k
.
type
=
==
'float'
)
{
k
.
type
=
'number'
;
k
.
type
=
'number'
;
}
}
// if type is model use foreignKey.html template to show them
// if type is model use foreignKey.html template to show them
if
(
k
.
type
==
'model'
)
{
if
(
k
.
type
==
=
'model'
)
{
var
formitem
=
scope
.
form
[
scope
.
form
.
indexOf
(
v
)];
var
formitem
=
scope
.
form
[
scope
.
form
.
indexOf
(
v
)];
var
modelscope
=
{
"url"
:
scope
.
url
,
"form_params"
:
{
model
:
k
.
model_name
}};
var
modelscope
=
{
"url"
:
scope
.
url
,
"form_params"
:
{
model
:
k
.
model_name
}};
...
@@ -93,7 +90,7 @@ form_generator.factory('Generator', function ($http, $q, $log, $location, $modal
...
@@ -93,7 +90,7 @@ form_generator.factory('Generator', function ($http, $q, $log, $location, $modal
angular
.
forEach
(
res
.
data
.
objects
,
function
(
item
)
{
angular
.
forEach
(
res
.
data
.
objects
,
function
(
item
)
{
formitem
.
titleMap
.
push
({
formitem
.
titleMap
.
push
({
"value"
:
item
.
key
,
"value"
:
item
.
key
,
"name"
:
item
.
data
.
name
?
item
.
data
.
name
:
item
.
data
.
username
"name"
:
item
.
data
.
name
||
item
.
data
.
username
});
});
});
});
}),
}),
...
@@ -113,9 +110,9 @@ form_generator.factory('Generator', function ($http, $q, $log, $location, $modal
...
@@ -113,9 +110,9 @@ form_generator.factory('Generator', function ($http, $q, $log, $location, $modal
//}
//}
}
}
if
(
k
.
type
==
'ListNode'
||
k
.
type
==
'Node'
)
{
if
(
k
.
type
==
=
'ListNode'
||
k
.
type
=
==
'Node'
)
{
scope
[
k
.
type
]
=
scope
[
k
.
type
]
?
scope
[
k
.
type
]
:
{};
scope
[
k
.
type
]
=
scope
[
k
.
type
]
||
{};
scope
[
k
.
type
][
v
]
=
{
scope
[
k
.
type
][
v
]
=
{
title
:
k
.
title
,
title
:
k
.
title
,
...
@@ -131,8 +128,8 @@ form_generator.factory('Generator', function ($http, $q, $log, $location, $modal
...
@@ -131,8 +128,8 @@ form_generator.factory('Generator', function ($http, $q, $log, $location, $modal
url
:
scope
.
url
url
:
scope
.
url
};
};
if
(
scope
.
model
[
v
]
==
null
)
{
if
(
scope
.
model
[
v
]
==
=
null
)
{
scope
[
k
.
type
][
v
].
model
=
k
.
type
==
'Node'
?
{}
:
[];
scope
[
k
.
type
][
v
].
model
=
k
.
type
==
=
'Node'
?
{}
:
[];
}
else
{
}
else
{
scope
[
k
.
type
][
v
].
model
=
scope
.
model
[
v
];
scope
[
k
.
type
][
v
].
model
=
scope
.
model
[
v
];
}
}
...
@@ -141,12 +138,12 @@ form_generator.factory('Generator', function ($http, $q, $log, $location, $modal
...
@@ -141,12 +138,12 @@ form_generator.factory('Generator', function ($http, $q, $log, $location, $modal
scope
[
k
.
type
][
v
].
schema
.
properties
[
item
.
name
]
=
item
;
scope
[
k
.
type
][
v
].
schema
.
properties
[
item
.
name
]
=
item
;
// prepare required fields
// prepare required fields
if
(
item
.
required
==
true
&&
item
.
name
!
=
'idx'
)
{
if
(
item
.
required
==
=
true
&&
item
.
name
!=
=
'idx'
)
{
scope
[
k
.
type
][
v
].
schema
.
required
.
push
(
item
.
name
);
scope
[
k
.
type
][
v
].
schema
.
required
.
push
(
item
.
name
);
}
}
// idx field must be hidden
// idx field must be hidden
if
(
item
.
name
==
'idx'
)
{
if
(
item
.
name
==
=
'idx'
)
{
scope
[
k
.
type
][
v
].
form
.
push
({
type
:
'string'
,
key
:
item
.
name
,
htmlClass
:
'hidden'
});
scope
[
k
.
type
][
v
].
form
.
push
({
type
:
'string'
,
key
:
item
.
name
,
htmlClass
:
'hidden'
});
}
else
{
}
else
{
scope
[
k
.
type
][
v
].
form
.
push
(
item
.
name
);
scope
[
k
.
type
][
v
].
form
.
push
(
item
.
name
);
...
@@ -165,8 +162,8 @@ form_generator.factory('Generator', function ($http, $q, $log, $location, $modal
...
@@ -165,8 +162,8 @@ form_generator.factory('Generator', function ($http, $q, $log, $location, $modal
};
};
generator
.
dateformatter
=
function
(
formObject
)
{
generator
.
dateformatter
=
function
(
formObject
)
{
var
ndate
=
new
Date
(
formObject
);
var
ndate
=
new
Date
(
formObject
);
if
(
ndate
==
'Invalid Date'
)
{
if
(
ndate
==
=
'Invalid Date'
)
{
return
''
return
''
;
}
}
var
newdatearray
=
[
ndate
.
getDate
(),
ndate
.
getMonth
(),
ndate
.
getFullYear
()];
var
newdatearray
=
[
ndate
.
getDate
(),
ndate
.
getMonth
(),
ndate
.
getFullYear
()];
return
newdatearray
.
join
(
'.'
);
return
newdatearray
.
join
(
'.'
);
...
@@ -201,7 +198,7 @@ form_generator.factory('Generator', function ($http, $q, $log, $location, $modal
...
@@ -201,7 +198,7 @@ form_generator.factory('Generator', function ($http, $q, $log, $location, $modal
var
re
=
/^
([\w
-
]
+
(?:\.[\w
-
]
+
)
*
)
@
((?:[\w
-
]
+
\.)
*
\w[\w
-
]{0,66})\.([
a-z
]{2,6}(?:\.[
a-z
]{2})?)
$/i
;
var
re
=
/^
([\w
-
]
+
(?:\.[\w
-
]
+
)
*
)
@
((?:[\w
-
]
+
\.)
*
\w[\w
-
]{0,66})\.([
a-z
]{2,6}(?:\.[
a-z
]{2})?)
$/i
;
return
re
.
test
(
email
);
return
re
.
test
(
email
);
};
};
generator
.
isValidTCNo
=
function
(
tcno
)
{
generator
.
isValidTCNo
=
function
(
tcno
)
{
var
re
=
/^
([
1-9
]{1}[
0-9
]{9}[
0,2,4,6,8
]{1})
$/i
;
var
re
=
/^
([
1-9
]{1}[
0-9
]{9}[
0,2,4,6,8
]{1})
$/i
;
return
re
.
test
(
tcno
);
return
re
.
test
(
tcno
);
};
};
...
@@ -271,7 +268,7 @@ form_generator.factory('Generator', function ($http, $q, $log, $location, $modal
...
@@ -271,7 +268,7 @@ form_generator.factory('Generator', function ($http, $q, $log, $location, $modal
* @returns: returns value for modal
* @returns: returns value for modal
*/
*/
form_generator
.
controller
(
'ModalCtrl'
,
function
(
$scope
,
$modalInstance
,
Generator
,
$route
,
items
)
{
form_generator
.
controller
(
'ModalCtrl'
,
function
(
$scope
,
$modalInstance
,
Generator
,
items
)
{
angular
.
forEach
(
items
,
function
(
value
,
key
)
{
angular
.
forEach
(
items
,
function
(
value
,
key
)
{
$scope
[
key
]
=
items
[
key
];
$scope
[
key
]
=
items
[
key
];
});
});
...
@@ -283,7 +280,7 @@ form_generator.controller('ModalCtrl', function ($scope, $modalInstance, Generat
...
@@ -283,7 +280,7 @@ form_generator.controller('ModalCtrl', function ($scope, $modalInstance, Generat
console
.
log
(
form
.
$valid
);
console
.
log
(
form
.
$valid
);
//if(form.$valid){
//if(form.$valid){
// todo: change to if form valid
// todo: change to if form valid
if
(
1
==
1
)
{
if
(
1
==
=
1
)
{
// send form to modalinstance result function
// send form to modalinstance result function
$modalInstance
.
close
(
$scope
);
$modalInstance
.
close
(
$scope
);
...
@@ -311,17 +308,17 @@ form_generator.directive('modalForNodes', function ($modal) {
...
@@ -311,17 +308,17 @@ form_generator.directive('modalForNodes', function ($modal) {
size
:
'lg'
,
size
:
'lg'
,
resolve
:
{
resolve
:
{
items
:
function
()
{
items
:
function
()
{
var
attribs
=
attributes
[
'modalForNodes'
]
.
split
(
','
);
var
attribs
=
attributes
.
modalForNodes
.
split
(
','
);
// get node from parent scope catch with attribute
// get node from parent scope catch with attribute
var
node
=
angular
.
copy
(
scope
.
$parent
[
attribs
[
1
]][
attribs
[
0
]]);
var
node
=
angular
.
copy
(
scope
.
$parent
[
attribs
[
1
]][
attribs
[
0
]]);
if
(
attribs
[
2
]
==
'add'
)
{
if
(
attribs
[
2
]
===
'add'
)
{
node
.
model
=
{};
node
.
model
=
{};
}
}
if
(
attribs
[
3
])
{
if
(
attribs
[
3
])
{
// if listnode catch edit object with index
// if listnode catch edit object with index
node
.
model
=
node
.
model
[
attribs
[
3
]];
node
.
model
=
node
.
model
[
attribs
[
3
]];
}
}
// tell result.then function which item to edit
// tell result.then function which item to edit
...
@@ -334,12 +331,12 @@ form_generator.directive('modalForNodes', function ($modal) {
...
@@ -334,12 +331,12 @@ form_generator.directive('modalForNodes', function ($modal) {
modalInstance
.
result
.
then
(
function
(
childmodel
,
key
)
{
modalInstance
.
result
.
then
(
function
(
childmodel
,
key
)
{
if
(
childmodel
.
schema
.
formType
==
'Node'
)
{
if
(
childmodel
.
schema
.
formType
==
=
'Node'
)
{
scope
.
$parent
[
childmodel
.
schema
.
formType
][
childmodel
.
schema
.
model_name
].
model
=
childmodel
.
model
;
scope
.
$parent
[
childmodel
.
schema
.
formType
][
childmodel
.
schema
.
model_name
].
model
=
childmodel
.
model
;
}
}
if
(
childmodel
.
schema
.
formType
==
'ListNode'
)
{
if
(
childmodel
.
schema
.
formType
==
=
'ListNode'
)
{
if
(
childmodel
.
edit
)
{
if
(
childmodel
.
edit
)
{
scope
.
$parent
[
childmodel
.
schema
.
formType
][
childmodel
.
schema
.
model_name
].
model
[
childmodel
.
edit
]
=
childmodel
.
model
;
scope
.
$parent
[
childmodel
.
schema
.
formType
][
childmodel
.
schema
.
model_name
].
model
[
childmodel
.
edit
]
=
childmodel
.
model
;
}
else
{
}
else
{
scope
.
$parent
[
childmodel
.
schema
.
formType
][
childmodel
.
schema
.
model_name
].
model
.
push
(
childmodel
.
model
);
scope
.
$parent
[
childmodel
.
schema
.
formType
][
childmodel
.
schema
.
model_name
].
model
.
push
(
childmodel
.
model
);
...
@@ -350,7 +347,7 @@ form_generator.directive('modalForNodes', function ($modal) {
...
@@ -350,7 +347,7 @@ form_generator.directive('modalForNodes', function ($modal) {
});
});
});
});
}
}
}
}
;
});
});
...
@@ -384,7 +381,7 @@ form_generator.directive('addModalForLinkedModel', function ($modal, Generator)
...
@@ -384,7 +381,7 @@ form_generator.directive('addModalForLinkedModel', function ($modal, Generator)
});
});
});
});
}
}
}
}
;
});
});
/**
/**
...
@@ -419,5 +416,5 @@ form_generator.directive('editModalForLinkedModel', function ($modal, Generator)
...
@@ -419,5 +416,5 @@ form_generator.directive('editModalForLinkedModel', function ($modal, Generator)
});
});
});
});
}
}
}
}
;
});
});
\ No newline at end of file
app/zetalib/forms/form_service_test.js
View file @
5249a046
...
@@ -14,6 +14,14 @@ describe('form service module', function () {
...
@@ -14,6 +14,14 @@ describe('form service module', function () {
describe
(
'form service'
,
function
()
{
describe
(
'form service'
,
function
()
{
it
(
'should generate url'
,
inject
([
'Generator'
,
function
(
Generator
)
{
expect
(
Generator
.
group
).
not
.
toBe
(
null
);
var
generated_url
=
Generator
.
makeUrl
(
'test'
);
expect
(
generated_url
).
toEqual
(
"http://api.ulakbus.net/test"
);
}])
);
it
(
'should generate form'
,
inject
([
'Generator'
,
it
(
'should generate form'
,
inject
([
'Generator'
,
function
(
Generator
)
{
function
(
Generator
)
{
expect
(
Generator
.
generate
).
not
.
toBe
(
null
);
expect
(
Generator
.
generate
).
not
.
toBe
(
null
);
...
@@ -59,6 +67,51 @@ describe('form service module', function () {
...
@@ -59,6 +67,51 @@ describe('form service module', function () {
}])
}])
);
);
it
(
'should prepare form items'
,
inject
([
'Generator'
,
function
(
Generator
)
{
expect
(
Generator
.
prepareFormItems
).
not
.
toBe
(
null
);
var
scope
=
{
form
:
[
'email'
,
'id'
,
'name'
],
schema
:
{
properties
:
{
email
:
{
title
:
'email'
,
type
:
'email'
},
id
:
{
title
:
'id'
,
type
:
'int'
},
name
:
{
title
:
'name'
,
type
:
'string'
}
},
required
:
[],
type
:
'object'
,
title
:
'servicetest'
},
model
:
{
email
:
'test@test.com'
,
id
:
2
,
name
:
'travolta'
}
};
var
form_json
=
{
form
:
[
'email'
,
'id'
,
'name'
],
schema
:
{
properties
:
{
email
:
{
title
:
'email'
,
type
:
'email'
},
id
:
{
title
:
'id'
,
type
:
'number'
},
name
:
{
title
:
'name'
,
type
:
'string'
}
},
required
:
[],
type
:
'object'
,
title
:
'servicetest'
},
model
:
{
email
:
'test@test.com'
,
id
:
2
,
name
:
'travolta'
},
};
var
form_generated
=
Generator
.
prepareFormItems
(
scope
);
expect
(
form_generated
).
toEqual
(
form_json
);
}])
);
it
(
'should format date'
,
inject
([
'Generator'
,
function
(
Generator
)
{
expect
(
Generator
.
dateformatter
).
not
.
toBe
(
null
);
var
generated_date
=
Generator
.
dateformatter
(
'2001-01-01T01:00:00Z'
);
expect
(
generated_date
).
toEqual
(
'1.0.2001'
);
}])
);
it
(
'should group form'
,
inject
([
'Generator'
,
it
(
'should group form'
,
inject
([
'Generator'
,
function
(
Generator
)
{
function
(
Generator
)
{
expect
(
Generator
.
group
).
not
.
toBe
(
null
);
expect
(
Generator
.
group
).
not
.
toBe
(
null
);
...
@@ -112,7 +165,71 @@ describe('form service module', function () {
...
@@ -112,7 +165,71 @@ describe('form service module', function () {
})
})
);
);
it
(
'should post form'
,
it
(
'should get list'
,
inject
(
function
(
Generator
,
$httpBackend
,
RESTURL
)
{
$httpBackend
.
expectPOST
(
RESTURL
.
url
+
'test'
,
{
cmd
:
'list'
})
.
respond
(
200
,
{
items
:
{
"client_cmd"
:
"list_objects"
,
"objects"
:
[
{
"data"
:
{
"ad"
:
"firstname"
,
"tckn"
:
"12345678910"
,
"timestamp"
:
1444133895215881
,
"soyad"
:
"lastname"
,
"deleted"
:
false
,
"cep_telefonu"
:
"05552223333"
},
"key"
:
"4MsKRH9435cdKOzKCITNPml5bhB"
}],
"is_login"
:
true
,
"nobjects"
:[
[
"Ad
\
u0131"
,
"Soyad
\
u0131"
,
"TC No"
,
"Durum"
],
[
"4MsKRH9435cdKOzKCITNPml5bhB"
,
"firstname"
,
"lastname"
,
"dksoap"
,
false
]
],
"token"
:
"0122b2843f504c15821bc25a90aa1370"
}
});
var
cred
=
{
cmd
:
'list'
};
Generator
.
get_list
({
url
:
'test'
,
form_params
:
cred
})
.
then
(
function
(
data
)
{
expect
(
data
.
data
.
items
.
token
).
toEqual
(
"0122b2843f504c15821bc25a90aa1370"
);
});
$httpBackend
.
flush
();
})
);
it
(
'should get single item'
,
inject
(
function
(
Generator
,
$httpBackend
,
RESTURL
)
{
$httpBackend
.
expectPOST
(
RESTURL
.
url
+
'test'
,
{
cmd
:
'show'
})
.
respond
(
200
,
{
items
:
{
"client_cmd"
:
"show_object"
,
"object"
:
{
"ad"
:
"name"
,
"soyad"
:
"lastname"
,
},
"token"
:
"da73993f439549e7855fd82deafbbc99"
,
"is_login"
:
true
}
});
var
cred
=
{
cmd
:
'show'
};
Generator
.
get_list
({
url
:
'test'
,
form_params
:
cred
})
.
then
(
function
(
data
)
{
expect
(
data
.
data
.
items
.
token
).
toEqual
(
"da73993f439549e7855fd82deafbbc99"
);
});
$httpBackend
.
flush
();
})
);
it
(
'should submit form'
,
inject
(
function
(
Generator
,
$httpBackend
,
RESTURL
)
{
inject
(
function
(
Generator
,
$httpBackend
,
RESTURL
)
{
$httpBackend
.
expectPOST
(
RESTURL
.
url
+
'student/add'
)
$httpBackend
.
expectPOST
(
RESTURL
.
url
+
'student/add'
)
...
@@ -189,4 +306,44 @@ describe('form service module', function () {
...
@@ -189,4 +306,44 @@ describe('form service module', function () {
);
);
});
});
var
$controller
;
beforeEach
(
inject
(
function
(
_$controller_
)
{
$controller
=
_$controller_
;
}));
describe
(
'form service modal controller'
,
function
()
{
it
(
'should have ModalCtrl'
,
inject
(
function
(
$controller
)
{
expect
(
$controller
).
toBeDefined
();
}));
});
// here begin the directive tests
var
compile
,
scope
,
directiveElem
;
beforeEach
(
function
(){
inject
(
function
(
$compile
,
$rootScope
){
compile
=
$compile
;
scope
=
$rootScope
.
$new
();
});
// directiveElem = getCompiledElement();
});
function
getCompiledElement
(){
var
element
=
angular
.
element
(
'<div modal-for-nodes="Personel,ListNode,add"></div>'
);
var
compiledElement
=
compile
(
element
)(
scope
);
scope
.
$digest
();
return
compiledElement
;
}
describe
(
'modal for nodes directive'
,
function
()
{
it
(
'should have div element'
,
function
()
{
var
modalElement
=
getCompiledElement
().
find
(
'div'
);
expect
(
modalElement
).
toBeDefined
();
expect
(
modalElement
.
html
()).
not
.
toEqual
(
''
);
});
});
});
});
\ No newline at end of file
karma.conf.js
View file @
5249a046
...
@@ -73,11 +73,25 @@ module.exports = function (config) {
...
@@ -73,11 +73,25 @@ module.exports = function (config) {
preprocessors
:
{
preprocessors
:
{
'app/app.js'
:
[
'coverage'
],
'app/app.js'
:
[
'coverage'
],
'app/components/**/*.js'
:
[
'coverage'
],
'app/components/auth/*.js'
:
[
'coverage'
],
'app/components/crud/*.js'
:
[
'coverage'
],
'app/components/dashboard/*.js'
:
[
'coverage'
],
'app/components/version/*.js'
:
[
'coverage'
],
'app/zetalib/**/*.js'
:
[
'coverage'
]
'app/zetalib/**/*.js'
:
[
'coverage'
]
},
},
coverageReporter
:
{
coverageReporter
:
{
check
:
{
global
:
{
statements
:
60
,
branches
:
10
,
functions
:
60
,
lines
:
60
,
excludes
:
[
'app/components/uitemplates/*.js'
,
]
}
},
type
:
'html'
,
type
:
'html'
,
dir
:
'coverage/'
dir
:
'coverage/'
}
}
...
...
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