Commit f9984444 authored by Evren Kutar's avatar Evren Kutar

ADD refs GH-6 add docstring details

FIX rrefs #5044 refs zetaops/ulakbusGH-153 refs GH-75
parent 608cfdac
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
<span ng-if="value.verbose_name">{{ value.verbose_name }}</span> <span ng-if="value.verbose_name">{{ value.verbose_name }}</span>
<span ng-if="!value.verbose_name">{{key}}</span> <span ng-if="!value.verbose_name">{{key}}</span>
</th> </th>
<th ng-if="action!==False">İşlem</th> <th ng-if="meta.allow_actions!==false">İşlem</th>
</tr> </tr>
</thead> </thead>
<tbody ng-class="{hidden: node.lengthModels < 1}"> <tbody ng-class="{hidden: node.lengthModels < 1}">
...@@ -55,7 +55,7 @@ ...@@ -55,7 +55,7 @@
ng-model="node.model[outerIndex][k]" ng-model="node.model[outerIndex][k]"
ng-change="nodeModelChange(this)"> ng-change="nodeModelChange(this)">
</td> </td>
<td ng-if="action!==False"> <td ng-if="meta.allow_actions!==false">
<button modal-for-nodes="{{node.schema.model_name}},{{node.schema.formType}},edit,{{$index}}">Düzenle <button modal-for-nodes="{{node.schema.model_name}},{{node.schema.formType}},edit,{{$index}}">Düzenle
</button> </button>
<br> <br>
......
...@@ -192,7 +192,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -192,7 +192,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @memberof ulakbus.formService * @memberof ulakbus.formService
* @ngdoc function * @ngdoc function
* @name prepareFormItems * @name prepareFormItems
* @param scope {object} given scope on which form items prepared * @param scope {Object} given scope on which form items prepared
* @description * @description
* It looks up fields of schema objects and changes their types to proper type for schemaform. * It looks up fields of schema objects and changes their types to proper type for schemaform.
* To prepare items for schemaform loop items of scope.schema.properties by checking index value's `type` key. * To prepare items for schemaform loop items of scope.schema.properties by checking index value's `type` key.
...@@ -204,7 +204,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -204,7 +204,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* For listnode, node and model types it uses templates to generate modal. The modal is aa instance of * For listnode, node and model types it uses templates to generate modal. The modal is aa instance of
* ui.bootstraps modal directive. * ui.bootstraps modal directive.
* *
* @returns scope {object} * @returns scope {Object}
*/ */
generator.prepareFormItems = function (scope) { generator.prepareFormItems = function (scope) {
...@@ -663,7 +663,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -663,7 +663,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name dateformatter * @name dateformatter
* @description dateformatter handles all date fields and returns humanized and jquery datepicker format dates * @description dateformatter handles all date fields and returns humanized and jquery datepicker format dates
* @param {object} formObject * @param {Object} formObject
* @returns {*} * @returns {*}
*/ */
generator.dateformatter = function (formObject) { generator.dateformatter = function (formObject) {
...@@ -684,9 +684,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -684,9 +684,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* on same * 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
* @param {object} $scope * @param {Object} $scope
* @param {string} key * @param {string} key
* @param {object} todo * @param {Object} todo
* @param {string} mode * @param {string} mode
* @returns {*} * @returns {*}
*/ */
...@@ -727,7 +727,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -727,7 +727,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name get_form * @name get_form
* @description Communicates with api with given scope object. * @description Communicates with api with given scope object.
* @param {object} scope * @param {Object} scope
* @returns {*} * @returns {*}
*/ */
generator.get_form = function (scope) { generator.get_form = function (scope) {
...@@ -836,8 +836,8 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -836,8 +836,8 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @name pathDecider * @name pathDecider
* @description pathDecider is used to redirect related path by looking up the data in response * @description pathDecider is used to redirect related path by looking up the data in response
* @param {string} client_cmd * @param {string} client_cmd
* @param {object} $scope * @param {Object} $scope
* @param {object} data * @param {Object} data
*/ */
generator.pathDecider = function (client_cmd, $scope, data) { generator.pathDecider = function (client_cmd, $scope, data) {
if (client_cmd[0] === 'reload' || client_cmd[0] === 'reset') { if (client_cmd[0] === 'reload' || client_cmd[0] === 'reset') {
...@@ -851,7 +851,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -851,7 +851,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @description redirectTo function redirects to related controller and path with given data * @description redirectTo function redirects to related controller and path with given data
* before redirect setPageData must be called and pageData need to be defined * before redirect setPageData must be called and pageData need to be defined
* otherwise redirected path will call api for its data * otherwise redirected path will call api for its data
* @param {object} scope * @param {Object} scope
* @param {string} page * @param {string} page
* @return {*} * @return {*}
*/ */
...@@ -902,9 +902,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -902,9 +902,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name get_diff * @name get_diff
* @description returns diff of the second param to first param * @description returns diff of the second param to first param
* @param {object} obj1 * @param {Object} obj1
* @param {object} obj2 * @param {Object} obj2
* @returns {{object}} diff object of two given objects * @returns {Object} diff object of two given objects
*/ */
generator.get_diff = function (obj1, obj2) { generator.get_diff = function (obj1, obj2) {
var result = {}; var result = {};
...@@ -926,10 +926,10 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -926,10 +926,10 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name get_diff_array * @name get_diff_array
* @description extracts items of second array from the first array * @description extracts items of second array from the first array
* @param {object} array1 * @param {Array} array1
* @param {object} array2 * @param {Array} array2
* @param {number} way * @param {Number} way
* @returns {Array} * @returns {Array} diff of arrays
*/ */
generator.get_diff_array = function (array1, array2, way) { generator.get_diff_array = function (array1, array2, way) {
var result = []; var result = [];
...@@ -951,8 +951,8 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -951,8 +951,8 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name item_from_array * @name item_from_array
* @description gets item unicode name from titleMap * @description gets item unicode name from titleMap
* @param {object} item * @param {Object} item
* @param {array} array * @param {Array} array
* @returns {*} * @returns {*}
*/ */
generator.item_from_array = function (item, array) { generator.item_from_array = function (item, array) {
...@@ -970,14 +970,40 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -970,14 +970,40 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name submit * @name submit
* @description Submit function is generic function for submiting forms. * @description Submit function is generic function for submiting forms.
* redirectTo param is used for redirect if return value will be evaluated in a new page. * - redirectTo param is used for redirect if return value will be evaluated in a new page.
* @param {object} $scope * - In case of unformatted date object in any key recursively, it must be converted by convertDate function.
* @param {object} redirectTo * - ListNode and Node objects get seperated from model in
* {@link prepareFormItems module:ulakbus.formService.function:prepareFormItems} They must be concat to model
* key of scope first.
* - Backend API waits form as model value. So `data.form` key must be set to `$scope.model`
* - Other parameters we pass to backend API are shown in the example below
* ```
* var data = {
"form": $scope.model,
"token": $scope.token,
"model": $scope.form_params.model,
"cmd": $scope.form_params.cmd,
"flow": $scope.form_params.flow,
"object_id": $scope.object_id,
"filter": $scope.filter,
"query": $scope.form_params.query
};
* ```
* ### Special response object process
* - If response object is a downloadable pdf file, checking from headers `headers('content-type') ===
* "application/pdf"` download using Blob object.
*
* @param {Object} $scope
* @param {Object} redirectTo
* @returns {*} * @returns {*}
* @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
*/ */
generator.submit = function ($scope, redirectTo) { generator.submit = function ($scope, redirectTo) {
/**
* In case of unformatted date object in any key recursively, it must be converted.
* @param model
*/
var convertDate = function (model) { var convertDate = function (model) {
angular.forEach(model, function (value, key) { angular.forEach(model, function (value, key) {
if (value && value.constructor === Date) { if (value && value.constructor === Date) {
...@@ -1039,11 +1065,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1039,11 +1065,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc controller * @ngdoc controller
* @name ModalCtrl * @name ModalCtrl
* @description controller for listnode, node and linkedmodel modal and save data of it * @description controller for listnode, node and linkedmodel modal and save data of it
* @param {object} items * @param {Object} items
* @param {object} $scope * @param {Object} $scope
* @param {object} $uibModalInstance * @param {Object} $uibModalInstance
* @param {object} $route * @param {Object} $route
* @returns returns value for modal * @returns {Object} returns value for modal
*/ */
.controller('ModalCtrl', function ($scope, $uibModalInstance, Generator, items) { .controller('ModalCtrl', function ($scope, $uibModalInstance, Generator, items) {
angular.forEach(items, function (value, key) { angular.forEach(items, function (value, key) {
...@@ -1091,9 +1117,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1091,9 +1117,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc directive * @ngdoc directive
* @name modalForNodes * @name modalForNodes
* @description add modal directive for nodes * @description add modal directive for nodes
* @param {module} $uibModal * @param {Module} $uibModal
* @param {service} Generator * @param {Service} Generator
* @returns openmodal directive * @returns {Object} openmodal directive
*/ */
.directive('modalForNodes', function ($uibModal, Generator) { .directive('modalForNodes', function ($uibModal, Generator) {
...@@ -1212,11 +1238,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1212,11 +1238,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc directive * @ngdoc directive
* @name addModalForLinkedModel * @name addModalForLinkedModel
* @description add modal directive for linked models * @description add modal directive for linked models
* @param {module} $uibModal * @param {Module} $uibModal
* @param {object} $rootScope * @param {Object} $rootScope
* @param {module} $route * @param {Module} $route
* @param {service} Generator * @param {Service} Generator
* @returns openmodal directive * @returns {Object} openmodal directive
*/ */
.directive('addModalForLinkedModel', function ($uibModal, $rootScope, $route, Generator) { .directive('addModalForLinkedModel', function ($uibModal, $rootScope, $route, Generator) {
return { return {
...@@ -1292,6 +1318,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1292,6 +1318,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc directive * @ngdoc directive
* @name modalFormLocator * @name modalFormLocator
* @description This directive helps to locate form object in modal. * @description This directive helps to locate form object in modal.
* @returns {Object} form object
*/ */
.directive('modalFormLocator', function () { .directive('modalFormLocator', function () {
return { return {
......
...@@ -508,7 +508,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -508,7 +508,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @memberof ulakbus.formService * @memberof ulakbus.formService
* @ngdoc function * @ngdoc function
* @name prepareFormItems * @name prepareFormItems
* @param scope {object} given scope on which form items prepared * @param scope {Object} given scope on which form items prepared
* @description * @description
* It looks up fields of schema objects and changes their types to proper type for schemaform. * It looks up fields of schema objects and changes their types to proper type for schemaform.
* To prepare items for schemaform loop items of scope.schema.properties by checking index value's `type` key. * To prepare items for schemaform loop items of scope.schema.properties by checking index value's `type` key.
...@@ -520,7 +520,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -520,7 +520,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* For listnode, node and model types it uses templates to generate modal. The modal is aa instance of * For listnode, node and model types it uses templates to generate modal. The modal is aa instance of
* ui.bootstraps modal directive. * ui.bootstraps modal directive.
* *
* @returns scope {object} * @returns scope {Object}
*/ */
generator.prepareFormItems = function (scope) { generator.prepareFormItems = function (scope) {
angular.forEach(scope.form, function (value, key) { angular.forEach(scope.form, function (value, key) {
...@@ -932,7 +932,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -932,7 +932,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name dateformatter * @name dateformatter
* @description dateformatter handles all date fields and returns humanized and jquery datepicker format dates * @description dateformatter handles all date fields and returns humanized and jquery datepicker format dates
* @param {object} formObject * @param {Object} formObject
* @returns {*} * @returns {*}
*/ */
generator.dateformatter = function (formObject) { generator.dateformatter = function (formObject) {
...@@ -953,9 +953,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -953,9 +953,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* on same * 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
* @param {object} $scope * @param {Object} $scope
* @param {string} key * @param {string} key
* @param {object} todo * @param {Object} todo
* @param {string} mode * @param {string} mode
* @returns {*} * @returns {*}
*/ */
...@@ -995,7 +995,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -995,7 +995,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name get_form * @name get_form
* @description Communicates with api with given scope object. * @description Communicates with api with given scope object.
* @param {object} scope * @param {Object} scope
* @returns {*} * @returns {*}
*/ */
generator.get_form = function (scope) { generator.get_form = function (scope) {
...@@ -1097,13 +1097,12 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1097,13 +1097,12 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
}; };
/** /**
* @memberof ulakbus.formService * @memberof ulakbus.formService
* @constructor
* @ngdoc function * @ngdoc function
* @name pathDecider * @name pathDecider
* @description pathDecider is used to redirect related path by looking up the data in response * @description pathDecider is used to redirect related path by looking up the data in response
* @param {string} client_cmd * @param {string} client_cmd
* @param {object} $scope * @param {Object} $scope
* @param {object} data * @param {Object} data
*/ */
generator.pathDecider = function (client_cmd, $scope, data) { generator.pathDecider = function (client_cmd, $scope, data) {
if (client_cmd[0] === 'reload' || client_cmd[0] === 'reset') { if (client_cmd[0] === 'reload' || client_cmd[0] === 'reset') {
...@@ -1117,7 +1116,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1117,7 +1116,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @description redirectTo function redirects to related controller and path with given data * @description redirectTo function redirects to related controller and path with given data
* before redirect setPageData must be called and pageData need to be defined * before redirect setPageData must be called and pageData need to be defined
* otherwise redirected path will call api for its data * otherwise redirected path will call api for its data
* @param {object} scope * @param {Object} scope
* @param {string} page * @param {string} page
* @return {*} * @return {*}
*/ */
...@@ -1163,9 +1162,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1163,9 +1162,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name get_diff * @name get_diff
* @description returns diff of the second param to first param * @description returns diff of the second param to first param
* @param {object} obj1 * @param {Object} obj1
* @param {object} obj2 * @param {Object} obj2
* @returns {{object}} diff object of two given objects * @returns {Object} diff object of two given objects
*/ */
generator.get_diff = function (obj1, obj2) { generator.get_diff = function (obj1, obj2) {
var result = {}; var result = {};
...@@ -1187,10 +1186,10 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1187,10 +1186,10 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name get_diff_array * @name get_diff_array
* @description extracts items of second array from the first array * @description extracts items of second array from the first array
* @param {object} array1 * @param {Array} array1
* @param {object} array2 * @param {Array} array2
* @param {number} way * @param {Number} way
* @returns {Array} * @returns {Array} diff of arrays
*/ */
generator.get_diff_array = function (array1, array2, way) { generator.get_diff_array = function (array1, array2, way) {
var result = []; var result = [];
...@@ -1212,8 +1211,8 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1212,8 +1211,8 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name item_from_array * @name item_from_array
* @description gets item unicode name from titleMap * @description gets item unicode name from titleMap
* @param {object} item * @param {Object} item
* @param {array} array * @param {Array} array
* @returns {*} * @returns {*}
*/ */
generator.item_from_array = function (item, array) { generator.item_from_array = function (item, array) {
...@@ -1230,13 +1229,39 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1230,13 +1229,39 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name submit * @name submit
* @description Submit function is generic function for submiting forms. * @description Submit function is generic function for submiting forms.
* redirectTo param is used for redirect if return value will be evaluated in a new page. * - redirectTo param is used for redirect if return value will be evaluated in a new page.
* @param {object} $scope * - In case of unformatted date object in any key recursively, it must be converted by convertDate function.
* @param {object} redirectTo * - ListNode and Node objects get seperated from model in
* {@link prepareFormItems module:ulakbus.formService.function:prepareFormItems} They must be concat to model
* key of scope first.
* - Backend API waits form as model value. So `data.form` key must be set to `$scope.model`
* - Other parameters we pass to backend API are shown in the example below
* ```
* var data = {
"form": $scope.model,
"token": $scope.token,
"model": $scope.form_params.model,
"cmd": $scope.form_params.cmd,
"flow": $scope.form_params.flow,
"object_id": $scope.object_id,
"filter": $scope.filter,
"query": $scope.form_params.query
};
* ```
* ### Special response object process
* - If response object is a downloadable pdf file, checking from headers `headers('content-type') ===
* "application/pdf"` download using Blob object.
*
* @param {Object} $scope
* @param {Object} redirectTo
* @returns {*} * @returns {*}
* @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
*/ */
generator.submit = function ($scope, redirectTo) { generator.submit = function ($scope, redirectTo) {
/**
* In case of unformatted date object in any key recursively, it must be converted.
* @param model
*/
var convertDate = function (model) { var convertDate = function (model) {
angular.forEach(model, function (value, key) { angular.forEach(model, function (value, key) {
if (value && value.constructor === Date) { if (value && value.constructor === Date) {
...@@ -1295,11 +1320,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1295,11 +1320,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc controller * @ngdoc controller
* @name ModalCtrl * @name ModalCtrl
* @description controller for listnode, node and linkedmodel modal and save data of it * @description controller for listnode, node and linkedmodel modal and save data of it
* @param {object} items * @param {Object} items
* @param {object} $scope * @param {Object} $scope
* @param {object} $uibModalInstance * @param {Object} $uibModalInstance
* @param {object} $route * @param {Object} $route
* @returns returns value for modal * @returns {Object} returns value for modal
*/ */
.controller('ModalCtrl', function ($scope, $uibModalInstance, Generator, items) { .controller('ModalCtrl', function ($scope, $uibModalInstance, Generator, items) {
angular.forEach(items, function (value, key) { angular.forEach(items, function (value, key) {
...@@ -1339,9 +1364,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1339,9 +1364,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc directive * @ngdoc directive
* @name modalForNodes * @name modalForNodes
* @description add modal directive for nodes * @description add modal directive for nodes
* @param {module} $uibModal * @param {Module} $uibModal
* @param {service} Generator * @param {Service} Generator
* @returns openmodal directive * @returns {Object} openmodal directive
*/ */
.directive('modalForNodes', function ($uibModal, Generator) { .directive('modalForNodes', function ($uibModal, Generator) {
return { return {
...@@ -1446,11 +1471,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1446,11 +1471,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc directive * @ngdoc directive
* @name addModalForLinkedModel * @name addModalForLinkedModel
* @description add modal directive for linked models * @description add modal directive for linked models
* @param {module} $uibModal * @param {Module} $uibModal
* @param {object} $rootScope * @param {Object} $rootScope
* @param {module} $route * @param {Module} $route
* @param {service} Generator * @param {Service} Generator
* @returns openmodal directive * @returns {Object} openmodal directive
*/ */
.directive('addModalForLinkedModel', function ($uibModal, $rootScope, $route, Generator) { .directive('addModalForLinkedModel', function ($uibModal, $rootScope, $route, Generator) {
return { return {
...@@ -1524,6 +1549,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1524,6 +1549,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc directive * @ngdoc directive
* @name modalFormLocator * @name modalFormLocator
* @description This directive helps to locate form object in modal. * @description This directive helps to locate form object in modal.
* @returns {Object} form object
*/ */
.directive('modalFormLocator', function () { .directive('modalFormLocator', function () {
return { return {
......
...@@ -508,7 +508,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -508,7 +508,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @memberof ulakbus.formService * @memberof ulakbus.formService
* @ngdoc function * @ngdoc function
* @name prepareFormItems * @name prepareFormItems
* @param scope {object} given scope on which form items prepared * @param scope {Object} given scope on which form items prepared
* @description * @description
* It looks up fields of schema objects and changes their types to proper type for schemaform. * It looks up fields of schema objects and changes their types to proper type for schemaform.
* To prepare items for schemaform loop items of scope.schema.properties by checking index value's `type` key. * To prepare items for schemaform loop items of scope.schema.properties by checking index value's `type` key.
...@@ -520,7 +520,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -520,7 +520,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* For listnode, node and model types it uses templates to generate modal. The modal is aa instance of * For listnode, node and model types it uses templates to generate modal. The modal is aa instance of
* ui.bootstraps modal directive. * ui.bootstraps modal directive.
* *
* @returns scope {object} * @returns scope {Object}
*/ */
generator.prepareFormItems = function (scope) { generator.prepareFormItems = function (scope) {
angular.forEach(scope.form, function (value, key) { angular.forEach(scope.form, function (value, key) {
...@@ -932,7 +932,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -932,7 +932,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name dateformatter * @name dateformatter
* @description dateformatter handles all date fields and returns humanized and jquery datepicker format dates * @description dateformatter handles all date fields and returns humanized and jquery datepicker format dates
* @param {object} formObject * @param {Object} formObject
* @returns {*} * @returns {*}
*/ */
generator.dateformatter = function (formObject) { generator.dateformatter = function (formObject) {
...@@ -953,9 +953,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -953,9 +953,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* on same * 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
* @param {object} $scope * @param {Object} $scope
* @param {string} key * @param {string} key
* @param {object} todo * @param {Object} todo
* @param {string} mode * @param {string} mode
* @returns {*} * @returns {*}
*/ */
...@@ -995,7 +995,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -995,7 +995,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name get_form * @name get_form
* @description Communicates with api with given scope object. * @description Communicates with api with given scope object.
* @param {object} scope * @param {Object} scope
* @returns {*} * @returns {*}
*/ */
generator.get_form = function (scope) { generator.get_form = function (scope) {
...@@ -1097,13 +1097,12 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1097,13 +1097,12 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
}; };
/** /**
* @memberof ulakbus.formService * @memberof ulakbus.formService
* @constructor
* @ngdoc function * @ngdoc function
* @name pathDecider * @name pathDecider
* @description pathDecider is used to redirect related path by looking up the data in response * @description pathDecider is used to redirect related path by looking up the data in response
* @param {string} client_cmd * @param {string} client_cmd
* @param {object} $scope * @param {Object} $scope
* @param {object} data * @param {Object} data
*/ */
generator.pathDecider = function (client_cmd, $scope, data) { generator.pathDecider = function (client_cmd, $scope, data) {
if (client_cmd[0] === 'reload' || client_cmd[0] === 'reset') { if (client_cmd[0] === 'reload' || client_cmd[0] === 'reset') {
...@@ -1117,7 +1116,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1117,7 +1116,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @description redirectTo function redirects to related controller and path with given data * @description redirectTo function redirects to related controller and path with given data
* before redirect setPageData must be called and pageData need to be defined * before redirect setPageData must be called and pageData need to be defined
* otherwise redirected path will call api for its data * otherwise redirected path will call api for its data
* @param {object} scope * @param {Object} scope
* @param {string} page * @param {string} page
* @return {*} * @return {*}
*/ */
...@@ -1163,9 +1162,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1163,9 +1162,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name get_diff * @name get_diff
* @description returns diff of the second param to first param * @description returns diff of the second param to first param
* @param {object} obj1 * @param {Object} obj1
* @param {object} obj2 * @param {Object} obj2
* @returns {{object}} diff object of two given objects * @returns {Object} diff object of two given objects
*/ */
generator.get_diff = function (obj1, obj2) { generator.get_diff = function (obj1, obj2) {
var result = {}; var result = {};
...@@ -1187,10 +1186,10 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1187,10 +1186,10 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name get_diff_array * @name get_diff_array
* @description extracts items of second array from the first array * @description extracts items of second array from the first array
* @param {object} array1 * @param {Array} array1
* @param {object} array2 * @param {Array} array2
* @param {number} way * @param {Number} way
* @returns {Array} * @returns {Array} diff of arrays
*/ */
generator.get_diff_array = function (array1, array2, way) { generator.get_diff_array = function (array1, array2, way) {
var result = []; var result = [];
...@@ -1212,8 +1211,8 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1212,8 +1211,8 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name item_from_array * @name item_from_array
* @description gets item unicode name from titleMap * @description gets item unicode name from titleMap
* @param {object} item * @param {Object} item
* @param {array} array * @param {Array} array
* @returns {*} * @returns {*}
*/ */
generator.item_from_array = function (item, array) { generator.item_from_array = function (item, array) {
...@@ -1230,13 +1229,39 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1230,13 +1229,39 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name submit * @name submit
* @description Submit function is generic function for submiting forms. * @description Submit function is generic function for submiting forms.
* redirectTo param is used for redirect if return value will be evaluated in a new page. * - redirectTo param is used for redirect if return value will be evaluated in a new page.
* @param {object} $scope * - In case of unformatted date object in any key recursively, it must be converted by convertDate function.
* @param {object} redirectTo * - ListNode and Node objects get seperated from model in
* {@link prepareFormItems module:ulakbus.formService.function:prepareFormItems} They must be concat to model
* key of scope first.
* - Backend API waits form as model value. So `data.form` key must be set to `$scope.model`
* - Other parameters we pass to backend API are shown in the example below
* ```
* var data = {
"form": $scope.model,
"token": $scope.token,
"model": $scope.form_params.model,
"cmd": $scope.form_params.cmd,
"flow": $scope.form_params.flow,
"object_id": $scope.object_id,
"filter": $scope.filter,
"query": $scope.form_params.query
};
* ```
* ### Special response object process
* - If response object is a downloadable pdf file, checking from headers `headers('content-type') ===
* "application/pdf"` download using Blob object.
*
* @param {Object} $scope
* @param {Object} redirectTo
* @returns {*} * @returns {*}
* @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
*/ */
generator.submit = function ($scope, redirectTo) { generator.submit = function ($scope, redirectTo) {
/**
* In case of unformatted date object in any key recursively, it must be converted.
* @param model
*/
var convertDate = function (model) { var convertDate = function (model) {
angular.forEach(model, function (value, key) { angular.forEach(model, function (value, key) {
if (value && value.constructor === Date) { if (value && value.constructor === Date) {
...@@ -1295,11 +1320,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1295,11 +1320,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc controller * @ngdoc controller
* @name ModalCtrl * @name ModalCtrl
* @description controller for listnode, node and linkedmodel modal and save data of it * @description controller for listnode, node and linkedmodel modal and save data of it
* @param {object} items * @param {Object} items
* @param {object} $scope * @param {Object} $scope
* @param {object} $uibModalInstance * @param {Object} $uibModalInstance
* @param {object} $route * @param {Object} $route
* @returns returns value for modal * @returns {Object} returns value for modal
*/ */
.controller('ModalCtrl', function ($scope, $uibModalInstance, Generator, items) { .controller('ModalCtrl', function ($scope, $uibModalInstance, Generator, items) {
angular.forEach(items, function (value, key) { angular.forEach(items, function (value, key) {
...@@ -1339,9 +1364,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1339,9 +1364,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc directive * @ngdoc directive
* @name modalForNodes * @name modalForNodes
* @description add modal directive for nodes * @description add modal directive for nodes
* @param {module} $uibModal * @param {Module} $uibModal
* @param {service} Generator * @param {Service} Generator
* @returns openmodal directive * @returns {Object} openmodal directive
*/ */
.directive('modalForNodes', function ($uibModal, Generator) { .directive('modalForNodes', function ($uibModal, Generator) {
return { return {
...@@ -1446,11 +1471,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1446,11 +1471,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc directive * @ngdoc directive
* @name addModalForLinkedModel * @name addModalForLinkedModel
* @description add modal directive for linked models * @description add modal directive for linked models
* @param {module} $uibModal * @param {Module} $uibModal
* @param {object} $rootScope * @param {Object} $rootScope
* @param {module} $route * @param {Module} $route
* @param {service} Generator * @param {Service} Generator
* @returns openmodal directive * @returns {Object} openmodal directive
*/ */
.directive('addModalForLinkedModel', function ($uibModal, $rootScope, $route, Generator) { .directive('addModalForLinkedModel', function ($uibModal, $rootScope, $route, Generator) {
return { return {
...@@ -1524,6 +1549,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1524,6 +1549,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc directive * @ngdoc directive
* @name modalFormLocator * @name modalFormLocator
* @description This directive helps to locate form object in modal. * @description This directive helps to locate form object in modal.
* @returns {Object} form object
*/ */
.directive('modalFormLocator', function () { .directive('modalFormLocator', function () {
return { return {
......
...@@ -508,7 +508,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -508,7 +508,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @memberof ulakbus.formService * @memberof ulakbus.formService
* @ngdoc function * @ngdoc function
* @name prepareFormItems * @name prepareFormItems
* @param scope {object} given scope on which form items prepared * @param scope {Object} given scope on which form items prepared
* @description * @description
* It looks up fields of schema objects and changes their types to proper type for schemaform. * It looks up fields of schema objects and changes their types to proper type for schemaform.
* To prepare items for schemaform loop items of scope.schema.properties by checking index value's `type` key. * To prepare items for schemaform loop items of scope.schema.properties by checking index value's `type` key.
...@@ -520,7 +520,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -520,7 +520,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* For listnode, node and model types it uses templates to generate modal. The modal is aa instance of * For listnode, node and model types it uses templates to generate modal. The modal is aa instance of
* ui.bootstraps modal directive. * ui.bootstraps modal directive.
* *
* @returns scope {object} * @returns scope {Object}
*/ */
generator.prepareFormItems = function (scope) { generator.prepareFormItems = function (scope) {
angular.forEach(scope.form, function (value, key) { angular.forEach(scope.form, function (value, key) {
...@@ -932,7 +932,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -932,7 +932,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name dateformatter * @name dateformatter
* @description dateformatter handles all date fields and returns humanized and jquery datepicker format dates * @description dateformatter handles all date fields and returns humanized and jquery datepicker format dates
* @param {object} formObject * @param {Object} formObject
* @returns {*} * @returns {*}
*/ */
generator.dateformatter = function (formObject) { generator.dateformatter = function (formObject) {
...@@ -953,9 +953,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -953,9 +953,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* on same * 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
* @param {object} $scope * @param {Object} $scope
* @param {string} key * @param {string} key
* @param {object} todo * @param {Object} todo
* @param {string} mode * @param {string} mode
* @returns {*} * @returns {*}
*/ */
...@@ -995,7 +995,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -995,7 +995,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name get_form * @name get_form
* @description Communicates with api with given scope object. * @description Communicates with api with given scope object.
* @param {object} scope * @param {Object} scope
* @returns {*} * @returns {*}
*/ */
generator.get_form = function (scope) { generator.get_form = function (scope) {
...@@ -1097,13 +1097,12 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1097,13 +1097,12 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
}; };
/** /**
* @memberof ulakbus.formService * @memberof ulakbus.formService
* @constructor
* @ngdoc function * @ngdoc function
* @name pathDecider * @name pathDecider
* @description pathDecider is used to redirect related path by looking up the data in response * @description pathDecider is used to redirect related path by looking up the data in response
* @param {string} client_cmd * @param {string} client_cmd
* @param {object} $scope * @param {Object} $scope
* @param {object} data * @param {Object} data
*/ */
generator.pathDecider = function (client_cmd, $scope, data) { generator.pathDecider = function (client_cmd, $scope, data) {
if (client_cmd[0] === 'reload' || client_cmd[0] === 'reset') { if (client_cmd[0] === 'reload' || client_cmd[0] === 'reset') {
...@@ -1117,7 +1116,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1117,7 +1116,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @description redirectTo function redirects to related controller and path with given data * @description redirectTo function redirects to related controller and path with given data
* before redirect setPageData must be called and pageData need to be defined * before redirect setPageData must be called and pageData need to be defined
* otherwise redirected path will call api for its data * otherwise redirected path will call api for its data
* @param {object} scope * @param {Object} scope
* @param {string} page * @param {string} page
* @return {*} * @return {*}
*/ */
...@@ -1163,9 +1162,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1163,9 +1162,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name get_diff * @name get_diff
* @description returns diff of the second param to first param * @description returns diff of the second param to first param
* @param {object} obj1 * @param {Object} obj1
* @param {object} obj2 * @param {Object} obj2
* @returns {{object}} diff object of two given objects * @returns {Object} diff object of two given objects
*/ */
generator.get_diff = function (obj1, obj2) { generator.get_diff = function (obj1, obj2) {
var result = {}; var result = {};
...@@ -1187,10 +1186,10 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1187,10 +1186,10 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name get_diff_array * @name get_diff_array
* @description extracts items of second array from the first array * @description extracts items of second array from the first array
* @param {object} array1 * @param {Array} array1
* @param {object} array2 * @param {Array} array2
* @param {number} way * @param {Number} way
* @returns {Array} * @returns {Array} diff of arrays
*/ */
generator.get_diff_array = function (array1, array2, way) { generator.get_diff_array = function (array1, array2, way) {
var result = []; var result = [];
...@@ -1212,8 +1211,8 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1212,8 +1211,8 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name item_from_array * @name item_from_array
* @description gets item unicode name from titleMap * @description gets item unicode name from titleMap
* @param {object} item * @param {Object} item
* @param {array} array * @param {Array} array
* @returns {*} * @returns {*}
*/ */
generator.item_from_array = function (item, array) { generator.item_from_array = function (item, array) {
...@@ -1230,13 +1229,39 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1230,13 +1229,39 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name submit * @name submit
* @description Submit function is generic function for submiting forms. * @description Submit function is generic function for submiting forms.
* redirectTo param is used for redirect if return value will be evaluated in a new page. * - redirectTo param is used for redirect if return value will be evaluated in a new page.
* @param {object} $scope * - In case of unformatted date object in any key recursively, it must be converted by convertDate function.
* @param {object} redirectTo * - ListNode and Node objects get seperated from model in
* {@link prepareFormItems module:ulakbus.formService.function:prepareFormItems} They must be concat to model
* key of scope first.
* - Backend API waits form as model value. So `data.form` key must be set to `$scope.model`
* - Other parameters we pass to backend API are shown in the example below
* ```
* var data = {
"form": $scope.model,
"token": $scope.token,
"model": $scope.form_params.model,
"cmd": $scope.form_params.cmd,
"flow": $scope.form_params.flow,
"object_id": $scope.object_id,
"filter": $scope.filter,
"query": $scope.form_params.query
};
* ```
* ### Special response object process
* - If response object is a downloadable pdf file, checking from headers `headers('content-type') ===
* "application/pdf"` download using Blob object.
*
* @param {Object} $scope
* @param {Object} redirectTo
* @returns {*} * @returns {*}
* @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
*/ */
generator.submit = function ($scope, redirectTo) { generator.submit = function ($scope, redirectTo) {
/**
* In case of unformatted date object in any key recursively, it must be converted.
* @param model
*/
var convertDate = function (model) { var convertDate = function (model) {
angular.forEach(model, function (value, key) { angular.forEach(model, function (value, key) {
if (value && value.constructor === Date) { if (value && value.constructor === Date) {
...@@ -1295,11 +1320,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1295,11 +1320,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc controller * @ngdoc controller
* @name ModalCtrl * @name ModalCtrl
* @description controller for listnode, node and linkedmodel modal and save data of it * @description controller for listnode, node and linkedmodel modal and save data of it
* @param {object} items * @param {Object} items
* @param {object} $scope * @param {Object} $scope
* @param {object} $uibModalInstance * @param {Object} $uibModalInstance
* @param {object} $route * @param {Object} $route
* @returns returns value for modal * @returns {Object} returns value for modal
*/ */
.controller('ModalCtrl', function ($scope, $uibModalInstance, Generator, items) { .controller('ModalCtrl', function ($scope, $uibModalInstance, Generator, items) {
angular.forEach(items, function (value, key) { angular.forEach(items, function (value, key) {
...@@ -1339,9 +1364,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1339,9 +1364,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc directive * @ngdoc directive
* @name modalForNodes * @name modalForNodes
* @description add modal directive for nodes * @description add modal directive for nodes
* @param {module} $uibModal * @param {Module} $uibModal
* @param {service} Generator * @param {Service} Generator
* @returns openmodal directive * @returns {Object} openmodal directive
*/ */
.directive('modalForNodes', function ($uibModal, Generator) { .directive('modalForNodes', function ($uibModal, Generator) {
return { return {
...@@ -1446,11 +1471,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1446,11 +1471,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc directive * @ngdoc directive
* @name addModalForLinkedModel * @name addModalForLinkedModel
* @description add modal directive for linked models * @description add modal directive for linked models
* @param {module} $uibModal * @param {Module} $uibModal
* @param {object} $rootScope * @param {Object} $rootScope
* @param {module} $route * @param {Module} $route
* @param {service} Generator * @param {Service} Generator
* @returns openmodal directive * @returns {Object} openmodal directive
*/ */
.directive('addModalForLinkedModel', function ($uibModal, $rootScope, $route, Generator) { .directive('addModalForLinkedModel', function ($uibModal, $rootScope, $route, Generator) {
return { return {
...@@ -1524,6 +1549,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1524,6 +1549,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc directive * @ngdoc directive
* @name modalFormLocator * @name modalFormLocator
* @description This directive helps to locate form object in modal. * @description This directive helps to locate form object in modal.
* @returns {Object} form object
*/ */
.directive('modalFormLocator', function () { .directive('modalFormLocator', function () {
return { return {
......
...@@ -508,7 +508,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -508,7 +508,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @memberof ulakbus.formService * @memberof ulakbus.formService
* @ngdoc function * @ngdoc function
* @name prepareFormItems * @name prepareFormItems
* @param scope {object} given scope on which form items prepared * @param scope {Object} given scope on which form items prepared
* @description * @description
* It looks up fields of schema objects and changes their types to proper type for schemaform. * It looks up fields of schema objects and changes their types to proper type for schemaform.
* To prepare items for schemaform loop items of scope.schema.properties by checking index value's `type` key. * To prepare items for schemaform loop items of scope.schema.properties by checking index value's `type` key.
...@@ -520,7 +520,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -520,7 +520,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* For listnode, node and model types it uses templates to generate modal. The modal is aa instance of * For listnode, node and model types it uses templates to generate modal. The modal is aa instance of
* ui.bootstraps modal directive. * ui.bootstraps modal directive.
* *
* @returns scope {object} * @returns scope {Object}
*/ */
generator.prepareFormItems = function (scope) { generator.prepareFormItems = function (scope) {
angular.forEach(scope.form, function (value, key) { angular.forEach(scope.form, function (value, key) {
...@@ -932,7 +932,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -932,7 +932,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name dateformatter * @name dateformatter
* @description dateformatter handles all date fields and returns humanized and jquery datepicker format dates * @description dateformatter handles all date fields and returns humanized and jquery datepicker format dates
* @param {object} formObject * @param {Object} formObject
* @returns {*} * @returns {*}
*/ */
generator.dateformatter = function (formObject) { generator.dateformatter = function (formObject) {
...@@ -953,9 +953,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -953,9 +953,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* on same * 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
* @param {object} $scope * @param {Object} $scope
* @param {string} key * @param {string} key
* @param {object} todo * @param {Object} todo
* @param {string} mode * @param {string} mode
* @returns {*} * @returns {*}
*/ */
...@@ -995,7 +995,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -995,7 +995,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name get_form * @name get_form
* @description Communicates with api with given scope object. * @description Communicates with api with given scope object.
* @param {object} scope * @param {Object} scope
* @returns {*} * @returns {*}
*/ */
generator.get_form = function (scope) { generator.get_form = function (scope) {
...@@ -1097,13 +1097,12 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1097,13 +1097,12 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
}; };
/** /**
* @memberof ulakbus.formService * @memberof ulakbus.formService
* @constructor
* @ngdoc function * @ngdoc function
* @name pathDecider * @name pathDecider
* @description pathDecider is used to redirect related path by looking up the data in response * @description pathDecider is used to redirect related path by looking up the data in response
* @param {string} client_cmd * @param {string} client_cmd
* @param {object} $scope * @param {Object} $scope
* @param {object} data * @param {Object} data
*/ */
generator.pathDecider = function (client_cmd, $scope, data) { generator.pathDecider = function (client_cmd, $scope, data) {
if (client_cmd[0] === 'reload' || client_cmd[0] === 'reset') { if (client_cmd[0] === 'reload' || client_cmd[0] === 'reset') {
...@@ -1117,7 +1116,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1117,7 +1116,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @description redirectTo function redirects to related controller and path with given data * @description redirectTo function redirects to related controller and path with given data
* before redirect setPageData must be called and pageData need to be defined * before redirect setPageData must be called and pageData need to be defined
* otherwise redirected path will call api for its data * otherwise redirected path will call api for its data
* @param {object} scope * @param {Object} scope
* @param {string} page * @param {string} page
* @return {*} * @return {*}
*/ */
...@@ -1163,9 +1162,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1163,9 +1162,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name get_diff * @name get_diff
* @description returns diff of the second param to first param * @description returns diff of the second param to first param
* @param {object} obj1 * @param {Object} obj1
* @param {object} obj2 * @param {Object} obj2
* @returns {{object}} diff object of two given objects * @returns {Object} diff object of two given objects
*/ */
generator.get_diff = function (obj1, obj2) { generator.get_diff = function (obj1, obj2) {
var result = {}; var result = {};
...@@ -1187,10 +1186,10 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1187,10 +1186,10 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name get_diff_array * @name get_diff_array
* @description extracts items of second array from the first array * @description extracts items of second array from the first array
* @param {object} array1 * @param {Array} array1
* @param {object} array2 * @param {Array} array2
* @param {number} way * @param {Number} way
* @returns {Array} * @returns {Array} diff of arrays
*/ */
generator.get_diff_array = function (array1, array2, way) { generator.get_diff_array = function (array1, array2, way) {
var result = []; var result = [];
...@@ -1212,8 +1211,8 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1212,8 +1211,8 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name item_from_array * @name item_from_array
* @description gets item unicode name from titleMap * @description gets item unicode name from titleMap
* @param {object} item * @param {Object} item
* @param {array} array * @param {Array} array
* @returns {*} * @returns {*}
*/ */
generator.item_from_array = function (item, array) { generator.item_from_array = function (item, array) {
...@@ -1230,13 +1229,39 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1230,13 +1229,39 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name submit * @name submit
* @description Submit function is generic function for submiting forms. * @description Submit function is generic function for submiting forms.
* redirectTo param is used for redirect if return value will be evaluated in a new page. * - redirectTo param is used for redirect if return value will be evaluated in a new page.
* @param {object} $scope * - In case of unformatted date object in any key recursively, it must be converted by convertDate function.
* @param {object} redirectTo * - ListNode and Node objects get seperated from model in
* {@link prepareFormItems module:ulakbus.formService.function:prepareFormItems} They must be concat to model
* key of scope first.
* - Backend API waits form as model value. So `data.form` key must be set to `$scope.model`
* - Other parameters we pass to backend API are shown in the example below
* ```
* var data = {
"form": $scope.model,
"token": $scope.token,
"model": $scope.form_params.model,
"cmd": $scope.form_params.cmd,
"flow": $scope.form_params.flow,
"object_id": $scope.object_id,
"filter": $scope.filter,
"query": $scope.form_params.query
};
* ```
* ### Special response object process
* - If response object is a downloadable pdf file, checking from headers `headers('content-type') ===
* "application/pdf"` download using Blob object.
*
* @param {Object} $scope
* @param {Object} redirectTo
* @returns {*} * @returns {*}
* @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
*/ */
generator.submit = function ($scope, redirectTo) { generator.submit = function ($scope, redirectTo) {
/**
* In case of unformatted date object in any key recursively, it must be converted.
* @param model
*/
var convertDate = function (model) { var convertDate = function (model) {
angular.forEach(model, function (value, key) { angular.forEach(model, function (value, key) {
if (value && value.constructor === Date) { if (value && value.constructor === Date) {
...@@ -1295,11 +1320,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1295,11 +1320,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc controller * @ngdoc controller
* @name ModalCtrl * @name ModalCtrl
* @description controller for listnode, node and linkedmodel modal and save data of it * @description controller for listnode, node and linkedmodel modal and save data of it
* @param {object} items * @param {Object} items
* @param {object} $scope * @param {Object} $scope
* @param {object} $uibModalInstance * @param {Object} $uibModalInstance
* @param {object} $route * @param {Object} $route
* @returns returns value for modal * @returns {Object} returns value for modal
*/ */
.controller('ModalCtrl', function ($scope, $uibModalInstance, Generator, items) { .controller('ModalCtrl', function ($scope, $uibModalInstance, Generator, items) {
angular.forEach(items, function (value, key) { angular.forEach(items, function (value, key) {
...@@ -1339,9 +1364,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1339,9 +1364,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc directive * @ngdoc directive
* @name modalForNodes * @name modalForNodes
* @description add modal directive for nodes * @description add modal directive for nodes
* @param {module} $uibModal * @param {Module} $uibModal
* @param {service} Generator * @param {Service} Generator
* @returns openmodal directive * @returns {Object} openmodal directive
*/ */
.directive('modalForNodes', function ($uibModal, Generator) { .directive('modalForNodes', function ($uibModal, Generator) {
return { return {
...@@ -1446,11 +1471,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1446,11 +1471,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc directive * @ngdoc directive
* @name addModalForLinkedModel * @name addModalForLinkedModel
* @description add modal directive for linked models * @description add modal directive for linked models
* @param {module} $uibModal * @param {Module} $uibModal
* @param {object} $rootScope * @param {Object} $rootScope
* @param {module} $route * @param {Module} $route
* @param {service} Generator * @param {Service} Generator
* @returns openmodal directive * @returns {Object} openmodal directive
*/ */
.directive('addModalForLinkedModel', function ($uibModal, $rootScope, $route, Generator) { .directive('addModalForLinkedModel', function ($uibModal, $rootScope, $route, Generator) {
return { return {
...@@ -1524,6 +1549,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1524,6 +1549,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc directive * @ngdoc directive
* @name modalFormLocator * @name modalFormLocator
* @description This directive helps to locate form object in modal. * @description This directive helps to locate form object in modal.
* @returns {Object} form object
*/ */
.directive('modalFormLocator', function () { .directive('modalFormLocator', function () {
return { return {
......
...@@ -508,7 +508,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -508,7 +508,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @memberof ulakbus.formService * @memberof ulakbus.formService
* @ngdoc function * @ngdoc function
* @name prepareFormItems * @name prepareFormItems
* @param scope {object} given scope on which form items prepared * @param scope {Object} given scope on which form items prepared
* @description * @description
* It looks up fields of schema objects and changes their types to proper type for schemaform. * It looks up fields of schema objects and changes their types to proper type for schemaform.
* To prepare items for schemaform loop items of scope.schema.properties by checking index value's `type` key. * To prepare items for schemaform loop items of scope.schema.properties by checking index value's `type` key.
...@@ -520,7 +520,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -520,7 +520,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* For listnode, node and model types it uses templates to generate modal. The modal is aa instance of * For listnode, node and model types it uses templates to generate modal. The modal is aa instance of
* ui.bootstraps modal directive. * ui.bootstraps modal directive.
* *
* @returns scope {object} * @returns scope {Object}
*/ */
generator.prepareFormItems = function (scope) { generator.prepareFormItems = function (scope) {
angular.forEach(scope.form, function (value, key) { angular.forEach(scope.form, function (value, key) {
...@@ -932,7 +932,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -932,7 +932,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name dateformatter * @name dateformatter
* @description dateformatter handles all date fields and returns humanized and jquery datepicker format dates * @description dateformatter handles all date fields and returns humanized and jquery datepicker format dates
* @param {object} formObject * @param {Object} formObject
* @returns {*} * @returns {*}
*/ */
generator.dateformatter = function (formObject) { generator.dateformatter = function (formObject) {
...@@ -953,9 +953,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -953,9 +953,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* on same * 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
* @param {object} $scope * @param {Object} $scope
* @param {string} key * @param {string} key
* @param {object} todo * @param {Object} todo
* @param {string} mode * @param {string} mode
* @returns {*} * @returns {*}
*/ */
...@@ -995,7 +995,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -995,7 +995,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name get_form * @name get_form
* @description Communicates with api with given scope object. * @description Communicates with api with given scope object.
* @param {object} scope * @param {Object} scope
* @returns {*} * @returns {*}
*/ */
generator.get_form = function (scope) { generator.get_form = function (scope) {
...@@ -1097,13 +1097,12 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1097,13 +1097,12 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
}; };
/** /**
* @memberof ulakbus.formService * @memberof ulakbus.formService
* @constructor
* @ngdoc function * @ngdoc function
* @name pathDecider * @name pathDecider
* @description pathDecider is used to redirect related path by looking up the data in response * @description pathDecider is used to redirect related path by looking up the data in response
* @param {string} client_cmd * @param {string} client_cmd
* @param {object} $scope * @param {Object} $scope
* @param {object} data * @param {Object} data
*/ */
generator.pathDecider = function (client_cmd, $scope, data) { generator.pathDecider = function (client_cmd, $scope, data) {
if (client_cmd[0] === 'reload' || client_cmd[0] === 'reset') { if (client_cmd[0] === 'reload' || client_cmd[0] === 'reset') {
...@@ -1117,7 +1116,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1117,7 +1116,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @description redirectTo function redirects to related controller and path with given data * @description redirectTo function redirects to related controller and path with given data
* before redirect setPageData must be called and pageData need to be defined * before redirect setPageData must be called and pageData need to be defined
* otherwise redirected path will call api for its data * otherwise redirected path will call api for its data
* @param {object} scope * @param {Object} scope
* @param {string} page * @param {string} page
* @return {*} * @return {*}
*/ */
...@@ -1163,9 +1162,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1163,9 +1162,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name get_diff * @name get_diff
* @description returns diff of the second param to first param * @description returns diff of the second param to first param
* @param {object} obj1 * @param {Object} obj1
* @param {object} obj2 * @param {Object} obj2
* @returns {{object}} diff object of two given objects * @returns {Object} diff object of two given objects
*/ */
generator.get_diff = function (obj1, obj2) { generator.get_diff = function (obj1, obj2) {
var result = {}; var result = {};
...@@ -1187,10 +1186,10 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1187,10 +1186,10 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name get_diff_array * @name get_diff_array
* @description extracts items of second array from the first array * @description extracts items of second array from the first array
* @param {object} array1 * @param {Array} array1
* @param {object} array2 * @param {Array} array2
* @param {number} way * @param {Number} way
* @returns {Array} * @returns {Array} diff of arrays
*/ */
generator.get_diff_array = function (array1, array2, way) { generator.get_diff_array = function (array1, array2, way) {
var result = []; var result = [];
...@@ -1212,8 +1211,8 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1212,8 +1211,8 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name item_from_array * @name item_from_array
* @description gets item unicode name from titleMap * @description gets item unicode name from titleMap
* @param {object} item * @param {Object} item
* @param {array} array * @param {Array} array
* @returns {*} * @returns {*}
*/ */
generator.item_from_array = function (item, array) { generator.item_from_array = function (item, array) {
...@@ -1230,13 +1229,39 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1230,13 +1229,39 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name submit * @name submit
* @description Submit function is generic function for submiting forms. * @description Submit function is generic function for submiting forms.
* redirectTo param is used for redirect if return value will be evaluated in a new page. * - redirectTo param is used for redirect if return value will be evaluated in a new page.
* @param {object} $scope * - In case of unformatted date object in any key recursively, it must be converted by convertDate function.
* @param {object} redirectTo * - ListNode and Node objects get seperated from model in
* {@link prepareFormItems module:ulakbus.formService.function:prepareFormItems} They must be concat to model
* key of scope first.
* - Backend API waits form as model value. So `data.form` key must be set to `$scope.model`
* - Other parameters we pass to backend API are shown in the example below
* ```
* var data = {
"form": $scope.model,
"token": $scope.token,
"model": $scope.form_params.model,
"cmd": $scope.form_params.cmd,
"flow": $scope.form_params.flow,
"object_id": $scope.object_id,
"filter": $scope.filter,
"query": $scope.form_params.query
};
* ```
* ### Special response object process
* - If response object is a downloadable pdf file, checking from headers `headers('content-type') ===
* "application/pdf"` download using Blob object.
*
* @param {Object} $scope
* @param {Object} redirectTo
* @returns {*} * @returns {*}
* @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
*/ */
generator.submit = function ($scope, redirectTo) { generator.submit = function ($scope, redirectTo) {
/**
* In case of unformatted date object in any key recursively, it must be converted.
* @param model
*/
var convertDate = function (model) { var convertDate = function (model) {
angular.forEach(model, function (value, key) { angular.forEach(model, function (value, key) {
if (value && value.constructor === Date) { if (value && value.constructor === Date) {
...@@ -1295,11 +1320,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1295,11 +1320,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc controller * @ngdoc controller
* @name ModalCtrl * @name ModalCtrl
* @description controller for listnode, node and linkedmodel modal and save data of it * @description controller for listnode, node and linkedmodel modal and save data of it
* @param {object} items * @param {Object} items
* @param {object} $scope * @param {Object} $scope
* @param {object} $uibModalInstance * @param {Object} $uibModalInstance
* @param {object} $route * @param {Object} $route
* @returns returns value for modal * @returns {Object} returns value for modal
*/ */
.controller('ModalCtrl', function ($scope, $uibModalInstance, Generator, items) { .controller('ModalCtrl', function ($scope, $uibModalInstance, Generator, items) {
angular.forEach(items, function (value, key) { angular.forEach(items, function (value, key) {
...@@ -1339,9 +1364,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1339,9 +1364,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc directive * @ngdoc directive
* @name modalForNodes * @name modalForNodes
* @description add modal directive for nodes * @description add modal directive for nodes
* @param {module} $uibModal * @param {Module} $uibModal
* @param {service} Generator * @param {Service} Generator
* @returns openmodal directive * @returns {Object} openmodal directive
*/ */
.directive('modalForNodes', function ($uibModal, Generator) { .directive('modalForNodes', function ($uibModal, Generator) {
return { return {
...@@ -1446,11 +1471,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1446,11 +1471,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc directive * @ngdoc directive
* @name addModalForLinkedModel * @name addModalForLinkedModel
* @description add modal directive for linked models * @description add modal directive for linked models
* @param {module} $uibModal * @param {Module} $uibModal
* @param {object} $rootScope * @param {Object} $rootScope
* @param {module} $route * @param {Module} $route
* @param {service} Generator * @param {Service} Generator
* @returns openmodal directive * @returns {Object} openmodal directive
*/ */
.directive('addModalForLinkedModel', function ($uibModal, $rootScope, $route, Generator) { .directive('addModalForLinkedModel', function ($uibModal, $rootScope, $route, Generator) {
return { return {
...@@ -1524,6 +1549,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1524,6 +1549,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc directive * @ngdoc directive
* @name modalFormLocator * @name modalFormLocator
* @description This directive helps to locate form object in modal. * @description This directive helps to locate form object in modal.
* @returns {Object} form object
*/ */
.directive('modalFormLocator', function () { .directive('modalFormLocator', function () {
return { return {
......
...@@ -508,7 +508,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -508,7 +508,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @memberof ulakbus.formService * @memberof ulakbus.formService
* @ngdoc function * @ngdoc function
* @name prepareFormItems * @name prepareFormItems
* @param scope {object} given scope on which form items prepared * @param scope {Object} given scope on which form items prepared
* @description * @description
* It looks up fields of schema objects and changes their types to proper type for schemaform. * It looks up fields of schema objects and changes their types to proper type for schemaform.
* To prepare items for schemaform loop items of scope.schema.properties by checking index value's `type` key. * To prepare items for schemaform loop items of scope.schema.properties by checking index value's `type` key.
...@@ -520,7 +520,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -520,7 +520,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* For listnode, node and model types it uses templates to generate modal. The modal is aa instance of * For listnode, node and model types it uses templates to generate modal. The modal is aa instance of
* ui.bootstraps modal directive. * ui.bootstraps modal directive.
* *
* @returns scope {object} * @returns scope {Object}
*/ */
generator.prepareFormItems = function (scope) { generator.prepareFormItems = function (scope) {
angular.forEach(scope.form, function (value, key) { angular.forEach(scope.form, function (value, key) {
...@@ -932,7 +932,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -932,7 +932,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name dateformatter * @name dateformatter
* @description dateformatter handles all date fields and returns humanized and jquery datepicker format dates * @description dateformatter handles all date fields and returns humanized and jquery datepicker format dates
* @param {object} formObject * @param {Object} formObject
* @returns {*} * @returns {*}
*/ */
generator.dateformatter = function (formObject) { generator.dateformatter = function (formObject) {
...@@ -953,9 +953,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -953,9 +953,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* on same * 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
* @param {object} $scope * @param {Object} $scope
* @param {string} key * @param {string} key
* @param {object} todo * @param {Object} todo
* @param {string} mode * @param {string} mode
* @returns {*} * @returns {*}
*/ */
...@@ -995,7 +995,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -995,7 +995,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name get_form * @name get_form
* @description Communicates with api with given scope object. * @description Communicates with api with given scope object.
* @param {object} scope * @param {Object} scope
* @returns {*} * @returns {*}
*/ */
generator.get_form = function (scope) { generator.get_form = function (scope) {
...@@ -1097,13 +1097,12 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1097,13 +1097,12 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
}; };
/** /**
* @memberof ulakbus.formService * @memberof ulakbus.formService
* @constructor
* @ngdoc function * @ngdoc function
* @name pathDecider * @name pathDecider
* @description pathDecider is used to redirect related path by looking up the data in response * @description pathDecider is used to redirect related path by looking up the data in response
* @param {string} client_cmd * @param {string} client_cmd
* @param {object} $scope * @param {Object} $scope
* @param {object} data * @param {Object} data
*/ */
generator.pathDecider = function (client_cmd, $scope, data) { generator.pathDecider = function (client_cmd, $scope, data) {
if (client_cmd[0] === 'reload' || client_cmd[0] === 'reset') { if (client_cmd[0] === 'reload' || client_cmd[0] === 'reset') {
...@@ -1117,7 +1116,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1117,7 +1116,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @description redirectTo function redirects to related controller and path with given data * @description redirectTo function redirects to related controller and path with given data
* before redirect setPageData must be called and pageData need to be defined * before redirect setPageData must be called and pageData need to be defined
* otherwise redirected path will call api for its data * otherwise redirected path will call api for its data
* @param {object} scope * @param {Object} scope
* @param {string} page * @param {string} page
* @return {*} * @return {*}
*/ */
...@@ -1163,9 +1162,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1163,9 +1162,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name get_diff * @name get_diff
* @description returns diff of the second param to first param * @description returns diff of the second param to first param
* @param {object} obj1 * @param {Object} obj1
* @param {object} obj2 * @param {Object} obj2
* @returns {{object}} diff object of two given objects * @returns {Object} diff object of two given objects
*/ */
generator.get_diff = function (obj1, obj2) { generator.get_diff = function (obj1, obj2) {
var result = {}; var result = {};
...@@ -1187,10 +1186,10 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1187,10 +1186,10 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name get_diff_array * @name get_diff_array
* @description extracts items of second array from the first array * @description extracts items of second array from the first array
* @param {object} array1 * @param {Array} array1
* @param {object} array2 * @param {Array} array2
* @param {number} way * @param {Number} way
* @returns {Array} * @returns {Array} diff of arrays
*/ */
generator.get_diff_array = function (array1, array2, way) { generator.get_diff_array = function (array1, array2, way) {
var result = []; var result = [];
...@@ -1212,8 +1211,8 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1212,8 +1211,8 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name item_from_array * @name item_from_array
* @description gets item unicode name from titleMap * @description gets item unicode name from titleMap
* @param {object} item * @param {Object} item
* @param {array} array * @param {Array} array
* @returns {*} * @returns {*}
*/ */
generator.item_from_array = function (item, array) { generator.item_from_array = function (item, array) {
...@@ -1230,13 +1229,39 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1230,13 +1229,39 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name submit * @name submit
* @description Submit function is generic function for submiting forms. * @description Submit function is generic function for submiting forms.
* redirectTo param is used for redirect if return value will be evaluated in a new page. * - redirectTo param is used for redirect if return value will be evaluated in a new page.
* @param {object} $scope * - In case of unformatted date object in any key recursively, it must be converted by convertDate function.
* @param {object} redirectTo * - ListNode and Node objects get seperated from model in
* {@link prepareFormItems module:ulakbus.formService.function:prepareFormItems} They must be concat to model
* key of scope first.
* - Backend API waits form as model value. So `data.form` key must be set to `$scope.model`
* - Other parameters we pass to backend API are shown in the example below
* ```
* var data = {
"form": $scope.model,
"token": $scope.token,
"model": $scope.form_params.model,
"cmd": $scope.form_params.cmd,
"flow": $scope.form_params.flow,
"object_id": $scope.object_id,
"filter": $scope.filter,
"query": $scope.form_params.query
};
* ```
* ### Special response object process
* - If response object is a downloadable pdf file, checking from headers `headers('content-type') ===
* "application/pdf"` download using Blob object.
*
* @param {Object} $scope
* @param {Object} redirectTo
* @returns {*} * @returns {*}
* @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
*/ */
generator.submit = function ($scope, redirectTo) { generator.submit = function ($scope, redirectTo) {
/**
* In case of unformatted date object in any key recursively, it must be converted.
* @param model
*/
var convertDate = function (model) { var convertDate = function (model) {
angular.forEach(model, function (value, key) { angular.forEach(model, function (value, key) {
if (value && value.constructor === Date) { if (value && value.constructor === Date) {
...@@ -1295,11 +1320,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1295,11 +1320,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc controller * @ngdoc controller
* @name ModalCtrl * @name ModalCtrl
* @description controller for listnode, node and linkedmodel modal and save data of it * @description controller for listnode, node and linkedmodel modal and save data of it
* @param {object} items * @param {Object} items
* @param {object} $scope * @param {Object} $scope
* @param {object} $uibModalInstance * @param {Object} $uibModalInstance
* @param {object} $route * @param {Object} $route
* @returns returns value for modal * @returns {Object} returns value for modal
*/ */
.controller('ModalCtrl', function ($scope, $uibModalInstance, Generator, items) { .controller('ModalCtrl', function ($scope, $uibModalInstance, Generator, items) {
angular.forEach(items, function (value, key) { angular.forEach(items, function (value, key) {
...@@ -1339,9 +1364,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1339,9 +1364,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc directive * @ngdoc directive
* @name modalForNodes * @name modalForNodes
* @description add modal directive for nodes * @description add modal directive for nodes
* @param {module} $uibModal * @param {Module} $uibModal
* @param {service} Generator * @param {Service} Generator
* @returns openmodal directive * @returns {Object} openmodal directive
*/ */
.directive('modalForNodes', function ($uibModal, Generator) { .directive('modalForNodes', function ($uibModal, Generator) {
return { return {
...@@ -1446,11 +1471,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1446,11 +1471,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc directive * @ngdoc directive
* @name addModalForLinkedModel * @name addModalForLinkedModel
* @description add modal directive for linked models * @description add modal directive for linked models
* @param {module} $uibModal * @param {Module} $uibModal
* @param {object} $rootScope * @param {Object} $rootScope
* @param {module} $route * @param {Module} $route
* @param {service} Generator * @param {Service} Generator
* @returns openmodal directive * @returns {Object} openmodal directive
*/ */
.directive('addModalForLinkedModel', function ($uibModal, $rootScope, $route, Generator) { .directive('addModalForLinkedModel', function ($uibModal, $rootScope, $route, Generator) {
return { return {
...@@ -1524,6 +1549,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1524,6 +1549,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc directive * @ngdoc directive
* @name modalFormLocator * @name modalFormLocator
* @description This directive helps to locate form object in modal. * @description This directive helps to locate form object in modal.
* @returns {Object} form object
*/ */
.directive('modalFormLocator', function () { .directive('modalFormLocator', function () {
return { return {
......
...@@ -508,7 +508,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -508,7 +508,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @memberof ulakbus.formService * @memberof ulakbus.formService
* @ngdoc function * @ngdoc function
* @name prepareFormItems * @name prepareFormItems
* @param scope {object} given scope on which form items prepared * @param scope {Object} given scope on which form items prepared
* @description * @description
* It looks up fields of schema objects and changes their types to proper type for schemaform. * It looks up fields of schema objects and changes their types to proper type for schemaform.
* To prepare items for schemaform loop items of scope.schema.properties by checking index value's `type` key. * To prepare items for schemaform loop items of scope.schema.properties by checking index value's `type` key.
...@@ -520,7 +520,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -520,7 +520,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* For listnode, node and model types it uses templates to generate modal. The modal is aa instance of * For listnode, node and model types it uses templates to generate modal. The modal is aa instance of
* ui.bootstraps modal directive. * ui.bootstraps modal directive.
* *
* @returns scope {object} * @returns scope {Object}
*/ */
generator.prepareFormItems = function (scope) { generator.prepareFormItems = function (scope) {
angular.forEach(scope.form, function (value, key) { angular.forEach(scope.form, function (value, key) {
...@@ -932,7 +932,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -932,7 +932,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name dateformatter * @name dateformatter
* @description dateformatter handles all date fields and returns humanized and jquery datepicker format dates * @description dateformatter handles all date fields and returns humanized and jquery datepicker format dates
* @param {object} formObject * @param {Object} formObject
* @returns {*} * @returns {*}
*/ */
generator.dateformatter = function (formObject) { generator.dateformatter = function (formObject) {
...@@ -953,9 +953,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -953,9 +953,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* on same * 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
* @param {object} $scope * @param {Object} $scope
* @param {string} key * @param {string} key
* @param {object} todo * @param {Object} todo
* @param {string} mode * @param {string} mode
* @returns {*} * @returns {*}
*/ */
...@@ -995,7 +995,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -995,7 +995,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name get_form * @name get_form
* @description Communicates with api with given scope object. * @description Communicates with api with given scope object.
* @param {object} scope * @param {Object} scope
* @returns {*} * @returns {*}
*/ */
generator.get_form = function (scope) { generator.get_form = function (scope) {
...@@ -1097,13 +1097,12 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1097,13 +1097,12 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
}; };
/** /**
* @memberof ulakbus.formService * @memberof ulakbus.formService
* @constructor
* @ngdoc function * @ngdoc function
* @name pathDecider * @name pathDecider
* @description pathDecider is used to redirect related path by looking up the data in response * @description pathDecider is used to redirect related path by looking up the data in response
* @param {string} client_cmd * @param {string} client_cmd
* @param {object} $scope * @param {Object} $scope
* @param {object} data * @param {Object} data
*/ */
generator.pathDecider = function (client_cmd, $scope, data) { generator.pathDecider = function (client_cmd, $scope, data) {
if (client_cmd[0] === 'reload' || client_cmd[0] === 'reset') { if (client_cmd[0] === 'reload' || client_cmd[0] === 'reset') {
...@@ -1117,7 +1116,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1117,7 +1116,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @description redirectTo function redirects to related controller and path with given data * @description redirectTo function redirects to related controller and path with given data
* before redirect setPageData must be called and pageData need to be defined * before redirect setPageData must be called and pageData need to be defined
* otherwise redirected path will call api for its data * otherwise redirected path will call api for its data
* @param {object} scope * @param {Object} scope
* @param {string} page * @param {string} page
* @return {*} * @return {*}
*/ */
...@@ -1163,9 +1162,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1163,9 +1162,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name get_diff * @name get_diff
* @description returns diff of the second param to first param * @description returns diff of the second param to first param
* @param {object} obj1 * @param {Object} obj1
* @param {object} obj2 * @param {Object} obj2
* @returns {{object}} diff object of two given objects * @returns {Object} diff object of two given objects
*/ */
generator.get_diff = function (obj1, obj2) { generator.get_diff = function (obj1, obj2) {
var result = {}; var result = {};
...@@ -1187,10 +1186,10 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1187,10 +1186,10 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name get_diff_array * @name get_diff_array
* @description extracts items of second array from the first array * @description extracts items of second array from the first array
* @param {object} array1 * @param {Array} array1
* @param {object} array2 * @param {Array} array2
* @param {number} way * @param {Number} way
* @returns {Array} * @returns {Array} diff of arrays
*/ */
generator.get_diff_array = function (array1, array2, way) { generator.get_diff_array = function (array1, array2, way) {
var result = []; var result = [];
...@@ -1212,8 +1211,8 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1212,8 +1211,8 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name item_from_array * @name item_from_array
* @description gets item unicode name from titleMap * @description gets item unicode name from titleMap
* @param {object} item * @param {Object} item
* @param {array} array * @param {Array} array
* @returns {*} * @returns {*}
*/ */
generator.item_from_array = function (item, array) { generator.item_from_array = function (item, array) {
...@@ -1230,13 +1229,39 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1230,13 +1229,39 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name submit * @name submit
* @description Submit function is generic function for submiting forms. * @description Submit function is generic function for submiting forms.
* redirectTo param is used for redirect if return value will be evaluated in a new page. * - redirectTo param is used for redirect if return value will be evaluated in a new page.
* @param {object} $scope * - In case of unformatted date object in any key recursively, it must be converted by convertDate function.
* @param {object} redirectTo * - ListNode and Node objects get seperated from model in
* {@link prepareFormItems module:ulakbus.formService.function:prepareFormItems} They must be concat to model
* key of scope first.
* - Backend API waits form as model value. So `data.form` key must be set to `$scope.model`
* - Other parameters we pass to backend API are shown in the example below
* ```
* var data = {
"form": $scope.model,
"token": $scope.token,
"model": $scope.form_params.model,
"cmd": $scope.form_params.cmd,
"flow": $scope.form_params.flow,
"object_id": $scope.object_id,
"filter": $scope.filter,
"query": $scope.form_params.query
};
* ```
* ### Special response object process
* - If response object is a downloadable pdf file, checking from headers `headers('content-type') ===
* "application/pdf"` download using Blob object.
*
* @param {Object} $scope
* @param {Object} redirectTo
* @returns {*} * @returns {*}
* @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
*/ */
generator.submit = function ($scope, redirectTo) { generator.submit = function ($scope, redirectTo) {
/**
* In case of unformatted date object in any key recursively, it must be converted.
* @param model
*/
var convertDate = function (model) { var convertDate = function (model) {
angular.forEach(model, function (value, key) { angular.forEach(model, function (value, key) {
if (value && value.constructor === Date) { if (value && value.constructor === Date) {
...@@ -1295,11 +1320,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1295,11 +1320,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc controller * @ngdoc controller
* @name ModalCtrl * @name ModalCtrl
* @description controller for listnode, node and linkedmodel modal and save data of it * @description controller for listnode, node and linkedmodel modal and save data of it
* @param {object} items * @param {Object} items
* @param {object} $scope * @param {Object} $scope
* @param {object} $uibModalInstance * @param {Object} $uibModalInstance
* @param {object} $route * @param {Object} $route
* @returns returns value for modal * @returns {Object} returns value for modal
*/ */
.controller('ModalCtrl', function ($scope, $uibModalInstance, Generator, items) { .controller('ModalCtrl', function ($scope, $uibModalInstance, Generator, items) {
angular.forEach(items, function (value, key) { angular.forEach(items, function (value, key) {
...@@ -1339,9 +1364,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1339,9 +1364,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc directive * @ngdoc directive
* @name modalForNodes * @name modalForNodes
* @description add modal directive for nodes * @description add modal directive for nodes
* @param {module} $uibModal * @param {Module} $uibModal
* @param {service} Generator * @param {Service} Generator
* @returns openmodal directive * @returns {Object} openmodal directive
*/ */
.directive('modalForNodes', function ($uibModal, Generator) { .directive('modalForNodes', function ($uibModal, Generator) {
return { return {
...@@ -1446,11 +1471,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1446,11 +1471,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc directive * @ngdoc directive
* @name addModalForLinkedModel * @name addModalForLinkedModel
* @description add modal directive for linked models * @description add modal directive for linked models
* @param {module} $uibModal * @param {Module} $uibModal
* @param {object} $rootScope * @param {Object} $rootScope
* @param {module} $route * @param {Module} $route
* @param {service} Generator * @param {Service} Generator
* @returns openmodal directive * @returns {Object} openmodal directive
*/ */
.directive('addModalForLinkedModel', function ($uibModal, $rootScope, $route, Generator) { .directive('addModalForLinkedModel', function ($uibModal, $rootScope, $route, Generator) {
return { return {
...@@ -1524,6 +1549,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1524,6 +1549,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc directive * @ngdoc directive
* @name modalFormLocator * @name modalFormLocator
* @description This directive helps to locate form object in modal. * @description This directive helps to locate form object in modal.
* @returns {Object} form object
*/ */
.directive('modalFormLocator', function () { .directive('modalFormLocator', function () {
return { return {
......
...@@ -508,7 +508,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -508,7 +508,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @memberof ulakbus.formService * @memberof ulakbus.formService
* @ngdoc function * @ngdoc function
* @name prepareFormItems * @name prepareFormItems
* @param scope {object} given scope on which form items prepared * @param scope {Object} given scope on which form items prepared
* @description * @description
* It looks up fields of schema objects and changes their types to proper type for schemaform. * It looks up fields of schema objects and changes their types to proper type for schemaform.
* To prepare items for schemaform loop items of scope.schema.properties by checking index value's `type` key. * To prepare items for schemaform loop items of scope.schema.properties by checking index value's `type` key.
...@@ -520,7 +520,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -520,7 +520,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* For listnode, node and model types it uses templates to generate modal. The modal is aa instance of * For listnode, node and model types it uses templates to generate modal. The modal is aa instance of
* ui.bootstraps modal directive. * ui.bootstraps modal directive.
* *
* @returns scope {object} * @returns scope {Object}
*/ */
generator.prepareFormItems = function (scope) { generator.prepareFormItems = function (scope) {
angular.forEach(scope.form, function (value, key) { angular.forEach(scope.form, function (value, key) {
...@@ -932,7 +932,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -932,7 +932,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name dateformatter * @name dateformatter
* @description dateformatter handles all date fields and returns humanized and jquery datepicker format dates * @description dateformatter handles all date fields and returns humanized and jquery datepicker format dates
* @param {object} formObject * @param {Object} formObject
* @returns {*} * @returns {*}
*/ */
generator.dateformatter = function (formObject) { generator.dateformatter = function (formObject) {
...@@ -953,9 +953,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -953,9 +953,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* on same * 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
* @param {object} $scope * @param {Object} $scope
* @param {string} key * @param {string} key
* @param {object} todo * @param {Object} todo
* @param {string} mode * @param {string} mode
* @returns {*} * @returns {*}
*/ */
...@@ -995,7 +995,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -995,7 +995,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name get_form * @name get_form
* @description Communicates with api with given scope object. * @description Communicates with api with given scope object.
* @param {object} scope * @param {Object} scope
* @returns {*} * @returns {*}
*/ */
generator.get_form = function (scope) { generator.get_form = function (scope) {
...@@ -1097,13 +1097,12 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1097,13 +1097,12 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
}; };
/** /**
* @memberof ulakbus.formService * @memberof ulakbus.formService
* @constructor
* @ngdoc function * @ngdoc function
* @name pathDecider * @name pathDecider
* @description pathDecider is used to redirect related path by looking up the data in response * @description pathDecider is used to redirect related path by looking up the data in response
* @param {string} client_cmd * @param {string} client_cmd
* @param {object} $scope * @param {Object} $scope
* @param {object} data * @param {Object} data
*/ */
generator.pathDecider = function (client_cmd, $scope, data) { generator.pathDecider = function (client_cmd, $scope, data) {
if (client_cmd[0] === 'reload' || client_cmd[0] === 'reset') { if (client_cmd[0] === 'reload' || client_cmd[0] === 'reset') {
...@@ -1117,7 +1116,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1117,7 +1116,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @description redirectTo function redirects to related controller and path with given data * @description redirectTo function redirects to related controller and path with given data
* before redirect setPageData must be called and pageData need to be defined * before redirect setPageData must be called and pageData need to be defined
* otherwise redirected path will call api for its data * otherwise redirected path will call api for its data
* @param {object} scope * @param {Object} scope
* @param {string} page * @param {string} page
* @return {*} * @return {*}
*/ */
...@@ -1163,9 +1162,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1163,9 +1162,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name get_diff * @name get_diff
* @description returns diff of the second param to first param * @description returns diff of the second param to first param
* @param {object} obj1 * @param {Object} obj1
* @param {object} obj2 * @param {Object} obj2
* @returns {{object}} diff object of two given objects * @returns {Object} diff object of two given objects
*/ */
generator.get_diff = function (obj1, obj2) { generator.get_diff = function (obj1, obj2) {
var result = {}; var result = {};
...@@ -1187,10 +1186,10 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1187,10 +1186,10 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name get_diff_array * @name get_diff_array
* @description extracts items of second array from the first array * @description extracts items of second array from the first array
* @param {object} array1 * @param {Array} array1
* @param {object} array2 * @param {Array} array2
* @param {number} way * @param {Number} way
* @returns {Array} * @returns {Array} diff of arrays
*/ */
generator.get_diff_array = function (array1, array2, way) { generator.get_diff_array = function (array1, array2, way) {
var result = []; var result = [];
...@@ -1212,8 +1211,8 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1212,8 +1211,8 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name item_from_array * @name item_from_array
* @description gets item unicode name from titleMap * @description gets item unicode name from titleMap
* @param {object} item * @param {Object} item
* @param {array} array * @param {Array} array
* @returns {*} * @returns {*}
*/ */
generator.item_from_array = function (item, array) { generator.item_from_array = function (item, array) {
...@@ -1230,13 +1229,39 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1230,13 +1229,39 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name submit * @name submit
* @description Submit function is generic function for submiting forms. * @description Submit function is generic function for submiting forms.
* redirectTo param is used for redirect if return value will be evaluated in a new page. * - redirectTo param is used for redirect if return value will be evaluated in a new page.
* @param {object} $scope * - In case of unformatted date object in any key recursively, it must be converted by convertDate function.
* @param {object} redirectTo * - ListNode and Node objects get seperated from model in
* {@link prepareFormItems module:ulakbus.formService.function:prepareFormItems} They must be concat to model
* key of scope first.
* - Backend API waits form as model value. So `data.form` key must be set to `$scope.model`
* - Other parameters we pass to backend API are shown in the example below
* ```
* var data = {
"form": $scope.model,
"token": $scope.token,
"model": $scope.form_params.model,
"cmd": $scope.form_params.cmd,
"flow": $scope.form_params.flow,
"object_id": $scope.object_id,
"filter": $scope.filter,
"query": $scope.form_params.query
};
* ```
* ### Special response object process
* - If response object is a downloadable pdf file, checking from headers `headers('content-type') ===
* "application/pdf"` download using Blob object.
*
* @param {Object} $scope
* @param {Object} redirectTo
* @returns {*} * @returns {*}
* @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
*/ */
generator.submit = function ($scope, redirectTo) { generator.submit = function ($scope, redirectTo) {
/**
* In case of unformatted date object in any key recursively, it must be converted.
* @param model
*/
var convertDate = function (model) { var convertDate = function (model) {
angular.forEach(model, function (value, key) { angular.forEach(model, function (value, key) {
if (value && value.constructor === Date) { if (value && value.constructor === Date) {
...@@ -1295,11 +1320,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1295,11 +1320,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc controller * @ngdoc controller
* @name ModalCtrl * @name ModalCtrl
* @description controller for listnode, node and linkedmodel modal and save data of it * @description controller for listnode, node and linkedmodel modal and save data of it
* @param {object} items * @param {Object} items
* @param {object} $scope * @param {Object} $scope
* @param {object} $uibModalInstance * @param {Object} $uibModalInstance
* @param {object} $route * @param {Object} $route
* @returns returns value for modal * @returns {Object} returns value for modal
*/ */
.controller('ModalCtrl', function ($scope, $uibModalInstance, Generator, items) { .controller('ModalCtrl', function ($scope, $uibModalInstance, Generator, items) {
angular.forEach(items, function (value, key) { angular.forEach(items, function (value, key) {
...@@ -1339,9 +1364,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1339,9 +1364,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc directive * @ngdoc directive
* @name modalForNodes * @name modalForNodes
* @description add modal directive for nodes * @description add modal directive for nodes
* @param {module} $uibModal * @param {Module} $uibModal
* @param {service} Generator * @param {Service} Generator
* @returns openmodal directive * @returns {Object} openmodal directive
*/ */
.directive('modalForNodes', function ($uibModal, Generator) { .directive('modalForNodes', function ($uibModal, Generator) {
return { return {
...@@ -1446,11 +1471,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1446,11 +1471,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc directive * @ngdoc directive
* @name addModalForLinkedModel * @name addModalForLinkedModel
* @description add modal directive for linked models * @description add modal directive for linked models
* @param {module} $uibModal * @param {Module} $uibModal
* @param {object} $rootScope * @param {Object} $rootScope
* @param {module} $route * @param {Module} $route
* @param {service} Generator * @param {Service} Generator
* @returns openmodal directive * @returns {Object} openmodal directive
*/ */
.directive('addModalForLinkedModel', function ($uibModal, $rootScope, $route, Generator) { .directive('addModalForLinkedModel', function ($uibModal, $rootScope, $route, Generator) {
return { return {
...@@ -1524,6 +1549,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1524,6 +1549,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc directive * @ngdoc directive
* @name modalFormLocator * @name modalFormLocator
* @description This directive helps to locate form object in modal. * @description This directive helps to locate form object in modal.
* @returns {Object} form object
*/ */
.directive('modalFormLocator', function () { .directive('modalFormLocator', function () {
return { return {
......
...@@ -508,7 +508,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -508,7 +508,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @memberof ulakbus.formService * @memberof ulakbus.formService
* @ngdoc function * @ngdoc function
* @name prepareFormItems * @name prepareFormItems
* @param scope {object} given scope on which form items prepared * @param scope {Object} given scope on which form items prepared
* @description * @description
* It looks up fields of schema objects and changes their types to proper type for schemaform. * It looks up fields of schema objects and changes their types to proper type for schemaform.
* To prepare items for schemaform loop items of scope.schema.properties by checking index value's `type` key. * To prepare items for schemaform loop items of scope.schema.properties by checking index value's `type` key.
...@@ -520,7 +520,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -520,7 +520,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* For listnode, node and model types it uses templates to generate modal. The modal is aa instance of * For listnode, node and model types it uses templates to generate modal. The modal is aa instance of
* ui.bootstraps modal directive. * ui.bootstraps modal directive.
* *
* @returns scope {object} * @returns scope {Object}
*/ */
generator.prepareFormItems = function (scope) { generator.prepareFormItems = function (scope) {
angular.forEach(scope.form, function (value, key) { angular.forEach(scope.form, function (value, key) {
...@@ -932,7 +932,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -932,7 +932,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name dateformatter * @name dateformatter
* @description dateformatter handles all date fields and returns humanized and jquery datepicker format dates * @description dateformatter handles all date fields and returns humanized and jquery datepicker format dates
* @param {object} formObject * @param {Object} formObject
* @returns {*} * @returns {*}
*/ */
generator.dateformatter = function (formObject) { generator.dateformatter = function (formObject) {
...@@ -953,9 +953,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -953,9 +953,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* on same * 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
* @param {object} $scope * @param {Object} $scope
* @param {string} key * @param {string} key
* @param {object} todo * @param {Object} todo
* @param {string} mode * @param {string} mode
* @returns {*} * @returns {*}
*/ */
...@@ -995,7 +995,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -995,7 +995,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name get_form * @name get_form
* @description Communicates with api with given scope object. * @description Communicates with api with given scope object.
* @param {object} scope * @param {Object} scope
* @returns {*} * @returns {*}
*/ */
generator.get_form = function (scope) { generator.get_form = function (scope) {
...@@ -1097,13 +1097,12 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1097,13 +1097,12 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
}; };
/** /**
* @memberof ulakbus.formService * @memberof ulakbus.formService
* @constructor
* @ngdoc function * @ngdoc function
* @name pathDecider * @name pathDecider
* @description pathDecider is used to redirect related path by looking up the data in response * @description pathDecider is used to redirect related path by looking up the data in response
* @param {string} client_cmd * @param {string} client_cmd
* @param {object} $scope * @param {Object} $scope
* @param {object} data * @param {Object} data
*/ */
generator.pathDecider = function (client_cmd, $scope, data) { generator.pathDecider = function (client_cmd, $scope, data) {
if (client_cmd[0] === 'reload' || client_cmd[0] === 'reset') { if (client_cmd[0] === 'reload' || client_cmd[0] === 'reset') {
...@@ -1117,7 +1116,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1117,7 +1116,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @description redirectTo function redirects to related controller and path with given data * @description redirectTo function redirects to related controller and path with given data
* before redirect setPageData must be called and pageData need to be defined * before redirect setPageData must be called and pageData need to be defined
* otherwise redirected path will call api for its data * otherwise redirected path will call api for its data
* @param {object} scope * @param {Object} scope
* @param {string} page * @param {string} page
* @return {*} * @return {*}
*/ */
...@@ -1163,9 +1162,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1163,9 +1162,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name get_diff * @name get_diff
* @description returns diff of the second param to first param * @description returns diff of the second param to first param
* @param {object} obj1 * @param {Object} obj1
* @param {object} obj2 * @param {Object} obj2
* @returns {{object}} diff object of two given objects * @returns {Object} diff object of two given objects
*/ */
generator.get_diff = function (obj1, obj2) { generator.get_diff = function (obj1, obj2) {
var result = {}; var result = {};
...@@ -1187,10 +1186,10 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1187,10 +1186,10 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name get_diff_array * @name get_diff_array
* @description extracts items of second array from the first array * @description extracts items of second array from the first array
* @param {object} array1 * @param {Array} array1
* @param {object} array2 * @param {Array} array2
* @param {number} way * @param {Number} way
* @returns {Array} * @returns {Array} diff of arrays
*/ */
generator.get_diff_array = function (array1, array2, way) { generator.get_diff_array = function (array1, array2, way) {
var result = []; var result = [];
...@@ -1212,8 +1211,8 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1212,8 +1211,8 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name item_from_array * @name item_from_array
* @description gets item unicode name from titleMap * @description gets item unicode name from titleMap
* @param {object} item * @param {Object} item
* @param {array} array * @param {Array} array
* @returns {*} * @returns {*}
*/ */
generator.item_from_array = function (item, array) { generator.item_from_array = function (item, array) {
...@@ -1230,13 +1229,39 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1230,13 +1229,39 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name submit * @name submit
* @description Submit function is generic function for submiting forms. * @description Submit function is generic function for submiting forms.
* redirectTo param is used for redirect if return value will be evaluated in a new page. * - redirectTo param is used for redirect if return value will be evaluated in a new page.
* @param {object} $scope * - In case of unformatted date object in any key recursively, it must be converted by convertDate function.
* @param {object} redirectTo * - ListNode and Node objects get seperated from model in
* {@link prepareFormItems module:ulakbus.formService.function:prepareFormItems} They must be concat to model
* key of scope first.
* - Backend API waits form as model value. So `data.form` key must be set to `$scope.model`
* - Other parameters we pass to backend API are shown in the example below
* ```
* var data = {
"form": $scope.model,
"token": $scope.token,
"model": $scope.form_params.model,
"cmd": $scope.form_params.cmd,
"flow": $scope.form_params.flow,
"object_id": $scope.object_id,
"filter": $scope.filter,
"query": $scope.form_params.query
};
* ```
* ### Special response object process
* - If response object is a downloadable pdf file, checking from headers `headers('content-type') ===
* "application/pdf"` download using Blob object.
*
* @param {Object} $scope
* @param {Object} redirectTo
* @returns {*} * @returns {*}
* @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
*/ */
generator.submit = function ($scope, redirectTo) { generator.submit = function ($scope, redirectTo) {
/**
* In case of unformatted date object in any key recursively, it must be converted.
* @param model
*/
var convertDate = function (model) { var convertDate = function (model) {
angular.forEach(model, function (value, key) { angular.forEach(model, function (value, key) {
if (value && value.constructor === Date) { if (value && value.constructor === Date) {
...@@ -1295,11 +1320,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1295,11 +1320,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc controller * @ngdoc controller
* @name ModalCtrl * @name ModalCtrl
* @description controller for listnode, node and linkedmodel modal and save data of it * @description controller for listnode, node and linkedmodel modal and save data of it
* @param {object} items * @param {Object} items
* @param {object} $scope * @param {Object} $scope
* @param {object} $uibModalInstance * @param {Object} $uibModalInstance
* @param {object} $route * @param {Object} $route
* @returns returns value for modal * @returns {Object} returns value for modal
*/ */
.controller('ModalCtrl', function ($scope, $uibModalInstance, Generator, items) { .controller('ModalCtrl', function ($scope, $uibModalInstance, Generator, items) {
angular.forEach(items, function (value, key) { angular.forEach(items, function (value, key) {
...@@ -1339,9 +1364,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1339,9 +1364,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc directive * @ngdoc directive
* @name modalForNodes * @name modalForNodes
* @description add modal directive for nodes * @description add modal directive for nodes
* @param {module} $uibModal * @param {Module} $uibModal
* @param {service} Generator * @param {Service} Generator
* @returns openmodal directive * @returns {Object} openmodal directive
*/ */
.directive('modalForNodes', function ($uibModal, Generator) { .directive('modalForNodes', function ($uibModal, Generator) {
return { return {
...@@ -1446,11 +1471,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1446,11 +1471,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc directive * @ngdoc directive
* @name addModalForLinkedModel * @name addModalForLinkedModel
* @description add modal directive for linked models * @description add modal directive for linked models
* @param {module} $uibModal * @param {Module} $uibModal
* @param {object} $rootScope * @param {Object} $rootScope
* @param {module} $route * @param {Module} $route
* @param {service} Generator * @param {Service} Generator
* @returns openmodal directive * @returns {Object} openmodal directive
*/ */
.directive('addModalForLinkedModel', function ($uibModal, $rootScope, $route, Generator) { .directive('addModalForLinkedModel', function ($uibModal, $rootScope, $route, Generator) {
return { return {
...@@ -1524,6 +1549,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1524,6 +1549,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc directive * @ngdoc directive
* @name modalFormLocator * @name modalFormLocator
* @description This directive helps to locate form object in modal. * @description This directive helps to locate form object in modal.
* @returns {Object} form object
*/ */
.directive('modalFormLocator', function () { .directive('modalFormLocator', function () {
return { return {
......
...@@ -508,7 +508,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -508,7 +508,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @memberof ulakbus.formService * @memberof ulakbus.formService
* @ngdoc function * @ngdoc function
* @name prepareFormItems * @name prepareFormItems
* @param scope {object} given scope on which form items prepared * @param scope {Object} given scope on which form items prepared
* @description * @description
* It looks up fields of schema objects and changes their types to proper type for schemaform. * It looks up fields of schema objects and changes their types to proper type for schemaform.
* To prepare items for schemaform loop items of scope.schema.properties by checking index value's `type` key. * To prepare items for schemaform loop items of scope.schema.properties by checking index value's `type` key.
...@@ -520,7 +520,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -520,7 +520,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* For listnode, node and model types it uses templates to generate modal. The modal is aa instance of * For listnode, node and model types it uses templates to generate modal. The modal is aa instance of
* ui.bootstraps modal directive. * ui.bootstraps modal directive.
* *
* @returns scope {object} * @returns scope {Object}
*/ */
generator.prepareFormItems = function (scope) { generator.prepareFormItems = function (scope) {
angular.forEach(scope.form, function (value, key) { angular.forEach(scope.form, function (value, key) {
...@@ -932,7 +932,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -932,7 +932,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name dateformatter * @name dateformatter
* @description dateformatter handles all date fields and returns humanized and jquery datepicker format dates * @description dateformatter handles all date fields and returns humanized and jquery datepicker format dates
* @param {object} formObject * @param {Object} formObject
* @returns {*} * @returns {*}
*/ */
generator.dateformatter = function (formObject) { generator.dateformatter = function (formObject) {
...@@ -953,9 +953,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -953,9 +953,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* on same * 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
* @param {object} $scope * @param {Object} $scope
* @param {string} key * @param {string} key
* @param {object} todo * @param {Object} todo
* @param {string} mode * @param {string} mode
* @returns {*} * @returns {*}
*/ */
...@@ -995,7 +995,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -995,7 +995,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name get_form * @name get_form
* @description Communicates with api with given scope object. * @description Communicates with api with given scope object.
* @param {object} scope * @param {Object} scope
* @returns {*} * @returns {*}
*/ */
generator.get_form = function (scope) { generator.get_form = function (scope) {
...@@ -1097,13 +1097,12 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1097,13 +1097,12 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
}; };
/** /**
* @memberof ulakbus.formService * @memberof ulakbus.formService
* @constructor
* @ngdoc function * @ngdoc function
* @name pathDecider * @name pathDecider
* @description pathDecider is used to redirect related path by looking up the data in response * @description pathDecider is used to redirect related path by looking up the data in response
* @param {string} client_cmd * @param {string} client_cmd
* @param {object} $scope * @param {Object} $scope
* @param {object} data * @param {Object} data
*/ */
generator.pathDecider = function (client_cmd, $scope, data) { generator.pathDecider = function (client_cmd, $scope, data) {
if (client_cmd[0] === 'reload' || client_cmd[0] === 'reset') { if (client_cmd[0] === 'reload' || client_cmd[0] === 'reset') {
...@@ -1117,7 +1116,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1117,7 +1116,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @description redirectTo function redirects to related controller and path with given data * @description redirectTo function redirects to related controller and path with given data
* before redirect setPageData must be called and pageData need to be defined * before redirect setPageData must be called and pageData need to be defined
* otherwise redirected path will call api for its data * otherwise redirected path will call api for its data
* @param {object} scope * @param {Object} scope
* @param {string} page * @param {string} page
* @return {*} * @return {*}
*/ */
...@@ -1163,9 +1162,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1163,9 +1162,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name get_diff * @name get_diff
* @description returns diff of the second param to first param * @description returns diff of the second param to first param
* @param {object} obj1 * @param {Object} obj1
* @param {object} obj2 * @param {Object} obj2
* @returns {{object}} diff object of two given objects * @returns {Object} diff object of two given objects
*/ */
generator.get_diff = function (obj1, obj2) { generator.get_diff = function (obj1, obj2) {
var result = {}; var result = {};
...@@ -1187,10 +1186,10 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1187,10 +1186,10 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name get_diff_array * @name get_diff_array
* @description extracts items of second array from the first array * @description extracts items of second array from the first array
* @param {object} array1 * @param {Array} array1
* @param {object} array2 * @param {Array} array2
* @param {number} way * @param {Number} way
* @returns {Array} * @returns {Array} diff of arrays
*/ */
generator.get_diff_array = function (array1, array2, way) { generator.get_diff_array = function (array1, array2, way) {
var result = []; var result = [];
...@@ -1212,8 +1211,8 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1212,8 +1211,8 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name item_from_array * @name item_from_array
* @description gets item unicode name from titleMap * @description gets item unicode name from titleMap
* @param {object} item * @param {Object} item
* @param {array} array * @param {Array} array
* @returns {*} * @returns {*}
*/ */
generator.item_from_array = function (item, array) { generator.item_from_array = function (item, array) {
...@@ -1230,13 +1229,39 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1230,13 +1229,39 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name submit * @name submit
* @description Submit function is generic function for submiting forms. * @description Submit function is generic function for submiting forms.
* redirectTo param is used for redirect if return value will be evaluated in a new page. * - redirectTo param is used for redirect if return value will be evaluated in a new page.
* @param {object} $scope * - In case of unformatted date object in any key recursively, it must be converted by convertDate function.
* @param {object} redirectTo * - ListNode and Node objects get seperated from model in
* {@link prepareFormItems module:ulakbus.formService.function:prepareFormItems} They must be concat to model
* key of scope first.
* - Backend API waits form as model value. So `data.form` key must be set to `$scope.model`
* - Other parameters we pass to backend API are shown in the example below
* ```
* var data = {
"form": $scope.model,
"token": $scope.token,
"model": $scope.form_params.model,
"cmd": $scope.form_params.cmd,
"flow": $scope.form_params.flow,
"object_id": $scope.object_id,
"filter": $scope.filter,
"query": $scope.form_params.query
};
* ```
* ### Special response object process
* - If response object is a downloadable pdf file, checking from headers `headers('content-type') ===
* "application/pdf"` download using Blob object.
*
* @param {Object} $scope
* @param {Object} redirectTo
* @returns {*} * @returns {*}
* @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
*/ */
generator.submit = function ($scope, redirectTo) { generator.submit = function ($scope, redirectTo) {
/**
* In case of unformatted date object in any key recursively, it must be converted.
* @param model
*/
var convertDate = function (model) { var convertDate = function (model) {
angular.forEach(model, function (value, key) { angular.forEach(model, function (value, key) {
if (value && value.constructor === Date) { if (value && value.constructor === Date) {
...@@ -1295,11 +1320,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1295,11 +1320,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc controller * @ngdoc controller
* @name ModalCtrl * @name ModalCtrl
* @description controller for listnode, node and linkedmodel modal and save data of it * @description controller for listnode, node and linkedmodel modal and save data of it
* @param {object} items * @param {Object} items
* @param {object} $scope * @param {Object} $scope
* @param {object} $uibModalInstance * @param {Object} $uibModalInstance
* @param {object} $route * @param {Object} $route
* @returns returns value for modal * @returns {Object} returns value for modal
*/ */
.controller('ModalCtrl', function ($scope, $uibModalInstance, Generator, items) { .controller('ModalCtrl', function ($scope, $uibModalInstance, Generator, items) {
angular.forEach(items, function (value, key) { angular.forEach(items, function (value, key) {
...@@ -1339,9 +1364,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1339,9 +1364,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc directive * @ngdoc directive
* @name modalForNodes * @name modalForNodes
* @description add modal directive for nodes * @description add modal directive for nodes
* @param {module} $uibModal * @param {Module} $uibModal
* @param {service} Generator * @param {Service} Generator
* @returns openmodal directive * @returns {Object} openmodal directive
*/ */
.directive('modalForNodes', function ($uibModal, Generator) { .directive('modalForNodes', function ($uibModal, Generator) {
return { return {
...@@ -1446,11 +1471,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1446,11 +1471,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc directive * @ngdoc directive
* @name addModalForLinkedModel * @name addModalForLinkedModel
* @description add modal directive for linked models * @description add modal directive for linked models
* @param {module} $uibModal * @param {Module} $uibModal
* @param {object} $rootScope * @param {Object} $rootScope
* @param {module} $route * @param {Module} $route
* @param {service} Generator * @param {Service} Generator
* @returns openmodal directive * @returns {Object} openmodal directive
*/ */
.directive('addModalForLinkedModel', function ($uibModal, $rootScope, $route, Generator) { .directive('addModalForLinkedModel', function ($uibModal, $rootScope, $route, Generator) {
return { return {
...@@ -1524,6 +1549,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1524,6 +1549,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc directive * @ngdoc directive
* @name modalFormLocator * @name modalFormLocator
* @description This directive helps to locate form object in modal. * @description This directive helps to locate form object in modal.
* @returns {Object} form object
*/ */
.directive('modalFormLocator', function () { .directive('modalFormLocator', function () {
return { return {
......
...@@ -508,7 +508,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -508,7 +508,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @memberof ulakbus.formService * @memberof ulakbus.formService
* @ngdoc function * @ngdoc function
* @name prepareFormItems * @name prepareFormItems
* @param scope {object} given scope on which form items prepared * @param scope {Object} given scope on which form items prepared
* @description * @description
* It looks up fields of schema objects and changes their types to proper type for schemaform. * It looks up fields of schema objects and changes their types to proper type for schemaform.
* To prepare items for schemaform loop items of scope.schema.properties by checking index value's `type` key. * To prepare items for schemaform loop items of scope.schema.properties by checking index value's `type` key.
...@@ -520,7 +520,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -520,7 +520,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* For listnode, node and model types it uses templates to generate modal. The modal is aa instance of * For listnode, node and model types it uses templates to generate modal. The modal is aa instance of
* ui.bootstraps modal directive. * ui.bootstraps modal directive.
* *
* @returns scope {object} * @returns scope {Object}
*/ */
generator.prepareFormItems = function (scope) { generator.prepareFormItems = function (scope) {
angular.forEach(scope.form, function (value, key) { angular.forEach(scope.form, function (value, key) {
...@@ -932,7 +932,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -932,7 +932,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name dateformatter * @name dateformatter
* @description dateformatter handles all date fields and returns humanized and jquery datepicker format dates * @description dateformatter handles all date fields and returns humanized and jquery datepicker format dates
* @param {object} formObject * @param {Object} formObject
* @returns {*} * @returns {*}
*/ */
generator.dateformatter = function (formObject) { generator.dateformatter = function (formObject) {
...@@ -953,9 +953,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -953,9 +953,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* on same * 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
* @param {object} $scope * @param {Object} $scope
* @param {string} key * @param {string} key
* @param {object} todo * @param {Object} todo
* @param {string} mode * @param {string} mode
* @returns {*} * @returns {*}
*/ */
...@@ -995,7 +995,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -995,7 +995,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name get_form * @name get_form
* @description Communicates with api with given scope object. * @description Communicates with api with given scope object.
* @param {object} scope * @param {Object} scope
* @returns {*} * @returns {*}
*/ */
generator.get_form = function (scope) { generator.get_form = function (scope) {
...@@ -1097,13 +1097,12 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1097,13 +1097,12 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
}; };
/** /**
* @memberof ulakbus.formService * @memberof ulakbus.formService
* @constructor
* @ngdoc function * @ngdoc function
* @name pathDecider * @name pathDecider
* @description pathDecider is used to redirect related path by looking up the data in response * @description pathDecider is used to redirect related path by looking up the data in response
* @param {string} client_cmd * @param {string} client_cmd
* @param {object} $scope * @param {Object} $scope
* @param {object} data * @param {Object} data
*/ */
generator.pathDecider = function (client_cmd, $scope, data) { generator.pathDecider = function (client_cmd, $scope, data) {
if (client_cmd[0] === 'reload' || client_cmd[0] === 'reset') { if (client_cmd[0] === 'reload' || client_cmd[0] === 'reset') {
...@@ -1117,7 +1116,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1117,7 +1116,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @description redirectTo function redirects to related controller and path with given data * @description redirectTo function redirects to related controller and path with given data
* before redirect setPageData must be called and pageData need to be defined * before redirect setPageData must be called and pageData need to be defined
* otherwise redirected path will call api for its data * otherwise redirected path will call api for its data
* @param {object} scope * @param {Object} scope
* @param {string} page * @param {string} page
* @return {*} * @return {*}
*/ */
...@@ -1163,9 +1162,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1163,9 +1162,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name get_diff * @name get_diff
* @description returns diff of the second param to first param * @description returns diff of the second param to first param
* @param {object} obj1 * @param {Object} obj1
* @param {object} obj2 * @param {Object} obj2
* @returns {{object}} diff object of two given objects * @returns {Object} diff object of two given objects
*/ */
generator.get_diff = function (obj1, obj2) { generator.get_diff = function (obj1, obj2) {
var result = {}; var result = {};
...@@ -1187,10 +1186,10 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1187,10 +1186,10 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name get_diff_array * @name get_diff_array
* @description extracts items of second array from the first array * @description extracts items of second array from the first array
* @param {object} array1 * @param {Array} array1
* @param {object} array2 * @param {Array} array2
* @param {number} way * @param {Number} way
* @returns {Array} * @returns {Array} diff of arrays
*/ */
generator.get_diff_array = function (array1, array2, way) { generator.get_diff_array = function (array1, array2, way) {
var result = []; var result = [];
...@@ -1212,8 +1211,8 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1212,8 +1211,8 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name item_from_array * @name item_from_array
* @description gets item unicode name from titleMap * @description gets item unicode name from titleMap
* @param {object} item * @param {Object} item
* @param {array} array * @param {Array} array
* @returns {*} * @returns {*}
*/ */
generator.item_from_array = function (item, array) { generator.item_from_array = function (item, array) {
...@@ -1230,13 +1229,39 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1230,13 +1229,39 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name submit * @name submit
* @description Submit function is generic function for submiting forms. * @description Submit function is generic function for submiting forms.
* redirectTo param is used for redirect if return value will be evaluated in a new page. * - redirectTo param is used for redirect if return value will be evaluated in a new page.
* @param {object} $scope * - In case of unformatted date object in any key recursively, it must be converted by convertDate function.
* @param {object} redirectTo * - ListNode and Node objects get seperated from model in
* {@link prepareFormItems module:ulakbus.formService.function:prepareFormItems} They must be concat to model
* key of scope first.
* - Backend API waits form as model value. So `data.form` key must be set to `$scope.model`
* - Other parameters we pass to backend API are shown in the example below
* ```
* var data = {
"form": $scope.model,
"token": $scope.token,
"model": $scope.form_params.model,
"cmd": $scope.form_params.cmd,
"flow": $scope.form_params.flow,
"object_id": $scope.object_id,
"filter": $scope.filter,
"query": $scope.form_params.query
};
* ```
* ### Special response object process
* - If response object is a downloadable pdf file, checking from headers `headers('content-type') ===
* "application/pdf"` download using Blob object.
*
* @param {Object} $scope
* @param {Object} redirectTo
* @returns {*} * @returns {*}
* @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
*/ */
generator.submit = function ($scope, redirectTo) { generator.submit = function ($scope, redirectTo) {
/**
* In case of unformatted date object in any key recursively, it must be converted.
* @param model
*/
var convertDate = function (model) { var convertDate = function (model) {
angular.forEach(model, function (value, key) { angular.forEach(model, function (value, key) {
if (value && value.constructor === Date) { if (value && value.constructor === Date) {
...@@ -1295,11 +1320,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1295,11 +1320,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc controller * @ngdoc controller
* @name ModalCtrl * @name ModalCtrl
* @description controller for listnode, node and linkedmodel modal and save data of it * @description controller for listnode, node and linkedmodel modal and save data of it
* @param {object} items * @param {Object} items
* @param {object} $scope * @param {Object} $scope
* @param {object} $uibModalInstance * @param {Object} $uibModalInstance
* @param {object} $route * @param {Object} $route
* @returns returns value for modal * @returns {Object} returns value for modal
*/ */
.controller('ModalCtrl', function ($scope, $uibModalInstance, Generator, items) { .controller('ModalCtrl', function ($scope, $uibModalInstance, Generator, items) {
angular.forEach(items, function (value, key) { angular.forEach(items, function (value, key) {
...@@ -1339,9 +1364,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1339,9 +1364,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc directive * @ngdoc directive
* @name modalForNodes * @name modalForNodes
* @description add modal directive for nodes * @description add modal directive for nodes
* @param {module} $uibModal * @param {Module} $uibModal
* @param {service} Generator * @param {Service} Generator
* @returns openmodal directive * @returns {Object} openmodal directive
*/ */
.directive('modalForNodes', function ($uibModal, Generator) { .directive('modalForNodes', function ($uibModal, Generator) {
return { return {
...@@ -1446,11 +1471,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1446,11 +1471,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc directive * @ngdoc directive
* @name addModalForLinkedModel * @name addModalForLinkedModel
* @description add modal directive for linked models * @description add modal directive for linked models
* @param {module} $uibModal * @param {Module} $uibModal
* @param {object} $rootScope * @param {Object} $rootScope
* @param {module} $route * @param {Module} $route
* @param {service} Generator * @param {Service} Generator
* @returns openmodal directive * @returns {Object} openmodal directive
*/ */
.directive('addModalForLinkedModel', function ($uibModal, $rootScope, $route, Generator) { .directive('addModalForLinkedModel', function ($uibModal, $rootScope, $route, Generator) {
return { return {
...@@ -1524,6 +1549,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1524,6 +1549,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc directive * @ngdoc directive
* @name modalFormLocator * @name modalFormLocator
* @description This directive helps to locate form object in modal. * @description This directive helps to locate form object in modal.
* @returns {Object} form object
*/ */
.directive('modalFormLocator', function () { .directive('modalFormLocator', function () {
return { return {
......
...@@ -508,7 +508,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -508,7 +508,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @memberof ulakbus.formService * @memberof ulakbus.formService
* @ngdoc function * @ngdoc function
* @name prepareFormItems * @name prepareFormItems
* @param scope {object} given scope on which form items prepared * @param scope {Object} given scope on which form items prepared
* @description * @description
* It looks up fields of schema objects and changes their types to proper type for schemaform. * It looks up fields of schema objects and changes their types to proper type for schemaform.
* To prepare items for schemaform loop items of scope.schema.properties by checking index value's `type` key. * To prepare items for schemaform loop items of scope.schema.properties by checking index value's `type` key.
...@@ -520,7 +520,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -520,7 +520,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* For listnode, node and model types it uses templates to generate modal. The modal is aa instance of * For listnode, node and model types it uses templates to generate modal. The modal is aa instance of
* ui.bootstraps modal directive. * ui.bootstraps modal directive.
* *
* @returns scope {object} * @returns scope {Object}
*/ */
generator.prepareFormItems = function (scope) { generator.prepareFormItems = function (scope) {
angular.forEach(scope.form, function (value, key) { angular.forEach(scope.form, function (value, key) {
...@@ -932,7 +932,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -932,7 +932,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name dateformatter * @name dateformatter
* @description dateformatter handles all date fields and returns humanized and jquery datepicker format dates * @description dateformatter handles all date fields and returns humanized and jquery datepicker format dates
* @param {object} formObject * @param {Object} formObject
* @returns {*} * @returns {*}
*/ */
generator.dateformatter = function (formObject) { generator.dateformatter = function (formObject) {
...@@ -953,9 +953,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -953,9 +953,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* on same * 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
* @param {object} $scope * @param {Object} $scope
* @param {string} key * @param {string} key
* @param {object} todo * @param {Object} todo
* @param {string} mode * @param {string} mode
* @returns {*} * @returns {*}
*/ */
...@@ -995,7 +995,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -995,7 +995,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name get_form * @name get_form
* @description Communicates with api with given scope object. * @description Communicates with api with given scope object.
* @param {object} scope * @param {Object} scope
* @returns {*} * @returns {*}
*/ */
generator.get_form = function (scope) { generator.get_form = function (scope) {
...@@ -1097,13 +1097,12 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1097,13 +1097,12 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
}; };
/** /**
* @memberof ulakbus.formService * @memberof ulakbus.formService
* @constructor
* @ngdoc function * @ngdoc function
* @name pathDecider * @name pathDecider
* @description pathDecider is used to redirect related path by looking up the data in response * @description pathDecider is used to redirect related path by looking up the data in response
* @param {string} client_cmd * @param {string} client_cmd
* @param {object} $scope * @param {Object} $scope
* @param {object} data * @param {Object} data
*/ */
generator.pathDecider = function (client_cmd, $scope, data) { generator.pathDecider = function (client_cmd, $scope, data) {
if (client_cmd[0] === 'reload' || client_cmd[0] === 'reset') { if (client_cmd[0] === 'reload' || client_cmd[0] === 'reset') {
...@@ -1117,7 +1116,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1117,7 +1116,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @description redirectTo function redirects to related controller and path with given data * @description redirectTo function redirects to related controller and path with given data
* before redirect setPageData must be called and pageData need to be defined * before redirect setPageData must be called and pageData need to be defined
* otherwise redirected path will call api for its data * otherwise redirected path will call api for its data
* @param {object} scope * @param {Object} scope
* @param {string} page * @param {string} page
* @return {*} * @return {*}
*/ */
...@@ -1163,9 +1162,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1163,9 +1162,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name get_diff * @name get_diff
* @description returns diff of the second param to first param * @description returns diff of the second param to first param
* @param {object} obj1 * @param {Object} obj1
* @param {object} obj2 * @param {Object} obj2
* @returns {{object}} diff object of two given objects * @returns {Object} diff object of two given objects
*/ */
generator.get_diff = function (obj1, obj2) { generator.get_diff = function (obj1, obj2) {
var result = {}; var result = {};
...@@ -1187,10 +1186,10 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1187,10 +1186,10 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name get_diff_array * @name get_diff_array
* @description extracts items of second array from the first array * @description extracts items of second array from the first array
* @param {object} array1 * @param {Array} array1
* @param {object} array2 * @param {Array} array2
* @param {number} way * @param {Number} way
* @returns {Array} * @returns {Array} diff of arrays
*/ */
generator.get_diff_array = function (array1, array2, way) { generator.get_diff_array = function (array1, array2, way) {
var result = []; var result = [];
...@@ -1212,8 +1211,8 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1212,8 +1211,8 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name item_from_array * @name item_from_array
* @description gets item unicode name from titleMap * @description gets item unicode name from titleMap
* @param {object} item * @param {Object} item
* @param {array} array * @param {Array} array
* @returns {*} * @returns {*}
*/ */
generator.item_from_array = function (item, array) { generator.item_from_array = function (item, array) {
...@@ -1230,13 +1229,39 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1230,13 +1229,39 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name submit * @name submit
* @description Submit function is generic function for submiting forms. * @description Submit function is generic function for submiting forms.
* redirectTo param is used for redirect if return value will be evaluated in a new page. * - redirectTo param is used for redirect if return value will be evaluated in a new page.
* @param {object} $scope * - In case of unformatted date object in any key recursively, it must be converted by convertDate function.
* @param {object} redirectTo * - ListNode and Node objects get seperated from model in
* {@link prepareFormItems module:ulakbus.formService.function:prepareFormItems} They must be concat to model
* key of scope first.
* - Backend API waits form as model value. So `data.form` key must be set to `$scope.model`
* - Other parameters we pass to backend API are shown in the example below
* ```
* var data = {
"form": $scope.model,
"token": $scope.token,
"model": $scope.form_params.model,
"cmd": $scope.form_params.cmd,
"flow": $scope.form_params.flow,
"object_id": $scope.object_id,
"filter": $scope.filter,
"query": $scope.form_params.query
};
* ```
* ### Special response object process
* - If response object is a downloadable pdf file, checking from headers `headers('content-type') ===
* "application/pdf"` download using Blob object.
*
* @param {Object} $scope
* @param {Object} redirectTo
* @returns {*} * @returns {*}
* @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
*/ */
generator.submit = function ($scope, redirectTo) { generator.submit = function ($scope, redirectTo) {
/**
* In case of unformatted date object in any key recursively, it must be converted.
* @param model
*/
var convertDate = function (model) { var convertDate = function (model) {
angular.forEach(model, function (value, key) { angular.forEach(model, function (value, key) {
if (value && value.constructor === Date) { if (value && value.constructor === Date) {
...@@ -1295,11 +1320,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1295,11 +1320,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc controller * @ngdoc controller
* @name ModalCtrl * @name ModalCtrl
* @description controller for listnode, node and linkedmodel modal and save data of it * @description controller for listnode, node and linkedmodel modal and save data of it
* @param {object} items * @param {Object} items
* @param {object} $scope * @param {Object} $scope
* @param {object} $uibModalInstance * @param {Object} $uibModalInstance
* @param {object} $route * @param {Object} $route
* @returns returns value for modal * @returns {Object} returns value for modal
*/ */
.controller('ModalCtrl', function ($scope, $uibModalInstance, Generator, items) { .controller('ModalCtrl', function ($scope, $uibModalInstance, Generator, items) {
angular.forEach(items, function (value, key) { angular.forEach(items, function (value, key) {
...@@ -1339,9 +1364,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1339,9 +1364,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc directive * @ngdoc directive
* @name modalForNodes * @name modalForNodes
* @description add modal directive for nodes * @description add modal directive for nodes
* @param {module} $uibModal * @param {Module} $uibModal
* @param {service} Generator * @param {Service} Generator
* @returns openmodal directive * @returns {Object} openmodal directive
*/ */
.directive('modalForNodes', function ($uibModal, Generator) { .directive('modalForNodes', function ($uibModal, Generator) {
return { return {
...@@ -1446,11 +1471,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1446,11 +1471,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc directive * @ngdoc directive
* @name addModalForLinkedModel * @name addModalForLinkedModel
* @description add modal directive for linked models * @description add modal directive for linked models
* @param {module} $uibModal * @param {Module} $uibModal
* @param {object} $rootScope * @param {Object} $rootScope
* @param {module} $route * @param {Module} $route
* @param {service} Generator * @param {Service} Generator
* @returns openmodal directive * @returns {Object} openmodal directive
*/ */
.directive('addModalForLinkedModel', function ($uibModal, $rootScope, $route, Generator) { .directive('addModalForLinkedModel', function ($uibModal, $rootScope, $route, Generator) {
return { return {
...@@ -1524,6 +1549,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1524,6 +1549,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc directive * @ngdoc directive
* @name modalFormLocator * @name modalFormLocator
* @description This directive helps to locate form object in modal. * @description This directive helps to locate form object in modal.
* @returns {Object} form object
*/ */
.directive('modalFormLocator', function () { .directive('modalFormLocator', function () {
return { return {
......
...@@ -508,7 +508,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -508,7 +508,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @memberof ulakbus.formService * @memberof ulakbus.formService
* @ngdoc function * @ngdoc function
* @name prepareFormItems * @name prepareFormItems
* @param scope {object} given scope on which form items prepared * @param scope {Object} given scope on which form items prepared
* @description * @description
* It looks up fields of schema objects and changes their types to proper type for schemaform. * It looks up fields of schema objects and changes their types to proper type for schemaform.
* To prepare items for schemaform loop items of scope.schema.properties by checking index value's `type` key. * To prepare items for schemaform loop items of scope.schema.properties by checking index value's `type` key.
...@@ -520,7 +520,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -520,7 +520,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* For listnode, node and model types it uses templates to generate modal. The modal is aa instance of * For listnode, node and model types it uses templates to generate modal. The modal is aa instance of
* ui.bootstraps modal directive. * ui.bootstraps modal directive.
* *
* @returns scope {object} * @returns scope {Object}
*/ */
generator.prepareFormItems = function (scope) { generator.prepareFormItems = function (scope) {
angular.forEach(scope.form, function (value, key) { angular.forEach(scope.form, function (value, key) {
...@@ -932,7 +932,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -932,7 +932,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name dateformatter * @name dateformatter
* @description dateformatter handles all date fields and returns humanized and jquery datepicker format dates * @description dateformatter handles all date fields and returns humanized and jquery datepicker format dates
* @param {object} formObject * @param {Object} formObject
* @returns {*} * @returns {*}
*/ */
generator.dateformatter = function (formObject) { generator.dateformatter = function (formObject) {
...@@ -953,9 +953,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -953,9 +953,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* on same * 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
* @param {object} $scope * @param {Object} $scope
* @param {string} key * @param {string} key
* @param {object} todo * @param {Object} todo
* @param {string} mode * @param {string} mode
* @returns {*} * @returns {*}
*/ */
...@@ -995,7 +995,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -995,7 +995,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name get_form * @name get_form
* @description Communicates with api with given scope object. * @description Communicates with api with given scope object.
* @param {object} scope * @param {Object} scope
* @returns {*} * @returns {*}
*/ */
generator.get_form = function (scope) { generator.get_form = function (scope) {
...@@ -1097,13 +1097,12 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1097,13 +1097,12 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
}; };
/** /**
* @memberof ulakbus.formService * @memberof ulakbus.formService
* @constructor
* @ngdoc function * @ngdoc function
* @name pathDecider * @name pathDecider
* @description pathDecider is used to redirect related path by looking up the data in response * @description pathDecider is used to redirect related path by looking up the data in response
* @param {string} client_cmd * @param {string} client_cmd
* @param {object} $scope * @param {Object} $scope
* @param {object} data * @param {Object} data
*/ */
generator.pathDecider = function (client_cmd, $scope, data) { generator.pathDecider = function (client_cmd, $scope, data) {
if (client_cmd[0] === 'reload' || client_cmd[0] === 'reset') { if (client_cmd[0] === 'reload' || client_cmd[0] === 'reset') {
...@@ -1117,7 +1116,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1117,7 +1116,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @description redirectTo function redirects to related controller and path with given data * @description redirectTo function redirects to related controller and path with given data
* before redirect setPageData must be called and pageData need to be defined * before redirect setPageData must be called and pageData need to be defined
* otherwise redirected path will call api for its data * otherwise redirected path will call api for its data
* @param {object} scope * @param {Object} scope
* @param {string} page * @param {string} page
* @return {*} * @return {*}
*/ */
...@@ -1163,9 +1162,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1163,9 +1162,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name get_diff * @name get_diff
* @description returns diff of the second param to first param * @description returns diff of the second param to first param
* @param {object} obj1 * @param {Object} obj1
* @param {object} obj2 * @param {Object} obj2
* @returns {{object}} diff object of two given objects * @returns {Object} diff object of two given objects
*/ */
generator.get_diff = function (obj1, obj2) { generator.get_diff = function (obj1, obj2) {
var result = {}; var result = {};
...@@ -1187,10 +1186,10 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1187,10 +1186,10 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name get_diff_array * @name get_diff_array
* @description extracts items of second array from the first array * @description extracts items of second array from the first array
* @param {object} array1 * @param {Array} array1
* @param {object} array2 * @param {Array} array2
* @param {number} way * @param {Number} way
* @returns {Array} * @returns {Array} diff of arrays
*/ */
generator.get_diff_array = function (array1, array2, way) { generator.get_diff_array = function (array1, array2, way) {
var result = []; var result = [];
...@@ -1212,8 +1211,8 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1212,8 +1211,8 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name item_from_array * @name item_from_array
* @description gets item unicode name from titleMap * @description gets item unicode name from titleMap
* @param {object} item * @param {Object} item
* @param {array} array * @param {Array} array
* @returns {*} * @returns {*}
*/ */
generator.item_from_array = function (item, array) { generator.item_from_array = function (item, array) {
...@@ -1230,13 +1229,39 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1230,13 +1229,39 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name submit * @name submit
* @description Submit function is generic function for submiting forms. * @description Submit function is generic function for submiting forms.
* redirectTo param is used for redirect if return value will be evaluated in a new page. * - redirectTo param is used for redirect if return value will be evaluated in a new page.
* @param {object} $scope * - In case of unformatted date object in any key recursively, it must be converted by convertDate function.
* @param {object} redirectTo * - ListNode and Node objects get seperated from model in
* {@link prepareFormItems module:ulakbus.formService.function:prepareFormItems} They must be concat to model
* key of scope first.
* - Backend API waits form as model value. So `data.form` key must be set to `$scope.model`
* - Other parameters we pass to backend API are shown in the example below
* ```
* var data = {
"form": $scope.model,
"token": $scope.token,
"model": $scope.form_params.model,
"cmd": $scope.form_params.cmd,
"flow": $scope.form_params.flow,
"object_id": $scope.object_id,
"filter": $scope.filter,
"query": $scope.form_params.query
};
* ```
* ### Special response object process
* - If response object is a downloadable pdf file, checking from headers `headers('content-type') ===
* "application/pdf"` download using Blob object.
*
* @param {Object} $scope
* @param {Object} redirectTo
* @returns {*} * @returns {*}
* @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
*/ */
generator.submit = function ($scope, redirectTo) { generator.submit = function ($scope, redirectTo) {
/**
* In case of unformatted date object in any key recursively, it must be converted.
* @param model
*/
var convertDate = function (model) { var convertDate = function (model) {
angular.forEach(model, function (value, key) { angular.forEach(model, function (value, key) {
if (value && value.constructor === Date) { if (value && value.constructor === Date) {
...@@ -1295,11 +1320,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1295,11 +1320,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc controller * @ngdoc controller
* @name ModalCtrl * @name ModalCtrl
* @description controller for listnode, node and linkedmodel modal and save data of it * @description controller for listnode, node and linkedmodel modal and save data of it
* @param {object} items * @param {Object} items
* @param {object} $scope * @param {Object} $scope
* @param {object} $uibModalInstance * @param {Object} $uibModalInstance
* @param {object} $route * @param {Object} $route
* @returns returns value for modal * @returns {Object} returns value for modal
*/ */
.controller('ModalCtrl', function ($scope, $uibModalInstance, Generator, items) { .controller('ModalCtrl', function ($scope, $uibModalInstance, Generator, items) {
angular.forEach(items, function (value, key) { angular.forEach(items, function (value, key) {
...@@ -1339,9 +1364,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1339,9 +1364,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc directive * @ngdoc directive
* @name modalForNodes * @name modalForNodes
* @description add modal directive for nodes * @description add modal directive for nodes
* @param {module} $uibModal * @param {Module} $uibModal
* @param {service} Generator * @param {Service} Generator
* @returns openmodal directive * @returns {Object} openmodal directive
*/ */
.directive('modalForNodes', function ($uibModal, Generator) { .directive('modalForNodes', function ($uibModal, Generator) {
return { return {
...@@ -1446,11 +1471,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1446,11 +1471,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc directive * @ngdoc directive
* @name addModalForLinkedModel * @name addModalForLinkedModel
* @description add modal directive for linked models * @description add modal directive for linked models
* @param {module} $uibModal * @param {Module} $uibModal
* @param {object} $rootScope * @param {Object} $rootScope
* @param {module} $route * @param {Module} $route
* @param {service} Generator * @param {Service} Generator
* @returns openmodal directive * @returns {Object} openmodal directive
*/ */
.directive('addModalForLinkedModel', function ($uibModal, $rootScope, $route, Generator) { .directive('addModalForLinkedModel', function ($uibModal, $rootScope, $route, Generator) {
return { return {
...@@ -1524,6 +1549,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1524,6 +1549,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc directive * @ngdoc directive
* @name modalFormLocator * @name modalFormLocator
* @description This directive helps to locate form object in modal. * @description This directive helps to locate form object in modal.
* @returns {Object} form object
*/ */
.directive('modalFormLocator', function () { .directive('modalFormLocator', function () {
return { return {
......
...@@ -508,7 +508,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -508,7 +508,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @memberof ulakbus.formService * @memberof ulakbus.formService
* @ngdoc function * @ngdoc function
* @name prepareFormItems * @name prepareFormItems
* @param scope {object} given scope on which form items prepared * @param scope {Object} given scope on which form items prepared
* @description * @description
* It looks up fields of schema objects and changes their types to proper type for schemaform. * It looks up fields of schema objects and changes their types to proper type for schemaform.
* To prepare items for schemaform loop items of scope.schema.properties by checking index value's `type` key. * To prepare items for schemaform loop items of scope.schema.properties by checking index value's `type` key.
...@@ -520,7 +520,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -520,7 +520,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* For listnode, node and model types it uses templates to generate modal. The modal is aa instance of * For listnode, node and model types it uses templates to generate modal. The modal is aa instance of
* ui.bootstraps modal directive. * ui.bootstraps modal directive.
* *
* @returns scope {object} * @returns scope {Object}
*/ */
generator.prepareFormItems = function (scope) { generator.prepareFormItems = function (scope) {
angular.forEach(scope.form, function (value, key) { angular.forEach(scope.form, function (value, key) {
...@@ -932,7 +932,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -932,7 +932,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name dateformatter * @name dateformatter
* @description dateformatter handles all date fields and returns humanized and jquery datepicker format dates * @description dateformatter handles all date fields and returns humanized and jquery datepicker format dates
* @param {object} formObject * @param {Object} formObject
* @returns {*} * @returns {*}
*/ */
generator.dateformatter = function (formObject) { generator.dateformatter = function (formObject) {
...@@ -953,9 +953,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -953,9 +953,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* on same * 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
* @param {object} $scope * @param {Object} $scope
* @param {string} key * @param {string} key
* @param {object} todo * @param {Object} todo
* @param {string} mode * @param {string} mode
* @returns {*} * @returns {*}
*/ */
...@@ -995,7 +995,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -995,7 +995,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name get_form * @name get_form
* @description Communicates with api with given scope object. * @description Communicates with api with given scope object.
* @param {object} scope * @param {Object} scope
* @returns {*} * @returns {*}
*/ */
generator.get_form = function (scope) { generator.get_form = function (scope) {
...@@ -1097,13 +1097,12 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1097,13 +1097,12 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
}; };
/** /**
* @memberof ulakbus.formService * @memberof ulakbus.formService
* @constructor
* @ngdoc function * @ngdoc function
* @name pathDecider * @name pathDecider
* @description pathDecider is used to redirect related path by looking up the data in response * @description pathDecider is used to redirect related path by looking up the data in response
* @param {string} client_cmd * @param {string} client_cmd
* @param {object} $scope * @param {Object} $scope
* @param {object} data * @param {Object} data
*/ */
generator.pathDecider = function (client_cmd, $scope, data) { generator.pathDecider = function (client_cmd, $scope, data) {
if (client_cmd[0] === 'reload' || client_cmd[0] === 'reset') { if (client_cmd[0] === 'reload' || client_cmd[0] === 'reset') {
...@@ -1117,7 +1116,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1117,7 +1116,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @description redirectTo function redirects to related controller and path with given data * @description redirectTo function redirects to related controller and path with given data
* before redirect setPageData must be called and pageData need to be defined * before redirect setPageData must be called and pageData need to be defined
* otherwise redirected path will call api for its data * otherwise redirected path will call api for its data
* @param {object} scope * @param {Object} scope
* @param {string} page * @param {string} page
* @return {*} * @return {*}
*/ */
...@@ -1163,9 +1162,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1163,9 +1162,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name get_diff * @name get_diff
* @description returns diff of the second param to first param * @description returns diff of the second param to first param
* @param {object} obj1 * @param {Object} obj1
* @param {object} obj2 * @param {Object} obj2
* @returns {{object}} diff object of two given objects * @returns {Object} diff object of two given objects
*/ */
generator.get_diff = function (obj1, obj2) { generator.get_diff = function (obj1, obj2) {
var result = {}; var result = {};
...@@ -1187,10 +1186,10 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1187,10 +1186,10 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name get_diff_array * @name get_diff_array
* @description extracts items of second array from the first array * @description extracts items of second array from the first array
* @param {object} array1 * @param {Array} array1
* @param {object} array2 * @param {Array} array2
* @param {number} way * @param {Number} way
* @returns {Array} * @returns {Array} diff of arrays
*/ */
generator.get_diff_array = function (array1, array2, way) { generator.get_diff_array = function (array1, array2, way) {
var result = []; var result = [];
...@@ -1212,8 +1211,8 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1212,8 +1211,8 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name item_from_array * @name item_from_array
* @description gets item unicode name from titleMap * @description gets item unicode name from titleMap
* @param {object} item * @param {Object} item
* @param {array} array * @param {Array} array
* @returns {*} * @returns {*}
*/ */
generator.item_from_array = function (item, array) { generator.item_from_array = function (item, array) {
...@@ -1230,13 +1229,39 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1230,13 +1229,39 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name submit * @name submit
* @description Submit function is generic function for submiting forms. * @description Submit function is generic function for submiting forms.
* redirectTo param is used for redirect if return value will be evaluated in a new page. * - redirectTo param is used for redirect if return value will be evaluated in a new page.
* @param {object} $scope * - In case of unformatted date object in any key recursively, it must be converted by convertDate function.
* @param {object} redirectTo * - ListNode and Node objects get seperated from model in
* {@link prepareFormItems module:ulakbus.formService.function:prepareFormItems} They must be concat to model
* key of scope first.
* - Backend API waits form as model value. So `data.form` key must be set to `$scope.model`
* - Other parameters we pass to backend API are shown in the example below
* ```
* var data = {
"form": $scope.model,
"token": $scope.token,
"model": $scope.form_params.model,
"cmd": $scope.form_params.cmd,
"flow": $scope.form_params.flow,
"object_id": $scope.object_id,
"filter": $scope.filter,
"query": $scope.form_params.query
};
* ```
* ### Special response object process
* - If response object is a downloadable pdf file, checking from headers `headers('content-type') ===
* "application/pdf"` download using Blob object.
*
* @param {Object} $scope
* @param {Object} redirectTo
* @returns {*} * @returns {*}
* @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
*/ */
generator.submit = function ($scope, redirectTo) { generator.submit = function ($scope, redirectTo) {
/**
* In case of unformatted date object in any key recursively, it must be converted.
* @param model
*/
var convertDate = function (model) { var convertDate = function (model) {
angular.forEach(model, function (value, key) { angular.forEach(model, function (value, key) {
if (value && value.constructor === Date) { if (value && value.constructor === Date) {
...@@ -1295,11 +1320,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1295,11 +1320,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc controller * @ngdoc controller
* @name ModalCtrl * @name ModalCtrl
* @description controller for listnode, node and linkedmodel modal and save data of it * @description controller for listnode, node and linkedmodel modal and save data of it
* @param {object} items * @param {Object} items
* @param {object} $scope * @param {Object} $scope
* @param {object} $uibModalInstance * @param {Object} $uibModalInstance
* @param {object} $route * @param {Object} $route
* @returns returns value for modal * @returns {Object} returns value for modal
*/ */
.controller('ModalCtrl', function ($scope, $uibModalInstance, Generator, items) { .controller('ModalCtrl', function ($scope, $uibModalInstance, Generator, items) {
angular.forEach(items, function (value, key) { angular.forEach(items, function (value, key) {
...@@ -1339,9 +1364,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1339,9 +1364,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc directive * @ngdoc directive
* @name modalForNodes * @name modalForNodes
* @description add modal directive for nodes * @description add modal directive for nodes
* @param {module} $uibModal * @param {Module} $uibModal
* @param {service} Generator * @param {Service} Generator
* @returns openmodal directive * @returns {Object} openmodal directive
*/ */
.directive('modalForNodes', function ($uibModal, Generator) { .directive('modalForNodes', function ($uibModal, Generator) {
return { return {
...@@ -1446,11 +1471,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1446,11 +1471,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc directive * @ngdoc directive
* @name addModalForLinkedModel * @name addModalForLinkedModel
* @description add modal directive for linked models * @description add modal directive for linked models
* @param {module} $uibModal * @param {Module} $uibModal
* @param {object} $rootScope * @param {Object} $rootScope
* @param {module} $route * @param {Module} $route
* @param {service} Generator * @param {Service} Generator
* @returns openmodal directive * @returns {Object} openmodal directive
*/ */
.directive('addModalForLinkedModel', function ($uibModal, $rootScope, $route, Generator) { .directive('addModalForLinkedModel', function ($uibModal, $rootScope, $route, Generator) {
return { return {
...@@ -1524,6 +1549,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1524,6 +1549,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc directive * @ngdoc directive
* @name modalFormLocator * @name modalFormLocator
* @description This directive helps to locate form object in modal. * @description This directive helps to locate form object in modal.
* @returns {Object} form object
*/ */
.directive('modalFormLocator', function () { .directive('modalFormLocator', function () {
return { return {
......
...@@ -508,7 +508,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -508,7 +508,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @memberof ulakbus.formService * @memberof ulakbus.formService
* @ngdoc function * @ngdoc function
* @name prepareFormItems * @name prepareFormItems
* @param scope {object} given scope on which form items prepared * @param scope {Object} given scope on which form items prepared
* @description * @description
* It looks up fields of schema objects and changes their types to proper type for schemaform. * It looks up fields of schema objects and changes their types to proper type for schemaform.
* To prepare items for schemaform loop items of scope.schema.properties by checking index value's `type` key. * To prepare items for schemaform loop items of scope.schema.properties by checking index value's `type` key.
...@@ -520,7 +520,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -520,7 +520,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* For listnode, node and model types it uses templates to generate modal. The modal is aa instance of * For listnode, node and model types it uses templates to generate modal. The modal is aa instance of
* ui.bootstraps modal directive. * ui.bootstraps modal directive.
* *
* @returns scope {object} * @returns scope {Object}
*/ */
generator.prepareFormItems = function (scope) { generator.prepareFormItems = function (scope) {
angular.forEach(scope.form, function (value, key) { angular.forEach(scope.form, function (value, key) {
...@@ -932,7 +932,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -932,7 +932,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name dateformatter * @name dateformatter
* @description dateformatter handles all date fields and returns humanized and jquery datepicker format dates * @description dateformatter handles all date fields and returns humanized and jquery datepicker format dates
* @param {object} formObject * @param {Object} formObject
* @returns {*} * @returns {*}
*/ */
generator.dateformatter = function (formObject) { generator.dateformatter = function (formObject) {
...@@ -953,9 +953,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -953,9 +953,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* on same * 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
* @param {object} $scope * @param {Object} $scope
* @param {string} key * @param {string} key
* @param {object} todo * @param {Object} todo
* @param {string} mode * @param {string} mode
* @returns {*} * @returns {*}
*/ */
...@@ -995,7 +995,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -995,7 +995,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name get_form * @name get_form
* @description Communicates with api with given scope object. * @description Communicates with api with given scope object.
* @param {object} scope * @param {Object} scope
* @returns {*} * @returns {*}
*/ */
generator.get_form = function (scope) { generator.get_form = function (scope) {
...@@ -1097,13 +1097,12 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1097,13 +1097,12 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
}; };
/** /**
* @memberof ulakbus.formService * @memberof ulakbus.formService
* @constructor
* @ngdoc function * @ngdoc function
* @name pathDecider * @name pathDecider
* @description pathDecider is used to redirect related path by looking up the data in response * @description pathDecider is used to redirect related path by looking up the data in response
* @param {string} client_cmd * @param {string} client_cmd
* @param {object} $scope * @param {Object} $scope
* @param {object} data * @param {Object} data
*/ */
generator.pathDecider = function (client_cmd, $scope, data) { generator.pathDecider = function (client_cmd, $scope, data) {
if (client_cmd[0] === 'reload' || client_cmd[0] === 'reset') { if (client_cmd[0] === 'reload' || client_cmd[0] === 'reset') {
...@@ -1117,7 +1116,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1117,7 +1116,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @description redirectTo function redirects to related controller and path with given data * @description redirectTo function redirects to related controller and path with given data
* before redirect setPageData must be called and pageData need to be defined * before redirect setPageData must be called and pageData need to be defined
* otherwise redirected path will call api for its data * otherwise redirected path will call api for its data
* @param {object} scope * @param {Object} scope
* @param {string} page * @param {string} page
* @return {*} * @return {*}
*/ */
...@@ -1163,9 +1162,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1163,9 +1162,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name get_diff * @name get_diff
* @description returns diff of the second param to first param * @description returns diff of the second param to first param
* @param {object} obj1 * @param {Object} obj1
* @param {object} obj2 * @param {Object} obj2
* @returns {{object}} diff object of two given objects * @returns {Object} diff object of two given objects
*/ */
generator.get_diff = function (obj1, obj2) { generator.get_diff = function (obj1, obj2) {
var result = {}; var result = {};
...@@ -1187,10 +1186,10 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1187,10 +1186,10 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name get_diff_array * @name get_diff_array
* @description extracts items of second array from the first array * @description extracts items of second array from the first array
* @param {object} array1 * @param {Array} array1
* @param {object} array2 * @param {Array} array2
* @param {number} way * @param {Number} way
* @returns {Array} * @returns {Array} diff of arrays
*/ */
generator.get_diff_array = function (array1, array2, way) { generator.get_diff_array = function (array1, array2, way) {
var result = []; var result = [];
...@@ -1212,8 +1211,8 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1212,8 +1211,8 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name item_from_array * @name item_from_array
* @description gets item unicode name from titleMap * @description gets item unicode name from titleMap
* @param {object} item * @param {Object} item
* @param {array} array * @param {Array} array
* @returns {*} * @returns {*}
*/ */
generator.item_from_array = function (item, array) { generator.item_from_array = function (item, array) {
...@@ -1230,13 +1229,39 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1230,13 +1229,39 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name submit * @name submit
* @description Submit function is generic function for submiting forms. * @description Submit function is generic function for submiting forms.
* redirectTo param is used for redirect if return value will be evaluated in a new page. * - redirectTo param is used for redirect if return value will be evaluated in a new page.
* @param {object} $scope * - In case of unformatted date object in any key recursively, it must be converted by convertDate function.
* @param {object} redirectTo * - ListNode and Node objects get seperated from model in
* {@link prepareFormItems module:ulakbus.formService.function:prepareFormItems} They must be concat to model
* key of scope first.
* - Backend API waits form as model value. So `data.form` key must be set to `$scope.model`
* - Other parameters we pass to backend API are shown in the example below
* ```
* var data = {
"form": $scope.model,
"token": $scope.token,
"model": $scope.form_params.model,
"cmd": $scope.form_params.cmd,
"flow": $scope.form_params.flow,
"object_id": $scope.object_id,
"filter": $scope.filter,
"query": $scope.form_params.query
};
* ```
* ### Special response object process
* - If response object is a downloadable pdf file, checking from headers `headers('content-type') ===
* "application/pdf"` download using Blob object.
*
* @param {Object} $scope
* @param {Object} redirectTo
* @returns {*} * @returns {*}
* @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
*/ */
generator.submit = function ($scope, redirectTo) { generator.submit = function ($scope, redirectTo) {
/**
* In case of unformatted date object in any key recursively, it must be converted.
* @param model
*/
var convertDate = function (model) { var convertDate = function (model) {
angular.forEach(model, function (value, key) { angular.forEach(model, function (value, key) {
if (value && value.constructor === Date) { if (value && value.constructor === Date) {
...@@ -1295,11 +1320,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1295,11 +1320,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc controller * @ngdoc controller
* @name ModalCtrl * @name ModalCtrl
* @description controller for listnode, node and linkedmodel modal and save data of it * @description controller for listnode, node and linkedmodel modal and save data of it
* @param {object} items * @param {Object} items
* @param {object} $scope * @param {Object} $scope
* @param {object} $uibModalInstance * @param {Object} $uibModalInstance
* @param {object} $route * @param {Object} $route
* @returns returns value for modal * @returns {Object} returns value for modal
*/ */
.controller('ModalCtrl', function ($scope, $uibModalInstance, Generator, items) { .controller('ModalCtrl', function ($scope, $uibModalInstance, Generator, items) {
angular.forEach(items, function (value, key) { angular.forEach(items, function (value, key) {
...@@ -1339,9 +1364,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1339,9 +1364,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc directive * @ngdoc directive
* @name modalForNodes * @name modalForNodes
* @description add modal directive for nodes * @description add modal directive for nodes
* @param {module} $uibModal * @param {Module} $uibModal
* @param {service} Generator * @param {Service} Generator
* @returns openmodal directive * @returns {Object} openmodal directive
*/ */
.directive('modalForNodes', function ($uibModal, Generator) { .directive('modalForNodes', function ($uibModal, Generator) {
return { return {
...@@ -1446,11 +1471,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1446,11 +1471,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc directive * @ngdoc directive
* @name addModalForLinkedModel * @name addModalForLinkedModel
* @description add modal directive for linked models * @description add modal directive for linked models
* @param {module} $uibModal * @param {Module} $uibModal
* @param {object} $rootScope * @param {Object} $rootScope
* @param {module} $route * @param {Module} $route
* @param {service} Generator * @param {Service} Generator
* @returns openmodal directive * @returns {Object} openmodal directive
*/ */
.directive('addModalForLinkedModel', function ($uibModal, $rootScope, $route, Generator) { .directive('addModalForLinkedModel', function ($uibModal, $rootScope, $route, Generator) {
return { return {
...@@ -1524,6 +1549,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1524,6 +1549,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc directive * @ngdoc directive
* @name modalFormLocator * @name modalFormLocator
* @description This directive helps to locate form object in modal. * @description This directive helps to locate form object in modal.
* @returns {Object} form object
*/ */
.directive('modalFormLocator', function () { .directive('modalFormLocator', function () {
return { return {
......
...@@ -508,7 +508,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -508,7 +508,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @memberof ulakbus.formService * @memberof ulakbus.formService
* @ngdoc function * @ngdoc function
* @name prepareFormItems * @name prepareFormItems
* @param scope {object} given scope on which form items prepared * @param scope {Object} given scope on which form items prepared
* @description * @description
* It looks up fields of schema objects and changes their types to proper type for schemaform. * It looks up fields of schema objects and changes their types to proper type for schemaform.
* To prepare items for schemaform loop items of scope.schema.properties by checking index value's `type` key. * To prepare items for schemaform loop items of scope.schema.properties by checking index value's `type` key.
...@@ -520,7 +520,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -520,7 +520,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* For listnode, node and model types it uses templates to generate modal. The modal is aa instance of * For listnode, node and model types it uses templates to generate modal. The modal is aa instance of
* ui.bootstraps modal directive. * ui.bootstraps modal directive.
* *
* @returns scope {object} * @returns scope {Object}
*/ */
generator.prepareFormItems = function (scope) { generator.prepareFormItems = function (scope) {
angular.forEach(scope.form, function (value, key) { angular.forEach(scope.form, function (value, key) {
...@@ -932,7 +932,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -932,7 +932,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name dateformatter * @name dateformatter
* @description dateformatter handles all date fields and returns humanized and jquery datepicker format dates * @description dateformatter handles all date fields and returns humanized and jquery datepicker format dates
* @param {object} formObject * @param {Object} formObject
* @returns {*} * @returns {*}
*/ */
generator.dateformatter = function (formObject) { generator.dateformatter = function (formObject) {
...@@ -953,9 +953,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -953,9 +953,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* on same * 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
* @param {object} $scope * @param {Object} $scope
* @param {string} key * @param {string} key
* @param {object} todo * @param {Object} todo
* @param {string} mode * @param {string} mode
* @returns {*} * @returns {*}
*/ */
...@@ -995,7 +995,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -995,7 +995,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name get_form * @name get_form
* @description Communicates with api with given scope object. * @description Communicates with api with given scope object.
* @param {object} scope * @param {Object} scope
* @returns {*} * @returns {*}
*/ */
generator.get_form = function (scope) { generator.get_form = function (scope) {
...@@ -1097,13 +1097,12 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1097,13 +1097,12 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
}; };
/** /**
* @memberof ulakbus.formService * @memberof ulakbus.formService
* @constructor
* @ngdoc function * @ngdoc function
* @name pathDecider * @name pathDecider
* @description pathDecider is used to redirect related path by looking up the data in response * @description pathDecider is used to redirect related path by looking up the data in response
* @param {string} client_cmd * @param {string} client_cmd
* @param {object} $scope * @param {Object} $scope
* @param {object} data * @param {Object} data
*/ */
generator.pathDecider = function (client_cmd, $scope, data) { generator.pathDecider = function (client_cmd, $scope, data) {
if (client_cmd[0] === 'reload' || client_cmd[0] === 'reset') { if (client_cmd[0] === 'reload' || client_cmd[0] === 'reset') {
...@@ -1117,7 +1116,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1117,7 +1116,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @description redirectTo function redirects to related controller and path with given data * @description redirectTo function redirects to related controller and path with given data
* before redirect setPageData must be called and pageData need to be defined * before redirect setPageData must be called and pageData need to be defined
* otherwise redirected path will call api for its data * otherwise redirected path will call api for its data
* @param {object} scope * @param {Object} scope
* @param {string} page * @param {string} page
* @return {*} * @return {*}
*/ */
...@@ -1163,9 +1162,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1163,9 +1162,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name get_diff * @name get_diff
* @description returns diff of the second param to first param * @description returns diff of the second param to first param
* @param {object} obj1 * @param {Object} obj1
* @param {object} obj2 * @param {Object} obj2
* @returns {{object}} diff object of two given objects * @returns {Object} diff object of two given objects
*/ */
generator.get_diff = function (obj1, obj2) { generator.get_diff = function (obj1, obj2) {
var result = {}; var result = {};
...@@ -1187,10 +1186,10 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1187,10 +1186,10 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name get_diff_array * @name get_diff_array
* @description extracts items of second array from the first array * @description extracts items of second array from the first array
* @param {object} array1 * @param {Array} array1
* @param {object} array2 * @param {Array} array2
* @param {number} way * @param {Number} way
* @returns {Array} * @returns {Array} diff of arrays
*/ */
generator.get_diff_array = function (array1, array2, way) { generator.get_diff_array = function (array1, array2, way) {
var result = []; var result = [];
...@@ -1212,8 +1211,8 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1212,8 +1211,8 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name item_from_array * @name item_from_array
* @description gets item unicode name from titleMap * @description gets item unicode name from titleMap
* @param {object} item * @param {Object} item
* @param {array} array * @param {Array} array
* @returns {*} * @returns {*}
*/ */
generator.item_from_array = function (item, array) { generator.item_from_array = function (item, array) {
...@@ -1230,13 +1229,39 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1230,13 +1229,39 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name submit * @name submit
* @description Submit function is generic function for submiting forms. * @description Submit function is generic function for submiting forms.
* redirectTo param is used for redirect if return value will be evaluated in a new page. * - redirectTo param is used for redirect if return value will be evaluated in a new page.
* @param {object} $scope * - In case of unformatted date object in any key recursively, it must be converted by convertDate function.
* @param {object} redirectTo * - ListNode and Node objects get seperated from model in
* {@link prepareFormItems module:ulakbus.formService.function:prepareFormItems} They must be concat to model
* key of scope first.
* - Backend API waits form as model value. So `data.form` key must be set to `$scope.model`
* - Other parameters we pass to backend API are shown in the example below
* ```
* var data = {
"form": $scope.model,
"token": $scope.token,
"model": $scope.form_params.model,
"cmd": $scope.form_params.cmd,
"flow": $scope.form_params.flow,
"object_id": $scope.object_id,
"filter": $scope.filter,
"query": $scope.form_params.query
};
* ```
* ### Special response object process
* - If response object is a downloadable pdf file, checking from headers `headers('content-type') ===
* "application/pdf"` download using Blob object.
*
* @param {Object} $scope
* @param {Object} redirectTo
* @returns {*} * @returns {*}
* @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
*/ */
generator.submit = function ($scope, redirectTo) { generator.submit = function ($scope, redirectTo) {
/**
* In case of unformatted date object in any key recursively, it must be converted.
* @param model
*/
var convertDate = function (model) { var convertDate = function (model) {
angular.forEach(model, function (value, key) { angular.forEach(model, function (value, key) {
if (value && value.constructor === Date) { if (value && value.constructor === Date) {
...@@ -1295,11 +1320,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1295,11 +1320,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc controller * @ngdoc controller
* @name ModalCtrl * @name ModalCtrl
* @description controller for listnode, node and linkedmodel modal and save data of it * @description controller for listnode, node and linkedmodel modal and save data of it
* @param {object} items * @param {Object} items
* @param {object} $scope * @param {Object} $scope
* @param {object} $uibModalInstance * @param {Object} $uibModalInstance
* @param {object} $route * @param {Object} $route
* @returns returns value for modal * @returns {Object} returns value for modal
*/ */
.controller('ModalCtrl', function ($scope, $uibModalInstance, Generator, items) { .controller('ModalCtrl', function ($scope, $uibModalInstance, Generator, items) {
angular.forEach(items, function (value, key) { angular.forEach(items, function (value, key) {
...@@ -1339,9 +1364,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1339,9 +1364,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc directive * @ngdoc directive
* @name modalForNodes * @name modalForNodes
* @description add modal directive for nodes * @description add modal directive for nodes
* @param {module} $uibModal * @param {Module} $uibModal
* @param {service} Generator * @param {Service} Generator
* @returns openmodal directive * @returns {Object} openmodal directive
*/ */
.directive('modalForNodes', function ($uibModal, Generator) { .directive('modalForNodes', function ($uibModal, Generator) {
return { return {
...@@ -1446,11 +1471,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1446,11 +1471,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc directive * @ngdoc directive
* @name addModalForLinkedModel * @name addModalForLinkedModel
* @description add modal directive for linked models * @description add modal directive for linked models
* @param {module} $uibModal * @param {Module} $uibModal
* @param {object} $rootScope * @param {Object} $rootScope
* @param {module} $route * @param {Module} $route
* @param {service} Generator * @param {Service} Generator
* @returns openmodal directive * @returns {Object} openmodal directive
*/ */
.directive('addModalForLinkedModel', function ($uibModal, $rootScope, $route, Generator) { .directive('addModalForLinkedModel', function ($uibModal, $rootScope, $route, Generator) {
return { return {
...@@ -1524,6 +1549,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1524,6 +1549,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc directive * @ngdoc directive
* @name modalFormLocator * @name modalFormLocator
* @description This directive helps to locate form object in modal. * @description This directive helps to locate form object in modal.
* @returns {Object} form object
*/ */
.directive('modalFormLocator', function () { .directive('modalFormLocator', function () {
return { return {
......
...@@ -508,7 +508,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -508,7 +508,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @memberof ulakbus.formService * @memberof ulakbus.formService
* @ngdoc function * @ngdoc function
* @name prepareFormItems * @name prepareFormItems
* @param scope {object} given scope on which form items prepared * @param scope {Object} given scope on which form items prepared
* @description * @description
* It looks up fields of schema objects and changes their types to proper type for schemaform. * It looks up fields of schema objects and changes their types to proper type for schemaform.
* To prepare items for schemaform loop items of scope.schema.properties by checking index value's `type` key. * To prepare items for schemaform loop items of scope.schema.properties by checking index value's `type` key.
...@@ -520,7 +520,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -520,7 +520,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* For listnode, node and model types it uses templates to generate modal. The modal is aa instance of * For listnode, node and model types it uses templates to generate modal. The modal is aa instance of
* ui.bootstraps modal directive. * ui.bootstraps modal directive.
* *
* @returns scope {object} * @returns scope {Object}
*/ */
generator.prepareFormItems = function (scope) { generator.prepareFormItems = function (scope) {
angular.forEach(scope.form, function (value, key) { angular.forEach(scope.form, function (value, key) {
...@@ -932,7 +932,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -932,7 +932,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name dateformatter * @name dateformatter
* @description dateformatter handles all date fields and returns humanized and jquery datepicker format dates * @description dateformatter handles all date fields and returns humanized and jquery datepicker format dates
* @param {object} formObject * @param {Object} formObject
* @returns {*} * @returns {*}
*/ */
generator.dateformatter = function (formObject) { generator.dateformatter = function (formObject) {
...@@ -953,9 +953,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -953,9 +953,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* on same * 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
* @param {object} $scope * @param {Object} $scope
* @param {string} key * @param {string} key
* @param {object} todo * @param {Object} todo
* @param {string} mode * @param {string} mode
* @returns {*} * @returns {*}
*/ */
...@@ -995,7 +995,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -995,7 +995,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name get_form * @name get_form
* @description Communicates with api with given scope object. * @description Communicates with api with given scope object.
* @param {object} scope * @param {Object} scope
* @returns {*} * @returns {*}
*/ */
generator.get_form = function (scope) { generator.get_form = function (scope) {
...@@ -1097,13 +1097,12 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1097,13 +1097,12 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
}; };
/** /**
* @memberof ulakbus.formService * @memberof ulakbus.formService
* @constructor
* @ngdoc function * @ngdoc function
* @name pathDecider * @name pathDecider
* @description pathDecider is used to redirect related path by looking up the data in response * @description pathDecider is used to redirect related path by looking up the data in response
* @param {string} client_cmd * @param {string} client_cmd
* @param {object} $scope * @param {Object} $scope
* @param {object} data * @param {Object} data
*/ */
generator.pathDecider = function (client_cmd, $scope, data) { generator.pathDecider = function (client_cmd, $scope, data) {
if (client_cmd[0] === 'reload' || client_cmd[0] === 'reset') { if (client_cmd[0] === 'reload' || client_cmd[0] === 'reset') {
...@@ -1117,7 +1116,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1117,7 +1116,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @description redirectTo function redirects to related controller and path with given data * @description redirectTo function redirects to related controller and path with given data
* before redirect setPageData must be called and pageData need to be defined * before redirect setPageData must be called and pageData need to be defined
* otherwise redirected path will call api for its data * otherwise redirected path will call api for its data
* @param {object} scope * @param {Object} scope
* @param {string} page * @param {string} page
* @return {*} * @return {*}
*/ */
...@@ -1163,9 +1162,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1163,9 +1162,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name get_diff * @name get_diff
* @description returns diff of the second param to first param * @description returns diff of the second param to first param
* @param {object} obj1 * @param {Object} obj1
* @param {object} obj2 * @param {Object} obj2
* @returns {{object}} diff object of two given objects * @returns {Object} diff object of two given objects
*/ */
generator.get_diff = function (obj1, obj2) { generator.get_diff = function (obj1, obj2) {
var result = {}; var result = {};
...@@ -1187,10 +1186,10 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1187,10 +1186,10 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name get_diff_array * @name get_diff_array
* @description extracts items of second array from the first array * @description extracts items of second array from the first array
* @param {object} array1 * @param {Array} array1
* @param {object} array2 * @param {Array} array2
* @param {number} way * @param {Number} way
* @returns {Array} * @returns {Array} diff of arrays
*/ */
generator.get_diff_array = function (array1, array2, way) { generator.get_diff_array = function (array1, array2, way) {
var result = []; var result = [];
...@@ -1212,8 +1211,8 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1212,8 +1211,8 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name item_from_array * @name item_from_array
* @description gets item unicode name from titleMap * @description gets item unicode name from titleMap
* @param {object} item * @param {Object} item
* @param {array} array * @param {Array} array
* @returns {*} * @returns {*}
*/ */
generator.item_from_array = function (item, array) { generator.item_from_array = function (item, array) {
...@@ -1230,13 +1229,39 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1230,13 +1229,39 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name submit * @name submit
* @description Submit function is generic function for submiting forms. * @description Submit function is generic function for submiting forms.
* redirectTo param is used for redirect if return value will be evaluated in a new page. * - redirectTo param is used for redirect if return value will be evaluated in a new page.
* @param {object} $scope * - In case of unformatted date object in any key recursively, it must be converted by convertDate function.
* @param {object} redirectTo * - ListNode and Node objects get seperated from model in
* {@link prepareFormItems module:ulakbus.formService.function:prepareFormItems} They must be concat to model
* key of scope first.
* - Backend API waits form as model value. So `data.form` key must be set to `$scope.model`
* - Other parameters we pass to backend API are shown in the example below
* ```
* var data = {
"form": $scope.model,
"token": $scope.token,
"model": $scope.form_params.model,
"cmd": $scope.form_params.cmd,
"flow": $scope.form_params.flow,
"object_id": $scope.object_id,
"filter": $scope.filter,
"query": $scope.form_params.query
};
* ```
* ### Special response object process
* - If response object is a downloadable pdf file, checking from headers `headers('content-type') ===
* "application/pdf"` download using Blob object.
*
* @param {Object} $scope
* @param {Object} redirectTo
* @returns {*} * @returns {*}
* @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
*/ */
generator.submit = function ($scope, redirectTo) { generator.submit = function ($scope, redirectTo) {
/**
* In case of unformatted date object in any key recursively, it must be converted.
* @param model
*/
var convertDate = function (model) { var convertDate = function (model) {
angular.forEach(model, function (value, key) { angular.forEach(model, function (value, key) {
if (value && value.constructor === Date) { if (value && value.constructor === Date) {
...@@ -1295,11 +1320,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1295,11 +1320,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc controller * @ngdoc controller
* @name ModalCtrl * @name ModalCtrl
* @description controller for listnode, node and linkedmodel modal and save data of it * @description controller for listnode, node and linkedmodel modal and save data of it
* @param {object} items * @param {Object} items
* @param {object} $scope * @param {Object} $scope
* @param {object} $uibModalInstance * @param {Object} $uibModalInstance
* @param {object} $route * @param {Object} $route
* @returns returns value for modal * @returns {Object} returns value for modal
*/ */
.controller('ModalCtrl', function ($scope, $uibModalInstance, Generator, items) { .controller('ModalCtrl', function ($scope, $uibModalInstance, Generator, items) {
angular.forEach(items, function (value, key) { angular.forEach(items, function (value, key) {
...@@ -1339,9 +1364,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1339,9 +1364,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc directive * @ngdoc directive
* @name modalForNodes * @name modalForNodes
* @description add modal directive for nodes * @description add modal directive for nodes
* @param {module} $uibModal * @param {Module} $uibModal
* @param {service} Generator * @param {Service} Generator
* @returns openmodal directive * @returns {Object} openmodal directive
*/ */
.directive('modalForNodes', function ($uibModal, Generator) { .directive('modalForNodes', function ($uibModal, Generator) {
return { return {
...@@ -1446,11 +1471,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1446,11 +1471,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc directive * @ngdoc directive
* @name addModalForLinkedModel * @name addModalForLinkedModel
* @description add modal directive for linked models * @description add modal directive for linked models
* @param {module} $uibModal * @param {Module} $uibModal
* @param {object} $rootScope * @param {Object} $rootScope
* @param {module} $route * @param {Module} $route
* @param {service} Generator * @param {Service} Generator
* @returns openmodal directive * @returns {Object} openmodal directive
*/ */
.directive('addModalForLinkedModel', function ($uibModal, $rootScope, $route, Generator) { .directive('addModalForLinkedModel', function ($uibModal, $rootScope, $route, Generator) {
return { return {
...@@ -1524,6 +1549,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1524,6 +1549,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc directive * @ngdoc directive
* @name modalFormLocator * @name modalFormLocator
* @description This directive helps to locate form object in modal. * @description This directive helps to locate form object in modal.
* @returns {Object} form object
*/ */
.directive('modalFormLocator', function () { .directive('modalFormLocator', function () {
return { return {
......
...@@ -508,7 +508,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -508,7 +508,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @memberof ulakbus.formService * @memberof ulakbus.formService
* @ngdoc function * @ngdoc function
* @name prepareFormItems * @name prepareFormItems
* @param scope {object} given scope on which form items prepared * @param scope {Object} given scope on which form items prepared
* @description * @description
* It looks up fields of schema objects and changes their types to proper type for schemaform. * It looks up fields of schema objects and changes their types to proper type for schemaform.
* To prepare items for schemaform loop items of scope.schema.properties by checking index value's `type` key. * To prepare items for schemaform loop items of scope.schema.properties by checking index value's `type` key.
...@@ -520,7 +520,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -520,7 +520,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* For listnode, node and model types it uses templates to generate modal. The modal is aa instance of * For listnode, node and model types it uses templates to generate modal. The modal is aa instance of
* ui.bootstraps modal directive. * ui.bootstraps modal directive.
* *
* @returns scope {object} * @returns scope {Object}
*/ */
generator.prepareFormItems = function (scope) { generator.prepareFormItems = function (scope) {
angular.forEach(scope.form, function (value, key) { angular.forEach(scope.form, function (value, key) {
...@@ -932,7 +932,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -932,7 +932,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name dateformatter * @name dateformatter
* @description dateformatter handles all date fields and returns humanized and jquery datepicker format dates * @description dateformatter handles all date fields and returns humanized and jquery datepicker format dates
* @param {object} formObject * @param {Object} formObject
* @returns {*} * @returns {*}
*/ */
generator.dateformatter = function (formObject) { generator.dateformatter = function (formObject) {
...@@ -953,9 +953,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -953,9 +953,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* on same * 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
* @param {object} $scope * @param {Object} $scope
* @param {string} key * @param {string} key
* @param {object} todo * @param {Object} todo
* @param {string} mode * @param {string} mode
* @returns {*} * @returns {*}
*/ */
...@@ -995,7 +995,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -995,7 +995,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name get_form * @name get_form
* @description Communicates with api with given scope object. * @description Communicates with api with given scope object.
* @param {object} scope * @param {Object} scope
* @returns {*} * @returns {*}
*/ */
generator.get_form = function (scope) { generator.get_form = function (scope) {
...@@ -1097,13 +1097,12 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1097,13 +1097,12 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
}; };
/** /**
* @memberof ulakbus.formService * @memberof ulakbus.formService
* @constructor
* @ngdoc function * @ngdoc function
* @name pathDecider * @name pathDecider
* @description pathDecider is used to redirect related path by looking up the data in response * @description pathDecider is used to redirect related path by looking up the data in response
* @param {string} client_cmd * @param {string} client_cmd
* @param {object} $scope * @param {Object} $scope
* @param {object} data * @param {Object} data
*/ */
generator.pathDecider = function (client_cmd, $scope, data) { generator.pathDecider = function (client_cmd, $scope, data) {
if (client_cmd[0] === 'reload' || client_cmd[0] === 'reset') { if (client_cmd[0] === 'reload' || client_cmd[0] === 'reset') {
...@@ -1117,7 +1116,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1117,7 +1116,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @description redirectTo function redirects to related controller and path with given data * @description redirectTo function redirects to related controller and path with given data
* before redirect setPageData must be called and pageData need to be defined * before redirect setPageData must be called and pageData need to be defined
* otherwise redirected path will call api for its data * otherwise redirected path will call api for its data
* @param {object} scope * @param {Object} scope
* @param {string} page * @param {string} page
* @return {*} * @return {*}
*/ */
...@@ -1163,9 +1162,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1163,9 +1162,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name get_diff * @name get_diff
* @description returns diff of the second param to first param * @description returns diff of the second param to first param
* @param {object} obj1 * @param {Object} obj1
* @param {object} obj2 * @param {Object} obj2
* @returns {{object}} diff object of two given objects * @returns {Object} diff object of two given objects
*/ */
generator.get_diff = function (obj1, obj2) { generator.get_diff = function (obj1, obj2) {
var result = {}; var result = {};
...@@ -1187,10 +1186,10 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1187,10 +1186,10 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name get_diff_array * @name get_diff_array
* @description extracts items of second array from the first array * @description extracts items of second array from the first array
* @param {object} array1 * @param {Array} array1
* @param {object} array2 * @param {Array} array2
* @param {number} way * @param {Number} way
* @returns {Array} * @returns {Array} diff of arrays
*/ */
generator.get_diff_array = function (array1, array2, way) { generator.get_diff_array = function (array1, array2, way) {
var result = []; var result = [];
...@@ -1212,8 +1211,8 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1212,8 +1211,8 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name item_from_array * @name item_from_array
* @description gets item unicode name from titleMap * @description gets item unicode name from titleMap
* @param {object} item * @param {Object} item
* @param {array} array * @param {Array} array
* @returns {*} * @returns {*}
*/ */
generator.item_from_array = function (item, array) { generator.item_from_array = function (item, array) {
...@@ -1230,13 +1229,39 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1230,13 +1229,39 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name submit * @name submit
* @description Submit function is generic function for submiting forms. * @description Submit function is generic function for submiting forms.
* redirectTo param is used for redirect if return value will be evaluated in a new page. * - redirectTo param is used for redirect if return value will be evaluated in a new page.
* @param {object} $scope * - In case of unformatted date object in any key recursively, it must be converted by convertDate function.
* @param {object} redirectTo * - ListNode and Node objects get seperated from model in
* {@link prepareFormItems module:ulakbus.formService.function:prepareFormItems} They must be concat to model
* key of scope first.
* - Backend API waits form as model value. So `data.form` key must be set to `$scope.model`
* - Other parameters we pass to backend API are shown in the example below
* ```
* var data = {
"form": $scope.model,
"token": $scope.token,
"model": $scope.form_params.model,
"cmd": $scope.form_params.cmd,
"flow": $scope.form_params.flow,
"object_id": $scope.object_id,
"filter": $scope.filter,
"query": $scope.form_params.query
};
* ```
* ### Special response object process
* - If response object is a downloadable pdf file, checking from headers `headers('content-type') ===
* "application/pdf"` download using Blob object.
*
* @param {Object} $scope
* @param {Object} redirectTo
* @returns {*} * @returns {*}
* @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
*/ */
generator.submit = function ($scope, redirectTo) { generator.submit = function ($scope, redirectTo) {
/**
* In case of unformatted date object in any key recursively, it must be converted.
* @param model
*/
var convertDate = function (model) { var convertDate = function (model) {
angular.forEach(model, function (value, key) { angular.forEach(model, function (value, key) {
if (value && value.constructor === Date) { if (value && value.constructor === Date) {
...@@ -1295,11 +1320,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1295,11 +1320,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc controller * @ngdoc controller
* @name ModalCtrl * @name ModalCtrl
* @description controller for listnode, node and linkedmodel modal and save data of it * @description controller for listnode, node and linkedmodel modal and save data of it
* @param {object} items * @param {Object} items
* @param {object} $scope * @param {Object} $scope
* @param {object} $uibModalInstance * @param {Object} $uibModalInstance
* @param {object} $route * @param {Object} $route
* @returns returns value for modal * @returns {Object} returns value for modal
*/ */
.controller('ModalCtrl', function ($scope, $uibModalInstance, Generator, items) { .controller('ModalCtrl', function ($scope, $uibModalInstance, Generator, items) {
angular.forEach(items, function (value, key) { angular.forEach(items, function (value, key) {
...@@ -1339,9 +1364,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1339,9 +1364,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc directive * @ngdoc directive
* @name modalForNodes * @name modalForNodes
* @description add modal directive for nodes * @description add modal directive for nodes
* @param {module} $uibModal * @param {Module} $uibModal
* @param {service} Generator * @param {Service} Generator
* @returns openmodal directive * @returns {Object} openmodal directive
*/ */
.directive('modalForNodes', function ($uibModal, Generator) { .directive('modalForNodes', function ($uibModal, Generator) {
return { return {
...@@ -1446,11 +1471,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1446,11 +1471,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc directive * @ngdoc directive
* @name addModalForLinkedModel * @name addModalForLinkedModel
* @description add modal directive for linked models * @description add modal directive for linked models
* @param {module} $uibModal * @param {Module} $uibModal
* @param {object} $rootScope * @param {Object} $rootScope
* @param {module} $route * @param {Module} $route
* @param {service} Generator * @param {Service} Generator
* @returns openmodal directive * @returns {Object} openmodal directive
*/ */
.directive('addModalForLinkedModel', function ($uibModal, $rootScope, $route, Generator) { .directive('addModalForLinkedModel', function ($uibModal, $rootScope, $route, Generator) {
return { return {
...@@ -1524,6 +1549,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1524,6 +1549,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc directive * @ngdoc directive
* @name modalFormLocator * @name modalFormLocator
* @description This directive helps to locate form object in modal. * @description This directive helps to locate form object in modal.
* @returns {Object} form object
*/ */
.directive('modalFormLocator', function () { .directive('modalFormLocator', function () {
return { return {
......
...@@ -508,7 +508,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -508,7 +508,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @memberof ulakbus.formService * @memberof ulakbus.formService
* @ngdoc function * @ngdoc function
* @name prepareFormItems * @name prepareFormItems
* @param scope {object} given scope on which form items prepared * @param scope {Object} given scope on which form items prepared
* @description * @description
* It looks up fields of schema objects and changes their types to proper type for schemaform. * It looks up fields of schema objects and changes their types to proper type for schemaform.
* To prepare items for schemaform loop items of scope.schema.properties by checking index value's `type` key. * To prepare items for schemaform loop items of scope.schema.properties by checking index value's `type` key.
...@@ -520,7 +520,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -520,7 +520,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* For listnode, node and model types it uses templates to generate modal. The modal is aa instance of * For listnode, node and model types it uses templates to generate modal. The modal is aa instance of
* ui.bootstraps modal directive. * ui.bootstraps modal directive.
* *
* @returns scope {object} * @returns scope {Object}
*/ */
generator.prepareFormItems = function (scope) { generator.prepareFormItems = function (scope) {
angular.forEach(scope.form, function (value, key) { angular.forEach(scope.form, function (value, key) {
...@@ -932,7 +932,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -932,7 +932,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name dateformatter * @name dateformatter
* @description dateformatter handles all date fields and returns humanized and jquery datepicker format dates * @description dateformatter handles all date fields and returns humanized and jquery datepicker format dates
* @param {object} formObject * @param {Object} formObject
* @returns {*} * @returns {*}
*/ */
generator.dateformatter = function (formObject) { generator.dateformatter = function (formObject) {
...@@ -953,9 +953,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -953,9 +953,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* on same * 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
* @param {object} $scope * @param {Object} $scope
* @param {string} key * @param {string} key
* @param {object} todo * @param {Object} todo
* @param {string} mode * @param {string} mode
* @returns {*} * @returns {*}
*/ */
...@@ -995,7 +995,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -995,7 +995,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name get_form * @name get_form
* @description Communicates with api with given scope object. * @description Communicates with api with given scope object.
* @param {object} scope * @param {Object} scope
* @returns {*} * @returns {*}
*/ */
generator.get_form = function (scope) { generator.get_form = function (scope) {
...@@ -1097,13 +1097,12 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1097,13 +1097,12 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
}; };
/** /**
* @memberof ulakbus.formService * @memberof ulakbus.formService
* @constructor
* @ngdoc function * @ngdoc function
* @name pathDecider * @name pathDecider
* @description pathDecider is used to redirect related path by looking up the data in response * @description pathDecider is used to redirect related path by looking up the data in response
* @param {string} client_cmd * @param {string} client_cmd
* @param {object} $scope * @param {Object} $scope
* @param {object} data * @param {Object} data
*/ */
generator.pathDecider = function (client_cmd, $scope, data) { generator.pathDecider = function (client_cmd, $scope, data) {
if (client_cmd[0] === 'reload' || client_cmd[0] === 'reset') { if (client_cmd[0] === 'reload' || client_cmd[0] === 'reset') {
...@@ -1117,7 +1116,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1117,7 +1116,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @description redirectTo function redirects to related controller and path with given data * @description redirectTo function redirects to related controller and path with given data
* before redirect setPageData must be called and pageData need to be defined * before redirect setPageData must be called and pageData need to be defined
* otherwise redirected path will call api for its data * otherwise redirected path will call api for its data
* @param {object} scope * @param {Object} scope
* @param {string} page * @param {string} page
* @return {*} * @return {*}
*/ */
...@@ -1163,9 +1162,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1163,9 +1162,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name get_diff * @name get_diff
* @description returns diff of the second param to first param * @description returns diff of the second param to first param
* @param {object} obj1 * @param {Object} obj1
* @param {object} obj2 * @param {Object} obj2
* @returns {{object}} diff object of two given objects * @returns {Object} diff object of two given objects
*/ */
generator.get_diff = function (obj1, obj2) { generator.get_diff = function (obj1, obj2) {
var result = {}; var result = {};
...@@ -1187,10 +1186,10 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1187,10 +1186,10 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name get_diff_array * @name get_diff_array
* @description extracts items of second array from the first array * @description extracts items of second array from the first array
* @param {object} array1 * @param {Array} array1
* @param {object} array2 * @param {Array} array2
* @param {number} way * @param {Number} way
* @returns {Array} * @returns {Array} diff of arrays
*/ */
generator.get_diff_array = function (array1, array2, way) { generator.get_diff_array = function (array1, array2, way) {
var result = []; var result = [];
...@@ -1212,8 +1211,8 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1212,8 +1211,8 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name item_from_array * @name item_from_array
* @description gets item unicode name from titleMap * @description gets item unicode name from titleMap
* @param {object} item * @param {Object} item
* @param {array} array * @param {Array} array
* @returns {*} * @returns {*}
*/ */
generator.item_from_array = function (item, array) { generator.item_from_array = function (item, array) {
...@@ -1230,13 +1229,39 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1230,13 +1229,39 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name submit * @name submit
* @description Submit function is generic function for submiting forms. * @description Submit function is generic function for submiting forms.
* redirectTo param is used for redirect if return value will be evaluated in a new page. * - redirectTo param is used for redirect if return value will be evaluated in a new page.
* @param {object} $scope * - In case of unformatted date object in any key recursively, it must be converted by convertDate function.
* @param {object} redirectTo * - ListNode and Node objects get seperated from model in
* {@link prepareFormItems module:ulakbus.formService.function:prepareFormItems} They must be concat to model
* key of scope first.
* - Backend API waits form as model value. So `data.form` key must be set to `$scope.model`
* - Other parameters we pass to backend API are shown in the example below
* ```
* var data = {
"form": $scope.model,
"token": $scope.token,
"model": $scope.form_params.model,
"cmd": $scope.form_params.cmd,
"flow": $scope.form_params.flow,
"object_id": $scope.object_id,
"filter": $scope.filter,
"query": $scope.form_params.query
};
* ```
* ### Special response object process
* - If response object is a downloadable pdf file, checking from headers `headers('content-type') ===
* "application/pdf"` download using Blob object.
*
* @param {Object} $scope
* @param {Object} redirectTo
* @returns {*} * @returns {*}
* @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
*/ */
generator.submit = function ($scope, redirectTo) { generator.submit = function ($scope, redirectTo) {
/**
* In case of unformatted date object in any key recursively, it must be converted.
* @param model
*/
var convertDate = function (model) { var convertDate = function (model) {
angular.forEach(model, function (value, key) { angular.forEach(model, function (value, key) {
if (value && value.constructor === Date) { if (value && value.constructor === Date) {
...@@ -1295,11 +1320,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1295,11 +1320,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc controller * @ngdoc controller
* @name ModalCtrl * @name ModalCtrl
* @description controller for listnode, node and linkedmodel modal and save data of it * @description controller for listnode, node and linkedmodel modal and save data of it
* @param {object} items * @param {Object} items
* @param {object} $scope * @param {Object} $scope
* @param {object} $uibModalInstance * @param {Object} $uibModalInstance
* @param {object} $route * @param {Object} $route
* @returns returns value for modal * @returns {Object} returns value for modal
*/ */
.controller('ModalCtrl', function ($scope, $uibModalInstance, Generator, items) { .controller('ModalCtrl', function ($scope, $uibModalInstance, Generator, items) {
angular.forEach(items, function (value, key) { angular.forEach(items, function (value, key) {
...@@ -1339,9 +1364,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1339,9 +1364,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc directive * @ngdoc directive
* @name modalForNodes * @name modalForNodes
* @description add modal directive for nodes * @description add modal directive for nodes
* @param {module} $uibModal * @param {Module} $uibModal
* @param {service} Generator * @param {Service} Generator
* @returns openmodal directive * @returns {Object} openmodal directive
*/ */
.directive('modalForNodes', function ($uibModal, Generator) { .directive('modalForNodes', function ($uibModal, Generator) {
return { return {
...@@ -1446,11 +1471,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1446,11 +1471,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc directive * @ngdoc directive
* @name addModalForLinkedModel * @name addModalForLinkedModel
* @description add modal directive for linked models * @description add modal directive for linked models
* @param {module} $uibModal * @param {Module} $uibModal
* @param {object} $rootScope * @param {Object} $rootScope
* @param {module} $route * @param {Module} $route
* @param {service} Generator * @param {Service} Generator
* @returns openmodal directive * @returns {Object} openmodal directive
*/ */
.directive('addModalForLinkedModel', function ($uibModal, $rootScope, $route, Generator) { .directive('addModalForLinkedModel', function ($uibModal, $rootScope, $route, Generator) {
return { return {
...@@ -1524,6 +1549,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1524,6 +1549,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc directive * @ngdoc directive
* @name modalFormLocator * @name modalFormLocator
* @description This directive helps to locate form object in modal. * @description This directive helps to locate form object in modal.
* @returns {Object} form object
*/ */
.directive('modalFormLocator', function () { .directive('modalFormLocator', function () {
return { return {
......
...@@ -508,7 +508,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -508,7 +508,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @memberof ulakbus.formService * @memberof ulakbus.formService
* @ngdoc function * @ngdoc function
* @name prepareFormItems * @name prepareFormItems
* @param scope {object} given scope on which form items prepared * @param scope {Object} given scope on which form items prepared
* @description * @description
* It looks up fields of schema objects and changes their types to proper type for schemaform. * It looks up fields of schema objects and changes their types to proper type for schemaform.
* To prepare items for schemaform loop items of scope.schema.properties by checking index value's `type` key. * To prepare items for schemaform loop items of scope.schema.properties by checking index value's `type` key.
...@@ -520,7 +520,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -520,7 +520,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* For listnode, node and model types it uses templates to generate modal. The modal is aa instance of * For listnode, node and model types it uses templates to generate modal. The modal is aa instance of
* ui.bootstraps modal directive. * ui.bootstraps modal directive.
* *
* @returns scope {object} * @returns scope {Object}
*/ */
generator.prepareFormItems = function (scope) { generator.prepareFormItems = function (scope) {
angular.forEach(scope.form, function (value, key) { angular.forEach(scope.form, function (value, key) {
...@@ -932,7 +932,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -932,7 +932,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name dateformatter * @name dateformatter
* @description dateformatter handles all date fields and returns humanized and jquery datepicker format dates * @description dateformatter handles all date fields and returns humanized and jquery datepicker format dates
* @param {object} formObject * @param {Object} formObject
* @returns {*} * @returns {*}
*/ */
generator.dateformatter = function (formObject) { generator.dateformatter = function (formObject) {
...@@ -953,9 +953,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -953,9 +953,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* on same * 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
* @param {object} $scope * @param {Object} $scope
* @param {string} key * @param {string} key
* @param {object} todo * @param {Object} todo
* @param {string} mode * @param {string} mode
* @returns {*} * @returns {*}
*/ */
...@@ -995,7 +995,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -995,7 +995,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name get_form * @name get_form
* @description Communicates with api with given scope object. * @description Communicates with api with given scope object.
* @param {object} scope * @param {Object} scope
* @returns {*} * @returns {*}
*/ */
generator.get_form = function (scope) { generator.get_form = function (scope) {
...@@ -1097,13 +1097,12 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1097,13 +1097,12 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
}; };
/** /**
* @memberof ulakbus.formService * @memberof ulakbus.formService
* @constructor
* @ngdoc function * @ngdoc function
* @name pathDecider * @name pathDecider
* @description pathDecider is used to redirect related path by looking up the data in response * @description pathDecider is used to redirect related path by looking up the data in response
* @param {string} client_cmd * @param {string} client_cmd
* @param {object} $scope * @param {Object} $scope
* @param {object} data * @param {Object} data
*/ */
generator.pathDecider = function (client_cmd, $scope, data) { generator.pathDecider = function (client_cmd, $scope, data) {
if (client_cmd[0] === 'reload' || client_cmd[0] === 'reset') { if (client_cmd[0] === 'reload' || client_cmd[0] === 'reset') {
...@@ -1117,7 +1116,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1117,7 +1116,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @description redirectTo function redirects to related controller and path with given data * @description redirectTo function redirects to related controller and path with given data
* before redirect setPageData must be called and pageData need to be defined * before redirect setPageData must be called and pageData need to be defined
* otherwise redirected path will call api for its data * otherwise redirected path will call api for its data
* @param {object} scope * @param {Object} scope
* @param {string} page * @param {string} page
* @return {*} * @return {*}
*/ */
...@@ -1163,9 +1162,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1163,9 +1162,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name get_diff * @name get_diff
* @description returns diff of the second param to first param * @description returns diff of the second param to first param
* @param {object} obj1 * @param {Object} obj1
* @param {object} obj2 * @param {Object} obj2
* @returns {{object}} diff object of two given objects * @returns {Object} diff object of two given objects
*/ */
generator.get_diff = function (obj1, obj2) { generator.get_diff = function (obj1, obj2) {
var result = {}; var result = {};
...@@ -1187,10 +1186,10 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1187,10 +1186,10 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name get_diff_array * @name get_diff_array
* @description extracts items of second array from the first array * @description extracts items of second array from the first array
* @param {object} array1 * @param {Array} array1
* @param {object} array2 * @param {Array} array2
* @param {number} way * @param {Number} way
* @returns {Array} * @returns {Array} diff of arrays
*/ */
generator.get_diff_array = function (array1, array2, way) { generator.get_diff_array = function (array1, array2, way) {
var result = []; var result = [];
...@@ -1212,8 +1211,8 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1212,8 +1211,8 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name item_from_array * @name item_from_array
* @description gets item unicode name from titleMap * @description gets item unicode name from titleMap
* @param {object} item * @param {Object} item
* @param {array} array * @param {Array} array
* @returns {*} * @returns {*}
*/ */
generator.item_from_array = function (item, array) { generator.item_from_array = function (item, array) {
...@@ -1230,13 +1229,39 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1230,13 +1229,39 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name submit * @name submit
* @description Submit function is generic function for submiting forms. * @description Submit function is generic function for submiting forms.
* redirectTo param is used for redirect if return value will be evaluated in a new page. * - redirectTo param is used for redirect if return value will be evaluated in a new page.
* @param {object} $scope * - In case of unformatted date object in any key recursively, it must be converted by convertDate function.
* @param {object} redirectTo * - ListNode and Node objects get seperated from model in
* {@link prepareFormItems module:ulakbus.formService.function:prepareFormItems} They must be concat to model
* key of scope first.
* - Backend API waits form as model value. So `data.form` key must be set to `$scope.model`
* - Other parameters we pass to backend API are shown in the example below
* ```
* var data = {
"form": $scope.model,
"token": $scope.token,
"model": $scope.form_params.model,
"cmd": $scope.form_params.cmd,
"flow": $scope.form_params.flow,
"object_id": $scope.object_id,
"filter": $scope.filter,
"query": $scope.form_params.query
};
* ```
* ### Special response object process
* - If response object is a downloadable pdf file, checking from headers `headers('content-type') ===
* "application/pdf"` download using Blob object.
*
* @param {Object} $scope
* @param {Object} redirectTo
* @returns {*} * @returns {*}
* @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
*/ */
generator.submit = function ($scope, redirectTo) { generator.submit = function ($scope, redirectTo) {
/**
* In case of unformatted date object in any key recursively, it must be converted.
* @param model
*/
var convertDate = function (model) { var convertDate = function (model) {
angular.forEach(model, function (value, key) { angular.forEach(model, function (value, key) {
if (value && value.constructor === Date) { if (value && value.constructor === Date) {
...@@ -1295,11 +1320,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1295,11 +1320,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc controller * @ngdoc controller
* @name ModalCtrl * @name ModalCtrl
* @description controller for listnode, node and linkedmodel modal and save data of it * @description controller for listnode, node and linkedmodel modal and save data of it
* @param {object} items * @param {Object} items
* @param {object} $scope * @param {Object} $scope
* @param {object} $uibModalInstance * @param {Object} $uibModalInstance
* @param {object} $route * @param {Object} $route
* @returns returns value for modal * @returns {Object} returns value for modal
*/ */
.controller('ModalCtrl', function ($scope, $uibModalInstance, Generator, items) { .controller('ModalCtrl', function ($scope, $uibModalInstance, Generator, items) {
angular.forEach(items, function (value, key) { angular.forEach(items, function (value, key) {
...@@ -1339,9 +1364,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1339,9 +1364,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc directive * @ngdoc directive
* @name modalForNodes * @name modalForNodes
* @description add modal directive for nodes * @description add modal directive for nodes
* @param {module} $uibModal * @param {Module} $uibModal
* @param {service} Generator * @param {Service} Generator
* @returns openmodal directive * @returns {Object} openmodal directive
*/ */
.directive('modalForNodes', function ($uibModal, Generator) { .directive('modalForNodes', function ($uibModal, Generator) {
return { return {
...@@ -1446,11 +1471,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1446,11 +1471,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc directive * @ngdoc directive
* @name addModalForLinkedModel * @name addModalForLinkedModel
* @description add modal directive for linked models * @description add modal directive for linked models
* @param {module} $uibModal * @param {Module} $uibModal
* @param {object} $rootScope * @param {Object} $rootScope
* @param {module} $route * @param {Module} $route
* @param {service} Generator * @param {Service} Generator
* @returns openmodal directive * @returns {Object} openmodal directive
*/ */
.directive('addModalForLinkedModel', function ($uibModal, $rootScope, $route, Generator) { .directive('addModalForLinkedModel', function ($uibModal, $rootScope, $route, Generator) {
return { return {
...@@ -1524,6 +1549,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1524,6 +1549,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc directive * @ngdoc directive
* @name modalFormLocator * @name modalFormLocator
* @description This directive helps to locate form object in modal. * @description This directive helps to locate form object in modal.
* @returns {Object} form object
*/ */
.directive('modalFormLocator', function () { .directive('modalFormLocator', function () {
return { return {
......
...@@ -508,7 +508,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -508,7 +508,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @memberof ulakbus.formService * @memberof ulakbus.formService
* @ngdoc function * @ngdoc function
* @name prepareFormItems * @name prepareFormItems
* @param scope {object} given scope on which form items prepared * @param scope {Object} given scope on which form items prepared
* @description * @description
* It looks up fields of schema objects and changes their types to proper type for schemaform. * It looks up fields of schema objects and changes their types to proper type for schemaform.
* To prepare items for schemaform loop items of scope.schema.properties by checking index value's `type` key. * To prepare items for schemaform loop items of scope.schema.properties by checking index value's `type` key.
...@@ -520,7 +520,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -520,7 +520,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* For listnode, node and model types it uses templates to generate modal. The modal is aa instance of * For listnode, node and model types it uses templates to generate modal. The modal is aa instance of
* ui.bootstraps modal directive. * ui.bootstraps modal directive.
* *
* @returns scope {object} * @returns scope {Object}
*/ */
generator.prepareFormItems = function (scope) { generator.prepareFormItems = function (scope) {
angular.forEach(scope.form, function (value, key) { angular.forEach(scope.form, function (value, key) {
...@@ -932,7 +932,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -932,7 +932,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name dateformatter * @name dateformatter
* @description dateformatter handles all date fields and returns humanized and jquery datepicker format dates * @description dateformatter handles all date fields and returns humanized and jquery datepicker format dates
* @param {object} formObject * @param {Object} formObject
* @returns {*} * @returns {*}
*/ */
generator.dateformatter = function (formObject) { generator.dateformatter = function (formObject) {
...@@ -953,9 +953,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -953,9 +953,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* on same * 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
* @param {object} $scope * @param {Object} $scope
* @param {string} key * @param {string} key
* @param {object} todo * @param {Object} todo
* @param {string} mode * @param {string} mode
* @returns {*} * @returns {*}
*/ */
...@@ -995,7 +995,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -995,7 +995,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name get_form * @name get_form
* @description Communicates with api with given scope object. * @description Communicates with api with given scope object.
* @param {object} scope * @param {Object} scope
* @returns {*} * @returns {*}
*/ */
generator.get_form = function (scope) { generator.get_form = function (scope) {
...@@ -1097,13 +1097,12 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1097,13 +1097,12 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
}; };
/** /**
* @memberof ulakbus.formService * @memberof ulakbus.formService
* @constructor
* @ngdoc function * @ngdoc function
* @name pathDecider * @name pathDecider
* @description pathDecider is used to redirect related path by looking up the data in response * @description pathDecider is used to redirect related path by looking up the data in response
* @param {string} client_cmd * @param {string} client_cmd
* @param {object} $scope * @param {Object} $scope
* @param {object} data * @param {Object} data
*/ */
generator.pathDecider = function (client_cmd, $scope, data) { generator.pathDecider = function (client_cmd, $scope, data) {
if (client_cmd[0] === 'reload' || client_cmd[0] === 'reset') { if (client_cmd[0] === 'reload' || client_cmd[0] === 'reset') {
...@@ -1117,7 +1116,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1117,7 +1116,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @description redirectTo function redirects to related controller and path with given data * @description redirectTo function redirects to related controller and path with given data
* before redirect setPageData must be called and pageData need to be defined * before redirect setPageData must be called and pageData need to be defined
* otherwise redirected path will call api for its data * otherwise redirected path will call api for its data
* @param {object} scope * @param {Object} scope
* @param {string} page * @param {string} page
* @return {*} * @return {*}
*/ */
...@@ -1163,9 +1162,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1163,9 +1162,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name get_diff * @name get_diff
* @description returns diff of the second param to first param * @description returns diff of the second param to first param
* @param {object} obj1 * @param {Object} obj1
* @param {object} obj2 * @param {Object} obj2
* @returns {{object}} diff object of two given objects * @returns {Object} diff object of two given objects
*/ */
generator.get_diff = function (obj1, obj2) { generator.get_diff = function (obj1, obj2) {
var result = {}; var result = {};
...@@ -1187,10 +1186,10 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1187,10 +1186,10 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name get_diff_array * @name get_diff_array
* @description extracts items of second array from the first array * @description extracts items of second array from the first array
* @param {object} array1 * @param {Array} array1
* @param {object} array2 * @param {Array} array2
* @param {number} way * @param {Number} way
* @returns {Array} * @returns {Array} diff of arrays
*/ */
generator.get_diff_array = function (array1, array2, way) { generator.get_diff_array = function (array1, array2, way) {
var result = []; var result = [];
...@@ -1212,8 +1211,8 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1212,8 +1211,8 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name item_from_array * @name item_from_array
* @description gets item unicode name from titleMap * @description gets item unicode name from titleMap
* @param {object} item * @param {Object} item
* @param {array} array * @param {Array} array
* @returns {*} * @returns {*}
*/ */
generator.item_from_array = function (item, array) { generator.item_from_array = function (item, array) {
...@@ -1230,13 +1229,39 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1230,13 +1229,39 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name submit * @name submit
* @description Submit function is generic function for submiting forms. * @description Submit function is generic function for submiting forms.
* redirectTo param is used for redirect if return value will be evaluated in a new page. * - redirectTo param is used for redirect if return value will be evaluated in a new page.
* @param {object} $scope * - In case of unformatted date object in any key recursively, it must be converted by convertDate function.
* @param {object} redirectTo * - ListNode and Node objects get seperated from model in
* {@link prepareFormItems module:ulakbus.formService.function:prepareFormItems} They must be concat to model
* key of scope first.
* - Backend API waits form as model value. So `data.form` key must be set to `$scope.model`
* - Other parameters we pass to backend API are shown in the example below
* ```
* var data = {
"form": $scope.model,
"token": $scope.token,
"model": $scope.form_params.model,
"cmd": $scope.form_params.cmd,
"flow": $scope.form_params.flow,
"object_id": $scope.object_id,
"filter": $scope.filter,
"query": $scope.form_params.query
};
* ```
* ### Special response object process
* - If response object is a downloadable pdf file, checking from headers `headers('content-type') ===
* "application/pdf"` download using Blob object.
*
* @param {Object} $scope
* @param {Object} redirectTo
* @returns {*} * @returns {*}
* @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
*/ */
generator.submit = function ($scope, redirectTo) { generator.submit = function ($scope, redirectTo) {
/**
* In case of unformatted date object in any key recursively, it must be converted.
* @param model
*/
var convertDate = function (model) { var convertDate = function (model) {
angular.forEach(model, function (value, key) { angular.forEach(model, function (value, key) {
if (value && value.constructor === Date) { if (value && value.constructor === Date) {
...@@ -1295,11 +1320,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1295,11 +1320,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc controller * @ngdoc controller
* @name ModalCtrl * @name ModalCtrl
* @description controller for listnode, node and linkedmodel modal and save data of it * @description controller for listnode, node and linkedmodel modal and save data of it
* @param {object} items * @param {Object} items
* @param {object} $scope * @param {Object} $scope
* @param {object} $uibModalInstance * @param {Object} $uibModalInstance
* @param {object} $route * @param {Object} $route
* @returns returns value for modal * @returns {Object} returns value for modal
*/ */
.controller('ModalCtrl', function ($scope, $uibModalInstance, Generator, items) { .controller('ModalCtrl', function ($scope, $uibModalInstance, Generator, items) {
angular.forEach(items, function (value, key) { angular.forEach(items, function (value, key) {
...@@ -1339,9 +1364,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1339,9 +1364,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc directive * @ngdoc directive
* @name modalForNodes * @name modalForNodes
* @description add modal directive for nodes * @description add modal directive for nodes
* @param {module} $uibModal * @param {Module} $uibModal
* @param {service} Generator * @param {Service} Generator
* @returns openmodal directive * @returns {Object} openmodal directive
*/ */
.directive('modalForNodes', function ($uibModal, Generator) { .directive('modalForNodes', function ($uibModal, Generator) {
return { return {
...@@ -1446,11 +1471,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1446,11 +1471,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc directive * @ngdoc directive
* @name addModalForLinkedModel * @name addModalForLinkedModel
* @description add modal directive for linked models * @description add modal directive for linked models
* @param {module} $uibModal * @param {Module} $uibModal
* @param {object} $rootScope * @param {Object} $rootScope
* @param {module} $route * @param {Module} $route
* @param {service} Generator * @param {Service} Generator
* @returns openmodal directive * @returns {Object} openmodal directive
*/ */
.directive('addModalForLinkedModel', function ($uibModal, $rootScope, $route, Generator) { .directive('addModalForLinkedModel', function ($uibModal, $rootScope, $route, Generator) {
return { return {
...@@ -1524,6 +1549,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1524,6 +1549,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc directive * @ngdoc directive
* @name modalFormLocator * @name modalFormLocator
* @description This directive helps to locate form object in modal. * @description This directive helps to locate form object in modal.
* @returns {Object} form object
*/ */
.directive('modalFormLocator', function () { .directive('modalFormLocator', function () {
return { return {
......
...@@ -508,7 +508,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -508,7 +508,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @memberof ulakbus.formService * @memberof ulakbus.formService
* @ngdoc function * @ngdoc function
* @name prepareFormItems * @name prepareFormItems
* @param scope {object} given scope on which form items prepared * @param scope {Object} given scope on which form items prepared
* @description * @description
* It looks up fields of schema objects and changes their types to proper type for schemaform. * It looks up fields of schema objects and changes their types to proper type for schemaform.
* To prepare items for schemaform loop items of scope.schema.properties by checking index value's `type` key. * To prepare items for schemaform loop items of scope.schema.properties by checking index value's `type` key.
...@@ -520,7 +520,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -520,7 +520,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* For listnode, node and model types it uses templates to generate modal. The modal is aa instance of * For listnode, node and model types it uses templates to generate modal. The modal is aa instance of
* ui.bootstraps modal directive. * ui.bootstraps modal directive.
* *
* @returns scope {object} * @returns scope {Object}
*/ */
generator.prepareFormItems = function (scope) { generator.prepareFormItems = function (scope) {
angular.forEach(scope.form, function (value, key) { angular.forEach(scope.form, function (value, key) {
...@@ -932,7 +932,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -932,7 +932,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name dateformatter * @name dateformatter
* @description dateformatter handles all date fields and returns humanized and jquery datepicker format dates * @description dateformatter handles all date fields and returns humanized and jquery datepicker format dates
* @param {object} formObject * @param {Object} formObject
* @returns {*} * @returns {*}
*/ */
generator.dateformatter = function (formObject) { generator.dateformatter = function (formObject) {
...@@ -953,9 +953,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -953,9 +953,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* on same * 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
* @param {object} $scope * @param {Object} $scope
* @param {string} key * @param {string} key
* @param {object} todo * @param {Object} todo
* @param {string} mode * @param {string} mode
* @returns {*} * @returns {*}
*/ */
...@@ -995,7 +995,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -995,7 +995,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name get_form * @name get_form
* @description Communicates with api with given scope object. * @description Communicates with api with given scope object.
* @param {object} scope * @param {Object} scope
* @returns {*} * @returns {*}
*/ */
generator.get_form = function (scope) { generator.get_form = function (scope) {
...@@ -1097,13 +1097,12 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1097,13 +1097,12 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
}; };
/** /**
* @memberof ulakbus.formService * @memberof ulakbus.formService
* @constructor
* @ngdoc function * @ngdoc function
* @name pathDecider * @name pathDecider
* @description pathDecider is used to redirect related path by looking up the data in response * @description pathDecider is used to redirect related path by looking up the data in response
* @param {string} client_cmd * @param {string} client_cmd
* @param {object} $scope * @param {Object} $scope
* @param {object} data * @param {Object} data
*/ */
generator.pathDecider = function (client_cmd, $scope, data) { generator.pathDecider = function (client_cmd, $scope, data) {
if (client_cmd[0] === 'reload' || client_cmd[0] === 'reset') { if (client_cmd[0] === 'reload' || client_cmd[0] === 'reset') {
...@@ -1117,7 +1116,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1117,7 +1116,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @description redirectTo function redirects to related controller and path with given data * @description redirectTo function redirects to related controller and path with given data
* before redirect setPageData must be called and pageData need to be defined * before redirect setPageData must be called and pageData need to be defined
* otherwise redirected path will call api for its data * otherwise redirected path will call api for its data
* @param {object} scope * @param {Object} scope
* @param {string} page * @param {string} page
* @return {*} * @return {*}
*/ */
...@@ -1163,9 +1162,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1163,9 +1162,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name get_diff * @name get_diff
* @description returns diff of the second param to first param * @description returns diff of the second param to first param
* @param {object} obj1 * @param {Object} obj1
* @param {object} obj2 * @param {Object} obj2
* @returns {{object}} diff object of two given objects * @returns {Object} diff object of two given objects
*/ */
generator.get_diff = function (obj1, obj2) { generator.get_diff = function (obj1, obj2) {
var result = {}; var result = {};
...@@ -1187,10 +1186,10 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1187,10 +1186,10 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name get_diff_array * @name get_diff_array
* @description extracts items of second array from the first array * @description extracts items of second array from the first array
* @param {object} array1 * @param {Array} array1
* @param {object} array2 * @param {Array} array2
* @param {number} way * @param {Number} way
* @returns {Array} * @returns {Array} diff of arrays
*/ */
generator.get_diff_array = function (array1, array2, way) { generator.get_diff_array = function (array1, array2, way) {
var result = []; var result = [];
...@@ -1212,8 +1211,8 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1212,8 +1211,8 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name item_from_array * @name item_from_array
* @description gets item unicode name from titleMap * @description gets item unicode name from titleMap
* @param {object} item * @param {Object} item
* @param {array} array * @param {Array} array
* @returns {*} * @returns {*}
*/ */
generator.item_from_array = function (item, array) { generator.item_from_array = function (item, array) {
...@@ -1230,13 +1229,39 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1230,13 +1229,39 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name submit * @name submit
* @description Submit function is generic function for submiting forms. * @description Submit function is generic function for submiting forms.
* redirectTo param is used for redirect if return value will be evaluated in a new page. * - redirectTo param is used for redirect if return value will be evaluated in a new page.
* @param {object} $scope * - In case of unformatted date object in any key recursively, it must be converted by convertDate function.
* @param {object} redirectTo * - ListNode and Node objects get seperated from model in
* {@link prepareFormItems module:ulakbus.formService.function:prepareFormItems} They must be concat to model
* key of scope first.
* - Backend API waits form as model value. So `data.form` key must be set to `$scope.model`
* - Other parameters we pass to backend API are shown in the example below
* ```
* var data = {
"form": $scope.model,
"token": $scope.token,
"model": $scope.form_params.model,
"cmd": $scope.form_params.cmd,
"flow": $scope.form_params.flow,
"object_id": $scope.object_id,
"filter": $scope.filter,
"query": $scope.form_params.query
};
* ```
* ### Special response object process
* - If response object is a downloadable pdf file, checking from headers `headers('content-type') ===
* "application/pdf"` download using Blob object.
*
* @param {Object} $scope
* @param {Object} redirectTo
* @returns {*} * @returns {*}
* @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
*/ */
generator.submit = function ($scope, redirectTo) { generator.submit = function ($scope, redirectTo) {
/**
* In case of unformatted date object in any key recursively, it must be converted.
* @param model
*/
var convertDate = function (model) { var convertDate = function (model) {
angular.forEach(model, function (value, key) { angular.forEach(model, function (value, key) {
if (value && value.constructor === Date) { if (value && value.constructor === Date) {
...@@ -1295,11 +1320,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1295,11 +1320,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc controller * @ngdoc controller
* @name ModalCtrl * @name ModalCtrl
* @description controller for listnode, node and linkedmodel modal and save data of it * @description controller for listnode, node and linkedmodel modal and save data of it
* @param {object} items * @param {Object} items
* @param {object} $scope * @param {Object} $scope
* @param {object} $uibModalInstance * @param {Object} $uibModalInstance
* @param {object} $route * @param {Object} $route
* @returns returns value for modal * @returns {Object} returns value for modal
*/ */
.controller('ModalCtrl', function ($scope, $uibModalInstance, Generator, items) { .controller('ModalCtrl', function ($scope, $uibModalInstance, Generator, items) {
angular.forEach(items, function (value, key) { angular.forEach(items, function (value, key) {
...@@ -1339,9 +1364,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1339,9 +1364,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc directive * @ngdoc directive
* @name modalForNodes * @name modalForNodes
* @description add modal directive for nodes * @description add modal directive for nodes
* @param {module} $uibModal * @param {Module} $uibModal
* @param {service} Generator * @param {Service} Generator
* @returns openmodal directive * @returns {Object} openmodal directive
*/ */
.directive('modalForNodes', function ($uibModal, Generator) { .directive('modalForNodes', function ($uibModal, Generator) {
return { return {
...@@ -1446,11 +1471,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1446,11 +1471,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc directive * @ngdoc directive
* @name addModalForLinkedModel * @name addModalForLinkedModel
* @description add modal directive for linked models * @description add modal directive for linked models
* @param {module} $uibModal * @param {Module} $uibModal
* @param {object} $rootScope * @param {Object} $rootScope
* @param {module} $route * @param {Module} $route
* @param {service} Generator * @param {Service} Generator
* @returns openmodal directive * @returns {Object} openmodal directive
*/ */
.directive('addModalForLinkedModel', function ($uibModal, $rootScope, $route, Generator) { .directive('addModalForLinkedModel', function ($uibModal, $rootScope, $route, Generator) {
return { return {
...@@ -1524,6 +1549,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1524,6 +1549,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc directive * @ngdoc directive
* @name modalFormLocator * @name modalFormLocator
* @description This directive helps to locate form object in modal. * @description This directive helps to locate form object in modal.
* @returns {Object} form object
*/ */
.directive('modalFormLocator', function () { .directive('modalFormLocator', function () {
return { return {
......
...@@ -508,7 +508,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -508,7 +508,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @memberof ulakbus.formService * @memberof ulakbus.formService
* @ngdoc function * @ngdoc function
* @name prepareFormItems * @name prepareFormItems
* @param scope {object} given scope on which form items prepared * @param scope {Object} given scope on which form items prepared
* @description * @description
* It looks up fields of schema objects and changes their types to proper type for schemaform. * It looks up fields of schema objects and changes their types to proper type for schemaform.
* To prepare items for schemaform loop items of scope.schema.properties by checking index value's `type` key. * To prepare items for schemaform loop items of scope.schema.properties by checking index value's `type` key.
...@@ -520,7 +520,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -520,7 +520,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* For listnode, node and model types it uses templates to generate modal. The modal is aa instance of * For listnode, node and model types it uses templates to generate modal. The modal is aa instance of
* ui.bootstraps modal directive. * ui.bootstraps modal directive.
* *
* @returns scope {object} * @returns scope {Object}
*/ */
generator.prepareFormItems = function (scope) { generator.prepareFormItems = function (scope) {
angular.forEach(scope.form, function (value, key) { angular.forEach(scope.form, function (value, key) {
...@@ -932,7 +932,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -932,7 +932,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name dateformatter * @name dateformatter
* @description dateformatter handles all date fields and returns humanized and jquery datepicker format dates * @description dateformatter handles all date fields and returns humanized and jquery datepicker format dates
* @param {object} formObject * @param {Object} formObject
* @returns {*} * @returns {*}
*/ */
generator.dateformatter = function (formObject) { generator.dateformatter = function (formObject) {
...@@ -953,9 +953,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -953,9 +953,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* on same * 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
* @param {object} $scope * @param {Object} $scope
* @param {string} key * @param {string} key
* @param {object} todo * @param {Object} todo
* @param {string} mode * @param {string} mode
* @returns {*} * @returns {*}
*/ */
...@@ -995,7 +995,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -995,7 +995,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name get_form * @name get_form
* @description Communicates with api with given scope object. * @description Communicates with api with given scope object.
* @param {object} scope * @param {Object} scope
* @returns {*} * @returns {*}
*/ */
generator.get_form = function (scope) { generator.get_form = function (scope) {
...@@ -1097,13 +1097,12 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1097,13 +1097,12 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
}; };
/** /**
* @memberof ulakbus.formService * @memberof ulakbus.formService
* @constructor
* @ngdoc function * @ngdoc function
* @name pathDecider * @name pathDecider
* @description pathDecider is used to redirect related path by looking up the data in response * @description pathDecider is used to redirect related path by looking up the data in response
* @param {string} client_cmd * @param {string} client_cmd
* @param {object} $scope * @param {Object} $scope
* @param {object} data * @param {Object} data
*/ */
generator.pathDecider = function (client_cmd, $scope, data) { generator.pathDecider = function (client_cmd, $scope, data) {
if (client_cmd[0] === 'reload' || client_cmd[0] === 'reset') { if (client_cmd[0] === 'reload' || client_cmd[0] === 'reset') {
...@@ -1117,7 +1116,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1117,7 +1116,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @description redirectTo function redirects to related controller and path with given data * @description redirectTo function redirects to related controller and path with given data
* before redirect setPageData must be called and pageData need to be defined * before redirect setPageData must be called and pageData need to be defined
* otherwise redirected path will call api for its data * otherwise redirected path will call api for its data
* @param {object} scope * @param {Object} scope
* @param {string} page * @param {string} page
* @return {*} * @return {*}
*/ */
...@@ -1163,9 +1162,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1163,9 +1162,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name get_diff * @name get_diff
* @description returns diff of the second param to first param * @description returns diff of the second param to first param
* @param {object} obj1 * @param {Object} obj1
* @param {object} obj2 * @param {Object} obj2
* @returns {{object}} diff object of two given objects * @returns {Object} diff object of two given objects
*/ */
generator.get_diff = function (obj1, obj2) { generator.get_diff = function (obj1, obj2) {
var result = {}; var result = {};
...@@ -1187,10 +1186,10 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1187,10 +1186,10 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name get_diff_array * @name get_diff_array
* @description extracts items of second array from the first array * @description extracts items of second array from the first array
* @param {object} array1 * @param {Array} array1
* @param {object} array2 * @param {Array} array2
* @param {number} way * @param {Number} way
* @returns {Array} * @returns {Array} diff of arrays
*/ */
generator.get_diff_array = function (array1, array2, way) { generator.get_diff_array = function (array1, array2, way) {
var result = []; var result = [];
...@@ -1212,8 +1211,8 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1212,8 +1211,8 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name item_from_array * @name item_from_array
* @description gets item unicode name from titleMap * @description gets item unicode name from titleMap
* @param {object} item * @param {Object} item
* @param {array} array * @param {Array} array
* @returns {*} * @returns {*}
*/ */
generator.item_from_array = function (item, array) { generator.item_from_array = function (item, array) {
...@@ -1230,13 +1229,39 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1230,13 +1229,39 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name submit * @name submit
* @description Submit function is generic function for submiting forms. * @description Submit function is generic function for submiting forms.
* redirectTo param is used for redirect if return value will be evaluated in a new page. * - redirectTo param is used for redirect if return value will be evaluated in a new page.
* @param {object} $scope * - In case of unformatted date object in any key recursively, it must be converted by convertDate function.
* @param {object} redirectTo * - ListNode and Node objects get seperated from model in
* {@link prepareFormItems module:ulakbus.formService.function:prepareFormItems} They must be concat to model
* key of scope first.
* - Backend API waits form as model value. So `data.form` key must be set to `$scope.model`
* - Other parameters we pass to backend API are shown in the example below
* ```
* var data = {
"form": $scope.model,
"token": $scope.token,
"model": $scope.form_params.model,
"cmd": $scope.form_params.cmd,
"flow": $scope.form_params.flow,
"object_id": $scope.object_id,
"filter": $scope.filter,
"query": $scope.form_params.query
};
* ```
* ### Special response object process
* - If response object is a downloadable pdf file, checking from headers `headers('content-type') ===
* "application/pdf"` download using Blob object.
*
* @param {Object} $scope
* @param {Object} redirectTo
* @returns {*} * @returns {*}
* @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
*/ */
generator.submit = function ($scope, redirectTo) { generator.submit = function ($scope, redirectTo) {
/**
* In case of unformatted date object in any key recursively, it must be converted.
* @param model
*/
var convertDate = function (model) { var convertDate = function (model) {
angular.forEach(model, function (value, key) { angular.forEach(model, function (value, key) {
if (value && value.constructor === Date) { if (value && value.constructor === Date) {
...@@ -1295,11 +1320,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1295,11 +1320,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc controller * @ngdoc controller
* @name ModalCtrl * @name ModalCtrl
* @description controller for listnode, node and linkedmodel modal and save data of it * @description controller for listnode, node and linkedmodel modal and save data of it
* @param {object} items * @param {Object} items
* @param {object} $scope * @param {Object} $scope
* @param {object} $uibModalInstance * @param {Object} $uibModalInstance
* @param {object} $route * @param {Object} $route
* @returns returns value for modal * @returns {Object} returns value for modal
*/ */
.controller('ModalCtrl', function ($scope, $uibModalInstance, Generator, items) { .controller('ModalCtrl', function ($scope, $uibModalInstance, Generator, items) {
angular.forEach(items, function (value, key) { angular.forEach(items, function (value, key) {
...@@ -1339,9 +1364,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1339,9 +1364,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc directive * @ngdoc directive
* @name modalForNodes * @name modalForNodes
* @description add modal directive for nodes * @description add modal directive for nodes
* @param {module} $uibModal * @param {Module} $uibModal
* @param {service} Generator * @param {Service} Generator
* @returns openmodal directive * @returns {Object} openmodal directive
*/ */
.directive('modalForNodes', function ($uibModal, Generator) { .directive('modalForNodes', function ($uibModal, Generator) {
return { return {
...@@ -1446,11 +1471,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1446,11 +1471,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc directive * @ngdoc directive
* @name addModalForLinkedModel * @name addModalForLinkedModel
* @description add modal directive for linked models * @description add modal directive for linked models
* @param {module} $uibModal * @param {Module} $uibModal
* @param {object} $rootScope * @param {Object} $rootScope
* @param {module} $route * @param {Module} $route
* @param {service} Generator * @param {Service} Generator
* @returns openmodal directive * @returns {Object} openmodal directive
*/ */
.directive('addModalForLinkedModel', function ($uibModal, $rootScope, $route, Generator) { .directive('addModalForLinkedModel', function ($uibModal, $rootScope, $route, Generator) {
return { return {
...@@ -1524,6 +1549,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1524,6 +1549,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc directive * @ngdoc directive
* @name modalFormLocator * @name modalFormLocator
* @description This directive helps to locate form object in modal. * @description This directive helps to locate form object in modal.
* @returns {Object} form object
*/ */
.directive('modalFormLocator', function () { .directive('modalFormLocator', function () {
return { return {
......
...@@ -508,7 +508,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -508,7 +508,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @memberof ulakbus.formService * @memberof ulakbus.formService
* @ngdoc function * @ngdoc function
* @name prepareFormItems * @name prepareFormItems
* @param scope {object} given scope on which form items prepared * @param scope {Object} given scope on which form items prepared
* @description * @description
* It looks up fields of schema objects and changes their types to proper type for schemaform. * It looks up fields of schema objects and changes their types to proper type for schemaform.
* To prepare items for schemaform loop items of scope.schema.properties by checking index value's `type` key. * To prepare items for schemaform loop items of scope.schema.properties by checking index value's `type` key.
...@@ -520,7 +520,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -520,7 +520,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* For listnode, node and model types it uses templates to generate modal. The modal is aa instance of * For listnode, node and model types it uses templates to generate modal. The modal is aa instance of
* ui.bootstraps modal directive. * ui.bootstraps modal directive.
* *
* @returns scope {object} * @returns scope {Object}
*/ */
generator.prepareFormItems = function (scope) { generator.prepareFormItems = function (scope) {
angular.forEach(scope.form, function (value, key) { angular.forEach(scope.form, function (value, key) {
...@@ -932,7 +932,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -932,7 +932,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name dateformatter * @name dateformatter
* @description dateformatter handles all date fields and returns humanized and jquery datepicker format dates * @description dateformatter handles all date fields and returns humanized and jquery datepicker format dates
* @param {object} formObject * @param {Object} formObject
* @returns {*} * @returns {*}
*/ */
generator.dateformatter = function (formObject) { generator.dateformatter = function (formObject) {
...@@ -953,9 +953,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -953,9 +953,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* on same * 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
* @param {object} $scope * @param {Object} $scope
* @param {string} key * @param {string} key
* @param {object} todo * @param {Object} todo
* @param {string} mode * @param {string} mode
* @returns {*} * @returns {*}
*/ */
...@@ -995,7 +995,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -995,7 +995,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name get_form * @name get_form
* @description Communicates with api with given scope object. * @description Communicates with api with given scope object.
* @param {object} scope * @param {Object} scope
* @returns {*} * @returns {*}
*/ */
generator.get_form = function (scope) { generator.get_form = function (scope) {
...@@ -1097,13 +1097,12 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1097,13 +1097,12 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
}; };
/** /**
* @memberof ulakbus.formService * @memberof ulakbus.formService
* @constructor
* @ngdoc function * @ngdoc function
* @name pathDecider * @name pathDecider
* @description pathDecider is used to redirect related path by looking up the data in response * @description pathDecider is used to redirect related path by looking up the data in response
* @param {string} client_cmd * @param {string} client_cmd
* @param {object} $scope * @param {Object} $scope
* @param {object} data * @param {Object} data
*/ */
generator.pathDecider = function (client_cmd, $scope, data) { generator.pathDecider = function (client_cmd, $scope, data) {
if (client_cmd[0] === 'reload' || client_cmd[0] === 'reset') { if (client_cmd[0] === 'reload' || client_cmd[0] === 'reset') {
...@@ -1117,7 +1116,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1117,7 +1116,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @description redirectTo function redirects to related controller and path with given data * @description redirectTo function redirects to related controller and path with given data
* before redirect setPageData must be called and pageData need to be defined * before redirect setPageData must be called and pageData need to be defined
* otherwise redirected path will call api for its data * otherwise redirected path will call api for its data
* @param {object} scope * @param {Object} scope
* @param {string} page * @param {string} page
* @return {*} * @return {*}
*/ */
...@@ -1163,9 +1162,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1163,9 +1162,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name get_diff * @name get_diff
* @description returns diff of the second param to first param * @description returns diff of the second param to first param
* @param {object} obj1 * @param {Object} obj1
* @param {object} obj2 * @param {Object} obj2
* @returns {{object}} diff object of two given objects * @returns {Object} diff object of two given objects
*/ */
generator.get_diff = function (obj1, obj2) { generator.get_diff = function (obj1, obj2) {
var result = {}; var result = {};
...@@ -1187,10 +1186,10 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1187,10 +1186,10 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name get_diff_array * @name get_diff_array
* @description extracts items of second array from the first array * @description extracts items of second array from the first array
* @param {object} array1 * @param {Array} array1
* @param {object} array2 * @param {Array} array2
* @param {number} way * @param {Number} way
* @returns {Array} * @returns {Array} diff of arrays
*/ */
generator.get_diff_array = function (array1, array2, way) { generator.get_diff_array = function (array1, array2, way) {
var result = []; var result = [];
...@@ -1212,8 +1211,8 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1212,8 +1211,8 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name item_from_array * @name item_from_array
* @description gets item unicode name from titleMap * @description gets item unicode name from titleMap
* @param {object} item * @param {Object} item
* @param {array} array * @param {Array} array
* @returns {*} * @returns {*}
*/ */
generator.item_from_array = function (item, array) { generator.item_from_array = function (item, array) {
...@@ -1230,13 +1229,39 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1230,13 +1229,39 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name submit * @name submit
* @description Submit function is generic function for submiting forms. * @description Submit function is generic function for submiting forms.
* redirectTo param is used for redirect if return value will be evaluated in a new page. * - redirectTo param is used for redirect if return value will be evaluated in a new page.
* @param {object} $scope * - In case of unformatted date object in any key recursively, it must be converted by convertDate function.
* @param {object} redirectTo * - ListNode and Node objects get seperated from model in
* {@link prepareFormItems module:ulakbus.formService.function:prepareFormItems} They must be concat to model
* key of scope first.
* - Backend API waits form as model value. So `data.form` key must be set to `$scope.model`
* - Other parameters we pass to backend API are shown in the example below
* ```
* var data = {
"form": $scope.model,
"token": $scope.token,
"model": $scope.form_params.model,
"cmd": $scope.form_params.cmd,
"flow": $scope.form_params.flow,
"object_id": $scope.object_id,
"filter": $scope.filter,
"query": $scope.form_params.query
};
* ```
* ### Special response object process
* - If response object is a downloadable pdf file, checking from headers `headers('content-type') ===
* "application/pdf"` download using Blob object.
*
* @param {Object} $scope
* @param {Object} redirectTo
* @returns {*} * @returns {*}
* @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
*/ */
generator.submit = function ($scope, redirectTo) { generator.submit = function ($scope, redirectTo) {
/**
* In case of unformatted date object in any key recursively, it must be converted.
* @param model
*/
var convertDate = function (model) { var convertDate = function (model) {
angular.forEach(model, function (value, key) { angular.forEach(model, function (value, key) {
if (value && value.constructor === Date) { if (value && value.constructor === Date) {
...@@ -1295,11 +1320,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1295,11 +1320,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc controller * @ngdoc controller
* @name ModalCtrl * @name ModalCtrl
* @description controller for listnode, node and linkedmodel modal and save data of it * @description controller for listnode, node and linkedmodel modal and save data of it
* @param {object} items * @param {Object} items
* @param {object} $scope * @param {Object} $scope
* @param {object} $uibModalInstance * @param {Object} $uibModalInstance
* @param {object} $route * @param {Object} $route
* @returns returns value for modal * @returns {Object} returns value for modal
*/ */
.controller('ModalCtrl', function ($scope, $uibModalInstance, Generator, items) { .controller('ModalCtrl', function ($scope, $uibModalInstance, Generator, items) {
angular.forEach(items, function (value, key) { angular.forEach(items, function (value, key) {
...@@ -1339,9 +1364,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1339,9 +1364,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc directive * @ngdoc directive
* @name modalForNodes * @name modalForNodes
* @description add modal directive for nodes * @description add modal directive for nodes
* @param {module} $uibModal * @param {Module} $uibModal
* @param {service} Generator * @param {Service} Generator
* @returns openmodal directive * @returns {Object} openmodal directive
*/ */
.directive('modalForNodes', function ($uibModal, Generator) { .directive('modalForNodes', function ($uibModal, Generator) {
return { return {
...@@ -1446,11 +1471,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1446,11 +1471,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc directive * @ngdoc directive
* @name addModalForLinkedModel * @name addModalForLinkedModel
* @description add modal directive for linked models * @description add modal directive for linked models
* @param {module} $uibModal * @param {Module} $uibModal
* @param {object} $rootScope * @param {Object} $rootScope
* @param {module} $route * @param {Module} $route
* @param {service} Generator * @param {Service} Generator
* @returns openmodal directive * @returns {Object} openmodal directive
*/ */
.directive('addModalForLinkedModel', function ($uibModal, $rootScope, $route, Generator) { .directive('addModalForLinkedModel', function ($uibModal, $rootScope, $route, Generator) {
return { return {
...@@ -1524,6 +1549,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1524,6 +1549,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc directive * @ngdoc directive
* @name modalFormLocator * @name modalFormLocator
* @description This directive helps to locate form object in modal. * @description This directive helps to locate form object in modal.
* @returns {Object} form object
*/ */
.directive('modalFormLocator', function () { .directive('modalFormLocator', function () {
return { return {
......
...@@ -508,7 +508,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -508,7 +508,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @memberof ulakbus.formService * @memberof ulakbus.formService
* @ngdoc function * @ngdoc function
* @name prepareFormItems * @name prepareFormItems
* @param scope {object} given scope on which form items prepared * @param scope {Object} given scope on which form items prepared
* @description * @description
* It looks up fields of schema objects and changes their types to proper type for schemaform. * It looks up fields of schema objects and changes their types to proper type for schemaform.
* To prepare items for schemaform loop items of scope.schema.properties by checking index value's `type` key. * To prepare items for schemaform loop items of scope.schema.properties by checking index value's `type` key.
...@@ -520,7 +520,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -520,7 +520,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* For listnode, node and model types it uses templates to generate modal. The modal is aa instance of * For listnode, node and model types it uses templates to generate modal. The modal is aa instance of
* ui.bootstraps modal directive. * ui.bootstraps modal directive.
* *
* @returns scope {object} * @returns scope {Object}
*/ */
generator.prepareFormItems = function (scope) { generator.prepareFormItems = function (scope) {
angular.forEach(scope.form, function (value, key) { angular.forEach(scope.form, function (value, key) {
...@@ -932,7 +932,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -932,7 +932,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name dateformatter * @name dateformatter
* @description dateformatter handles all date fields and returns humanized and jquery datepicker format dates * @description dateformatter handles all date fields and returns humanized and jquery datepicker format dates
* @param {object} formObject * @param {Object} formObject
* @returns {*} * @returns {*}
*/ */
generator.dateformatter = function (formObject) { generator.dateformatter = function (formObject) {
...@@ -953,9 +953,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -953,9 +953,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* on same * 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
* @param {object} $scope * @param {Object} $scope
* @param {string} key * @param {string} key
* @param {object} todo * @param {Object} todo
* @param {string} mode * @param {string} mode
* @returns {*} * @returns {*}
*/ */
...@@ -995,7 +995,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -995,7 +995,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name get_form * @name get_form
* @description Communicates with api with given scope object. * @description Communicates with api with given scope object.
* @param {object} scope * @param {Object} scope
* @returns {*} * @returns {*}
*/ */
generator.get_form = function (scope) { generator.get_form = function (scope) {
...@@ -1097,13 +1097,12 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1097,13 +1097,12 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
}; };
/** /**
* @memberof ulakbus.formService * @memberof ulakbus.formService
* @constructor
* @ngdoc function * @ngdoc function
* @name pathDecider * @name pathDecider
* @description pathDecider is used to redirect related path by looking up the data in response * @description pathDecider is used to redirect related path by looking up the data in response
* @param {string} client_cmd * @param {string} client_cmd
* @param {object} $scope * @param {Object} $scope
* @param {object} data * @param {Object} data
*/ */
generator.pathDecider = function (client_cmd, $scope, data) { generator.pathDecider = function (client_cmd, $scope, data) {
if (client_cmd[0] === 'reload' || client_cmd[0] === 'reset') { if (client_cmd[0] === 'reload' || client_cmd[0] === 'reset') {
...@@ -1117,7 +1116,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1117,7 +1116,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @description redirectTo function redirects to related controller and path with given data * @description redirectTo function redirects to related controller and path with given data
* before redirect setPageData must be called and pageData need to be defined * before redirect setPageData must be called and pageData need to be defined
* otherwise redirected path will call api for its data * otherwise redirected path will call api for its data
* @param {object} scope * @param {Object} scope
* @param {string} page * @param {string} page
* @return {*} * @return {*}
*/ */
...@@ -1163,9 +1162,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1163,9 +1162,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name get_diff * @name get_diff
* @description returns diff of the second param to first param * @description returns diff of the second param to first param
* @param {object} obj1 * @param {Object} obj1
* @param {object} obj2 * @param {Object} obj2
* @returns {{object}} diff object of two given objects * @returns {Object} diff object of two given objects
*/ */
generator.get_diff = function (obj1, obj2) { generator.get_diff = function (obj1, obj2) {
var result = {}; var result = {};
...@@ -1187,10 +1186,10 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1187,10 +1186,10 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name get_diff_array * @name get_diff_array
* @description extracts items of second array from the first array * @description extracts items of second array from the first array
* @param {object} array1 * @param {Array} array1
* @param {object} array2 * @param {Array} array2
* @param {number} way * @param {Number} way
* @returns {Array} * @returns {Array} diff of arrays
*/ */
generator.get_diff_array = function (array1, array2, way) { generator.get_diff_array = function (array1, array2, way) {
var result = []; var result = [];
...@@ -1212,8 +1211,8 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1212,8 +1211,8 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name item_from_array * @name item_from_array
* @description gets item unicode name from titleMap * @description gets item unicode name from titleMap
* @param {object} item * @param {Object} item
* @param {array} array * @param {Array} array
* @returns {*} * @returns {*}
*/ */
generator.item_from_array = function (item, array) { generator.item_from_array = function (item, array) {
...@@ -1230,13 +1229,39 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1230,13 +1229,39 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc function * @ngdoc function
* @name submit * @name submit
* @description Submit function is generic function for submiting forms. * @description Submit function is generic function for submiting forms.
* redirectTo param is used for redirect if return value will be evaluated in a new page. * - redirectTo param is used for redirect if return value will be evaluated in a new page.
* @param {object} $scope * - In case of unformatted date object in any key recursively, it must be converted by convertDate function.
* @param {object} redirectTo * - ListNode and Node objects get seperated from model in
* {@link prepareFormItems module:ulakbus.formService.function:prepareFormItems} They must be concat to model
* key of scope first.
* - Backend API waits form as model value. So `data.form` key must be set to `$scope.model`
* - Other parameters we pass to backend API are shown in the example below
* ```
* var data = {
"form": $scope.model,
"token": $scope.token,
"model": $scope.form_params.model,
"cmd": $scope.form_params.cmd,
"flow": $scope.form_params.flow,
"object_id": $scope.object_id,
"filter": $scope.filter,
"query": $scope.form_params.query
};
* ```
* ### Special response object process
* - If response object is a downloadable pdf file, checking from headers `headers('content-type') ===
* "application/pdf"` download using Blob object.
*
* @param {Object} $scope
* @param {Object} redirectTo
* @returns {*} * @returns {*}
* @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
*/ */
generator.submit = function ($scope, redirectTo) { generator.submit = function ($scope, redirectTo) {
/**
* In case of unformatted date object in any key recursively, it must be converted.
* @param model
*/
var convertDate = function (model) { var convertDate = function (model) {
angular.forEach(model, function (value, key) { angular.forEach(model, function (value, key) {
if (value && value.constructor === Date) { if (value && value.constructor === Date) {
...@@ -1295,11 +1320,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1295,11 +1320,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc controller * @ngdoc controller
* @name ModalCtrl * @name ModalCtrl
* @description controller for listnode, node and linkedmodel modal and save data of it * @description controller for listnode, node and linkedmodel modal and save data of it
* @param {object} items * @param {Object} items
* @param {object} $scope * @param {Object} $scope
* @param {object} $uibModalInstance * @param {Object} $uibModalInstance
* @param {object} $route * @param {Object} $route
* @returns returns value for modal * @returns {Object} returns value for modal
*/ */
.controller('ModalCtrl', function ($scope, $uibModalInstance, Generator, items) { .controller('ModalCtrl', function ($scope, $uibModalInstance, Generator, items) {
angular.forEach(items, function (value, key) { angular.forEach(items, function (value, key) {
...@@ -1339,9 +1364,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1339,9 +1364,9 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc directive * @ngdoc directive
* @name modalForNodes * @name modalForNodes
* @description add modal directive for nodes * @description add modal directive for nodes
* @param {module} $uibModal * @param {Module} $uibModal
* @param {service} Generator * @param {Service} Generator
* @returns openmodal directive * @returns {Object} openmodal directive
*/ */
.directive('modalForNodes', function ($uibModal, Generator) { .directive('modalForNodes', function ($uibModal, Generator) {
return { return {
...@@ -1446,11 +1471,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1446,11 +1471,11 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc directive * @ngdoc directive
* @name addModalForLinkedModel * @name addModalForLinkedModel
* @description add modal directive for linked models * @description add modal directive for linked models
* @param {module} $uibModal * @param {Module} $uibModal
* @param {object} $rootScope * @param {Object} $rootScope
* @param {module} $route * @param {Module} $route
* @param {service} Generator * @param {Service} Generator
* @returns openmodal directive * @returns {Object} openmodal directive
*/ */
.directive('addModalForLinkedModel', function ($uibModal, $rootScope, $route, Generator) { .directive('addModalForLinkedModel', function ($uibModal, $rootScope, $route, Generator) {
return { return {
...@@ -1524,6 +1549,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap']) ...@@ -1524,6 +1549,7 @@ angular.module('ulakbus.formService', ['ui.bootstrap'])
* @ngdoc directive * @ngdoc directive
* @name modalFormLocator * @name modalFormLocator
* @description This directive helps to locate form object in modal. * @description This directive helps to locate form object in modal.
* @returns {Object} form object
*/ */
.directive('modalFormLocator', function () { .directive('modalFormLocator', function () {
return { return {
......
...@@ -333,7 +333,7 @@ ...@@ -333,7 +333,7 @@
</h3> </h3>
<h1 class="title"> <h1 class="title">
redirectTo redirectTo
<a class="name-link signature-attributes" href="source/ulakbus.formService~pathDecider.redirectTo.html#line848">source</a> <a class="name-link signature-attributes" href="source/ulakbus.formService~pathDecider.redirectTo.html#line847">source</a>
</h1> </h1>
<div id="main" class="big-container"> <div id="main" class="big-container">
<!-- source code html --> <!-- source code html -->
...@@ -359,7 +359,7 @@ otherwise redirected path will call api for its data</p> ...@@ -359,7 +359,7 @@ otherwise redirected path will call api for its data</p>
<tr> <tr>
<td class="name" nowrap="">scope</td> <td class="name" nowrap="">scope</td>
<td class="type"><span class="param-type"> <td class="type"><span class="param-type">
object Object
</span></td> </span></td>
<td class="description last"></td> <td class="description last"></td>
</tr><tr> </tr><tr>
......
...@@ -333,7 +333,7 @@ ...@@ -333,7 +333,7 @@
</h3> </h3>
<h1 class="title"> <h1 class="title">
ModalCtrl ModalCtrl
<a class="name-link signature-attributes" href="source/ulakbus.formService.ModalCtrl.html#line1038">source</a> <a class="name-link signature-attributes" href="source/ulakbus.formService.ModalCtrl.html#line1063">source</a>
</h1> </h1>
<div id="main" class="big-container"> <div id="main" class="big-container">
<!-- source code html --> <!-- source code html -->
...@@ -357,25 +357,25 @@ ...@@ -357,25 +357,25 @@
<tr> <tr>
<td class="name" nowrap="">items</td> <td class="name" nowrap="">items</td>
<td class="type"><span class="param-type"> <td class="type"><span class="param-type">
object Object
</span></td> </span></td>
<td class="description last"></td> <td class="description last"></td>
</tr><tr> </tr><tr>
<td class="name" nowrap="">$scope</td> <td class="name" nowrap="">$scope</td>
<td class="type"><span class="param-type"> <td class="type"><span class="param-type">
object Object
</span></td> </span></td>
<td class="description last"></td> <td class="description last"></td>
</tr><tr> </tr><tr>
<td class="name" nowrap="">$uibModalInstance</td> <td class="name" nowrap="">$uibModalInstance</td>
<td class="type"><span class="param-type"> <td class="type"><span class="param-type">
object Object
</span></td> </span></td>
<td class="description last"></td> <td class="description last"></td>
</tr><tr> </tr><tr>
<td class="name" nowrap="">$route</td> <td class="name" nowrap="">$route</td>
<td class="type"><span class="param-type"> <td class="type"><span class="param-type">
object Object
</span></td> </span></td>
<td class="description last"></td> <td class="description last"></td>
</tr> </tr>
......
...@@ -333,7 +333,7 @@ ...@@ -333,7 +333,7 @@
</h3> </h3>
<h1 class="title"> <h1 class="title">
addModalForLinkedModel addModalForLinkedModel
<a class="name-link signature-attributes" href="source/ulakbus.formService.addModalForLinkedModel.html#line1211">source</a> <a class="name-link signature-attributes" href="source/ulakbus.formService.addModalForLinkedModel.html#line1236">source</a>
<a class="name-link signature-attributes" href="templates/shared_templates_filefield.html">template</a> <a class="name-link signature-attributes" href="templates/shared_templates_filefield.html">template</a>
</h1> </h1>
<div id="main" class="big-container"> <div id="main" class="big-container">
...@@ -358,25 +358,25 @@ ...@@ -358,25 +358,25 @@
<tr> <tr>
<td class="name" nowrap="">$uibModal</td> <td class="name" nowrap="">$uibModal</td>
<td class="type"><span class="param-type"> <td class="type"><span class="param-type">
module Module
</span></td> </span></td>
<td class="description last"></td> <td class="description last"></td>
</tr><tr> </tr><tr>
<td class="name" nowrap="">$rootScope</td> <td class="name" nowrap="">$rootScope</td>
<td class="type"><span class="param-type"> <td class="type"><span class="param-type">
object Object
</span></td> </span></td>
<td class="description last"></td> <td class="description last"></td>
</tr><tr> </tr><tr>
<td class="name" nowrap="">$route</td> <td class="name" nowrap="">$route</td>
<td class="type"><span class="param-type"> <td class="type"><span class="param-type">
module Module
</span></td> </span></td>
<td class="description last"></td> <td class="description last"></td>
</tr><tr> </tr><tr>
<td class="name" nowrap="">Generator</td> <td class="name" nowrap="">Generator</td>
<td class="type"><span class="param-type"> <td class="type"><span class="param-type">
service Service
</span></td> </span></td>
<td class="description last"></td> <td class="description last"></td>
</tr> </tr>
......
...@@ -357,7 +357,7 @@ ...@@ -357,7 +357,7 @@
<tr> <tr>
<td class="name" nowrap="">formObject</td> <td class="name" nowrap="">formObject</td>
<td class="type"><span class="param-type"> <td class="type"><span class="param-type">
object Object
</span></td> </span></td>
<td class="description last"></td> <td class="description last"></td>
</tr> </tr>
......
...@@ -333,7 +333,7 @@ ...@@ -333,7 +333,7 @@
</h3> </h3>
<h1 class="title"> <h1 class="title">
dispatchClientCmd dispatchClientCmd
<a class="name-link signature-attributes" href="source/ulakbus.formService.dispatchClientCmd.html#line878">source</a> <a class="name-link signature-attributes" href="source/ulakbus.formService.dispatchClientCmd.html#line877">source</a>
</h1> </h1>
<div id="main" class="big-container"> <div id="main" class="big-container">
<!-- source code html --> <!-- source code html -->
......
...@@ -360,7 +360,7 @@ will be open new page with response data</p> ...@@ -360,7 +360,7 @@ will be open new page with response data</p>
<tr> <tr>
<td class="name" nowrap="">$scope</td> <td class="name" nowrap="">$scope</td>
<td class="type"><span class="param-type"> <td class="type"><span class="param-type">
object Object
</span></td> </span></td>
<td class="description last"></td> <td class="description last"></td>
</tr><tr> </tr><tr>
...@@ -372,7 +372,7 @@ will be open new page with response data</p> ...@@ -372,7 +372,7 @@ will be open new page with response data</p>
</tr><tr> </tr><tr>
<td class="name" nowrap="">todo</td> <td class="name" nowrap="">todo</td>
<td class="type"><span class="param-type"> <td class="type"><span class="param-type">
object Object
</span></td> </span></td>
<td class="description last"></td> <td class="description last"></td>
</tr><tr> </tr><tr>
......
...@@ -333,7 +333,7 @@ ...@@ -333,7 +333,7 @@
</h3> </h3>
<h1 class="title"> <h1 class="title">
get_diff get_diff
<a class="name-link signature-attributes" href="source/ulakbus.formService.get_diff.html#line901">source</a> <a class="name-link signature-attributes" href="source/ulakbus.formService.get_diff.html#line900">source</a>
</h1> </h1>
<div id="main" class="big-container"> <div id="main" class="big-container">
<!-- source code html --> <!-- source code html -->
...@@ -357,13 +357,13 @@ ...@@ -357,13 +357,13 @@
<tr> <tr>
<td class="name" nowrap="">obj1</td> <td class="name" nowrap="">obj1</td>
<td class="type"><span class="param-type"> <td class="type"><span class="param-type">
object Object
</span></td> </span></td>
<td class="description last"></td> <td class="description last"></td>
</tr><tr> </tr><tr>
<td class="name" nowrap="">obj2</td> <td class="name" nowrap="">obj2</td>
<td class="type"><span class="param-type"> <td class="type"><span class="param-type">
object Object
</span></td> </span></td>
<td class="description last"></td> <td class="description last"></td>
</tr> </tr>
......
...@@ -333,7 +333,7 @@ ...@@ -333,7 +333,7 @@
</h3> </h3>
<h1 class="title"> <h1 class="title">
get_diff_array get_diff_array
<a class="name-link signature-attributes" href="source/ulakbus.formService.get_diff_array.html#line925">source</a> <a class="name-link signature-attributes" href="source/ulakbus.formService.get_diff_array.html#line924">source</a>
</h1> </h1>
<div id="main" class="big-container"> <div id="main" class="big-container">
<!-- source code html --> <!-- source code html -->
...@@ -357,19 +357,19 @@ ...@@ -357,19 +357,19 @@
<tr> <tr>
<td class="name" nowrap="">array1</td> <td class="name" nowrap="">array1</td>
<td class="type"><span class="param-type"> <td class="type"><span class="param-type">
object Array
</span></td> </span></td>
<td class="description last"></td> <td class="description last"></td>
</tr><tr> </tr><tr>
<td class="name" nowrap="">array2</td> <td class="name" nowrap="">array2</td>
<td class="type"><span class="param-type"> <td class="type"><span class="param-type">
object Array
</span></td> </span></td>
<td class="description last"></td> <td class="description last"></td>
</tr><tr> </tr><tr>
<td class="name" nowrap="">way</td> <td class="name" nowrap="">way</td>
<td class="type"><span class="param-type"> <td class="type"><span class="param-type">
number Number
</span></td> </span></td>
<td class="description last"></td> <td class="description last"></td>
</tr> </tr>
......
...@@ -357,7 +357,7 @@ ...@@ -357,7 +357,7 @@
<tr> <tr>
<td class="name" nowrap="">scope</td> <td class="name" nowrap="">scope</td>
<td class="type"><span class="param-type"> <td class="type"><span class="param-type">
object Object
</span></td> </span></td>
<td class="description last"></td> <td class="description last"></td>
</tr> </tr>
......
...@@ -333,7 +333,7 @@ ...@@ -333,7 +333,7 @@
</h3> </h3>
<h1 class="title"> <h1 class="title">
item_from_array item_from_array
<a class="name-link signature-attributes" href="source/ulakbus.formService.item_from_array.html#line950">source</a> <a class="name-link signature-attributes" href="source/ulakbus.formService.item_from_array.html#line949">source</a>
</h1> </h1>
<div id="main" class="big-container"> <div id="main" class="big-container">
<!-- source code html --> <!-- source code html -->
...@@ -357,13 +357,13 @@ ...@@ -357,13 +357,13 @@
<tr> <tr>
<td class="name" nowrap="">item</td> <td class="name" nowrap="">item</td>
<td class="type"><span class="param-type"> <td class="type"><span class="param-type">
object Object
</span></td> </span></td>
<td class="description last"></td> <td class="description last"></td>
</tr><tr> </tr><tr>
<td class="name" nowrap="">array</td> <td class="name" nowrap="">array</td>
<td class="type"><span class="param-type"> <td class="type"><span class="param-type">
array Array
</span></td> </span></td>
<td class="description last"></td> <td class="description last"></td>
</tr> </tr>
......
...@@ -333,7 +333,7 @@ ...@@ -333,7 +333,7 @@
</h3> </h3>
<h1 class="title"> <h1 class="title">
modalForNodes modalForNodes
<a class="name-link signature-attributes" href="source/ulakbus.formService.modalForNodes.html#line1090">source</a> <a class="name-link signature-attributes" href="source/ulakbus.formService.modalForNodes.html#line1115">source</a>
<a class="name-link signature-attributes" href="templates/shared_templates_filefield.html">template</a> <a class="name-link signature-attributes" href="templates/shared_templates_filefield.html">template</a>
</h1> </h1>
<div id="main" class="big-container"> <div id="main" class="big-container">
...@@ -358,13 +358,13 @@ ...@@ -358,13 +358,13 @@
<tr> <tr>
<td class="name" nowrap="">$uibModal</td> <td class="name" nowrap="">$uibModal</td>
<td class="type"><span class="param-type"> <td class="type"><span class="param-type">
module Module
</span></td> </span></td>
<td class="description last"></td> <td class="description last"></td>
</tr><tr> </tr><tr>
<td class="name" nowrap="">Generator</td> <td class="name" nowrap="">Generator</td>
<td class="type"><span class="param-type"> <td class="type"><span class="param-type">
service Service
</span></td> </span></td>
<td class="description last"></td> <td class="description last"></td>
</tr> </tr>
......
...@@ -333,7 +333,7 @@ ...@@ -333,7 +333,7 @@
</h3> </h3>
<h1 class="title"> <h1 class="title">
modalFormLocator modalFormLocator
<a class="name-link signature-attributes" href="source/ulakbus.formService.modalFormLocator.html#line1291">source</a> <a class="name-link signature-attributes" href="source/ulakbus.formService.modalFormLocator.html#line1316">source</a>
<a class="name-link signature-attributes" href="templates/shared_templates_filefield.html">template</a> <a class="name-link signature-attributes" href="templates/shared_templates_filefield.html">template</a>
</h1> </h1>
<div id="main" class="big-container"> <div id="main" class="big-container">
......
...@@ -363,13 +363,13 @@ ...@@ -363,13 +363,13 @@
</tr><tr> </tr><tr>
<td class="name" nowrap="">$scope</td> <td class="name" nowrap="">$scope</td>
<td class="type"><span class="param-type"> <td class="type"><span class="param-type">
object Object
</span></td> </span></td>
<td class="description last"></td> <td class="description last"></td>
</tr><tr> </tr><tr>
<td class="name" nowrap="">data</td> <td class="name" nowrap="">data</td>
<td class="type"><span class="param-type"> <td class="type"><span class="param-type">
object Object
</span></td> </span></td>
<td class="description last"></td> <td class="description last"></td>
</tr> </tr>
......
...@@ -362,7 +362,7 @@ ui.bootstraps modal directive.</p> ...@@ -362,7 +362,7 @@ ui.bootstraps modal directive.</p>
<tr> <tr>
<td class="name" nowrap="">scope</td> <td class="name" nowrap="">scope</td>
<td class="type"><span class="param-type"> <td class="type"><span class="param-type">
object Object
</span></td> </span></td>
<td class="description last"><p>given scope on which form items prepared</p></td> <td class="description last"><p>given scope on which form items prepared</p></td>
</tr> </tr>
......
...@@ -333,7 +333,7 @@ ...@@ -333,7 +333,7 @@
</h3> </h3>
<h1 class="title"> <h1 class="title">
submit submit
<a class="name-link signature-attributes" href="source/ulakbus.formService.submit.html#line969">source</a> <a class="name-link signature-attributes" href="source/ulakbus.formService.submit.html#line968">source</a>
</h1> </h1>
<div id="main" class="big-container"> <div id="main" class="big-container">
<!-- source code html --> <!-- source code html -->
...@@ -344,8 +344,27 @@ ...@@ -344,8 +344,27 @@
<dt></dt> <dt></dt>
<dd> <dd>
<div class="description"> <div class="description">
<p>Submit function is generic function for submiting forms. <p>Submit function is generic function for submiting forms.</p>
redirectTo param is used for redirect if return value will be evaluated in a new page.</p> <ul>
<li>redirectTo param is used for redirect if return value will be evaluated in a new page.</li>
<li>In case of unformatted date object in any key recursively, it must be converted by convertDate function.</li>
<li>ListNode and Node objects get seperated from model in
{@link prepareFormItems module:ulakbus.formService.function:prepareFormItems} They must be concat to model
key of scope first.</li>
<li>Backend API waits form as model value. So <code>data.form</code> key must be set to <code>$scope.model</code></li>
<li>Other parameters we pass to backend API are shown in the example below<pre class="prettyprint source"><code>var data = {
&quot;form&quot;: $scope.model,
&quot;token&quot;: $scope.token,
&quot;model&quot;: $scope.form_params.model,
&quot;cmd&quot;: $scope.form_params.cmd,
&quot;flow&quot;: $scope.form_params.flow,
&quot;object_id&quot;: $scope.object_id,
&quot;filter&quot;: $scope.filter,
&quot;query&quot;: $scope.form_params.query
};</code></pre><h3>Special response object process</h3></li>
<li>If response object is a downloadable pdf file, checking from headers <code>headers('content-type') ===
&quot;application/pdf&quot;</code> download using Blob object.</li>
</ul>
</div> </div>
<div class="details"></div> <div class="details"></div>
<div> <div>
...@@ -358,13 +377,13 @@ redirectTo param is used for redirect if return value will be evaluated in a new ...@@ -358,13 +377,13 @@ redirectTo param is used for redirect if return value will be evaluated in a new
<tr> <tr>
<td class="name" nowrap="">$scope</td> <td class="name" nowrap="">$scope</td>
<td class="type"><span class="param-type"> <td class="type"><span class="param-type">
object Object
</span></td> </span></td>
<td class="description last"></td> <td class="description last"></td>
</tr><tr> </tr><tr>
<td class="name" nowrap="">redirectTo</td> <td class="name" nowrap="">redirectTo</td>
<td class="type"><span class="param-type"> <td class="type"><span class="param-type">
object Object
</span></td> </span></td>
<td class="description last"></td> <td class="description last"></td>
</tr> </tr>
......
ULAKBUS API-UI Etkileşimi ULAKBUS API-UI Etkileşimi
========================= =========================
.. figure:: http://ulakbus.net/img/brand-logo.png .. figure:: http://ulakbus.net/img/brand-logo.png :alt: Ulakbus_logo
:alt: Ulakbus logo
Ulakbus logo Bu belge **Ulakbus API ve UI** bileşenlerinin etkileşimini göstermek
için hazırlanmıştır. API kullanılarak hazırlanan view, model ve jenerik fonksiyonlarda hangi tip verinin kullanıcı
arayüzünde nasıl gösterildiğini bu belgede bulabilirsiniz.
Bu belge **Ulakbus** API ve UI bileşenlerinin etkileşimini göstermek
için hazırlanmıştır.
Ulakbüs UI Sayfa Tipleri Ulakbüs UI Sayfa Tipleri
------------------------ ------------------------
...@@ -18,10 +17,9 @@ Ulakbüs kullanıcı arayüzünde sunulan temel içerik türleri şunlardır; ...@@ -18,10 +17,9 @@ Ulakbüs kullanıcı arayüzünde sunulan temel içerik türleri şunlardır;
- Liste sayfası - Liste sayfası
- Detay sayfası - Detay sayfası
Bu içerik türleri API'ın iş akışlarında sunduğu temel içerik türleridir. Bu içerik türleri API'ın iş akışlarında sunduğu temel içerik türleridir. Bu içerik türlerinin kullanıcı arayüzünde
Bu içerik türlerinin kullanıcı arayüzünde doğru biçimde yorumlanması doğru biçimde yorumlanması için ``response`` nesnesinde gönderilecek anahtar değerler belirlenmiştir. Bu anahtarlar
için ``response`` nesnesinde gönderilecek anahtar değerler aşağıdaki tablodaki gibidir;
belirlenmiştir. Bu anahtarlar aşağıdaki tablodaki gibidir;
+---------------+---------------+ +---------------+---------------+
| İçerik türü | Anahtar | | İçerik türü | Anahtar |
...@@ -37,22 +35,26 @@ belirlenmiştir. Bu anahtarlar aşağıdaki tablodaki gibidir; ...@@ -37,22 +35,26 @@ belirlenmiştir. Bu anahtarlar aşağıdaki tablodaki gibidir;
yukarıdan aşağıya doğru detay - form - liste olacak şekilde aynı yukarıdan aşağıya doğru detay - form - liste olacak şekilde aynı
sayfada yorumlanırlar. sayfada yorumlanırlar.
Her sayfaya ait alt özellikler ilgili başlık altında anlatılacaktır.
Form sayfası Form sayfası
~~~~~~~~~~~~ ~~~~~~~~~~~~
Örnek bir forms nesnesi aşağıdaki gibidir: Ulakbus UI form işlemlerini gerçekleştirmek için angular-schemaform_ Örnek bir ``forms`` nesnesi aşağıdaki gibidir:
.. _angular-schemaform:
.. code:: json .. code:: json
{ {
forms: { "forms": {
form: [], "form": [],
schema: { "schema": {
properties: {}, "properties": {},
type: object, "type": Object,
required: [] "required": []
}, },
model: {} "model": {}
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment