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
2072228e
Commit
2072228e
authored
Sep 21, 2015
by
Evren Kutar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add node item to table and edit
parent
45aca914
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
92 additions
and
31 deletions
+92
-31
crud_controller.js
app/components/crud/crud_controller.js
+1
-0
add.html
app/components/crud/templates/add.html
+33
-3
list.html
app/components/crud/templates/list.html
+1
-1
add.html
app/shared/templates/add.html
+8
-2
nodeTable.html
app/shared/templates/nodeTable.html
+21
-4
form_service.js
app/zetalib/forms/form_service.js
+28
-21
No files found.
app/components/crud/crud_controller.js
View file @
2072228e
...
...
@@ -58,6 +58,7 @@ crud.controller('CRUDListCtrl', function ($scope, $rootScope, Generator, $routeP
// call generator's get_list func
Generator
.
get_list
(
$scope
)
.
then
(
function
(
res
)
{
debugger
;
$scope
.
nobjects
=
res
.
data
.
nobjects
;
$scope
.
model
=
$routeParams
.
model
;
});
...
...
app/components/crud/templates/add.html
View file @
2072228e
<div>
<ng-include
src=
"'shared/templates/add.html'"
></ng-include>
</div>
\ No newline at end of file
<h1>
{{ schema.title }}
</h1>
<form
id=
"formgenerated"
name=
"formgenerated"
sf-schema=
"schema"
sf-form=
"form"
sf-model=
"model"
></form>
<div
ng-repeat=
"node in Node"
>
<h3>
{{ node.title }}
<span
ng-if=
"node.lengthModels < 1"
>
<a
href=
"javascript:void(0);"
modal-for-nodes=
"{{node.schema.model_name}},Node"
>
<i
class=
"fa fa-plus-circle fa-fw"
></i>
</a>
</span>
</h3>
<div
class=
"node-table"
>
<ng-include
src=
"'shared/templates/nodeTable.html'"
></ng-include>
</div>
<hr>
</div>
<div
ng-repeat=
"node in ListNode"
>
<h3>
{{ node.title }}
<span>
<a
href=
"javascript:void(0);"
modal-for-nodes=
"{{node.schema.model_name}},ListNode,add"
>
<i
class=
"fa fa-plus-circle fa-fw"
></i>
</a>
</span>
</h3>
<div
class=
"list-node-table"
>
<ng-include
src=
"'shared/templates/nodeTable.html'"
></ng-include>
</div>
<hr>
</div>
<button
id=
"submitbutton"
type=
"button"
class=
"btn btn-primary"
ng-click=
"onSubmit(formgenerated)"
>
Kaydet
</button>
<!-- <button type="button" class="btn btn-warning">Düzenle</button> todo: make it conditional -->
<!-- <button type="button" class="btn btn-danger">İptal</button> todo: turn back to previous page -->
\ No newline at end of file
app/components/crud/templates/list.html
View file @
2072228e
<div
class=
"starter-template"
>
<h1>
{{model}}
</h1>
<h1>
{{model}}
<a
href=
"#/{{model}}/add"
><button
type=
"button"
class=
"btn btn-primary"
>
Ekle
</button></a>
</h1>
<div
class=
"tablescroll"
>
<table
class=
"table table-bordered"
style=
"background-color:#fff;"
>
<thead>
...
...
app/shared/templates/add.html
View file @
2072228e
<!-- todo: remove this template -->
<h1>
{{ schema.title }}
</h1>
<form
id=
"formgenerated"
name=
"formgenerated"
sf-schema=
"schema"
sf-form=
"form"
sf-model=
"model"
></form>
{{Node}}
<div
ng-repeat=
"node in Node"
>
<h3>
{{ node.title }}
<span
ng-if=
"node.lengthModels < 1"
>
...
...
@@ -8,7 +10,9 @@
</a>
</span>
</h3>
<ng-include
src=
"'shared/templates/nodeTable.html'"
></ng-include>
<div
class=
"node-table"
>
<ng-include
src=
"'shared/templates/nodeTable.html'"
></ng-include>
</div>
<hr>
</div>
<div
ng-repeat=
"node in ListNode"
>
...
...
@@ -19,7 +23,9 @@
</a>
</span>
</h3>
<ng-include
src=
"'shared/templates/nodeTable.html'"
></ng-include>
<div
class=
"list-node-table"
>
<ng-include
src=
"'shared/templates/nodeTable.html'"
></ng-include>
</div>
<hr>
</div>
...
...
app/shared/templates/nodeTable.html
View file @
2072228e
...
...
@@ -8,12 +8,13 @@
Hepsini Seç
</label>
</th>
<th
ng-repeat=
"(key,value) in node.
form"
>
{{ value
}}
</th>
<th
ng-repeat=
"(key,value) in node.
model"
>
{{ key
}}
</th>
<th>
action
</th>
</tr>
</thead>
<tbody
ng-class=
"{true: '', false: 'hidden'}[node.lengthModels > 0]"
>
<tr>
<tbody
ng-class=
"{hidden: node.lengthModels < 1}"
>
<tr
ng-if=
"node.schema.formType=='Node'"
>
<td
width=
"60"
>
<label>
<input
type=
"checkbox"
style=
"zoom:1.5; margin:5px 0 0 8px;"
>
...
...
@@ -22,11 +23,27 @@
<th
scope=
"row"
style=
"text-align:center"
>
1
</th>
<td
ng-repeat=
"value in node.model"
>
{{ value }}
</td>
<td>
<button
modal-for-nodes=
"{{node.title}},ListNode"
>
Edit
</button><br>
<button
modal-for-nodes=
"{{node.schema.model_name}},{{node.schema.formType}},edit"
>
Edit
</button><br>
<button>
Show
</button>
<button>
Delete
</button>
</td>
</tr>
<tr
ng-repeat=
"listnodemodel in node.model"
ng-if=
"node.schema.formType=='ListNode'"
>
<td
width=
"60"
>
<label>
<input
type=
"checkbox"
style=
"zoom:1.5; margin:5px 0 0 8px;"
>
</label>
</td>
<th
scope=
"row"
style=
"text-align:center"
>
1
</th>
<td
ng-repeat=
"value in listnodemodel"
>
{{ value }}
</td>
<td>
<button
modal-for-nodes=
"{{node.schema.model_name}},{{node.schema.formType}},edit"
>
Edit
</button><br>
<button>
Show
</button>
<button>
Delete
</button>
</td>
</tr>
</tbody>
</table>
</div>
\ No newline at end of file
app/zetalib/forms/form_service.js
View file @
2072228e
...
...
@@ -76,7 +76,7 @@ form_generator.factory('Generator', function ($http, $q, $log, $location, $modal
var
formitem
=
scope
.
form
[
scope
.
form
.
indexOf
(
v
)];
var
modelscope
=
{
"url"
:
scope
.
url
,
"form_params"
:
{
model
:
k
.
model_name
}};
debugger
;
formitem
=
{
type
:
"template"
,
templateUrl
:
"shared/templates/foreignKey.html"
,
...
...
@@ -111,9 +111,7 @@ form_generator.factory('Generator', function ($http, $q, $log, $location, $modal
scope
[
k
.
type
]
=
scope
[
k
.
type
]
?
scope
[
k
.
type
]
:
{};
debugger
;
scope
[
k
.
type
][
k
.
title
]
=
{
scope
[
k
.
type
][
v
]
=
{
title
:
k
.
title
,
form
:
[],
schema
:
{
...
...
@@ -127,32 +125,31 @@ form_generator.factory('Generator', function ($http, $q, $log, $location, $modal
url
:
scope
.
url
};
scope
[
k
.
type
][
k
.
title
].
model
=
scope
.
model
[
v
]
!=
null
?
scope
.
model
[
v
]
:
{};
if
(
scope
.
model
[
v
]
==
null
)
{
scope
[
k
.
type
][
v
].
model
=
k
.
type
==
'Node'
?
[]
:
{};
}
else
{
scope
[
k
.
type
][
v
].
model
=
scope
.
model
[
v
];
}
angular
.
forEach
(
k
.
schema
,
function
(
item
)
{
scope
[
k
.
type
][
k
.
title
].
schema
.
properties
[
item
.
name
]
=
item
;
// if model is empty object then fill it with scope model item
//if (scope[k.type][k.title] == {}){
// scope[k.type][k.title].model[item.name] = item.value;
//}
scope
[
k
.
type
][
v
].
schema
.
properties
[
item
.
name
]
=
item
;
// prepare required fields
if
(
item
.
required
==
true
&&
item
.
name
!=
'idx'
)
{
scope
[
k
.
type
][
k
.
title
].
schema
.
required
.
push
(
item
.
name
);
scope
[
k
.
type
][
v
].
schema
.
required
.
push
(
item
.
name
);
}
// idx field must be hidden
if
(
item
.
name
==
'idx'
)
{
scope
[
k
.
type
][
k
.
title
].
form
.
push
({
type
:
'string'
,
key
:
item
.
name
,
htmlClass
:
'hidden'
});
scope
[
k
.
type
][
v
].
form
.
push
({
type
:
'string'
,
key
:
item
.
name
,
htmlClass
:
'hidden'
});
}
else
{
scope
[
k
.
type
][
k
.
title
].
form
.
push
(
item
.
name
);
scope
[
k
.
type
][
v
].
form
.
push
(
item
.
name
);
}
});
// lengthModels is length of the listnode models. if greater than 0 show records on template
scope
[
k
.
type
][
k
.
title
][
'lengthModels'
]
=
scope
.
model
[
k
.
title
]
?
1
:
0
;
scope
[
k
.
type
][
v
][
'lengthModels'
]
=
scope
.
model
[
v
]
?
1
:
0
;
}
...
...
@@ -226,6 +223,8 @@ form_generator.factory('Generator', function ($http, $q, $log, $location, $modal
//data.form = get_diff;
}
debugger
;
return
$http
.
post
(
generator
.
makeUrl
(
$scope
.
url
),
data
);
//.success(function () {
//
...
...
@@ -287,8 +286,12 @@ form_generator.directive('modalForNodes', function ($modal) {
resolve
:
{
items
:
function
()
{
var
attribs
=
attributes
[
'modalForNodes'
].
split
(
','
);
debugger
;
// get node from parent scope catch with attribute
var
node
=
angular
.
copy
(
scope
.
$parent
.
$parent
[
attribs
[
1
]][
attribs
[
0
]]);
var
node
=
angular
.
copy
(
scope
.
$parent
[
attribs
[
1
]][
attribs
[
0
]]);
if
(
attribs
[
2
]
==
'add'
){
node
.
model
=
{};
}
return
node
;
}
}
...
...
@@ -299,16 +302,21 @@ form_generator.directive('modalForNodes', function ($modal) {
//var subfix = scope.schema.title.replace(/([a-z])([A-Z])/g, '$1_$2').toLowerCase();
if
(
childmodel
.
schema
.
formType
==
'Node'
)
{
scope
.
$parent
.
model
[
childmodel
.
schema
.
model_name
]
=
childmodel
.
model
;
//scope.$parent.model[childmodel.schema.model_name] = childmodel.model;
scope
.
$parent
[
childmodel
.
schema
.
formType
][
childmodel
.
schema
.
model_name
].
model
=
childmodel
.
model
;
}
if
(
childmodel
.
schema
.
formType
==
'ListNode'
)
{
debugger
;
if
(
scope
.
$parent
.
model
[
childmodel
.
schema
.
model_name
]
==
null
)
{
scope
.
$parent
.
model
[
childmodel
.
schema
.
model_name
]
=
[];
}
scope
.
$parent
.
model
[
childmodel
.
schema
.
model_name
].
push
(
childmodel
.
model
);
//scope.$parent.model[childmodel.schema.model_name].push(childmodel.model);
scope
.
$parent
[
childmodel
.
schema
.
formType
][
childmodel
.
schema
.
model_name
].
model
.
push
(
childmodel
.
model
);
}
childmodel
.
lengthModels
+=
1
;
scope
.
$parent
[
childmodel
.
schema
.
formType
][
childmodel
.
schema
.
model_name
].
lengthModels
+=
1
;
});
});
}
...
...
@@ -333,7 +341,6 @@ form_generator.directive('addModalForLinkedModel', function ($modal, Generator)
size
:
'lg'
,
resolve
:
{
items
:
function
()
{
debugger
;
return
Generator
.
get_form
({
url
:
'crud'
,
form_params
:
{
'model'
:
scope
.
form
.
model_name
,
"cmd"
:
"add"
}
...
...
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