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
169cf02a
Commit
169cf02a
authored
Dec 16, 2015
by
Evren Kutar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feature form grouping added
parent
1fd76eb2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
113 additions
and
17 deletions
+113
-17
crud_controller.js
app/components/crud/crud_controller.js
+2
-1
foreignKey.html
app/shared/templates/foreignKey.html
+2
-3
form_service.js
app/zetalib/form_service.js
+109
-13
No files found.
app/components/crud/crud_controller.js
View file @
169cf02a
...
@@ -173,7 +173,8 @@ angular.module('ulakbus.crud', ['ui.bootstrap', 'schemaForm', 'formService'])
...
@@ -173,7 +173,8 @@ angular.module('ulakbus.crud', ['ui.bootstrap', 'schemaForm', 'formService'])
};
};
$scope
.
do_action
=
function
(
key
,
todo
)
{
$scope
.
do_action
=
function
(
key
,
todo
)
{
Generator
.
doItemAction
(
$scope
,
key
,
todo
.
cmd
,
todo
.
wf
,
todo
.
mode
||
'normal'
);
//Generator.doItemAction($scope, key, todo.cmd, todo.wf, todo.mode || 'normal');
Generator
.
doItemAction
(
$scope
,
key
,
todo
,
todo
.
mode
||
'normal'
);
};
};
$scope
.
getNumber
=
function
(
num
)
{
$scope
.
getNumber
=
function
(
num
)
{
...
...
app/shared/templates/foreignKey.html
View file @
169cf02a
<div
class=
"form-group {{form.htmlClass}} schema-form-select col-md-12"
<div
class=
"form-group {{form.htmlClass}} schema-form-select col-md-12"
ng-class=
"{'has-error': form.disableErrorState !== true && hasError(), 'has-success': form.disableSuccessState !== true && hasSuccess(), 'has-feedback': form.feedback !== false}"
>
ng-class=
"{'has-error': form.disableErrorState !== true && hasError(), 'has-success': form.disableSuccessState !== true && hasSuccess(), 'has-feedback': form.feedback !== false}"
>
<div
class=
"col-md-12"
>
<label
class=
"control-label {{form.labelHtmlClass}}"
ng-show=
"showTitle()"
>
<label
class=
"control-label {{form.labelHtmlClass}}"
ng-show=
"showTitle()"
>
{{form.title}}
{{form.title}}
</label>
</label>
<a
role=
"button"
><i
class=
"fa fa-plus-circle fa-fw"
add-modal-for-linked-model=
"{{form.formName}}"
></i></a>
<button
class=
"btn btn-default"
>
Ekle
<i
class=
"fa fa-plus-circle fa-fw"
add-modal-for-linked-model=
"{{form.formName}}"
></i></button>
<div
class=
"form-group input-group"
>
<div
class=
"form-group input-group"
>
<span
class=
"input-group-btn"
>
<span
class=
"input-group-btn"
>
...
@@ -51,5 +51,4 @@
...
@@ -51,5 +51,4 @@
<!--</select>-->
<!--</select>-->
<div
class=
"help-block"
sf-message=
"form.description"
></div>
<div
class=
"help-block"
sf-message=
"form.description"
></div>
</div>
</div>
</div>
\ No newline at end of file
app/zetalib/form_service.js
View file @
169cf02a
...
@@ -75,13 +75,101 @@ angular.module('formService', ['ui.bootstrap'])
...
@@ -75,13 +75,101 @@ angular.module('formService', ['ui.bootstrap'])
};
};
/**
/**
* @name group
* @name group
* @param
formObject
* @param
scope
* @description
* @description
* group function to group form layout by form meta data for layout
* group function to group form layout by form meta data for layout
*
* grouping will use an object like below when parsing its items:
*
* grouping = [
* {
* "groups": [
* {
* "group_title": "title1",
* "items": ["item1", "item2", "item3", "item4"],
* }
* ],
* "layout": "4",
* "collapse": False
* },
* {
* "groups": [
* {
* "group_title": "title2",
* "items": ["item5", "item6"],
* }
* ],
* "layout": "2",
* "collapse": False
* }]
*
* @returns {object}
* @returns {object}
*/
*/
generator
.
group
=
function
(
formObject
)
{
generator
.
group
=
function
(
scope
)
{
return
formObject
;
if
(
!
scope
.
grouping
)
{
return
scope
;}
var
newForm
=
[];
var
extractFormItem
=
function
(
itemList
)
{
var
extractedList
=
[];
angular
.
forEach
(
itemList
,
function
(
value
,
key
)
{
var
item
=
getFormItem
(
value
);
if
(
item
)
{
extractedList
.
push
(
item
);}
});
$log
.
debug
(
'extractedList: '
,
extractedList
);
return
extractedList
;
};
var
getFormItem
=
function
(
item
)
{
var
formItem
;
if
(
scope
.
form
.
indexOf
(
item
)
>
-
1
)
{
formItem
=
scope
.
form
[
scope
.
form
.
indexOf
(
item
)];
scope
.
form
.
splice
(
scope
.
form
.
indexOf
(
item
),
1
);
return
formItem
;
}
else
{
angular
.
forEach
(
scope
.
form
,
function
(
value
,
key
)
{
if
(
value
.
key
===
item
)
{
formItem
=
value
;
scope
.
form
.
splice
(
key
,
1
);
return
;
}
});
return
formItem
;
}
};
var
makeGroup
=
function
(
itemsToGroup
)
{
var
subItems
=
[];
angular
.
forEach
(
itemsToGroup
,
function
(
value
,
key
)
{
subItems
.
push
({
type
:
'fieldset'
,
items
:
extractFormItem
(
value
.
items
),
title
:
value
.
group_title
});
});
return
subItems
;
};
angular
.
forEach
(
scope
.
grouping
,
function
(
value
,
key
)
{
newForm
.
push
(
{
type
:
'fieldset'
,
items
:
makeGroup
(
value
.
groups
),
htmlClass
:
'col-md-'
+
value
.
layout
,
title
:
value
.
group_title
}
)
});
$log
.
debug
(
'grouped form: '
,
newForm
);
$log
.
debug
(
'rest of form: '
,
scope
.
form
);
$log
.
debug
(
'form united: '
,
newForm
.
concat
(
scope
.
form
));
scope
.
form
=
newForm
.
concat
(
scope
.
form
);
return
scope
;
};
};
/**
/**
* @name prepareFormItems
* @name prepareFormItems
...
@@ -277,16 +365,19 @@ angular.module('formService', ['ui.bootstrap'])
...
@@ -277,16 +365,19 @@ angular.module('formService', ['ui.bootstrap'])
// get selected item from titleMap using model value
// get selected item from titleMap using model value
if
(
scope
.
model
[
k
])
{
if
(
scope
.
model
[
k
])
{
generator
.
get_list
({
url
:
'crud'
,
form_params
:
{
model
:
v
.
model_name
,
object_id
:
scope
.
model
[
k
],
cmd
:
'show'
}})
generator
.
get_list
({
url
:
'crud'
,
form_params
:
{
model
:
v
.
model_name
,
object_id
:
scope
.
model
[
k
],
cmd
:
'show'
}
})
.
then
(
function
(
data
)
{
.
then
(
function
(
data
)
{
try
{
try
{
scope
.
$watch
(
document
.
querySelector
(
'input[name='
+
v
.
model_name
+
']'
),
scope
.
$watch
(
document
.
querySelector
(
'input[name='
+
v
.
model_name
+
']'
),
function
()
{
function
()
{
angular
.
element
(
document
.
querySelector
(
'input[name='
+
k
+
']'
)).
val
(
data
.
data
.
object
.
unicode
);
angular
.
element
(
document
.
querySelector
(
'input[name='
+
k
+
']'
)).
val
(
data
.
data
.
object
.
unicode
);
}
}
);
);
}
}
catch
(
e
)
{
catch
(
e
)
{
angular
.
element
(
document
.
querySelector
(
'input[name='
+
k
+
']'
)).
val
(
data
.
data
.
object
.
unicode
);
angular
.
element
(
document
.
querySelector
(
'input[name='
+
k
+
']'
)).
val
(
data
.
data
.
object
.
unicode
);
$log
.
debug
(
'exception'
,
e
);
$log
.
debug
(
'exception'
,
e
);
}
}
...
@@ -303,6 +394,7 @@ angular.module('formService', ['ui.bootstrap'])
...
@@ -303,6 +394,7 @@ angular.module('formService', ['ui.bootstrap'])
wf
:
v
.
wf
,
wf
:
v
.
wf
,
add_cmd
:
v
.
add_cmd
,
add_cmd
:
v
.
add_cmd
,
name
:
k
,
name
:
k
,
key
:
k
,
model_name
:
v
.
model_name
,
model_name
:
v
.
model_name
,
selected_item
:
{},
selected_item
:
{},
titleMap
:
[],
titleMap
:
[],
...
@@ -493,7 +585,7 @@ angular.module('formService', ['ui.bootstrap'])
...
@@ -493,7 +585,7 @@ angular.module('formService', ['ui.bootstrap'])
});
});
$log
.
debug
(
'scope at after prepareformitems'
,
scope
);
$log
.
debug
(
'scope at after prepareformitems'
,
scope
);
return
scope
;
return
generator
.
group
(
scope
)
;
};
};
/**
/**
* dateformatter handles all date fields and returns humanized and jquery datepicker format dates
* dateformatter handles all date fields and returns humanized and jquery datepicker format dates
...
@@ -510,22 +602,26 @@ angular.module('formService', ['ui.bootstrap'])
...
@@ -510,22 +602,26 @@ angular.module('formService', ['ui.bootstrap'])
return
newdatearray
.
join
(
'.'
);
return
newdatearray
.
join
(
'.'
);
}
}
};
};
generator
.
doItemAction
=
function
(
$scope
,
key
,
cmd
,
wf
,
mode
)
{
generator
.
doItemAction
=
function
(
$scope
,
key
,
todo
,
mode
)
{
// mode could be in ['normal', 'modal', 'new'] . the default mode is 'normal' and it loads data on same
// mode could be in ['normal', 'modal', 'new'] . the default mode is 'normal' and it loads data on same
// tab without modal. 'modal' will use modal to manipulate data and do all actions in that modal. 'new'
// tab without modal. 'modal' will use modal to manipulate data and do all actions in that modal. 'new'
// will be open new page with response data
// will be open new page with response data
var
_do
=
{
var
_do
=
{
normal
:
function
()
{
normal
:
function
()
{
$log
.
debug
(
'normal mode starts'
);
$log
.
debug
(
'normal mode starts'
);
$scope
.
form_params
.
cmd
=
cmd
;
$scope
.
form_params
.
cmd
=
todo
.
cmd
;
if
(
wf
)
{
if
(
todo
.
wf
)
{
$scope
.
url
=
wf
;
$scope
.
url
=
todo
.
wf
;
$scope
.
form_params
.
wf
=
wf
;
$scope
.
form_params
.
wf
=
todo
.
wf
;
delete
$scope
.
token
;
delete
$scope
.
token
;
delete
$scope
.
form_params
.
model
;
delete
$scope
.
form_params
.
model
;
delete
$scope
.
form_params
.
cmd
delete
$scope
.
form_params
.
cmd
}
}
$scope
.
form_params
.
object_id
=
key
;
if
(
todo
.
object_key
)
{
$scope
.
form_params
[
todo
.
object_key
]
=
key
;
}
else
{
$scope
.
form_params
.
object_id
=
key
;
}
$scope
.
form_params
.
param
=
$scope
.
param
;
$scope
.
form_params
.
param
=
$scope
.
param
;
$scope
.
form_params
.
id
=
$scope
.
param_id
;
$scope
.
form_params
.
id
=
$scope
.
param_id
;
$scope
.
form_params
.
token
=
$scope
.
token
;
$scope
.
form_params
.
token
=
$scope
.
token
;
...
...
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