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
22e4a979
Commit
22e4a979
authored
Nov 16, 2015
by
Evren Kutar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
general documentations for form service
parent
b14dd974
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
59 additions
and
0 deletions
+59
-0
form_service.js
app/zetalib/forms/form_service.js
+59
-0
No files found.
app/zetalib/forms/form_service.js
View file @
22e4a979
...
@@ -7,12 +7,22 @@
...
@@ -7,12 +7,22 @@
var
form_generator
=
angular
.
module
(
'formService'
,
[
'general'
]);
var
form_generator
=
angular
.
module
(
'formService'
,
[
'general'
]);
/**
* form service's Generator factory service handles all generic form operations
*/
form_generator
.
factory
(
'Generator'
,
function
(
$http
,
$q
,
$timeout
,
$location
,
$compile
,
RESTURL
,
FormDiff
,
$rootScope
)
{
form_generator
.
factory
(
'Generator'
,
function
(
$http
,
$q
,
$timeout
,
$location
,
$compile
,
RESTURL
,
FormDiff
,
$rootScope
)
{
var
generator
=
{};
var
generator
=
{};
generator
.
makeUrl
=
function
(
scope
)
{
generator
.
makeUrl
=
function
(
scope
)
{
var
getparams
=
scope
.
form_params
.
param
?
"?"
+
scope
.
form_params
.
param
+
"="
+
scope
.
form_params
.
id
:
""
;
var
getparams
=
scope
.
form_params
.
param
?
"?"
+
scope
.
form_params
.
param
+
"="
+
scope
.
form_params
.
id
:
""
;
return
RESTURL
.
url
+
scope
.
url
+
'/'
+
(
scope
.
form_params
.
model
||
''
)
+
getparams
;
return
RESTURL
.
url
+
scope
.
url
+
'/'
+
(
scope
.
form_params
.
model
||
''
)
+
getparams
;
};
};
/**
* generate function is inclusive for form generation
* defines given scope's client_cmd, model, schema, form, token, object_id objects
* @param scope
* @param data
* @returns {*}
*/
generator
.
generate
=
function
(
scope
,
data
)
{
generator
.
generate
=
function
(
scope
,
data
)
{
// if no form in response (in case of list and single item request) return scope
// if no form in response (in case of list and single item request) return scope
...
@@ -46,9 +56,20 @@ form_generator.factory('Generator', function ($http, $q, $timeout, $location, $c
...
@@ -46,9 +56,20 @@ form_generator.factory('Generator', function ($http, $q, $timeout, $location, $c
return
scope
;
return
scope
;
};
};
/**
* group function to group form layout by form meta data for layout
* @param formObject
* @returns {*}
*/
generator
.
group
=
function
(
formObject
)
{
generator
.
group
=
function
(
formObject
)
{
return
formObject
;
return
formObject
;
};
};
/**
* prepareFormItems looks up fields of schema objects and changes their types to proper type for schemaform
* for listnode, node and model types it uses templates to generate modal
* @param scope
* @returns {*}
*/
generator
.
prepareFormItems
=
function
(
scope
)
{
generator
.
prepareFormItems
=
function
(
scope
)
{
/**
/**
* prepareforms checks input types and convert if necessary
* prepareforms checks input types and convert if necessary
...
@@ -241,6 +262,11 @@ form_generator.factory('Generator', function ($http, $q, $timeout, $location, $c
...
@@ -241,6 +262,11 @@ form_generator.factory('Generator', function ($http, $q, $timeout, $location, $c
return
scope
;
return
scope
;
};
};
/**
* dateformatter handles all date fields and returns humanized and jquery datepicker format dates
* @param formObject
* @returns {*}
*/
generator
.
dateformatter
=
function
(
formObject
)
{
generator
.
dateformatter
=
function
(
formObject
)
{
var
ndate
=
new
Date
(
formObject
);
var
ndate
=
new
Date
(
formObject
);
if
(
ndate
==
'Invalid Date'
)
{
if
(
ndate
==
'Invalid Date'
)
{
...
@@ -250,6 +276,13 @@ form_generator.factory('Generator', function ($http, $q, $timeout, $location, $c
...
@@ -250,6 +276,13 @@ form_generator.factory('Generator', function ($http, $q, $timeout, $location, $c
return
newdatearray
.
join
(
'.'
);
return
newdatearray
.
join
(
'.'
);
}
}
};
};
/**
* itemLinksGenerator function used for generic links for list items
* basicly creates add, edit, detail links
* @param scope
* @param itemlist
* @returns links
*/
generator
.
itemLinksGenerator
=
function
(
scope
,
itemlist
)
{
generator
.
itemLinksGenerator
=
function
(
scope
,
itemlist
)
{
angular
.
forEach
(
itemlist
.
objects
,
function
(
value
,
key
)
{
angular
.
forEach
(
itemlist
.
objects
,
function
(
value
,
key
)
{
function
makelink
(
page
)
{
function
makelink
(
page
)
{
...
@@ -289,6 +322,11 @@ form_generator.factory('Generator', function ($http, $q, $timeout, $location, $c
...
@@ -289,6 +322,11 @@ form_generator.factory('Generator', function ($http, $q, $timeout, $location, $c
}
}
});
});
};
};
/**
* gets form
* @param scope
* @returns {*}
*/
generator
.
get_form
=
function
(
scope
)
{
generator
.
get_form
=
function
(
scope
)
{
return
$http
return
$http
.
post
(
generator
.
makeUrl
(
scope
),
scope
.
form_params
)
.
post
(
generator
.
makeUrl
(
scope
),
scope
.
form_params
)
...
@@ -296,6 +334,11 @@ form_generator.factory('Generator', function ($http, $q, $timeout, $location, $c
...
@@ -296,6 +334,11 @@ form_generator.factory('Generator', function ($http, $q, $timeout, $location, $c
return
generator
.
generate
(
scope
,
res
.
data
);
return
generator
.
generate
(
scope
,
res
.
data
);
});
});
};
};
/**
* gets list of related wf/model
* @param scope
* @returns {*}
*/
generator
.
get_list
=
function
(
scope
)
{
generator
.
get_list
=
function
(
scope
)
{
return
$http
return
$http
.
get
(
generator
.
makeUrl
(
scope
))
.
get
(
generator
.
makeUrl
(
scope
))
...
@@ -305,6 +348,11 @@ form_generator.factory('Generator', function ($http, $q, $timeout, $location, $c
...
@@ -305,6 +348,11 @@ form_generator.factory('Generator', function ($http, $q, $timeout, $location, $c
return
res
;
return
res
;
});
});
};
};
/**
* gets single object with object_id
* @param scope
* @returns {*}
*/
generator
.
get_single_item
=
function
(
scope
)
{
generator
.
get_single_item
=
function
(
scope
)
{
return
$http
return
$http
.
post
(
generator
.
makeUrl
(
scope
),
scope
.
form_params
)
.
post
(
generator
.
makeUrl
(
scope
),
scope
.
form_params
)
...
@@ -313,6 +361,12 @@ form_generator.factory('Generator', function ($http, $q, $timeout, $location, $c
...
@@ -313,6 +361,12 @@ form_generator.factory('Generator', function ($http, $q, $timeout, $location, $c
return
res
;
return
res
;
});
});
};
};
/**
* get_wf is the main function for client_cmd based api calls
* based on response content it redirects to related path/controller with pathDecider function
* @param scope
* @returns {*}
*/
generator
.
get_wf
=
function
(
scope
)
{
generator
.
get_wf
=
function
(
scope
)
{
return
$http
return
$http
.
post
(
generator
.
makeUrl
(
scope
),
scope
.
form_params
)
.
post
(
generator
.
makeUrl
(
scope
),
scope
.
form_params
)
...
@@ -425,6 +479,11 @@ form_generator.factory('Generator', function ($http, $q, $timeout, $location, $c
...
@@ -425,6 +479,11 @@ form_generator.factory('Generator', function ($http, $q, $timeout, $location, $c
//}
//}
};
};
/**
* submit function is general function for submiting forms
* @param $scope
* @returns {*}
*/
generator
.
submit
=
function
(
$scope
)
{
generator
.
submit
=
function
(
$scope
)
{
// todo: diff for all submits to recognize form change. if no change returns to view with no submit
// todo: diff for all submits to recognize form change. if no change returns to view with no submit
...
...
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