Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
U
ulakbus-ui
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ulakbus
ulakbus-ui
Commits
d136b928
Commit
d136b928
authored
Nov 03, 2015
by
Evren Kutar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
crud views edit according to new structure of api
parent
012529d5
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
108 additions
and
87 deletions
+108
-87
app_routes.js
app/app_routes.js
+11
-15
crud_controller.js
app/components/crud/crud_controller.js
+22
-12
add.html
app/components/crud/templates/add.html
+1
-1
list.html
app/components/crud/templates/list.html
+9
-4
directives.js
app/shared/directives.js
+0
-1
sidebar.html
app/shared/templates/directives/sidebar.html
+4
-1
form_service.js
app/zetalib/forms/form_service.js
+61
-53
No files found.
app/app_routes.js
View file @
d136b928
...
@@ -10,29 +10,25 @@ app.config(['$routeProvider', function ($routeProvider, $route) {
...
@@ -10,29 +10,25 @@ app.config(['$routeProvider', function ($routeProvider, $route) {
templateUrl
:
'components/dashboard/dashboard.html'
,
templateUrl
:
'components/dashboard/dashboard.html'
,
controller
:
'DashCtrl'
controller
:
'DashCtrl'
})
})
.
when
(
'/crud/
:model
/:id'
,
{
.
when
(
'/crud/
add/:model/:param
/:id'
,
{
templateUrl
:
'components/crud/templates/add.html'
,
templateUrl
:
'components/crud/templates/add.html'
,
controller
:
'CRUDAddEditCtrl'
,
controller
:
'CRUDAddEditCtrl'
reloadOnSearch
:
true
})
})
.
when
(
'/crud/edit/:model/:param/:id/:key'
,
{
//.when('/crud/:model/edit/:id', {
templateUrl
:
'components/crud/templates/add.html'
,
// templateUrl: 'components/crud/templates/add.html',
controller
:
'CRUDAddEditCtrl'
// controller: 'CRUDAddEditCtrl'
//})
.
when
(
'/crud/:model'
,
{
templateUrl
:
'components/crud/templates/list.html'
,
controller
:
'CRUDListCtrl'
,
reloadOnSearch
:
true
})
})
.
when
(
'/crud/:model/:param/:id'
,
{
.
when
(
'/crud/:model/:param/:id'
,
{
templateUrl
:
'components/crud/templates/list.html'
,
controller
:
'CRUDListCtrl'
})
.
when
(
'/crud/detail/:model/:param/:id/:key'
,
{
templateUrl
:
'components/crud/templates/show.html'
,
templateUrl
:
'components/crud/templates/show.html'
,
controller
:
'CRUDShowCtrl'
,
controller
:
'CRUDShowCtrl'
reloadOnSearch
:
true
})
})
.
when
(
'/:model/'
,
{
.
when
(
'/:model/'
,
{
templateUrl
:
'components/wf/templates/add.html'
,
templateUrl
:
'components/wf/templates/add.html'
,
controller
:
'WFAddEditCtrl'
,
controller
:
'WFAddEditCtrl'
reloadOnSearch
:
true
})
})
.
otherwise
({
redirectTo
:
'/dashboard'
});
.
otherwise
({
redirectTo
:
'/dashboard'
});
}])
}])
...
...
app/components/crud/crud_controller.js
View file @
d136b928
...
@@ -17,10 +17,10 @@ var crud = angular.module('ulakbus.crud', ['ui.bootstrap', 'schemaForm', 'formSe
...
@@ -17,10 +17,10 @@ var crud = angular.module('ulakbus.crud', ['ui.bootstrap', 'schemaForm', 'formSe
*/
*/
crud
.
controller
(
'CRUDAddEditCtrl'
,
function
(
$scope
,
$rootScope
,
$location
,
$http
,
$log
,
$modal
,
$timeout
,
Generator
,
$routeParams
)
{
crud
.
controller
(
'CRUDAddEditCtrl'
,
function
(
$scope
,
$rootScope
,
$location
,
$http
,
$log
,
$modal
,
$timeout
,
Generator
,
$routeParams
)
{
$scope
.
url
=
'crud'
;
$scope
.
url
=
'crud
/
'
;
$scope
.
form_params
=
{
'model'
:
$routeParams
.
model
};
$scope
.
form_params
=
{
'model'
:
$routeParams
.
model
,
param
:
$routeParams
.
param
,
id
:
$routeParams
.
id
};
if
(
$routeParams
.
id
)
{
if
(
$routeParams
.
key
)
{
$scope
.
form_params
[
'
object_id'
]
=
$routeParams
.
id
;
$scope
.
form_params
[
'
key'
]
=
$routeParams
.
key
;
$scope
.
form_params
[
'cmd'
]
=
'edit'
;
$scope
.
form_params
[
'cmd'
]
=
'edit'
;
}
}
else
{
else
{
...
@@ -37,10 +37,10 @@ crud.controller('CRUDAddEditCtrl', function ($scope, $rootScope, $location, $htt
...
@@ -37,10 +37,10 @@ crud.controller('CRUDAddEditCtrl', function ($scope, $rootScope, $location, $htt
if
(
form
.
$valid
)
{
if
(
form
.
$valid
)
{
Generator
.
submit
(
$scope
)
Generator
.
submit
(
$scope
)
.
success
(
function
(
data
)
{
.
success
(
function
(
data
)
{
$location
.
path
(
'/crud/'
+
$scope
.
form_params
.
model
).
search
(
data
);
$location
.
path
(
'/crud/'
+
$scope
.
form_params
.
model
).
search
(
data
);
})
})
.
error
(
function
(
data
)
{
.
error
(
function
(
data
)
{
$scope
.
message
=
data
.
title
;
$scope
.
message
=
data
.
title
;
});
});
}
}
...
@@ -56,7 +56,7 @@ crud.controller('CRUDListCtrl', function ($scope, $rootScope, Generator, $routeP
...
@@ -56,7 +56,7 @@ crud.controller('CRUDListCtrl', function ($scope, $rootScope, Generator, $routeP
$scope
.
url
=
'crud/'
;
$scope
.
url
=
'crud/'
;
$scope
.
form_params
=
$routeParams
;
$scope
.
form_params
=
$routeParams
;
if
(
$routeParams
.
nobjects
){
if
(
$routeParams
.
nobjects
)
{
$scope
.
nobjects
=
$routeParams
.
nobjects
;
$scope
.
nobjects
=
$routeParams
.
nobjects
;
$scope
.
model
=
$routeParams
.
model
;
$scope
.
model
=
$routeParams
.
model
;
}
else
{
}
else
{
...
@@ -72,16 +72,26 @@ crud.controller('CRUDListCtrl', function ($scope, $rootScope, Generator, $routeP
...
@@ -72,16 +72,26 @@ crud.controller('CRUDListCtrl', function ($scope, $rootScope, Generator, $routeP
/**
/**
* CRUD Show Controller
* CRUD Show Controller
*/
*/
crud
.
controller
(
'CRUDShowCtrl'
,
function
(
$scope
,
$rootScope
,
Generator
,
$routeParams
)
{
crud
.
controller
(
'CRUDShowCtrl'
,
function
(
$scope
,
$rootScope
,
$location
,
Generator
,
$routeParams
)
{
$scope
.
url
=
'crud/'
;
$scope
.
url
=
'crud/'
;
$scope
.
form_params
=
{
"object_id"
:
$routeParams
.
id
,
"cmd"
:
"show"
,
"model"
:
$routeParams
.
model
};
$scope
.
form_params
=
{
// call generator's get_single_itemfunc
"object_id"
:
$routeParams
.
id
,
"cmd"
:
"show"
,
param
:
$routeParams
.
param
,
"model"
:
$routeParams
.
model
};
// call generator's get_single_item func
Generator
.
get_single_item
(
$scope
).
then
(
function
(
res
)
{
Generator
.
get_single_item
(
$scope
).
then
(
function
(
res
)
{
console
.
log
(
res
.
data
.
nobjects
);
// if no data to show redirect to add/edit view
if
(
res
.
data
.
nobjects
[
0
]
===
"-1"
)
{
$location
.
path
(
'crud/'
+
$scope
.
form_params
.
model
+
'/'
+
$scope
.
form_params
.
param
+
'/'
+
$scope
.
form_params
.
object_id
+
'/edit'
);
}
$scope
.
listobjects
=
{};
$scope
.
listobjects
=
{};
$scope
.
object
=
res
.
data
.
object
;
$scope
.
object
=
res
.
data
.
object
;
angular
.
forEach
(
$scope
.
object
,
function
(
value
,
key
)
{
angular
.
forEach
(
$scope
.
object
,
function
(
value
,
key
)
{
if
(
typeof
value
==
'object'
)
{
if
(
typeof
value
==
'object'
)
{
$scope
.
listobjects
[
key
]
=
value
;
$scope
.
listobjects
[
key
]
=
value
;
delete
$scope
.
object
[
key
];
delete
$scope
.
object
[
key
];
}
}
...
...
app/components/crud/templates/add.html
View file @
d136b928
<h1>
{{ schema.title }}
</h1>
<h1>
{{ schema.title }}
</h1>
<form
id=
"formgenerated"
name=
"formgenerated"
sf-schema=
"schema"
sf-form=
"form"
sf-model=
"model"
></form>
<form
id=
"formgenerated"
name=
"formgenerated"
sf-schema=
"schema"
sf-form=
"form"
sf-model=
"model"
ng-submit=
"onSubmit(formgenerated)"
></form>
<div
ng-repeat=
"node in Node"
>
<div
ng-repeat=
"node in Node"
>
<h3>
{{ node.title }}
<h3>
{{ node.title }}
...
...
app/components/crud/templates/list.html
View file @
d136b928
<div
class=
"starter-template"
>
<div
class=
"starter-template"
>
<h1>
{{model}}
<a
href=
"#/crud/{{model}}/add"
><button
type=
"button"
class=
"btn btn-primary"
>
Ekle
</button></a></h1>
<h1>
{{model}}
<a
href=
"#/crud/add/{{model}}/{{form_params.param}}/{{form_params.id}}"
>
<button
type=
"button"
class=
"btn btn-primary"
>
Ekle
</button>
</a>
</h1>
<div
class=
"row"
ng-if=
"!nobjects[1]"
>
<div
class=
"row"
ng-if=
"!nobjects[1]"
>
<div
class=
"col-md-12"
>
<div
class=
"col-md-12"
>
<p
class=
"no-content"
>
Listelenecek içerik yok.
</p>
<p
class=
"no-content"
>
Listelenecek içerik yok.
</p>
...
@@ -29,15 +33,16 @@
...
@@ -29,15 +33,16 @@
</td>
</td>
<th
scope=
"row"
style=
"text-align:center"
>
{{$index}}
</th>
<th
scope=
"row"
style=
"text-align:center"
>
{{$index}}
</th>
<td
ng-repeat=
"k in object track by $index"
ng-if=
"nobjects[0]=='-1' && $index>0"
>
<td
ng-repeat=
"k in object track by $index"
ng-if=
"nobjects[0]=='-1' && $index>0"
>
<a
ng-href=
"#/crud/
{{model}}/
{{object[0]}}"
>
{{object[1]}}
</a>
<a
ng-href=
"#/crud/
edit/{{model}}/{{form_params.param}}/{{form_params.id}}
{{object[0]}}"
>
{{object[1]}}
</a>
</td>
</td>
<td
ng-repeat=
"(key,value) in object track by $index"
ng-if=
"nobjects[0]!='-1' && $index>0"
>
<td
ng-repeat=
"(key,value) in object track by $index"
ng-if=
"nobjects[0]!='-1' && $index>0"
>
<a
ng-href=
"#/crud/
{{model}}/
{{object[0]}}"
ng-if=
"$index==1"
>
{{object[key]}}
</a>
<a
ng-href=
"#/crud/
edit/{{model}}/{{form_params.param}}/{{form_params.id}}
{{object[0]}}"
ng-if=
"$index==1"
>
{{object[key]}}
</a>
<span
ng-if=
"$index!=1"
>
{{object[key]}}
</span>
<span
ng-if=
"$index!=1"
>
{{object[key]}}
</span>
</td>
</td>
<td>
<td>
<a
ng-href=
"#/crud/{{model}}/edit/{{object[0]}}"
>
Edit
</a><br>
<a
ng-href=
"#/crud/edit/{{model}}/{{form_params.param}}/{{form_params.id}}{{object[0]}}"
>
Edit
</a>
<br>
</td>
</td>
</tr>
</tr>
</tbody>
</tbody>
...
...
app/shared/directives.js
View file @
d136b928
...
@@ -43,7 +43,6 @@ app.directive('headerNotification', function ($http, $rootScope, $interval, REST
...
@@ -43,7 +43,6 @@ app.directive('headerNotification', function ($http, $rootScope, $interval, REST
$scope
.
notifications
[
value
.
type
].
push
(
value
);
$scope
.
notifications
[
value
.
type
].
push
(
value
);
});
});
$rootScope
.
$broadcast
(
"notifications"
,
$scope
.
notifications
);
$rootScope
.
$broadcast
(
"notifications"
,
$scope
.
notifications
);
console
.
log
(
$scope
.
notifications
);
});
});
},
5000
);
},
5000
);
}
}
...
...
app/shared/templates/directives/sidebar.html
View file @
d136b928
...
@@ -24,7 +24,10 @@
...
@@ -24,7 +24,10 @@
</a>
</a>
<ul
class=
"nav nav-second-level"
ng-class=
"{hidden: $root.collapsed}"
>
<ul
class=
"nav nav-second-level"
ng-class=
"{hidden: $root.collapsed}"
>
<li
ng-repeat=
"v in item"
>
<li
ng-repeat=
"v in item"
>
<a
ng-href=
"#{{v.url}}{{$root.selectedUser.key}}"
<a
ng-if=
"key == 'other'"
ng-href=
"#{{v.url}}/{{$root.selectedUser.key}}"
ng-click=
"breadcrumb([key, v.text], $event)"
>
{{v.text}}
</a>
<a
ng-if=
"key == 'ogrenci' || key == 'personel'"
ng-href=
"#{{v.url}}{{v.param}}/{{$root.selectedUser.key}}"
ng-click=
"breadcrumb([key, v.text], $event)"
>
{{v.text}}
</a>
ng-click=
"breadcrumb([key, v.text], $event)"
>
{{v.text}}
</a>
</li>
</li>
</ul>
</ul>
...
...
app/zetalib/forms/form_service.js
View file @
d136b928
...
@@ -9,16 +9,8 @@ var form_generator = angular.module('formService', ['general']);
...
@@ -9,16 +9,8 @@ var form_generator = angular.module('formService', ['general']);
form_generator
.
factory
(
'Generator'
,
function
(
$http
,
$q
,
$timeout
,
RESTURL
,
FormDiff
,
$rootScope
)
{
form_generator
.
factory
(
'Generator'
,
function
(
$http
,
$q
,
$timeout
,
RESTURL
,
FormDiff
,
$rootScope
)
{
var
generator
=
{};
var
generator
=
{};
generator
.
makePostUrl
=
function
(
scope
)
{
generator
.
makeUrl
=
function
(
scope
)
{
return
RESTURL
.
url
+
scope
.
url
;
var
getparams
=
"?"
+
scope
.
form_params
.
param
+
"="
+
scope
.
form_params
.
id
;
};
generator
.
makeGetUrl
=
function
(
scope
)
{
if
(
scope
.
form_params
.
cmd
===
"list"
)
{
var
getparams
=
""
;
}
if
(
scope
.
form_params
.
cmd
===
"show"
)
{
var
getparams
=
"?"
+
scope
.
form_params
.
param
+
"="
+
scope
.
form_params
.
object_id
;
}
return
RESTURL
.
url
+
scope
.
url
+
scope
.
form_params
.
model
+
getparams
;
return
RESTURL
.
url
+
scope
.
url
+
scope
.
form_params
.
model
+
getparams
;
};
};
generator
.
generate
=
function
(
scope
,
data
)
{
generator
.
generate
=
function
(
scope
,
data
)
{
...
@@ -59,52 +51,60 @@ form_generator.factory('Generator', function ($http, $q, $timeout, RESTURL, Form
...
@@ -59,52 +51,60 @@ form_generator.factory('Generator', function ($http, $q, $timeout, RESTURL, Form
/**
/**
* prepareforms checks input types and convert if necessary
* prepareforms checks input types and convert if necessary
*/
*/
angular
.
forEach
(
scope
.
schema
.
properties
,
function
(
k
,
v
)
{
angular
.
forEach
(
scope
.
schema
.
properties
,
function
(
v
,
k
)
{
// check if type is date and if type date found change it to string
// check if type is date and if type date found change it to string
if
(
k
.
type
===
'submit'
||
k
.
type
===
'button'
)
{
if
(
v
.
type
===
'submit'
||
v
.
type
===
'button'
)
{
//k.type = 'button';
//k.type = 'button';
angular
.
forEach
(
scope
.
form
,
function
(
value
,
key
)
{
angular
.
forEach
(
scope
.
form
,
function
(
value
,
key
)
{
if
(
value
===
v
)
{
if
(
value
===
v
)
{
k
.
type
=
'button'
;
v
.
type
=
'button'
;
scope
.
form
[
key
]
=
{
type
:
k
.
type
,
title
:
k
.
title
,
onClick
:
function
(){
scope
.
model
[
v
]
=
1
;
generator
.
submit
(
scope
);}};
scope
.
form
[
key
]
=
{
type
:
v
.
type
,
title
:
v
.
title
,
onClick
:
function
(){
scope
.
model
[
v
]
=
1
;
generator
.
submit
(
scope
);}};
}
}
});
});
}
}
if
(
k
.
type
===
'date'
)
{
if
(
v
.
type
===
'date'
)
{
k
.
type
=
'string'
;
v
.
type
=
'string'
;
scope
.
model
[
v
]
=
generator
.
dateformatter
(
scope
.
model
[
v
]);
scope
.
model
[
k
]
=
generator
.
dateformatter
(
scope
.
model
[
k
]);
$timeout
(
function
()
{
$timeout
(
function
()
{
jQuery
(
'#'
+
v
).
datepicker
({
jQuery
(
'#'
+
k
).
datepicker
({
changeMonth
:
true
,
changeMonth
:
true
,
changeYear
:
true
,
changeYear
:
true
,
dateFormat
:
"dd.mm.yy"
,
dateFormat
:
"dd.mm.yy"
,
onSelect
:
function
(
date
)
{
onSelect
:
function
(
date
)
{
scope
.
model
[
v
]
=
date
;
scope
.
model
[
k
]
=
date
;
}
}
});
});
});
});
}
}
if
(
k
.
type
===
'int'
||
k
.
type
===
'float'
)
{
if
(
v
.
type
===
'int'
||
v
.
type
===
'float'
)
{
k
.
type
=
'number'
;
v
.
type
=
'number'
;
}
if
(
v
.
type
===
'text_general'
)
{
v
.
type
=
'string'
;
v
[
"x-schema-form"
]
=
{
"type"
:
"textarea"
,
//"placeholder": ""
}
}
}
// if type is model use foreignKey.html template to show them
// if type is model use foreignKey.html template to show them
if
(
k
.
type
===
'model'
)
{
if
(
v
.
type
===
'model'
)
{
var
formitem
=
scope
.
form
[
scope
.
form
.
indexOf
(
v
)];
var
formitem
=
scope
.
form
[
scope
.
form
.
indexOf
(
k
)];
var
modelscope
=
{
"url"
:
scope
.
url
,
"form_params"
:
{
model
:
k
.
model_name
}};
var
modelscope
=
{
"url"
:
scope
.
url
,
"form_params"
:
{
model
:
v
.
model_name
,
param
:
scope
.
form_params
.
param
,
id
:
scope
.
form_params
.
id
}};
formitem
=
{
formitem
=
{
type
:
"template"
,
type
:
"template"
,
templateUrl
:
"shared/templates/foreignKey.html"
,
templateUrl
:
"shared/templates/foreignKey.html"
,
title
:
k
.
title
,
title
:
v
.
title
,
name
:
k
.
model_name
,
name
:
v
.
model_name
,
model_name
:
k
.
model_name
,
model_name
:
v
.
model_name
,
titleMap
:
generator
.
get_list
(
modelscope
).
then
(
function
(
res
)
{
titleMap
:
generator
.
get_list
(
modelscope
).
then
(
function
(
res
)
{
formitem
.
titleMap
=
[];
formitem
.
titleMap
=
[];
angular
.
forEach
(
res
.
data
.
nobjects
,
function
(
item
)
{
angular
.
forEach
(
res
.
data
.
nobjects
,
function
(
item
)
{
...
@@ -117,17 +117,17 @@ form_generator.factory('Generator', function ($http, $q, $timeout, RESTURL, Form
...
@@ -117,17 +117,17 @@ form_generator.factory('Generator', function ($http, $q, $timeout, RESTURL, Form
});
});
}),
}),
onSelect
:
function
(
item
)
{
onSelect
:
function
(
item
)
{
scope
.
model
[
v
]
=
item
.
value
;
scope
.
model
[
k
]
=
item
.
value
;
},
},
onDropdownSelect
:
function
(
item
,
inputname
)
{
onDropdownSelect
:
function
(
item
,
inputname
)
{
scope
.
model
[
v
]
=
item
.
value
;
scope
.
model
[
k
]
=
item
.
value
;
jQuery
(
'input[name='
+
inputname
+
']'
).
val
(
item
.
name
);
jQuery
(
'input[name='
+
inputname
+
']'
).
val
(
item
.
name
);
}
}
};
};
// get model objects from db and add to select list
// get model objects from db and add to select list
scope
.
form
[
scope
.
form
.
indexOf
(
v
)]
=
formitem
;
scope
.
form
[
scope
.
form
.
indexOf
(
k
)]
=
formitem
;
//scope.$broadcast('schemaFormRedraw');
//scope.$broadcast('schemaFormRedraw');
// todo: make lines below work properly
// todo: make lines below work properly
...
@@ -136,74 +136,82 @@ form_generator.factory('Generator', function ($http, $q, $timeout, RESTURL, Form
...
@@ -136,74 +136,82 @@ form_generator.factory('Generator', function ($http, $q, $timeout, RESTURL, Form
//}
//}
}
}
if
(
k
.
type
===
'ListNode'
||
k
.
type
===
'Node'
)
{
if
(
v
.
type
===
'ListNode'
||
v
.
type
===
'Node'
)
{
scope
[
k
.
type
]
=
scope
[
k
.
type
]
||
{};
scope
[
v
.
type
]
=
scope
[
v
.
type
]
||
{};
scope
[
k
.
type
][
v
]
=
{
scope
[
v
.
type
][
k
]
=
{
title
:
k
.
title
,
title
:
v
.
title
,
form
:
[],
form
:
[],
schema
:
{
schema
:
{
properties
:
{},
properties
:
{},
required
:
[],
required
:
[],
title
:
k
.
title
,
title
:
v
.
title
,
type
:
"object"
,
type
:
"object"
,
formType
:
k
.
type
,
formType
:
v
.
type
,
model_name
:
v
model_name
:
k
},
},
url
:
scope
.
url
url
:
scope
.
url
};
};
if
(
scope
.
model
[
v
]
===
null
)
{
if
(
scope
.
model
[
k
]
===
null
)
{
scope
[
k
.
type
][
v
].
model
=
k
.
type
===
'Node'
?
{}
:
[];
scope
[
v
.
type
][
k
].
model
=
v
.
type
===
'Node'
?
{}
:
[];
}
else
{
}
else
{
scope
[
k
.
type
][
v
].
model
=
scope
.
model
[
v
];
scope
[
v
.
type
][
k
].
model
=
scope
.
model
[
k
];
}
}
angular
.
forEach
(
k
.
schema
,
function
(
item
)
{
angular
.
forEach
(
v
.
schema
,
function
(
item
)
{
scope
[
k
.
type
][
v
].
schema
.
properties
[
item
.
name
]
=
item
;
scope
[
v
.
type
][
k
].
schema
.
properties
[
item
.
name
]
=
item
;
// prepare required fields
// prepare required fields
if
(
item
.
required
===
true
&&
item
.
name
!==
'idx'
)
{
if
(
item
.
required
===
true
&&
item
.
name
!==
'idx'
)
{
scope
[
k
.
type
][
v
].
schema
.
required
.
push
(
item
.
name
);
scope
[
v
.
type
][
k
].
schema
.
required
.
push
(
item
.
name
);
}
}
// idx field must be hidden
// idx field must be hidden
if
(
item
.
name
===
'idx'
)
{
if
(
item
.
name
===
'idx'
)
{
scope
[
k
.
type
][
v
].
form
.
push
({
type
:
'string'
,
key
:
item
.
name
,
htmlClass
:
'hidden'
});
scope
[
v
.
type
][
k
].
form
.
push
({
type
:
'string'
,
key
:
item
.
name
,
htmlClass
:
'hidden'
});
}
else
{
}
else
{
scope
[
k
.
type
][
v
].
form
.
push
(
item
.
name
);
scope
[
v
.
type
][
k
].
form
.
push
(
item
.
name
);
}
}
});
});
// lengthModels is length of the listnode models. if greater than 0 show records on template
// lengthModels is length of the listnode models. if greater than 0 show records on template
scope
[
k
.
type
][
v
][
'lengthModels'
]
=
scope
.
model
[
v
]
?
1
:
0
;
scope
[
v
.
type
][
k
][
'lengthModels'
]
=
scope
.
model
[
k
]
?
1
:
0
;
}
}
// generically change _id fields model value
if
(
k
===
scope
.
form_params
.
param
+
'_id'
)
{
scope
.
model
[
k
]
=
scope
.
form_params
.
id
;
scope
.
form
.
splice
(
scope
.
form
.
indexOf
(
k
),
1
);
}
});
});
return
scope
;
return
scope
;
};
};
generator
.
dateformatter
=
function
(
formObject
)
{
generator
.
dateformatter
=
function
(
formObject
)
{
var
ndate
=
new
Date
(
formObject
);
var
ndate
=
new
Date
(
formObject
);
if
(
ndate
==
=
'Invalid Date'
)
{
if
(
ndate
==
'Invalid Date'
)
{
return
''
;
return
''
;
}
}
else
{
var
newdatearray
=
[
ndate
.
getDate
(),
ndate
.
getMonth
(),
ndate
.
getFullYear
()];
var
newdatearray
=
[
ndate
.
getDate
(),
ndate
.
getMonth
(),
ndate
.
getFullYear
()];
return
newdatearray
.
join
(
'.'
);
return
newdatearray
.
join
(
'.'
);
}
};
};
generator
.
get_form
=
function
(
scope
)
{
generator
.
get_form
=
function
(
scope
)
{
return
$http
return
$http
.
post
(
generator
.
make
Post
Url
(
scope
),
scope
.
form_params
)
.
post
(
generator
.
makeUrl
(
scope
),
scope
.
form_params
)
.
then
(
function
(
res
)
{
.
then
(
function
(
res
)
{
return
generator
.
generate
(
scope
,
res
.
data
);
return
generator
.
generate
(
scope
,
res
.
data
);
});
});
};
};
generator
.
get_list
=
function
(
scope
)
{
generator
.
get_list
=
function
(
scope
)
{
return
$http
return
$http
.
get
(
generator
.
make
Get
Url
(
scope
))
.
get
(
generator
.
makeUrl
(
scope
))
.
then
(
function
(
res
)
{
.
then
(
function
(
res
)
{
//generator.dateformatter(res);
//generator.dateformatter(res);
return
res
;
return
res
;
...
@@ -211,7 +219,7 @@ form_generator.factory('Generator', function ($http, $q, $timeout, RESTURL, Form
...
@@ -211,7 +219,7 @@ form_generator.factory('Generator', function ($http, $q, $timeout, RESTURL, Form
};
};
generator
.
get_single_item
=
function
(
scope
)
{
generator
.
get_single_item
=
function
(
scope
)
{
return
$http
return
$http
.
get
(
generator
.
make
Get
Url
(
scope
))
.
get
(
generator
.
makeUrl
(
scope
))
.
then
(
function
(
res
)
{
.
then
(
function
(
res
)
{
//generator.dateformatter(res);
//generator.dateformatter(res);
return
res
;
return
res
;
...
@@ -275,7 +283,7 @@ form_generator.factory('Generator', function ($http, $q, $timeout, RESTURL, Form
...
@@ -275,7 +283,7 @@ form_generator.factory('Generator', function ($http, $q, $timeout, RESTURL, Form
//data.form = get_diff;
//data.form = get_diff;
}
}
return
$http
.
post
(
generator
.
make
Post
Url
(
$scope
),
data
)
return
$http
.
post
(
generator
.
makeUrl
(
$scope
),
data
)
.
success
(
function
(
data
)
{
.
success
(
function
(
data
)
{
// if return data consists forms key then trogger redraw the form with updated data
// if return data consists forms key then trogger redraw the form with updated data
if
(
data
.
forms
)
{
if
(
data
.
forms
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment