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
d4607e1d
Commit
d4607e1d
authored
Jan 27, 2016
by
Evren Kutar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ADD fixes GH-76 rfix #5065 button_switch function
parent
8b45d19c
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
65 additions
and
31 deletions
+65
-31
auth_controller.js
app/components/auth/auth_controller.js
+2
-0
auth_test.js
app/components/auth/auth_test.js
+17
-14
form_service.js
app/zetalib/form_service.js
+37
-10
form_service_test.js
app/zetalib/form_service_test.js
+6
-6
karma.conf.js
karma.conf.js
+3
-1
No files found.
app/components/auth/auth_controller.js
View file @
d4607e1d
...
...
@@ -42,6 +42,7 @@ angular.module('ulakbus.auth', ['ngRoute', 'ngCookies'])
if
(
form
.
$valid
)
{
$scope
.
loggingIn
=
true
;
$rootScope
.
loginAttempt
=
1
;
Generator
.
button_switch
(
false
);
AuthService
.
login
(
$scope
.
url
,
$scope
.
model
)
.
error
(
function
(
data
)
{
$scope
.
message
=
data
.
title
;
...
...
@@ -49,6 +50,7 @@ angular.module('ulakbus.auth', ['ngRoute', 'ngCookies'])
})
.
then
(
function
()
{
$scope
.
loggingIn
=
false
;
Generator
.
button_switch
(
false
);
})
}
else
{
...
...
app/components/auth/auth_test.js
View file @
d4607e1d
...
...
@@ -10,26 +10,30 @@
describe
(
'ulakbus.auth module'
,
function
()
{
// load dependencies of modules e.g REST_URL
beforeEach
(
module
(
'ulakbus'
));
beforeEach
(
module
(
'ulakbus.auth'
));
describe
(
'login controller and service'
,
function
()
{
var
$controller
;
var
$rootScope
;
it
(
'should have a login controller'
,
inject
(
function
(
)
{
expect
(
'ulakbus.auth.LoginCtrl'
).
toBeDefined
()
;
}));
beforeEach
(
inject
(
function
(
_$controller_
)
{
$controller
=
_$controller_
;
}));
var
$controller
;
var
$rootScope
;
beforeEach
(
inject
(
function
(
$injector
)
{
$rootScope
=
$injector
.
get
(
'$rootScope'
);
}));
beforeEach
(
inject
(
function
(
_$controller_
)
{
$controller
=
_$controller_
;
}));
beforeEach
(
inject
(
function
(
$injector
)
{
$httpBackend
=
$injector
.
get
(
'$httpBackend'
);
var
authRequestHandler
=
$httpBackend
.
when
(
'GET'
,
/
\.[
0-9a-z
]
+$/i
)
.
respond
({
userId
:
'userX'
},
{
'A-Token'
:
'xxx'
});
}));
beforeEach
(
inject
(
function
(
$injector
)
{
$httpBackend
=
$injector
.
get
(
'$httpBackend'
);
$rootScope
=
$injector
.
get
(
'$rootScope'
);
describe
(
'login controller and service'
,
function
()
{
it
(
'should have a login controller'
,
inject
(
function
()
{
expect
(
'ulakbus.auth.LoginCtrl'
).
toBeDefined
();
}));
it
(
'should get login form'
,
inject
(
...
...
@@ -43,7 +47,6 @@ describe('ulakbus.auth module', function () {
var
controller
=
$controller
(
'LoginCtrl'
,
{
$scope
:
$scope
});
expect
(
$scope
.
onSubmit
).
toBeDefined
();
expect
(
$scope
.
loginForm
).
toBeDefined
();
})
);
...
...
app/zetalib/form_service.js
View file @
d4607e1d
...
...
@@ -722,6 +722,21 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
};
return
_do
[
mode
]();
};
/**
* @memberof ulakbus.formService
* @ngdoc function
* @name button_switch
* @description Changes html disabled and enabled attributes of all buttons on current page.
* @param {boolean} position
*/
generator
.
button_switch
=
function
(
position
)
{
var
buttons
=
angular
.
element
(
document
.
querySelectorAll
(
'button'
));
positions
=
{
true
:
"enabled"
,
false
:
"disabled"
};
angular
.
forEach
(
buttons
,
function
(
button
,
key
)
{
button
[
positions
[
position
]]
=
true
;
});
$log
.
debug
(
'buttons >> '
,
positions
[
position
])
}
/**
* @memberof ulakbus.formService
* @ngdoc function
...
...
@@ -731,9 +746,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @returns {*}
*/
generator
.
get_form
=
function
(
scope
)
{
generator
.
button_switch
(
false
);
return
$http
.
post
(
generator
.
makeUrl
(
scope
),
scope
.
form_params
)
.
then
(
function
(
res
)
{
generator
.
button_switch
(
true
);
return
generator
.
generate
(
scope
,
res
.
data
);
});
};
...
...
@@ -746,9 +763,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @returns {*}
*/
generator
.
get_list
=
function
(
scope
)
{
generator
.
button_switch
(
false
);
return
$http
.
post
(
generator
.
makeUrl
(
scope
),
scope
.
form_params
)
.
then
(
function
(
res
)
{
generator
.
button_switch
(
true
);
return
res
;
});
};
...
...
@@ -762,9 +781,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @returns {*}
*/
generator
.
get_wf
=
function
(
scope
)
{
generator
.
button_switch
(
false
);
return
$http
.
post
(
generator
.
makeUrl
(
scope
),
scope
.
form_params
)
.
then
(
function
(
res
)
{
generator
.
button_switch
(
true
);
if
(
res
.
data
.
client_cmd
)
{
return
generator
.
pathDecider
(
res
.
data
.
client_cmd
,
scope
,
res
.
data
);
}
...
...
@@ -906,17 +927,23 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @param {Object} obj2
* @returns {Object} diff object of two given objects
*/
generator
.
get_diff
=
function
(
o
bj1
,
obj2
)
{
generator
.
get_diff
=
function
(
o
ldObj
,
newObj
)
{
var
result
=
{};
angular
.
forEach
(
obj1
,
function
(
value
,
key
)
{
if
(
obj2
[
key
]
!=
obj1
[
key
])
{
result
[
key
]
=
angular
.
copy
(
obj1
[
key
])
}
if
(
obj2
[
key
].
constructor
===
Array
&&
obj1
[
key
].
constructor
===
Array
)
{
result
[
key
]
=
arguments
.
callee
(
obj1
[
key
],
obj2
[
key
]);
}
if
(
obj2
[
key
].
constructor
===
Object
&&
obj1
[
key
].
constructor
===
Object
)
{
result
[
key
]
=
arguments
.
callee
(
obj1
[
key
],
obj2
[
key
]);
angular
.
forEach
(
newObj
,
function
(
value
,
key
)
{
if
(
oldObj
[
key
])
{
if
((
oldObj
[
key
].
constructor
===
newObj
[
key
].
constructor
)
&&
(
newObj
[
key
].
constructor
===
Object
||
newObj
[
key
].
constructor
===
Array
))
{
angular
.
forEach
(
value
,
function
(
v
,
k
)
{
if
(
oldObj
[
key
][
k
]
!=
value
[
k
])
{
result
[
key
][
k
]
=
angular
.
copy
(
value
[
k
]);
}
});
}
else
{
if
(
oldObj
[
key
]
!=
newObj
[
key
])
{
result
[
key
]
=
angular
.
copy
(
newObj
[
key
]);
}
}
}
else
{
result
[
key
]
=
angular
.
copy
(
newObj
[
key
]);
}
});
return
result
;
...
...
app/zetalib/form_service_test.js
View file @
d4607e1d
...
...
@@ -483,8 +483,8 @@ describe('form service module', function () {
// test cases - testing for success
var
same_json
=
[
{
email
:
'test@test.com'
,
id
:
2
,
name
:
'travolta'
,
foo
:
{
'a'
:
1
},
foo2
:
[
1
,
2
,
3
]
},
{
email
:
'test@test.com'
,
id
:
2
,
name
:
'travolta'
,
foo
:
{
'a'
:
1
},
foo2
:
[
1
,
2
,
3
]
}
{
email
:
'test@test.com'
,
id
:
2
,
name
:
'travolta'
,
foo
2
:
[
1
,
2
,
3
],
foo
:
{
'a'
:
1
}
},
{
email
:
'test@test.com'
,
id
:
2
,
name
:
'travolta'
,
foo
2
:
[
1
,
2
,
3
],
foo
:
{
'a'
:
1
}
}
];
// test cases - testing for failure
...
...
@@ -511,21 +511,21 @@ describe('form service module', function () {
var
diff
=
{
email
:
'test1@test.com'
,
name
:
'john'
};
var
diff2
=
{
email
:
'test1@test.com'
,
id
:
2
,
name
:
'john'
};
var
noequal
=
{
email
:
'test1@test.com'
,
id
:
2
,
name
:
'john
'
};
var
noequal
=
{
name
:
'travolta
'
};
var
nodiff
=
{};
var
same
=
Generator
.
get_diff
(
same_json
[
0
],
same_json
[
1
]);
expect
(
same
).
toEqual
(
nodiff
);
for
(
var
json_obj
in
different_jsons
)
{
var
different
=
Generator
.
get_diff
(
different_jsons
[
json_obj
][
1
],
different_jsons
[
json_obj
][
0
]);
var
different
=
Generator
.
get_diff
(
different_jsons
[
json_obj
][
0
],
different_jsons
[
json_obj
][
1
]);
expect
(
different
).
toEqual
(
diff
);
}
var
different2
=
Generator
.
get_diff
(
different_json
[
1
],
different_json
[
0
]);
var
different2
=
Generator
.
get_diff
(
different_json
[
0
],
different_json
[
1
]);
expect
(
different2
).
toEqual
(
diff2
);
var
not_equal
=
Generator
.
get_diff
(
notEqual
[
1
],
notEqual
[
0
]);
var
not_equal
=
Generator
.
get_diff
(
notEqual
[
0
],
notEqual
[
1
]);
expect
(
not_equal
).
toEqual
(
noequal
);
})
);
...
...
karma.conf.js
View file @
d4607e1d
...
...
@@ -73,7 +73,8 @@ module.exports = function (config) {
reporters
:
[
'progress'
,
'coverage'
],
preprocessors
:
{
//'app/app.js': ['coverage'],
'app/app.js'
:
[
'coverage'
],
'app/app_routes.js'
:
[
'coverage'
],
'app/components/auth/*.js'
:
[
'coverage'
],
'app/components/crud/*.js'
:
[
'coverage'
],
'app/components/dashboard/*.js'
:
[
'coverage'
],
...
...
@@ -90,6 +91,7 @@ module.exports = function (config) {
lines
:
60
,
excludes
:
[
'app/components/uitemplates/*.js'
,
//'app/zetalib/interceptors.js'
]
}
},
...
...
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