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
f8d98a0a
Commit
f8d98a0a
authored
Jun 09, 2015
by
Evren Kutar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
form_diff function and test
parent
b6e2cadc
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
80 additions
and
10 deletions
+80
-10
app.js
app/app.js
+1
-0
index.html
app/index.html
+1
-0
login.js
app/login/login.js
+2
-1
general.js
app/zlib/general.js
+25
-0
general_test.js
app/zlib/general_test.js
+40
-0
karma.conf.js
karma.conf.js
+11
-9
No files found.
app/app.js
View file @
f8d98a0a
...
@@ -7,6 +7,7 @@ angular.module(
...
@@ -7,6 +7,7 @@ angular.module(
'ngSanitize'
,
'ngSanitize'
,
'ngAnimate'
,
'ngAnimate'
,
'ngQuantum'
,
'ngQuantum'
,
'general'
,
'zaerp.dashboard'
,
'zaerp.dashboard'
,
'zaerp.login'
,
'zaerp.login'
,
'zaerp.version'
,
'zaerp.version'
,
...
...
app/index.html
View file @
f8d98a0a
...
@@ -97,6 +97,7 @@
...
@@ -97,6 +97,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=
"zlib/general.js"
></script>
<!-- login js -->
<!-- login js -->
...
...
app/login/login.js
View file @
f8d98a0a
...
@@ -11,7 +11,7 @@ login.config(['$routeProvider', function ($routeProvider) {
...
@@ -11,7 +11,7 @@ login.config(['$routeProvider', function ($routeProvider) {
// controller: 'LoginCtrl'
// controller: 'LoginCtrl'
//});
//});
}]);
}]);
login
.
controller
(
'LoginCtrl'
,
function
(
$scope
,
$q
,
$timeout
,
$http
,
$location
,
$rootScope
,
AUTH_EVENTS
,
LoginService
)
{
login
.
controller
(
'LoginCtrl'
,
function
(
$scope
,
$q
,
$timeout
,
$http
,
$location
,
$rootScope
,
AUTH_EVENTS
,
LoginService
,
FormDiff
)
{
$scope
.
schema
=
$scope
.
schema
=
{
{
title
:
"Login"
,
title
:
"Login"
,
...
@@ -74,6 +74,7 @@ login.controller('LoginCtrl', function ($scope, $q, $timeout, $http, $location,
...
@@ -74,6 +74,7 @@ login.controller('LoginCtrl', function ($scope, $q, $timeout, $http, $location,
}
}
];
];
$scope
.
onSubmit
=
function
(
form
){
$scope
.
onSubmit
=
function
(
form
){
console
.
log
(
FormDiff
.
get_diff
({
adad
:
2
,
adada
:
3
},{
adad
:
2
,
adada
:
4
}));
$scope
.
$broadcast
(
'schemaFormValidate'
);
$scope
.
$broadcast
(
'schemaFormValidate'
);
if
(
form
.
$valid
){
if
(
form
.
$valid
){
var
credentials
=
{
email
:
form
.
email
.
$modelValue
,
password
:
form
.
password
.
$modelValue
};
var
credentials
=
{
email
:
form
.
email
.
$modelValue
,
password
:
form
.
password
.
$modelValue
};
...
...
app/zlib/general.js
0 → 100644
View file @
f8d98a0a
/**
* Created by Evren Kutar on 09/06/15.
*/
//angular.module('FormDiff', [])
/**
* service to return form diff for all form submits
*/
var
general
=
angular
.
module
(
'general'
,
[]);
general
.
factory
(
'FormDiff'
,
function
(){
var
formDiff
=
{};
formDiff
.
get_diff
=
function
(
obj1
,
obj2
)
{
var
result
=
{};
for
(
key
in
obj1
)
{
if
(
obj2
[
key
]
!=
obj1
[
key
])
result
[
key
]
=
obj2
[
key
];
if
(
typeof
obj2
[
key
]
==
'array'
&&
typeof
obj1
[
key
]
==
'array'
)
result
[
key
]
=
arguments
.
callee
(
obj1
[
key
],
obj2
[
key
]);
if
(
typeof
obj2
[
key
]
==
'object'
&&
typeof
obj1
[
key
]
==
'object'
)
result
[
key
]
=
arguments
.
callee
(
obj1
[
key
],
obj2
[
key
]);
}
return
result
;
}
return
formDiff
;
});
\ No newline at end of file
app/zlib/general_test.js
0 → 100644
View file @
f8d98a0a
/**
* Created by Evren Kutar on 09/06/15.
*/
'use strict'
;
describe
(
'general module'
,
function
()
{
beforeEach
(
module
(
'general'
));
describe
(
'form diff factory'
,
function
()
{
it
(
'should return diff object'
,
inject
([
'FormDiff'
,
function
(
FormDiff
)
{
expect
(
FormDiff
.
get_diff
).
not
.
toBe
(
null
);
// test cases - testing for success
var
same_json
=
[
{
email
:
'test@test.com'
,
id
:
2
,
name
:
'travolta'
},
{
email
:
'test@test.com'
,
id
:
2
,
name
:
'travolta'
}
];
// test cases - testing for failure
var
different_json
=
[
{
email
:
'test@test.com'
,
id
:
2
,
name
:
'travolta'
},
{
email
:
'test1@test.com'
,
id
:
2
,
name
:
'john'
}
];
var
diff
=
{
email
:
'test1@test.com'
,
name
:
'john'
};
var
nodiff
=
{};
var
same
=
FormDiff
.
get_diff
(
same_json
[
0
],
same_json
[
1
]);
expect
(
same
).
toEqual
(
nodiff
);
var
different
=
FormDiff
.
get_diff
(
different_json
[
0
],
different_json
[
1
]);
expect
(
different
).
toEqual
(
diff
);
}])
);
});
});
\ No newline at end of file
karma.conf.js
View file @
f8d98a0a
...
@@ -15,24 +15,26 @@ module.exports = function (config) {
...
@@ -15,24 +15,26 @@ module.exports = function (config) {
'app/bower_components/angular-mocks/angular-mocks.js'
,
'app/bower_components/angular-mocks/angular-mocks.js'
,
'app/app.js'
,
'app/app.js'
,
'app/components/**/*.js'
,
'app/components/**/*.js'
,
'app/zlib/*.js'
,
'app/login/*.js'
,
'app/login/*.js'
,
'app/dashboard/*.js'
'app/dashboard/*.js'
],
],
preprocessors
:
{
//preprocessors: {
//'app/app.js': 'coverage',
// 'app/app.js': 'coverage',
'app/components/**/*.js'
:
'coverage'
,
// 'app/components/**/*.js': 'coverage',
'app/login/*.js'
:
'coverage'
,
// 'app/zlib/*.js': 'coverage',
'app/dashboard/*.js'
:
'coverage'
// 'app/login/*.js': 'coverage',
},
// 'app/dashboard/*.js': 'coverage'
//},
reporters
:
[
'coverage'
],
//
//reporters: ['coverage'],
autoWatch
:
true
,
autoWatch
:
true
,
frameworks
:
[
'jasmine'
],
frameworks
:
[
'jasmine'
],
browsers
:
[
'Chrome
Canary
'
],
browsers
:
[
'Chrome'
],
plugins
:
[
plugins
:
[
'karma-chrome-launcher'
,
'karma-chrome-launcher'
,
...
...
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