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
a5fdb461
Commit
a5fdb461
authored
Nov 17, 2015
by
Evren Kutar
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'Feature/issue34'
parents
22e4a979
308715bd
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
139 additions
and
30 deletions
+139
-30
crud_controller.js
app/components/crud/crud_controller.js
+23
-16
list.html
app/components/crud/templates/list.html
+5
-5
version_test.js
app/components/version/version_test.js
+1
-1
form_service.js
app/zetalib/forms/form_service.js
+8
-1
form_service_test.js
app/zetalib/forms/form_service_test.js
+101
-6
karma.conf.js
karma.conf.js
+1
-1
No files found.
app/components/crud/crud_controller.js
View file @
a5fdb461
...
@@ -14,7 +14,7 @@ var crud = angular.module('ulakbus.crud', ['ui.bootstrap', 'schemaForm', 'formSe
...
@@ -14,7 +14,7 @@ var crud = angular.module('ulakbus.crud', ['ui.bootstrap', 'schemaForm', 'formSe
*/
*/
crud
.
service
(
'CrudUtility'
,
function
()
{
crud
.
service
(
'CrudUtility'
,
function
()
{
return
{
return
{
generateParam
:
function
(
scope
,
routeParams
)
{
generateParam
:
function
(
scope
,
routeParams
,
cmd
)
{
// define api request url path
// define api request url path
scope
.
url
=
routeParams
.
wf
;
scope
.
url
=
routeParams
.
wf
;
angular
.
forEach
(
routeParams
,
function
(
value
,
key
)
{
angular
.
forEach
(
routeParams
,
function
(
value
,
key
)
{
...
@@ -24,6 +24,7 @@ crud.service('CrudUtility', function () {
...
@@ -24,6 +24,7 @@ crud.service('CrudUtility', function () {
}
}
});
});
scope
.
form_params
=
{
scope
.
form_params
=
{
cmd
:
cmd
,
model
:
routeParams
.
model
,
model
:
routeParams
.
model
,
param
:
scope
.
param
,
param
:
scope
.
param
,
id
:
scope
.
param_id
,
id
:
scope
.
param_id
,
...
@@ -44,6 +45,7 @@ crud.service('CrudUtility', function () {
...
@@ -44,6 +45,7 @@ crud.service('CrudUtility', function () {
*
*
*/
*/
crud
.
controller
(
'CRUDCtrl'
,
function
(
$scope
,
$routeParams
,
Generator
,
CrudUtility
)
{
crud
.
controller
(
'CRUDCtrl'
,
function
(
$scope
,
$routeParams
,
Generator
,
CrudUtility
)
{
// get required params by calling CrudUtility.generateParam function
CrudUtility
.
generateParam
(
$scope
,
$routeParams
);
CrudUtility
.
generateParam
(
$scope
,
$routeParams
);
Generator
.
get_wf
(
$scope
);
Generator
.
get_wf
(
$scope
);
});
});
...
@@ -54,13 +56,10 @@ crud.controller('CRUDCtrl', function ($scope, $routeParams, Generator, CrudUtili
...
@@ -54,13 +56,10 @@ crud.controller('CRUDCtrl', function ($scope, $routeParams, Generator, CrudUtili
*/
*/
crud
.
controller
(
'CRUDAddEditCtrl'
,
function
(
$scope
,
$rootScope
,
$location
,
$http
,
$log
,
$modal
,
$timeout
,
Generator
,
$routeParams
,
CrudUtility
)
{
crud
.
controller
(
'CRUDAddEditCtrl'
,
function
(
$scope
,
$rootScope
,
$location
,
$http
,
$log
,
$modal
,
$timeout
,
Generator
,
$routeParams
,
CrudUtility
)
{
CrudUtility
.
generateParam
(
$scope
,
$routeParams
);
CrudUtility
.
generateParam
(
$scope
,
$routeParams
,
'form'
);
$scope
.
form_params
[
'cmd'
]
=
'form'
;
// get form with generator
// get form with generator
if
(
$routeParams
.
pageData
)
{
if
(
$routeParams
.
pageData
)
{
console
.
log
(
Generator
.
getPageData
());
Generator
.
generate
(
$scope
,
Generator
.
getPageData
());
Generator
.
generate
(
$scope
,
Generator
.
getPageData
());
}
else
{
}
else
{
Generator
.
get_form
(
$scope
);
Generator
.
get_form
(
$scope
);
...
@@ -80,8 +79,7 @@ crud.controller('CRUDAddEditCtrl', function ($scope, $rootScope, $location, $htt
...
@@ -80,8 +79,7 @@ crud.controller('CRUDAddEditCtrl', function ($scope, $rootScope, $location, $htt
*/
*/
crud
.
controller
(
'CRUDListCtrl'
,
function
(
$scope
,
$rootScope
,
Generator
,
$routeParams
,
CrudUtility
)
{
crud
.
controller
(
'CRUDListCtrl'
,
function
(
$scope
,
$rootScope
,
Generator
,
$routeParams
,
CrudUtility
)
{
CrudUtility
.
generateParam
(
$scope
,
$routeParams
);
CrudUtility
.
generateParam
(
$scope
,
$routeParams
,
'list'
);
$scope
.
form_params
[
'cmd'
]
=
'list'
;
if
(
$routeParams
.
pageData
)
{
if
(
$routeParams
.
pageData
)
{
var
pageData
=
Generator
.
getPageData
();
var
pageData
=
Generator
.
getPageData
();
...
@@ -100,20 +98,29 @@ crud.controller('CRUDListCtrl', function ($scope, $rootScope, Generator, $routeP
...
@@ -100,20 +98,29 @@ crud.controller('CRUDListCtrl', function ($scope, $rootScope, Generator, $routeP
* CRUD Show Controller
* CRUD Show Controller
*/
*/
crud
.
controller
(
'CRUDShowCtrl'
,
function
(
$scope
,
$rootScope
,
$location
,
Generator
,
$routeParams
,
CrudUtility
)
{
crud
.
controller
(
'CRUDShowCtrl'
,
function
(
$scope
,
$rootScope
,
$location
,
Generator
,
$routeParams
,
CrudUtility
)
{
CrudUtility
.
generateParam
(
$scope
,
$routeParams
);
CrudUtility
.
generateParam
(
$scope
,
$routeParams
,
'show'
);
$scope
.
form_params
[
'cmd'
]
=
'show'
;
// todo: refactor createListObjects func
// call generator's get_single_item func
var
createListObjects
=
function
()
{
Generator
.
get_single_item
(
$scope
).
then
(
function
(
res
)
{
$scope
.
listobjects
=
{};
$scope
.
object
=
res
.
data
.
object
;
angular
.
forEach
(
$scope
.
object
,
function
(
value
,
key
)
{
angular
.
forEach
(
$scope
.
object
,
function
(
value
,
key
)
{
if
(
typeof
value
==
'object'
)
{
if
(
typeof
value
==
'object'
)
{
$scope
.
listobjects
[
key
]
=
value
;
$scope
.
listobjects
[
key
]
=
value
;
delete
$scope
.
object
[
key
];
delete
$scope
.
object
[
key
];
}
}
});
});
};
$scope
.
listobjects
=
{};
$scope
.
model
=
$routeParams
.
model
;
if
(
$routeParams
.
pageData
)
{
});
var
pageData
=
Generator
.
getPageData
();
$scope
.
object
=
pageData
.
object
;
}
else
{
// call generator's get_single_item func
Generator
.
get_single_item
(
$scope
).
then
(
function
(
res
)
{
$scope
.
object
=
res
.
data
.
object
;
$scope
.
model
=
$routeParams
.
model
;
});
}
createListObjects
();
});
});
\ No newline at end of file
app/components/crud/templates/list.html
View file @
a5fdb461
...
@@ -19,8 +19,8 @@
...
@@ -19,8 +19,8 @@
Hepsini Seç
Hepsini Seç
</label>
</label>
</td>
</td>
<td
ng-repeat=
"value in objects[0]"
ng-if=
"objects[0]!='-1'
&& !$last
"
>
{{ value }}
</td>
<td
ng-repeat=
"value in objects[0]"
ng-if=
"objects[0]!='-1'"
>
{{ value }}
</td>
<td
ng-if=
"objects[0]=='-1'"
>
{{ model }}
</td>
<td
ng-if=
"objects[0]=='-1'"
>
{{ model
|| wf
}}
</td>
<td>
action
</td>
<td>
action
</td>
</tr>
</tr>
</thead>
</thead>
...
@@ -37,9 +37,9 @@
...
@@ -37,9 +37,9 @@
<a
ng-href=
"{{object.detailLink}}"
>
{{field}}
</a>
<a
ng-href=
"{{object.detailLink}}"
>
{{field}}
</a>
</td>
</td>
<td
ng-repeat=
"
(key,value) in object.fieldset
track by $index"
ng-if=
"objects[0]!='-1'"
>
<td
ng-repeat=
"
field in object.fields
track by $index"
ng-if=
"objects[0]!='-1'"
>
<a
ng-href=
"{{object.detailLink}}"
ng-if=
"$index==1"
>
{{
object.fields
}}
</a>
<a
ng-href=
"{{object.detailLink}}"
ng-if=
"$index==1"
>
{{
field
}}
</a>
<span
ng-if=
"$index!=1"
>
{{
object[key]
}}
</span>
<span
ng-if=
"$index!=1"
>
{{
field
}}
</span>
</td>
</td>
<td>
<td>
<a
ng-href=
"{{object.editLink}}"
>
Edit
</a>
<a
ng-href=
"{{object.editLink}}"
>
Edit
</a>
...
...
app/components/version/version_test.js
View file @
a5fdb461
...
@@ -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.
1.0
'
);
expect
(
version
).
toEqual
(
'0.
4.1
'
);
}));
}));
});
});
});
});
app/zetalib/forms/form_service.js
View file @
a5fdb461
...
@@ -469,6 +469,11 @@ form_generator.factory('Generator', function ($http, $q, $timeout, $location, $c
...
@@ -469,6 +469,11 @@ form_generator.factory('Generator', function ($http, $q, $timeout, $location, $c
redirectTo
(
$scope
,
'formwithlist'
);
redirectTo
(
$scope
,
'formwithlist'
);
}
}
if
(
client_cmd
.
indexOf
(
'show'
)
>
-
1
)
{
generator
.
setPageData
(
data
);
redirectTo
(
$scope
,
'detail'
);
}
//todo: msgbox make it work
//todo: msgbox make it work
// if submit returns msgbox after save
// if submit returns msgbox after save
//if (data.msgbox) {
//if (data.msgbox) {
...
@@ -516,7 +521,9 @@ form_generator.factory('Generator', function ($http, $q, $timeout, $location, $c
...
@@ -516,7 +521,9 @@ form_generator.factory('Generator', function ($http, $q, $timeout, $location, $c
return
$http
.
post
(
generator
.
makeUrl
(
$scope
),
data
)
return
$http
.
post
(
generator
.
makeUrl
(
$scope
),
data
)
.
success
(
function
(
data
)
{
.
success
(
function
(
data
)
{
generator
.
pathDecider
(
data
.
client_cmd
,
$scope
,
data
);
if
(
data
.
client_cmd
)
{
generator
.
pathDecider
(
data
.
client_cmd
,
$scope
,
data
);
}
});
});
};
};
return
generator
;
return
generator
;
...
...
app/zetalib/forms/form_service_test.js
View file @
a5fdb461
...
@@ -11,6 +11,10 @@ describe('form service module', function () {
...
@@ -11,6 +11,10 @@ describe('form service module', function () {
beforeEach
(
module
(
'ulakbus'
));
beforeEach
(
module
(
'ulakbus'
));
beforeEach
(
module
(
'formService'
));
beforeEach
(
module
(
'formService'
));
var
location
;
beforeEach
(
inject
(
function
(
$location
)
{
location
=
$location
;
}));
describe
(
'form service'
,
function
()
{
describe
(
'form service'
,
function
()
{
...
@@ -18,7 +22,7 @@ describe('form service module', function () {
...
@@ -18,7 +22,7 @@ describe('form service module', function () {
function
(
Generator
)
{
function
(
Generator
)
{
expect
(
Generator
.
group
).
not
.
toBe
(
null
);
expect
(
Generator
.
group
).
not
.
toBe
(
null
);
var
generated_url
=
Generator
.
makeUrl
({
url
:
'test'
,
form_params
:
{}});
var
generated_url
=
Generator
.
makeUrl
({
url
:
'test'
,
form_params
:
{}});
expect
(
generated_url
).
toEqual
(
"http://api.ulakbus.net/test"
);
expect
(
generated_url
).
toEqual
(
"http://api.ulakbus.net/test
/
"
);
}])
}])
);
);
...
@@ -110,7 +114,7 @@ describe('form service module', function () {
...
@@ -110,7 +114,7 @@ describe('form service module', function () {
function
(
Generator
)
{
function
(
Generator
)
{
expect
(
Generator
.
dateformatter
).
not
.
toBe
(
null
);
expect
(
Generator
.
dateformatter
).
not
.
toBe
(
null
);
var
generated_date
=
Generator
.
dateformatter
(
'2001-01-01T01:00:00Z'
);
var
generated_date
=
Generator
.
dateformatter
(
'2001-01-01T01:00:00Z'
);
expect
(
generated_date
).
toEqual
(
'1.
0
.2001'
);
expect
(
generated_date
).
toEqual
(
'1.
1
.2001'
);
}])
}])
);
);
...
@@ -132,7 +136,7 @@ describe('form service module', function () {
...
@@ -132,7 +136,7 @@ describe('form service module', function () {
it
(
'should get form'
,
it
(
'should get form'
,
inject
(
function
(
Generator
,
$httpBackend
,
RESTURL
)
{
inject
(
function
(
Generator
,
$httpBackend
,
RESTURL
)
{
$httpBackend
.
expectPOST
(
RESTURL
.
url
+
'add_student'
,
{
cmd
:
'add'
})
$httpBackend
.
expectPOST
(
RESTURL
.
url
+
'add_student
/
'
,
{
cmd
:
'add'
})
.
respond
(
200
,
{
.
respond
(
200
,
{
forms
:
{
forms
:
{
schema
:
{
schema
:
{
...
@@ -184,7 +188,7 @@ describe('form service module', function () {
...
@@ -184,7 +188,7 @@ describe('form service module', function () {
});
});
var
cred
=
{
cmd
:
'list'
,
model
:
"personel"
,
object_id
:
"5821bc25a90aa1"
};
var
cred
=
{
cmd
:
'list'
,
model
:
"personel"
,
object_id
:
"5821bc25a90aa1"
};
Generator
.
get_list
({
url
:
'test
/
'
,
form_params
:
cred
})
Generator
.
get_list
({
url
:
'test'
,
form_params
:
cred
})
.
then
(
function
(
data
)
{
.
then
(
function
(
data
)
{
expect
(
data
.
data
.
items
.
token
).
toEqual
(
"0122b2843f504c15821bc25a90aa1370"
);
expect
(
data
.
data
.
items
.
token
).
toEqual
(
"0122b2843f504c15821bc25a90aa1370"
);
});
});
...
@@ -210,7 +214,7 @@ describe('form service module', function () {
...
@@ -210,7 +214,7 @@ describe('form service module', function () {
});
});
var
cred
=
{
cmd
:
'show'
,
model
:
'personel'
,
param
:
'personel_id'
,
id
:
'123'
};
var
cred
=
{
cmd
:
'show'
,
model
:
'personel'
,
param
:
'personel_id'
,
id
:
'123'
};
Generator
.
get_single_item
({
url
:
'test
/
'
,
form_params
:
cred
})
Generator
.
get_single_item
({
url
:
'test'
,
form_params
:
cred
})
.
then
(
function
(
data
)
{
.
then
(
function
(
data
)
{
expect
(
data
.
data
.
items
.
token
).
toEqual
(
"da73993f439549e7855fd82deafbbc99"
);
expect
(
data
.
data
.
items
.
token
).
toEqual
(
"da73993f439549e7855fd82deafbbc99"
);
});
});
...
@@ -229,7 +233,7 @@ describe('form service module', function () {
...
@@ -229,7 +233,7 @@ describe('form service module', function () {
model
:
{
email
:
'test@test.com'
},
model
:
{
email
:
'test@test.com'
},
form_params
:
{
cmd
:
'add'
,
model
:
'testmodel'
},
form_params
:
{
cmd
:
'add'
,
model
:
'testmodel'
},
token
:
'123456'
,
token
:
'123456'
,
url
:
'student/add
/
'
url
:
'student/add'
};
};
Generator
.
submit
(
scope
)
Generator
.
submit
(
scope
)
.
success
(
function
(){
.
success
(
function
(){
...
@@ -294,6 +298,97 @@ describe('form service module', function () {
...
@@ -294,6 +298,97 @@ describe('form service module', function () {
}
}
})
})
);
);
it
(
'should get wf and redirect according to client_cmd'
,
inject
(
function
(
Generator
,
$httpBackend
,
RESTURL
)
{
$httpBackend
.
expectPOST
(
RESTURL
.
url
+
'test/testModel?test=xyz123'
)
.
respond
(
200
,
{
"client_cmd"
:
"form"
,
"object"
:
{
"ad"
:
"name"
,
"soyad"
:
"lastname"
,
},
forms
:
{
schema
:
{
type
:
"object"
,
properties
:
{
name
:
{
type
:
"string"
,
minLength
:
2
,
title
:
"Name"
,
description
:
"Name or alias"
},
title
:
{
type
:
"string"
,
enum
:
[
'dr'
,
'jr'
,
'sir'
,
'mrs'
,
'mr'
,
'NaN'
,
'dj'
]
}
}
},
form
:
[
"*"
,
{
type
:
"submit"
,
title
:
"Save"
}
],
model
:
{}
},
"token"
:
"da73993f439549e7855fd82deafbbc99"
,
"is_login"
:
true
});
console
.
log
(
32131
);
scope
.
url
=
'test'
;
scope
.
form_params
=
{
param
:
'test'
,
id
:
'xyz123'
,
model
:
'testModel'
,
object_id
:
'xxx11'
,
wf
:
'testModel'
};
Generator
.
get_wf
(
scope
);
$httpBackend
.
flush
();
expect
(
location
.
path
()).
toEqual
(
'/testModel/testModel/add'
);
})
);
});
describe
(
'form service'
,
function
()
{
var
location
,
rootScope
,
scope
,
ctrl
;
beforeEach
(
inject
(
function
(
$location
,
$rootScope
)
{
location
=
$location
;
rootScope
=
$rootScope
;
scope
=
$rootScope
.
$new
();
ctrl
=
$controller
(
"CRUDCtrl"
,
{
$scope
:
scope
});
}));
it
(
'should generate itemlinks of objects in response data'
,
inject
(
function
(
Generator
)
{
var
responseObject
=
{
"objects"
:
[
"-1"
,
{
"fields"
:
[
"test object"
],
"actions"
:
[{
"cmd"
:
"delete"
,
"name"
:
"Sil"
},
{
"wf"
:
"manage_permissions"
,
"name"
:
"Yetkilendir"
,
"mode"
:
"modal"
}],
"do_list"
:
true
,
"key"
:
"xx10"
},
{
"fields"
:
[
"test object 2"
],
"actions"
:
[{
"cmd"
:
"delete"
,
"name"
:
"Sil"
},
{
"wf"
:
"manage_permissions"
,
"name"
:
"Yetkilendir"
,
"mode"
:
"modal"
}],
"do_list"
:
true
,
"key"
:
"xx11"
}
]
};
scope
.
url
=
'test'
;
scope
.
form_params
=
{
param
:
'test'
,
id
:
'xyz123'
,
model
:
'testModel'
,
object_id
:
'xxx11'
,
wf
:
'testModel'
};
Generator
.
itemLinksGenerator
(
scope
,
responseObject
);
expect
(
responseObject
.
objects
[
1
].
detailLink
).
toEqual
(
'#test/testModel/detail/xx10?test=xyz123'
);
})
);
});
});
...
...
karma.conf.js
View file @
a5fdb461
...
@@ -32,7 +32,7 @@ module.exports = function (config) {
...
@@ -32,7 +32,7 @@ module.exports = function (config) {
'app/components/**/*.js'
'app/components/**/*.js'
],
],
autoWatch
:
tru
e
,
autoWatch
:
fals
e
,
frameworks
:
[
'jasmine'
],
frameworks
:
[
'jasmine'
],
...
...
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