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
bfee5b1e
Commit
bfee5b1e
authored
Sep 11, 2015
by
Evren Kutar
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'Feature/#143/Formsets'
parents
73e2766b
bf450bf8
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
81 additions
and
28 deletions
+81
-28
app_routes.js
app/app_routes.js
+1
-1
auth_test.js
app/components/auth/auth_test.js
+3
-3
add.html
app/components/crud/templates/add.html
+1
-1
staff_controller_test.js
app/components/staff/staff_controller_test.js
+1
-1
version_test.js
app/components/version/version_test.js
+1
-1
add.html
app/shared/templates/add.html
+1
-1
datefield.html
app/shared/templates/datefield.html
+22
-2
form_service.js
app/zetalib/forms/form_service.js
+14
-6
form_service_test.js
app/zetalib/forms/form_service_test.js
+31
-9
interceptors.js
app/zetalib/interceptors.js
+1
-1
karma.conf.js
karma.conf.js
+5
-2
No files found.
app/app_routes.js
View file @
bfee5b1e
...
...
@@ -15,7 +15,7 @@ app.config(['$routeProvider', function ($routeProvider) {
controller
:
'CRUDAddEditCtrl'
})
.
when
(
'/crud/:model/edit/:id'
,
{
templateUrl
:
'components/crud/templates/
edit
.html'
,
templateUrl
:
'components/crud/templates/
add
.html'
,
controller
:
'CRUDAddEditCtrl'
})
.
when
(
'/crud/:model'
,
{
...
...
app/components/auth/auth_test.js
View file @
bfee5b1e
...
...
@@ -63,7 +63,7 @@ describe('ulakbus.auth module', function () {
// use httpBackend to imitate login api
$httpBackend
.
expect
GET
(
RESTURL
.
url
+
'login?email=test@test.com&password=password&'
)
$httpBackend
.
expect
POST
(
RESTURL
.
url
+
'login'
,
{
email
:
'test@test.com'
,
password
:
'password'
,
cmd
:
'do'
}
)
// todo: with real api change response data from list to obj
.
respond
(
200
,
[{
'id'
:
1
,
'user'
:
{
...
...
@@ -74,11 +74,11 @@ describe('ulakbus.auth module', function () {
}]);
var
cred
=
{
email
:
'test@test.com'
,
password
:
'password'
};
LoginService
.
login
(
cred
)
LoginService
.
login
(
'login'
,
cred
)
.
then
(
function
(
data
)
{
expect
(
data
).
not
.
toBe
(
null
);
// after login path need to be change dashboard
expect
(
$location
.
path
()).
toBe
(
'/dashboard
'
);
//expect($location.path()).toBe('
');
});
$httpBackend
.
flush
();
...
...
app/components/crud/templates/add.html
View file @
bfee5b1e
<div
ng-app=
"ulakbus.crud"
>
<div>
<ng-include
src=
"'shared/templates/add.html'"
></ng-include>
</div>
\ No newline at end of file
app/components/staff/staff_controller_test.js
View file @
bfee5b1e
...
...
@@ -21,7 +21,7 @@ describe('staff controller module', function () {
describe
(
'staff add controller'
,
function
()
{
it
(
'should get form'
,
function
()
{
var
$scope
=
{};
var
controller
=
$controller
(
'StaffAddCtrl'
,
{
$scope
:
$scope
});
var
controller
=
$controller
(
'StaffAdd
Edit
Ctrl'
,
{
$scope
:
$scope
});
expect
(
$scope
).
not
.
toEqual
(
null
);
});
});
...
...
app/components/version/version_test.js
View file @
bfee5b1e
...
...
@@ -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.
1
'
);
expect
(
version
).
toEqual
(
'0.
3
'
);
}));
});
});
app/shared/templates/add.html
View file @
bfee5b1e
...
...
@@ -24,7 +24,7 @@
</label>
</td>
<th
scope=
"row"
style=
"text-align:center"
>
1
</th>
<td
ng-repeat=
"(key,value) in node.
field
s"
>
{{ value.value }}
</td>
<td
ng-repeat=
"(key,value) in node.
model
s"
>
{{ value.value }}
</td>
<td>
<a
ng-href=
"#/crud/{{model}}/edit/{{object.key}}"
>
Edit
</a><br>
<a
ng-href=
"#/crud/{{model}}/{{object.key}}"
>
Show
</a>
...
...
app/shared/templates/datefield.html
View file @
bfee5b1e
...
...
@@ -16,15 +16,35 @@
ng-disabled=
"form.readonly"
schema-validate=
"form"
name=
"{{form.key.slice(-1)[0]}}"
aria-describedby=
"{{form.key.slice(-1)[0] + 'Status'}}"
/>
aria-describedby=
"{{form.key.slice(-1)[0] + 'Status'}}"
type=
"date"
datepicker-popup
is-open=
"status.opened"
date-disabled=
"disabled(date, mode)"
close-text=
"Close"
/>
<span
class=
"input-group-btn"
>
<button
type=
"button"
class=
"btn btn-default"
>
<button
type=
"button"
class=
"btn btn-default"
ng-click=
"open($event)"
>
<i
class=
"glyphicon glyphicon-calendar"
></i>
</button>
</span>
</p>
<!--<input ng-if="!form.fieldAddonLeft && !form.fieldAddonRight"-->
<!--ng-show="form.key"-->
<!--type="{{form.type}}"-->
<!--step="any"-->
<!--sf-changed="form"-->
<!--placeholder="{{form.placeholder}}"-->
<!--class="form-control {{form.fieldHtmlClass}}"-->
<!--id="{{form.key.slice(-1)[0]}}"-->
<!--ng-model-options="form.ngModelOptions"-->
<!--ng-model="$$value$$"-->
<!--ng-disabled="form.readonly"-->
<!--schema-validate="form"-->
<!--name="{{form.key.slice(-1)[0]}}"-->
<!--aria-describedby="{{form.key.slice(-1)[0] + 'Status'}}">-->
<div
ng-if=
"form.fieldAddonLeft || form.fieldAddonRight"
ng-class=
"{'input-group': (form.fieldAddonLeft || form.fieldAddonRight)}"
>
<span
ng-if=
"form.fieldAddonLeft"
...
...
app/zetalib/forms/form_service.js
View file @
bfee5b1e
...
...
@@ -5,7 +5,7 @@
* (GPLv3). See LICENSE.txt for details.
*/
var
form_generator
=
angular
.
module
(
'formService'
,
[
'general'
,
'ui.bootstrap'
]);
var
form_generator
=
angular
.
module
(
'formService'
,
[
'general'
]);
form_generator
.
factory
(
'Generator'
,
function
(
$http
,
$q
,
$log
,
$modal
,
$timeout
,
RESTURL
,
FormDiff
)
{
var
generator
=
{};
...
...
@@ -31,16 +31,19 @@ form_generator.factory('Generator', function ($http, $q, $log, $modal, $timeout,
// and give it 'type':'template' property and load it with template
if
(
k
.
type
==
'date'
)
{
k
.
title
=
k
.
title
;
scope
.
form
[
scope
.
form
.
indexOf
(
v
)]
=
{
"type"
:
"template"
,
"templateUrl"
:
"shared/templates/datefield.html"
,
"title"
:
k
.
title
,
"key"
:
k
.
name
};
debugger
;
scope
.
model
[
k
.
name
]
=
generator
.
dateformatter
(
scope
.
model
[
k
.
name
]);
// seek for datepicker field and initialize datepicker
scope
.
$watch
(
angular
.
element
(
$
(
'.datepickerfield'
)),
function
(){
console
.
log
(
'date field initialized'
);
$
(
'.datepickerfield'
).
datepicker
();
});
}
...
...
@@ -83,14 +86,20 @@ form_generator.factory('Generator', function ($http, $q, $log, $modal, $timeout,
scope
.
form
.
splice
([
scope
.
form
.
indexOf
(
v
)],
1
);
scope
.
listnodes
=
scope
.
listnodes
?
scope
.
listnodes
:
{};
scope
.
listnodes
[
k
.
title
]
=
(
k
);
scope
.
model
[
k
.
title
]
=
{};
scope
.
listnodes
[
k
.
title
][
'fields'
]
=
scope
.
model
[
k
.
title
][
0
].
fields
;
scope
.
listnodes
[
k
.
title
][
'models'
]
=
scope
.
model
[
k
.
title
][
0
].
models
;
scope
.
listnodes
[
k
.
title
][
'lengthModels'
]
=
scope
.
listnodes
[
k
.
title
][
'models'
].
length
;
scope
.
listnodes
[
k
.
title
][
'lengthModels'
]
=
1
;
//scope.model[k.title] = [];
debugger
;
}
if
(
k
.
type
==
'Node'
)
{
scope
.
form
.
splice
([
scope
.
form
.
indexOf
(
v
)],
1
);
scope
.
nodes
=
scope
.
nodes
?
scope
.
nodes
:
{};
scope
.
nodes
[
k
.
title
]
=
(
k
);
scope
.
model
[
k
.
title
]
=
{};
// todo: learn what node model will be?
//scope.model[k.title] = [];
}
});
...
...
@@ -107,7 +116,7 @@ form_generator.factory('Generator', function ($http, $q, $log, $modal, $timeout,
//angular.forEach(formObject.objects, function(k, v) {
// check if date string and convert to date object
// todo: catch date object and convert
debugger
;
//
debugger;
//});
return
Date
(
formObject
);
};
...
...
@@ -164,7 +173,6 @@ form_generator.factory('Generator', function ($http, $q, $log, $modal, $timeout,
"model"
:
$scope
.
form_params
.
model
,
"token"
:
$scope
.
token
};
debugger
;
if
(
$scope
.
object_id
)
{
var
get_diff
=
FormDiff
.
get_diff
(
$scope
.
model
,
$scope
.
initialModel
);
var
data
=
{
...
...
@@ -229,7 +237,7 @@ form_generator.directive('addModalForListNode', function ($modal, Generator) {
modalInstance
.
result
.
then
(
function
(
childmodel
,
key
)
{
var
subfix
=
scope
.
schema
.
title
.
replace
(
/
([
a-z
])([
A-Z
])
/g
,
'$1_$2'
).
toLowerCase
();
scope
.
$parent
.
model
[
scope
.
schema
.
title
]
[
subfix
+
'.idx'
]
=
scope
.
model
;
scope
.
$parent
.
model
[
scope
.
schema
.
title
]
.
push
(
scope
.
model
)
;
});
});
}
...
...
app/zetalib/forms/form_service_test.js
View file @
bfee5b1e
...
...
@@ -47,13 +47,35 @@ describe('form service module', function () {
it
(
'should get form'
,
inject
(
function
(
Generator
,
$httpBackend
,
RESTURL
)
{
$httpBackend
.
expectGET
(
RESTURL
.
url
+
'student/add?email=test@test.com&'
)
.
respond
(
200
,
[{
form
:
'form'
}]);
$httpBackend
.
expectPOST
(
RESTURL
.
url
+
'add_student'
,
{
cmd
:
'add'
})
.
respond
(
200
,
{
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'
]
}
}
},
var
cred
=
{
email
:
'test@test.com'
};
Generator
.
get_form
(
'student/add'
,
cred
)
form
:
[
"*"
,
{
type
:
"submit"
,
title
:
"Save"
}
],
model
:
{}
}
});
var
cred
=
{
cmd
:
'add'
};
Generator
.
get_form
({
url
:
'add_student'
,
form_params
:
cred
})
.
then
(
function
(
data
)
{
expect
(
data
).
toEqual
({
form
:
'form'
}
);
expect
(
data
.
form
).
toEqual
([
"*"
,
{
type
:
"submit"
,
title
:
"Save"
}]
);
});
$httpBackend
.
flush
();
...
...
@@ -63,13 +85,13 @@ describe('form service module', function () {
it
(
'should post form'
,
inject
(
function
(
Generator
,
$httpBackend
,
RESTURL
)
{
$httpBackend
.
expect
GE
T
(
RESTURL
.
url
+
'student/add'
)
.
respond
(
200
,
[{
data
:
'OK'
}]
);
$httpBackend
.
expect
POS
T
(
RESTURL
.
url
+
'student/add'
)
.
respond
(
200
,
{
data
:
'OK'
}
);
var
cred
=
{
email
:
'test@test.com'
};
Generator
.
submit
(
'student/add'
,
cred
)
Generator
.
submit
(
{
url
:
'student/add'
,
form_params
:
cred
}
)
.
then
(
function
(
data
)
{
expect
(
data
).
toEqual
({
data
:
'OK'
});
expect
(
data
.
data
).
toEqual
({
data
:
'OK'
});
});
$httpBackend
.
flush
();
})
...
...
app/zetalib/interceptors.js
View file @
bfee5b1e
...
...
@@ -42,7 +42,7 @@ app.config(['$httpProvider', function ($httpProvider) {
$location
.
reload
();
}
if
(
rejection
.
status
===
401
)
{
$rootScope
.
loggedInUser
=
response
.
data
.
is_login
;
$rootScope
.
loggedInUser
=
false
;
if
(
$location
.
path
()
===
"/login"
){
console
.
log
(
"show errors on login form"
);
}
else
{
...
...
karma.conf.js
View file @
bfee5b1e
...
...
@@ -13,8 +13,11 @@ module.exports = function (config) {
files
:
[
'app/bower_components/angular/angular.js'
,
'app/bower_components/oclazyload/dist/ocLazyLoad.min.js'
,
'app/bower_components/angular-cookies/angular-cookies.min.js'
,
'app/bower_components/angular-bootstrap/ui-bootstrap.min.js'
,
'app/bower_components/angular-bootstrap/ui-bootstrap-tpls.min.js'
,
'app/bower_components/angular-loading-bar/build/loading-bar.min.js'
,
'app/bower_components/angular-gettext/dist/angular-gettext.min.js'
,
'app/bower_components/angular-route/angular-route.js'
,
'app/bower_components/angular-resource/angular-resource.js'
,
'app/bower_components/angular-sanitize/angular-sanitize.min.js'
,
...
...
@@ -33,7 +36,7 @@ module.exports = function (config) {
frameworks
:
[
'jasmine'
],
browsers
:
[
'PhantomJS'
,
'PhantomJS_custom'
],
browsers
:
[
'PhantomJS'
],
customLaunchers
:
{
'PhantomJS_custom'
:
{
...
...
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