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
4da02b24
Commit
4da02b24
authored
Oct 09, 2015
by
Erkan Öğümsöğütlü
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://github.com/zetaops/ulakbus-ui
parents
56bdca8c
95b88046
Changes
31
Hide whitespace changes
Inline
Side-by-side
Showing
31 changed files
with
360 additions
and
650 deletions
+360
-650
Gruntfile.js
Gruntfile.js
+1
-1
VERSION
VERSION
+1
-0
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
directives.js
app/shared/directives.js
+33
-25
header-notification.html
app/shared/templates/directives/header-notification.html
+20
-20
form_service.js
app/zetalib/forms/form_service.js
+36
-39
form_service_test.js
app/zetalib/forms/form_service_test.js
+158
-1
bower.json
bower.json
+6
-6
karma.conf.js
karma.conf.js
+15
-1
No files found.
Gruntfile.js
View file @
4da02b24
...
...
@@ -329,6 +329,6 @@ module.exports = function (grunt) {
'preprocess:prod_branch'
,
'html2js:prod_branch'
,
'uglify:branch'
])
])
;
});
};
\ No newline at end of file
VERSION
0 → 100644
View file @
4da02b24
0.1.2
\ No newline at end of file
app/app.js
View file @
4da02b24
...
...
@@ -24,7 +24,7 @@ var app = angular.module(
'ulakbus.version'
,
'schemaForm'
,
'gettext'
,
//'templates-dev
',
'ulakbus.uitemplates
'
,
]).
/**
* RESTURL is the url of rest api to talk
...
...
app/components/auth/auth_service.js
View file @
4da02b24
...
...
@@ -9,7 +9,7 @@
// 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
=
{};
loginService
.
login
=
function
(
url
,
credentials
)
{
...
...
@@ -22,35 +22,18 @@ auth.factory('LoginService', function ($http, $rootScope, $location, $log, $cook
$rootScope
.
loggedInUser
=
true
;
})
.
error
(
function
(
data
,
status
,
headers
,
config
)
{
// Erase the token if the user fails to log in
//delete $window.sessionStorage.token;
// Handle login errors here
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
()
{
console
.
log
(
"logout"
);
$http
.
post
(
RESTURL
.
url
+
'logout'
,
{}).
then
(
function
()
{
loginService
.
logout
=
function
()
{
$log
.
info
(
"logout"
);
return
$http
.
post
(
RESTURL
.
url
+
'logout'
,
{}).
success
(
function
(
data
)
{
$rootScope
.
loggedInUser
=
false
;
$location
.
path
(
"/login"
);
});
console
.
log
(
"loggedout"
);
$log
.
info
(
"loggedout"
);
};
...
...
app/components/auth/auth_test.js
View file @
4da02b24
...
...
@@ -7,8 +7,6 @@
'use strict'
;
// TODO: fill up the test cases correctly
describe
(
'ulakbus.auth module'
,
function
()
{
// load dependencies of modules e.g REST_URL
...
...
@@ -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
});
...
...
@@ -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',
// inject(function ($httpBackend, $http, $location, $window) {
//
// $httpBackend.whenGET('http://127.0.0.1:8000/#/dashboard').respond(401, '');
//
// $http.get('http://127.0.0.1:8000/#/dashboard');
// expect($window.location == '/#/login');
//
// $httpBackend.flush();
// })
//);
// use httpBackend to imitate login api
$httpBackend
.
expectPOST
(
RESTURL
.
url
+
'logout'
,
{})
.
respond
(
200
,
{
is_login
:
false
});
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 @
56bdca8c
/**
* 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 @
4da02b24
...
...
@@ -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
)
{
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 @
4da02b24
...
...
@@ -11,8 +11,8 @@
angular
.
module
(
'ulakbus.dashboard'
,
[
'ngRoute'
])
.
controller
(
'DashCtrl'
,
function
(
$scope
,
$rootScope
,
$location
)
{
$scope
.
section
=
function
(
section_index
)
{
.
controller
(
'DashCtrl'
,
function
(
$scope
,
$rootScope
)
{
$scope
.
section
=
function
(
section_index
)
{
$rootScope
.
section
=
section_index
;
}
}
;
});
\ No newline at end of file
app/components/dashboard/dashboard_test.js
View file @
4da02b24
...
...
@@ -3,4 +3,37 @@
*
* This file is licensed under the GNU General Public License v3
* (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 @
56bdca8c
<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 @
56bdca8c
/**
* 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 @
56bdca8c
/**
* 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 @
56bdca8c
/**
* 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 @
56bdca8c
<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 @
56bdca8c
<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 @
56bdca8c
<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 @
56bdca8c
<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 @
56bdca8c
<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 @
56bdca8c
/**
* 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 @
56bdca8c
<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 @
56bdca8c
/**
* 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 @
56bdca8c
<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 @
4da02b24
...
...
@@ -5,4 +5,4 @@ angular.module('ulakbus.version', [
'ulakbus.version.version-directive'
])
.
value
(
'version'
,
'0.
3
.0'
);
.
value
(
'version'
,
'0.
1
.0'
);
app/components/version/version_test.js
View file @
4da02b24
...
...
@@ -5,7 +5,7 @@ describe('ulakbus.version module', function() {
describe
(
'version service'
,
function
()
{
it
(
'should return current version'
,
inject
(
function
(
version
)
{
expect
(
version
).
toEqual
(
'0.
3
'
);
expect
(
version
).
toEqual
(
'0.
1.0
'
);
}));
});
});
app/index.html
View file @
4da02b24
...
...
@@ -99,8 +99,8 @@
<script
src=
"components/auth/auth_service.js"
></script>
<script
src=
"components/dashboard/dashboard_controller.js"
></script>
<script
src=
"components/crud/crud_controller.js"
></script>
<script
src=
"components/
staff/staff_controller
.js"
></script>
<
script
src=
"components/student/student_controller.js"
></script
>
<script
src=
"components/
uitemplates/uitemplates
.js"
></script>
<
!--<script src="components/student/student_controller.js"></script>--
>
<script
src=
"components/version/interpolate-filter.js"
></script>
<script
src=
"components/version/version-directive.js"
></script>
<script
src=
"components/version/version.js"
></script>
...
...
app/shared/directives.js
View file @
4da02b24
...
...
@@ -14,23 +14,30 @@ app.directive('logout', function ($http, $location, RESTURL) {
$element
.
on
(
'click'
,
function
()
{
$http
.
post
(
RESTURL
.
url
+
'logout'
,
{}).
then
(
function
()
{
$rootScope
.
loggedInUser
=
false
;
console
.
log
(
$rootScope
.
loggedInUser
);
$location
.
path
(
"/login"
);
});
});
}
}
}
;
});
/**
* headerNotification directive for header
*/
app
.
directive
(
'headerNotification'
,
function
()
{
app
.
directive
(
'headerNotification'
,
function
(
$http
,
$interval
)
{
return
{
templateUrl
:
'shared/templates/directives/header-notification.html'
,
restrict
:
'E'
,
replace
:
true
}
replace
:
true
,
link
:
function
(
$scope
)
{
$interval
(
function
()
{
// todo: change url to backend
$http
.
get
(
"http://google.com"
).
success
(
function
(
data
)
{
$scope
.
notifications
=
data
;
});
},
15000
);
}
};
});
app
.
directive
(
'headerSubMenu'
,
function
()
{
...
...
@@ -44,9 +51,9 @@ app.directive('headerSubMenu', function () {
// todo: double make it but single not solve this!
angular
.
element
(
$
(
'#submitbutton'
)).
triggerHandler
(
'click'
);
angular
.
element
(
$
(
'#submitbutton'
)).
triggerHandler
(
'click'
);
}
}
;
}
}
}
;
});
app
.
directive
(
'headerBreadcrumb'
,
function
()
{
...
...
@@ -54,7 +61,7 @@ app.directive('headerBreadcrumb', function () {
templateUrl
:
'shared/templates/directives/header-breadcrumb.html'
,
restrict
:
'E'
,
replace
:
true
}
}
;
});
app
.
directive
(
'sidebar'
,
[
'$location'
,
function
()
{
...
...
@@ -65,12 +72,12 @@ app.directive('sidebar', ['$location', function () {
scope
:
{},
controller
:
function
(
$scope
,
$rootScope
,
$http
,
RESTURL
,
$location
,
$timeout
)
{
$http
.
post
(
RESTURL
.
url
+
'crud/'
).
success
(
function
(
data
)
{
$scope
.
allMenuItems
=
data
.
app_models
;
$scope
.
allMenuItems
=
angular
.
copy
(
data
.
app_models
)
;
$scope
.
menuItems
=
[];
// angular.copy($scope.allMenuItems);
// at start define breadcrumblinks for breadcrumb
angular
.
forEach
(
data
.
app_models
,
function
(
value
,
key
)
{
angular
.
forEach
(
value
[
1
],
function
(
v
,
k
)
{
if
(
v
[
1
]
==
$location
.
path
().
split
(
'/'
)[
2
])
{
if
(
v
[
1
]
==
=
$location
.
path
().
split
(
'/'
)[
2
])
{
$rootScope
.
breadcrumblinks
=
[
value
[
0
],
v
[
0
]];
$scope
.
menuItems
=
[
$scope
.
allMenuItems
[
key
]];
}
else
{
...
...
@@ -80,17 +87,16 @@ app.directive('sidebar', ['$location', function () {
});
});
$rootScope
.
$watch
(
function
(
$rootScope
)
{
return
$rootScope
.
section
},
function
(
newindex
,
oldindex
)
{
if
(
newindex
>
-
1
)
{
$rootScope
.
$watch
(
function
(
$rootScope
)
{
return
$rootScope
.
section
;
},
function
(
newindex
,
oldindex
)
{
if
(
newindex
>
-
1
)
{
$scope
.
menuItems
=
[
$scope
.
allMenuItems
[
newindex
]];
$scope
.
collapseVar
=
1
;
$timeout
(
function
()
{
$
(
'#side-menu'
).
metisMenu
();
});
}
}
);
});
// todo: change to $watch to init
//$timeout(function () {
...
...
@@ -103,10 +109,11 @@ app.directive('sidebar', ['$location', function () {
$scope
.
check
=
function
(
x
)
{
if
(
x
==
$scope
.
collapseVar
)
if
(
x
==
=
$scope
.
collapseVar
)
{
$scope
.
collapseVar
=
0
;
else
}
else
{
$scope
.
collapseVar
=
x
;
}
};
...
...
@@ -119,14 +126,15 @@ app.directive('sidebar', ['$location', function () {
$scope
.
multiCheck
=
function
(
y
)
{
if
(
y
==
$scope
.
multiCollapseVar
)
if
(
y
==
=
$scope
.
multiCollapseVar
)
{
$scope
.
multiCollapseVar
=
0
;
else
}
else
{
$scope
.
multiCollapseVar
=
y
;
}
};
}
}
}
;
}]);
app
.
directive
(
'stats'
,
function
()
{
...
...
@@ -145,7 +153,7 @@ app.directive('stats', function () {
'goto'
:
'@'
}
}
}
;
});
app
.
directive
(
'notifications'
,
function
()
{
...
...
@@ -153,7 +161,7 @@ app.directive('notifications', function () {
templateUrl
:
'shared/templates/directives/notifications.html'
,
restrict
:
'E'
,
replace
:
true
,
}
}
;
});
app
.
directive
(
'sidebarSearch'
,
function
()
{
...
...
@@ -165,7 +173,7 @@ app.directive('sidebarSearch', function () {
controller
:
function
(
$scope
)
{
$scope
.
selectedMenu
=
'home'
;
}
}
}
;
});
app
.
directive
(
'timeline'
,
function
()
{
...
...
@@ -173,7 +181,7 @@ app.directive('timeline', function () {
templateUrl
:
'shared/templates/directives/timeline.html'
,
restrict
:
'E'
,
replace
:
true
,
}
}
;
});
app
.
directive
(
'chat'
,
function
()
{
...
...
@@ -181,5 +189,5 @@ app.directive('chat', function () {
templateUrl
:
'shared/templates/directives/chat.html'
,
restrict
:
'E'
,
replace
:
true
,
}
}
;
});
\ No newline at end of file
app/shared/templates/directives/header-notification.html
View file @
4da02b24
...
...
@@ -3,26 +3,26 @@
<a
class=
"dropdown-toggle"
data-toggle=
"dropdown"
>
<i
class=
"fa fa-envelope fa-fw"
></i>
<i
class=
"fa fa-caret-down"
></i>
</a>
<
!--<ul class="dropdown-menu dropdown-messages">--
>
<
!--<li>--
>
<
!--<a href="#">--
>
<
!--<div>--
>
<
!--<strong>John Smith</strong>--
>
<
!--<span class="pull-right text-muted">--
>
<
!--<em>Yesterday</em>--
>
<
!--</span>--
>
<
!--</div>--
>
<
!--<div>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque eleifend...</div>--
>
<
!--</a>--
>
<
!--</li>--
>
<
!--<li class="divider"></li>--
>
<
!--<li>--
>
<
!--<a class="text-center" href="#">--
>
<
!--<strong>Read All Messages</strong>--
>
<
!--<i class="fa fa-angle-right"></i>--
>
<
!--</a>--
>
<
!--</li>--
>
<
!--</ul>--
>
<
ul
class=
"dropdown-menu dropdown-messages"
>
<
li
>
<
a
href=
"#"
>
<
div
>
<
strong>
John Smith
</strong
>
<
span
class=
"pull-right text-muted"
>
<
em>
Yesterday
</em
>
<
/span
>
<
/div
>
<
div>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque eleifend...
</div
>
<
/a
>
<
/li
>
<
li
class=
"divider"
></li
>
<
li
>
<
a
class=
"text-center"
href=
"#"
>
<
strong>
Read All Messages
</strong
>
<
i
class=
"fa fa-angle-right"
></i
>
<
/a
>
<
/li
>
<
/ul
>
<!-- /.dropdown-messages -->
</li>
<!-- /.dropdown -->
...
...
app/zetalib/forms/form_service.js
View file @
4da02b24
...
...
@@ -7,7 +7,7 @@
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
=
{};
generator
.
makeUrl
=
function
(
url
)
{
return
RESTURL
.
url
+
url
;
...
...
@@ -35,7 +35,7 @@ form_generator.factory('Generator', function ($http, $q, $log, $location, $modal
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
// 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
angular
.
forEach
(
scope
.
schema
.
properties
,
function
(
k
,
v
)
{
// 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'
;
scope
.
model
[
v
]
=
generator
.
dateformatter
(
scope
.
model
[
v
]);
// seek for datepicker field and initialize datepicker
//scope.$watch($('#' + v), function () {
$timeout
(
function
()
{
jQuery
(
'#'
+
v
).
datepicker
({
changeMonth
:
true
,
changeYear
:
true
,
dateFormat
:
"dd.mm.yy"
,
onSelect
:
function
(
date
)
{
scope
.
model
[
v
]
=
date
;
}
});
$timeout
(
function
()
{
jQuery
(
'#'
+
v
).
datepicker
({
changeMonth
:
true
,
changeYear
:
true
,
dateFormat
:
"dd.mm.yy"
,
onSelect
:
function
(
date
)
{
scope
.
model
[
v
]
=
date
;
}
});
//
});
});
}
if
(
k
.
type
==
'int'
||
k
.
type
==
'float'
)
{
if
(
k
.
type
==
=
'int'
||
k
.
type
=
==
'float'
)
{
k
.
type
=
'number'
;
}
// 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
modelscope
=
{
"url"
:
scope
.
url
,
"form_params"
:
{
model
:
k
.
model_name
}};
...
...
@@ -93,7 +90,7 @@ form_generator.factory('Generator', function ($http, $q, $log, $location, $modal
angular
.
forEach
(
res
.
data
.
objects
,
function
(
item
)
{
formitem
.
titleMap
.
push
({
"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
//}
}
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
]
=
{
title
:
k
.
title
,
...
...
@@ -131,8 +128,8 @@ form_generator.factory('Generator', function ($http, $q, $log, $location, $modal
url
:
scope
.
url
};
if
(
scope
.
model
[
v
]
==
null
)
{
scope
[
k
.
type
][
v
].
model
=
k
.
type
==
'Node'
?
{}
:
[];
if
(
scope
.
model
[
v
]
==
=
null
)
{
scope
[
k
.
type
][
v
].
model
=
k
.
type
==
=
'Node'
?
{}
:
[];
}
else
{
scope
[
k
.
type
][
v
].
model
=
scope
.
model
[
v
];
}
...
...
@@ -141,12 +138,12 @@ form_generator.factory('Generator', function ($http, $q, $log, $location, $modal
scope
[
k
.
type
][
v
].
schema
.
properties
[
item
.
name
]
=
item
;
// 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
);
}
// 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'
});
}
else
{
scope
[
k
.
type
][
v
].
form
.
push
(
item
.
name
);
...
...
@@ -165,8 +162,8 @@ form_generator.factory('Generator', function ($http, $q, $log, $location, $modal
};
generator
.
dateformatter
=
function
(
formObject
)
{
var
ndate
=
new
Date
(
formObject
);
if
(
ndate
==
'Invalid Date'
)
{
return
''
if
(
ndate
==
=
'Invalid Date'
)
{
return
''
;
}
var
newdatearray
=
[
ndate
.
getDate
(),
ndate
.
getMonth
(),
ndate
.
getFullYear
()];
return
newdatearray
.
join
(
'.'
);
...
...
@@ -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
;
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
;
return
re
.
test
(
tcno
);
};
...
...
@@ -271,7 +268,7 @@ form_generator.factory('Generator', function ($http, $q, $log, $location, $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
)
{
$scope
[
key
]
=
items
[
key
];
});
...
...
@@ -283,7 +280,7 @@ form_generator.controller('ModalCtrl', function ($scope, $modalInstance, Generat
console
.
log
(
form
.
$valid
);
//if(form.$valid){
// todo: change to if form valid
if
(
1
==
1
)
{
if
(
1
==
=
1
)
{
// send form to modalinstance result function
$modalInstance
.
close
(
$scope
);
...
...
@@ -311,17 +308,17 @@ form_generator.directive('modalForNodes', function ($modal) {
size
:
'lg'
,
resolve
:
{
items
:
function
()
{
var
attribs
=
attributes
[
'modalForNodes'
]
.
split
(
','
);
var
attribs
=
attributes
.
modalForNodes
.
split
(
','
);
// get node from parent scope catch with attribute
var
node
=
angular
.
copy
(
scope
.
$parent
[
attribs
[
1
]][
attribs
[
0
]]);
if
(
attribs
[
2
]
==
'add'
)
{
if
(
attribs
[
2
]
===
'add'
)
{
node
.
model
=
{};
}
if
(
attribs
[
3
])
{
if
(
attribs
[
3
])
{
// 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
...
...
@@ -334,12 +331,12 @@ form_generator.directive('modalForNodes', function ($modal) {
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
;
}
if
(
childmodel
.
schema
.
formType
==
'ListNode'
)
{
if
(
childmodel
.
edit
)
{
if
(
childmodel
.
schema
.
formType
==
=
'ListNode'
)
{
if
(
childmodel
.
edit
)
{
scope
.
$parent
[
childmodel
.
schema
.
formType
][
childmodel
.
schema
.
model_name
].
model
[
childmodel
.
edit
]
=
childmodel
.
model
;
}
else
{
scope
.
$parent
[
childmodel
.
schema
.
formType
][
childmodel
.
schema
.
model_name
].
model
.
push
(
childmodel
.
model
);
...
...
@@ -350,7 +347,7 @@ form_generator.directive('modalForNodes', function ($modal) {
});
});
}
}
}
;
});
...
...
@@ -384,7 +381,7 @@ form_generator.directive('addModalForLinkedModel', 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 @
4da02b24
...
...
@@ -14,6 +14,14 @@ describe('form service module', 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'
,
function
(
Generator
)
{
expect
(
Generator
.
generate
).
not
.
toBe
(
null
);
...
...
@@ -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'
,
function
(
Generator
)
{
expect
(
Generator
.
group
).
not
.
toBe
(
null
);
...
...
@@ -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
)
{
$httpBackend
.
expectPOST
(
RESTURL
.
url
+
'student/add'
)
...
...
@@ -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
bower.json
View file @
4da02b24
...
...
@@ -6,13 +6,13 @@
"license"
:
"GPL"
,
"private"
:
false
,
"dependencies"
:
{
"angular"
:
"1.3.
x
"
,
"angular"
:
"1.3.
20
"
,
"json3"
:
"~3.3.2"
,
"es5-shim"
:
"~4.1.10"
,
"angular-mocks"
:
"1.3.
x
"
,
"angular-route"
:
"1.3.
x
"
,
"angular-resource"
:
"1.3.
x
"
,
"angular-cookies"
:
"1.3.
x
"
,
"angular-mocks"
:
"1.3.
20
"
,
"angular-route"
:
"1.3.
20
"
,
"angular-resource"
:
"1.3.
20
"
,
"angular-cookies"
:
"1.3.
20
"
,
"angular-bootstrap"
:
"0.13.1"
,
"font-awesome"
:
"4.3.0"
,
"angular-schema-form"
:
"0.8.3"
,
...
...
@@ -24,6 +24,6 @@
"angular-gettext"
:
"2.1.0"
},
"resolutions"
:
{
"angular"
:
"1.3.
19
"
"angular"
:
"1.3.
20
"
}
}
karma.conf.js
View file @
4da02b24
...
...
@@ -73,11 +73,25 @@ module.exports = function (config) {
preprocessors
:
{
'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'
]
},
coverageReporter
:
{
check
:
{
global
:
{
statements
:
60
,
branches
:
10
,
functions
:
60
,
lines
:
60
,
excludes
:
[
'app/components/uitemplates/*.js'
,
]
}
},
type
:
'html'
,
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