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
d9596de4
Commit
d9596de4
authored
Sep 16, 2015
by
Evren Kutar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
listnode implementation to new data structure
parent
af63f0f7
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
102 additions
and
224 deletions
+102
-224
crud_controller.js
app/components/crud/crud_controller.js
+0
-2
directives.js
app/shared/directives.js
+1
-0
add.html
app/shared/templates/add.html
+4
-4
header-breadcrumb.html
app/shared/templates/directives/header-breadcrumb.html
+6
-0
header-notification.html
app/shared/templates/directives/header-notification.html
+3
-4
form_service.js
app/zetalib/forms/form_service.js
+85
-212
interceptors.js
app/zetalib/interceptors.js
+3
-2
No files found.
app/components/crud/crud_controller.js
View file @
d9596de4
...
...
@@ -33,8 +33,6 @@ crud.controller('CRUDAddEditCtrl', function ($scope, $rootScope, $location, $htt
$scope
.
onSubmit
=
function
(
form
)
{
$scope
.
$broadcast
(
'schemaFormValidate'
);
debugger
;
if
(
form
.
$valid
)
{
Generator
.
submit
(
$scope
)
.
success
(
function
(
data
){
...
...
app/shared/directives.js
View file @
d9596de4
...
...
@@ -58,6 +58,7 @@ app.directive('headerBreadcrumb', function ($location) {
link
:
function
(
$scope
){
$scope
.
$watch
(
'$routeUpdate'
,
function
(){
// todo: create actual links
//debugger;
$scope
.
links
=
$location
.
path
().
split
(
'/'
);
});
}
...
...
app/shared/templates/add.html
View file @
d9596de4
<h1>
{{ schema.title }}
</h1>
<form
id=
"formgenerated"
name=
"formgenerated"
sf-schema=
"schema"
sf-form=
"form"
sf-model=
"model"
></form>
<div
ng-repeat=
"node in
nodes
"
>
<div
ng-repeat=
"node in
Node
"
>
<h3>
{{ node.title }}
<span
ng-if=
"node.lengthModels < 1"
>
<a
href=
"javascript:void(0);"
add-modal-for-node=
{{node.title}}
>
<a
href=
"javascript:void(0);"
modal-for-nodes=
"{{node.title}},Node"
>
<i
class=
"fa fa-plus-circle fa-fw"
></i>
</a>
</span>
...
...
@@ -11,10 +11,10 @@
<ng-include
src=
"'shared/templates/nodeTable.html'"
ng-if=
"node.lengthModels > 0"
></ng-include>
<hr>
</div>
<div
ng-repeat=
"node in
listnodes
"
>
<div
ng-repeat=
"node in
ListNode
"
>
<h3>
{{ node.title }}
<span>
<a
href=
"javascript:void(0);"
add-modal-for-list-node=
{{node.title}}
>
<a
href=
"javascript:void(0);"
modal-for-nodes=
"{{node.title}},ListNode"
>
<i
class=
"fa fa-plus-circle fa-fw"
></i>
</a>
</span>
...
...
app/shared/templates/directives/header-breadcrumb.html
0 → 100644
View file @
d9596de4
<ul
class=
"breadcrumb"
>
<li
ng-repeat=
"link in links"
ng-class=
"{'active':$last}"
>
<a
href=
"#"
ng-if=
"!$last"
>
{{link}}
</a>
<span
ng-if=
"$last"
>
{{link}}
</span>
</li>
</ul>
\ No newline at end of file
app/shared/templates/directives/header-notification.html
View file @
d9596de4
...
...
@@ -194,13 +194,12 @@
<i
class=
"fa fa-user fa-fw"
></i>
<i
class=
"fa fa-caret-down"
></i>
</a>
<ul
class=
"dropdown-menu dropdown-user"
>
<li><a
href=
"#"
><i
class=
"fa fa-user fa-fw"
></i>
User Profile
</a>
<li><a
href=
"#"
><i
class=
"fa fa-user fa-fw"
></i>
Profil
</a>
</li>
<li><a
href=
"#"
><i
class=
"fa fa-gear fa-fw"
></i>
Settings
</a>
<li><a
href=
"#"
><i
class=
"fa fa-gear fa-fw"
></i>
Ayarlar
</a>
</li>
<li><a
href=
"http://www.strapui.com/"
><i
class=
"fa fa-eye fa-fw"
></i>
Premium Angular Themes
</a></li>
<li
class=
"divider"
></li>
<li><a
ui-sref=
"login"
href=
"javascript:void(0);"
logout
><i
class=
"fa fa-sign-out fa-fw"
></i>
Logout
</a>
<li><a
ui-sref=
"login"
href=
"javascript:void(0);"
logout
><i
class=
"fa fa-sign-out fa-fw"
></i>
Çıkış
</a>
</li>
</ul>
<!-- /.dropdown-user -->
...
...
app/zetalib/forms/form_service.js
View file @
d9596de4
...
...
@@ -7,27 +7,40 @@
var
form_generator
=
angular
.
module
(
'formService'
,
[
'general'
]);
form_generator
.
factory
(
'Generator'
,
function
(
$http
,
$q
,
$log
,
$modal
,
$timeout
,
RESTURL
,
FormDiff
)
{
form_generator
.
factory
(
'Generator'
,
function
(
$http
,
$q
,
$log
,
$
location
,
$
modal
,
$timeout
,
RESTURL
,
FormDiff
)
{
var
generator
=
{};
generator
.
makeUrl
=
function
(
url
)
{
return
RESTURL
.
url
+
url
;
};
generator
.
generate
=
function
(
scope
,
forms
)
{
generator
.
generate
=
function
(
scope
,
data
)
{
// if no form in response (in case of list and single item request) return scope
if
(
!
forms
)
{
return
scope
;
}
for
(
var
key
in
forms
)
scope
[
key
]
=
forms
[
key
];
if
(
!
data
.
forms
)
{
return
scope
;
}
// initialModel will be used in formDiff when submiting the form to submit only
// prepare scope form, schema and model from response object
angular
.
forEach
(
data
.
forms
,
function
(
value
,
key
)
{
scope
[
key
]
=
data
.
forms
[
key
];
});
scope
.
token
=
data
.
token
;
// initialModel will be used in formDiff when submiting the form to submit only
scope
.
initialModel
=
angular
.
copy
(
scope
.
model
);
// if fieldset in form, make it collapsable with template
//scope.listnodeform = {};
//scope.isCollapsed = true;
generator
.
prepareFormItems
(
scope
);
scope
.
object_id
=
scope
.
form_params
[
'object_id'
];
return
generator
.
group
(
scope
);
};
generator
.
group
=
function
(
formObject
)
{
return
formObject
;
};
generator
.
prepareFormItems
=
function
(
scope
)
{
angular
.
forEach
(
scope
.
schema
.
properties
,
function
(
k
,
v
)
{
// check if type is date and if type date found change it to string
...
...
@@ -43,7 +56,7 @@ form_generator.factory('Generator', function ($http, $q, $log, $modal, $timeout,
}
if
(
k
.
type
==
'int'
)
{
k
.
type
=
'number'
k
.
type
=
'number'
;
}
// if type is model use foreignKey.html template to show them
...
...
@@ -76,41 +89,42 @@ form_generator.factory('Generator', function ($http, $q, $log, $modal, $timeout,
scope
.
form
[
scope
.
form
.
indexOf
(
v
)]
=
formitem
;
}
if
(
k
.
type
==
'ListNode'
)
{
// if listnode remove from form to generate its own form
//scope.form.splice([scope.form.indexOf(v)], 1);
scope
.
listnodes
=
scope
.
listnodes
?
scope
.
listnodes
:
{};
console
.
log
(
k
,
'<=====>'
,
scope
.
model
[
k
.
title
]);
//debugger;
scope
.
listnodes
[
k
.
title
]
=
(
k
);
scope
.
listnodes
[
k
.
title
][
'fields'
]
=
scope
.
model
[
k
.
title
][
0
].
fields
;
scope
.
listnodes
[
k
.
title
][
'models'
]
=
scope
.
model
[
k
.
title
][
0
].
models
;
// lengthModels is length of the listnode models. if greater than 0 show records on template
scope
.
listnodes
[
k
.
title
][
'lengthModels'
]
=
scope
.
listnodes
[
k
.
title
][
'models'
].
length
;
}
if
(
k
.
type
==
'ListNode'
||
k
.
type
==
'Node'
)
{
if
(
k
.
type
==
'Node'
)
{
//scope.form.splice([scope.form.indexOf(v)], 1);
scope
.
nodes
=
scope
.
nodes
?
scope
.
nodes
:
{};
scope
.
nodes
[
k
.
title
]
=
(
k
);
scope
.
nodes
[
k
.
title
][
'fields'
]
=
scope
.
model
[
k
.
title
][
0
].
fields
;
scope
.
nodes
[
k
.
title
][
'models'
]
=
scope
.
model
[
k
.
title
][
0
].
models
;
// lengthModels is length of the node models. if greater than 0 show records on template
scope
.
nodes
[
k
.
title
][
'lengthModels'
]
=
scope
.
nodes
[
k
.
title
][
'models'
].
length
;
// todo: learn what node model will be?
//scope.model[k.title] = [];
}
scope
[
k
.
type
]
=
scope
[
k
.
type
]
?
scope
[
k
.
type
]
:
{};
});
scope
[
k
.
type
][
k
.
title
]
=
{
title
:
k
.
title
,
form
:
[],
schema
:
{
properties
:
{},
required
:
[],
title
:
k
.
title
,
type
:
"object"
},
model
:
{}
};
scope
.
isCollapsed
=
true
;
angular
.
forEach
(
k
.
schema
,
function
(
item
)
{
scope
[
k
.
type
][
k
.
title
].
schema
.
properties
[
item
.
name
]
=
item
;
scope
[
k
.
type
][
k
.
title
].
model
[
item
.
name
]
=
item
.
value
;
scope
.
object_id
=
scope
.
form_params
[
'object_id'
];
// prepare required fields
if
(
item
.
required
==
true
)
{
scope
[
k
.
type
][
k
.
title
].
schema
.
required
.
push
(
item
.
name
);
}
return
generator
.
group
(
scope
);
};
generator
.
group
=
function
(
formObject
)
{
return
formObject
;
// idx field must be hidden
if
(
item
.
name
==
'idx'
)
{
scope
[
k
.
type
][
k
.
title
].
form
.
push
({
type
:
'string'
,
key
:
item
.
name
,
htmlClass
:
'hidden'
});
}
else
{
scope
[
k
.
type
][
k
.
title
].
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
;
}
});
return
scope
;
};
generator
.
dateformatter
=
function
(
formObject
)
{
//angular.forEach(formObject.objects, function(k, v) {
...
...
@@ -123,7 +137,7 @@ form_generator.factory('Generator', function ($http, $q, $log, $modal, $timeout,
return
$http
.
post
(
generator
.
makeUrl
(
scope
.
url
),
scope
.
form_params
)
.
then
(
function
(
res
)
{
return
generator
.
generate
(
scope
,
res
.
data
.
forms
);
return
generator
.
generate
(
scope
,
res
.
data
);
// todo: cover all other exceptions (4xx, 5xx)
});
};
...
...
@@ -164,6 +178,7 @@ form_generator.factory('Generator', function ($http, $q, $log, $modal, $timeout,
};
generator
.
submit
=
function
(
$scope
)
{
// todo: diff for all submits to recognize form change. if no change returns to view with no submit
data
=
{
"form"
:
$scope
.
model
,
"cmd"
:
$scope
.
form_params
.
cmd
,
...
...
@@ -173,12 +188,17 @@ form_generator.factory('Generator', function ($http, $q, $log, $modal, $timeout,
};
if
(
$scope
.
object_id
)
{
var
get_diff
=
FormDiff
.
get_diff
(
$scope
.
model
,
$scope
.
initialModel
);
var
data
=
{
"object_id"
:
$scope
.
object_id
,
"form"
:
get_diff
};
data
.
object_id
=
$scope
.
object_id
;
data
.
form
=
get_diff
;
}
return
$http
.
post
(
generator
.
makeUrl
(
$scope
.
url
),
data
);
debugger
;
$http
.
post
(
generator
.
makeUrl
(
$scope
.
url
),
data
)
.
success
()
.
then
(
function
(
res
){
if
(
res
.
data
.
client_cmd
){
$location
.
path
(
data
.
model
);
}
});
};
return
generator
;
});
...
...
@@ -190,123 +210,34 @@ form_generator.factory('Generator', function ($http, $q, $log, $modal, $timeout,
* @returns: returns value for modal
*/
form_generator
.
controller
(
'ModalCtrl'
,
function
(
$scope
,
$modalInstance
,
$route
,
items
)
{
form_generator
.
controller
(
'ModalCtrl'
,
function
(
$scope
,
$modalInstance
,
Generator
,
$route
,
items
)
{
angular
.
forEach
([
"model"
,
"schema"
,
"form"
],
function
(
key
)
{
$scope
[
key
]
=
items
[
key
];
});
$scope
.
onSubmit
=
function
()
{
// send form to modalinstance result function
$modalInstance
.
close
(
$scope
);
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
);
}
};
$scope
.
cancel
=
function
()
{
$modalInstance
.
dismiss
(
'cancel'
);
};
});
/**
* add modal directive for listnodes
* @params: $modal, Generator
* @return: openmodal directive
*/
form_generator
.
directive
(
'addModalForListNode'
,
function
(
$modal
,
Generator
)
{
return
{
link
:
function
(
scope
,
element
,
attributes
)
{
element
.
on
(
'click'
,
function
()
{
var
modalInstance
=
$modal
.
open
({
animation
:
false
,
templateUrl
:
'shared/templates/listnodeModalContent.html'
,
controller
:
'ModalCtrl'
,
size
:
'lg'
,
resolve
:
{
items
:
function
()
{
// get node from parent scope catch with attribute
var
node
=
scope
.
$parent
.
$parent
.
listnodes
[
attributes
[
'addModalForListNode'
]];
var
items
=
{
form
:
[],
schema
:
{
properties
:
{},
title
:
node
.
title
,
type
:
"object"
},
model
:
{}};
angular
.
forEach
(
node
.
fields
,
function
(
item
)
{
debugger
;
items
.
schema
.
properties
[
item
.
name
]
=
item
;
items
.
model
[
item
.
name
]
=
item
.
value
;
// idx field must be hidden
if
(
item
.
name
!=
'idx'
)
{
items
.
form
.
push
({
type
:
item
.
type
,
key
:
item
.
name
});
}
else
{
items
.
form
.
push
({
type
:
item
.
type
,
key
:
item
.
name
,
htmlClass
:
'hidden'
});
}
});
return
Generator
.
generate
(
scope
,
items
);
}
}
});
modalInstance
.
result
.
then
(
function
(
childmodel
,
key
)
{
// subfix will be remove
//var subfix = scope.schema.title.replace(/([a-z])([A-Z])/g, '$1_$2').toLowerCase();
// todo: run form validator here
debugger
;
scope
.
$parent
.
model
[
scope
.
schema
.
title
].
push
(
scope
.
model
);
});
});
}
}
});
/**
* edit modal directive for listnodes
* @params: $modal, Generator
* @return: openmodal directive
*/
// todo: edit modal make work properly
form_generator
.
directive
(
'editModalForListNode'
,
function
(
$modal
,
Generator
)
{
return
{
link
:
function
(
scope
,
element
,
attributes
)
{
element
.
on
(
'click'
,
function
()
{
var
modalInstance
=
$modal
.
open
({
animation
:
false
,
templateUrl
:
'shared/templates/listnodeModalContent.html'
,
controller
:
'ModalCtrl'
,
size
:
'lg'
,
resolve
:
{
items
:
function
()
{
// get node from parent scope catch with attribute
var
node
=
angular
.
copy
(
scope
.
$parent
.
$parent
.
listnodes
[
attributes
[
'addModalForListNode'
]]);
var
items
=
{
form
:
[],
schema
:
{
properties
:
{},
title
:
node
.
title
,
type
:
"object"
},
model
:
{}};
angular
.
forEach
(
node
.
fields
,
function
(
item
)
{
items
.
schema
.
properties
[
item
.
name
]
=
item
;
items
.
model
[
item
.
name
]
=
item
.
value
;
// idx field must be hidden
if
(
item
.
name
!=
'idx'
)
{
items
.
form
.
push
({
type
:
item
.
type
,
key
:
item
.
name
});
}
else
{
items
.
form
.
push
({
type
:
item
.
type
,
key
:
item
.
name
,
htmlClass
:
'hidden'
});
}
});
return
Generator
.
generate
(
scope
,
items
);
}
}
});
modalInstance
.
result
.
then
(
function
(
childmodel
,
key
)
{
// subfix will be remove
//var subfix = scope.schema.title.replace(/([a-z])([A-Z])/g, '$1_$2').toLowerCase();
// todo: run form validator here
debugger
;
scope
.
$parent
.
model
[
scope
.
schema
.
title
].
push
(
scope
.
model
);
});
});
}
}
});
/**
* add modal directive for nodes
* @params: $modal
, Generator
* @params: $modal
* @return: openmodal directive
*/
form_generator
.
directive
(
'
addModalForNode'
,
function
(
$modal
,
Generator
)
{
form_generator
.
directive
(
'
modalForNodes'
,
function
(
$modal
)
{
return
{
link
:
function
(
scope
,
element
,
attributes
)
{
element
.
on
(
'click'
,
function
()
{
...
...
@@ -317,84 +248,26 @@ form_generator.directive('addModalForNode', function ($modal, Generator) {
size
:
'lg'
,
resolve
:
{
items
:
function
()
{
var
attribs
=
attributes
[
'modalForNodes'
].
split
(
','
);
// get node from parent scope catch with attribute
var
node
=
angular
.
copy
(
scope
.
$parent
.
$parent
.
nodes
[
attributes
[
'addModalForNode'
]]);
var
items
=
{
form
:
[],
schema
:
{
properties
:
{},
title
:
node
.
title
,
type
:
"object"
},
model
:
{}};
angular
.
forEach
(
node
.
fields
,
function
(
item
)
{
items
.
schema
.
properties
[
item
.
name
]
=
item
;
items
.
model
[
item
.
name
]
=
item
.
value
;
// idx field must be hidden
if
(
item
.
name
!=
'idx'
)
{
items
.
form
.
push
({
type
:
item
.
type
,
key
:
item
.
name
});
}
else
{
items
.
form
.
push
({
type
:
item
.
type
,
key
:
item
.
name
,
htmlClass
:
'hidden'
});
}
});
return
Generator
.
generate
(
scope
,
items
);
var
node
=
angular
.
copy
(
scope
.
$parent
.
$parent
[
attribs
[
1
]][
attribs
[
0
]]);
return
node
;
}
}
});
modalInstance
.
result
.
then
(
function
(
childmodel
,
key
)
{
// subfix will be remove
// subfix will be remove
d
//var subfix = scope.schema.title.replace(/([a-z])([A-Z])/g, '$1_$2').toLowerCase();
// todo: run form validator here
debugger
;
scope
.
$parent
.
model
[
scope
.
schema
.
title
].
push
(
scope
.
model
);
scope
.
$parent
.
model
[
childmodel
.
schema
.
title
]
=
childmodel
.
model
;
console
.
log
(
scope
.
$parent
.
model
);
});
});
}
}
});
/**
* edit modal directive for nodes
* @params: $modal, Generator
* @return: openmodal directive
*/
// todo: edit modal make work properly
form_generator
.
directive
(
'editModalForNode'
,
function
(
$modal
,
Generator
)
{
return
{
link
:
function
(
scope
,
element
,
attributes
)
{
element
.
on
(
'click'
,
function
()
{
var
modalInstance
=
$modal
.
open
({
animation
:
false
,
templateUrl
:
'shared/templates/listnodeModalContent.html'
,
controller
:
'ModalCtrl'
,
size
:
'lg'
,
resolve
:
{
items
:
function
()
{
// get node from parent scope catch with attribute
var
node
=
angular
.
copy
(
scope
.
$parent
.
$parent
.
nodes
[
attributes
[
'addModalForNode'
]]);
var
items
=
{
form
:
[],
schema
:
{
properties
:
{},
title
:
node
.
title
,
type
:
"object"
},
model
:
{}};
angular
.
forEach
(
node
.
fields
,
function
(
item
)
{
items
.
schema
.
properties
[
item
.
name
]
=
item
;
items
.
model
[
item
.
name
]
=
item
.
value
;
// idx field must be hidden
if
(
item
.
name
!=
'idx'
)
{
items
.
form
.
push
({
type
:
item
.
type
,
key
:
item
.
name
});
}
else
{
items
.
form
.
push
({
type
:
item
.
type
,
key
:
item
.
name
,
htmlClass
:
'hidden'
});
}
});
return
Generator
.
generate
(
scope
,
items
);
}
}
});
modalInstance
.
result
.
then
(
function
(
childmodel
,
key
)
{
// subfix will be remove
//var subfix = scope.schema.title.replace(/([a-z])([A-Z])/g, '$1_$2').toLowerCase();
// todo: run form validator here
debugger
;
scope
.
$parent
.
model
[
scope
.
schema
.
title
].
push
(
scope
.
model
);
});
});
}
}
});
/**
* add modal directive for linked models
...
...
app/zetalib/interceptors.js
View file @
d9596de4
...
...
@@ -31,8 +31,9 @@ app.config(['$httpProvider', function ($httpProvider) {
$location
.
path
(
"/dashboard"
);
}
}
if
(
response
.
data
.
screen
)
{
$location
.
path
(
response
.
data
.
screen
);
if
(
response
.
data
.
client_cmd
)
{
//$location.path(response.data.screen);
console
.
log
(
response
.
data
.
client_cmd
);
}
return
response
;
},
...
...
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