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
9233d51f
Commit
9233d51f
authored
Sep 17, 2015
by
Evren Kutar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
v0.0.3.1
parent
4ec688a8
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
46 additions
and
28 deletions
+46
-28
crud_controller.js
app/components/crud/crud_controller.js
+3
-1
add.html
app/shared/templates/add.html
+1
-1
form_service.js
app/zetalib/forms/form_service.js
+38
-22
app.js
dist/app.js
+2
-2
components.js
dist/bower_components/components.js
+1
-1
templates.js
dist/templates.js
+1
-1
No files found.
app/components/crud/crud_controller.js
View file @
9233d51f
...
...
@@ -28,7 +28,9 @@ crud.controller('CRUDAddEditCtrl', function ($scope, $rootScope, $location, $htt
}
// get form with generator
Generator
.
get_form
(
$scope
);
if
(
$routeParams
.
model
)
{
Generator
.
get_form
(
$scope
);
}
$scope
.
onSubmit
=
function
(
form
)
{
$scope
.
$broadcast
(
'schemaFormValidate'
);
...
...
app/shared/templates/add.html
View file @
9233d51f
...
...
@@ -19,7 +19,7 @@
</a>
</span>
</h3>
<ng-include
src=
"'shared/templates/nodeTable.html'"
ng-if=
"node.lengthModels > 0"
></ng-include>
<ng-include
src=
"'shared/templates/nodeTable.html'"
ng-if=
"node.lengthModels > 0"
ng-bind=
"node.lengthModels"
></ng-include>
<hr>
</div>
...
...
app/zetalib/forms/form_service.js
View file @
9233d51f
...
...
@@ -46,11 +46,17 @@ form_generator.factory('Generator', function ($http, $q, $log, $location, $modal
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
();
jQuery
(
'#'
+
v
).
datepicker
({
dateFormat
:
"dd.mm.yy"
,
onSelect
:
function
(
date
){
scope
.
model
[
v
]
=
date
;
}
});
});
});
}
...
...
@@ -96,8 +102,9 @@ form_generator.factory('Generator', function ($http, $q, $log, $location, $modal
scope
[
k
.
type
][
k
.
title
]
=
{
title
:
k
.
title
,
form
:
[],
schema
:
{
properties
:
{},
required
:
[],
title
:
k
.
title
,
type
:
"object"
},
model
:
{}
schema
:
{
properties
:
{},
required
:
[],
title
:
k
.
title
,
type
:
"object"
,
formType
:
k
.
type
},
model
:
{},
url
:
scope
.
url
};
angular
.
forEach
(
k
.
schema
,
function
(
item
)
{
...
...
@@ -105,7 +112,7 @@ form_generator.factory('Generator', function ($http, $q, $log, $location, $modal
scope
[
k
.
type
][
k
.
title
].
model
[
item
.
name
]
=
item
.
value
;
// prepare required fields
if
(
item
.
required
==
true
)
{
if
(
item
.
required
==
true
&&
item
.
name
!=
'idx'
)
{
scope
[
k
.
type
][
k
.
title
].
schema
.
required
.
push
(
item
.
name
);
}
...
...
@@ -127,11 +134,10 @@ form_generator.factory('Generator', function ($http, $q, $log, $location, $modal
return
scope
;
};
generator
.
dateformatter
=
function
(
formObject
)
{
//angular.forEach(formObject.objects, function(k, v) {
// check if date string and convert to date object
// todo: catch date object and convert
//});
return
Date
(
formObject
);
var
ndate
=
new
Date
(
formObject
);
if
(
ndate
==
'Invalid Date'
)
{
return
''
}
var
newdatearray
=
[
ndate
.
getDate
(),
ndate
.
getMonth
(),
ndate
.
getFullYear
()];
return
newdatearray
.
join
(
'.'
);
};
generator
.
get_form
=
function
(
scope
)
{
return
$http
...
...
@@ -145,7 +151,7 @@ form_generator.factory('Generator', function ($http, $q, $log, $location, $modal
return
$http
.
post
(
generator
.
makeUrl
(
scope
.
url
),
scope
.
form_params
)
.
then
(
function
(
res
)
{
generator
.
dateformatter
(
res
);
//
generator.dateformatter(res);
return
res
;
// todo: cover all other exceptions (4xx, 5xx)
});
...
...
@@ -154,7 +160,7 @@ form_generator.factory('Generator', function ($http, $q, $log, $location, $modal
return
$http
.
post
(
generator
.
makeUrl
(
scope
.
url
),
scope
.
form_params
)
.
then
(
function
(
res
)
{
generator
.
dateformatter
(
res
);
//
generator.dateformatter(res);
return
res
;
// todo: cover all other exceptions (4xx, 5xx)
});
...
...
@@ -187,11 +193,10 @@ form_generator.factory('Generator', function ($http, $q, $log, $location, $modal
"token"
:
$scope
.
token
};
if
(
$scope
.
object_id
)
{
var
get_diff
=
FormDiff
.
get_diff
(
$scope
.
model
,
$scope
.
initialModel
);
//
var get_diff = FormDiff.get_diff($scope.model, $scope.initialModel);
data
.
object_id
=
$scope
.
object_id
;
data
.
form
=
get_diff
;
//
data.form = get_diff;
}
debugger
;
$http
.
post
(
generator
.
makeUrl
(
$scope
.
url
),
data
)
.
success
()
.
then
(
function
(
res
){
...
...
@@ -211,19 +216,22 @@ form_generator.factory('Generator', function ($http, $q, $log, $location, $modal
*/
form_generator
.
controller
(
'ModalCtrl'
,
function
(
$scope
,
$modalInstance
,
Generator
,
$route
,
items
)
{
angular
.
forEach
(
[
"model"
,
"schema"
,
"form"
],
function
(
key
)
{
angular
.
forEach
(
items
,
function
(
value
,
key
)
{
$scope
[
key
]
=
items
[
key
];
});
console
.
log
(
items
);
Generator
.
prepareFormItems
(
$scope
);
$scope
.
onSubmit
=
function
(
form
)
{
$scope
.
$broadcast
(
'schemaFormValidate'
);
console
.
log
(
form
.
$valid
);
if
(
form
.
$valid
){
// send form to modalinstance result function
debugger
;
$modalInstance
.
close
(
$scope
);
//if(form.$valid){
if
(
1
==
1
){
// send form to modalinstance result function
$modalInstance
.
close
(
$scope
);
}
};
$scope
.
cancel
=
function
()
{
...
...
@@ -259,9 +267,17 @@ form_generator.directive('modalForNodes', function ($modal) {
modalInstance
.
result
.
then
(
function
(
childmodel
,
key
)
{
// subfix will be removed
//var subfix = scope.schema.title.replace(/([a-z])([A-Z])/g, '$1_$2').toLowerCase();
// todo: run form validator here
scope
.
$parent
.
model
[
childmodel
.
schema
.
title
]
=
childmodel
.
model
;
console
.
log
(
scope
.
$parent
.
model
);
if
(
childmodel
.
schema
.
formType
==
'Node'
){
scope
.
$parent
.
model
[
childmodel
.
schema
.
title
]
=
childmodel
.
model
;
}
if
(
childmodel
.
schema
.
formType
==
'ListNode'
){
if
(
scope
.
$parent
.
model
[
childmodel
.
schema
.
title
]
==
null
){
scope
.
$parent
.
model
[
childmodel
.
schema
.
title
]
=
[];
}
scope
.
$parent
.
model
[
childmodel
.
schema
.
title
].
push
(
childmodel
.
model
);
}
childmodel
.
lengthModels
+=
1
;
});
});
}
...
...
dist/app.js
View file @
9233d51f
This diff is collapsed.
Click to expand it.
dist/bower_components/components.js
View file @
9233d51f
This diff is collapsed.
Click to expand it.
dist/templates.js
View file @
9233d51f
...
...
@@ -480,7 +480,7 @@ angular.module("shared/templates/add.html", []).run(["$templateCache", function(
" </a>
\n
"
+
" </span>
\n
"
+
" </h3>
\n
"
+
" <ng-include src=
\"
'shared/templates/nodeTable.html'
\"
ng-if=
\"
node.lengthModels > 0
\"
></ng-include>
\n
"
+
" <ng-include src=
\"
'shared/templates/nodeTable.html'
\"
ng-if=
\"
node.lengthModels > 0
\"
ng-bind=
\"
node.lengthModels
\"
></ng-include>
\n
"
+
" <hr>
\n
"
+
"</div>
\n
"
+
"
\n
"
+
...
...
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