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
13842038
Commit
13842038
authored
Jul 07, 2015
by
Evren Kutar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
url değişikliği
post metodu uygulandı staff add ve edit tek controllerdan yapılıyor
parent
a00a725a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
39 deletions
+48
-39
app_routes.js
app/app_routes.js
+2
-2
staff_controller.js
app/components/staff/staff_controller.js
+33
-25
form_service.js
app/zetalib/forms/form_service.js
+13
-12
No files found.
app/app_routes.js
View file @
13842038
...
@@ -89,7 +89,7 @@ app.config(['$routeProvider', function ($routeProvider) {
...
@@ -89,7 +89,7 @@ app.config(['$routeProvider', function ($routeProvider) {
})
})
.
when
(
'/staff/add'
,
{
.
when
(
'/staff/add'
,
{
templateUrl
:
'components/staff/templates/add.html'
,
templateUrl
:
'components/staff/templates/add.html'
,
controller
:
'StaffAddCtrl'
,
controller
:
'StaffAdd
Edit
Ctrl'
,
resolve
:
{
resolve
:
{
loadMyCtrl
:
[
'$ocLazyLoad'
,
function
(
$ocLazyLoad
)
{
loadMyCtrl
:
[
'$ocLazyLoad'
,
function
(
$ocLazyLoad
)
{
return
$ocLazyLoad
.
load
(
'components/staff/staff_controller.js'
);
return
$ocLazyLoad
.
load
(
'components/staff/staff_controller.js'
);
...
@@ -104,7 +104,7 @@ app.config(['$routeProvider', function ($routeProvider) {
...
@@ -104,7 +104,7 @@ app.config(['$routeProvider', function ($routeProvider) {
})
})
.
when
(
'/staff/edit/:id'
,
{
.
when
(
'/staff/edit/:id'
,
{
templateUrl
:
'components/staff/templates/edit.html'
,
templateUrl
:
'components/staff/templates/edit.html'
,
controller
:
'StaffEditCtrl'
,
controller
:
'Staff
Add
EditCtrl'
,
resolve
:
{
resolve
:
{
loadMyCtrl
:
[
'$ocLazyLoad'
,
function
(
$ocLazyLoad
)
{
loadMyCtrl
:
[
'$ocLazyLoad'
,
function
(
$ocLazyLoad
)
{
return
$ocLazyLoad
.
load
(
'components/staff/staff_controller.js'
);
return
$ocLazyLoad
.
load
(
'components/staff/staff_controller.js'
);
...
...
app/components/staff/staff_controller.js
View file @
13842038
...
@@ -16,31 +16,39 @@ var staff = angular.module('zaerp.staff', ['ngRoute', 'schemaForm', 'formService
...
@@ -16,31 +16,39 @@ var staff = angular.module('zaerp.staff', ['ngRoute', 'schemaForm', 'formService
* which provide a form with form generator.
* which provide a form with form generator.
*/
*/
staff
.
controller
(
'StaffAddCtrl'
,
function
(
$scope
,
$http
,
$log
,
Generator
)
{
//
staff.controller('StaffAddCtrl', function ($scope, $http, $log, Generator) {
Generator
.
get_form
(
'add_staff'
,
''
).
then
(
function
(
d
)
{
//
Generator.get_form('add_staff', '').then(function (d) {
$scope
.
schema
=
d
.
schema
;
//
$scope.schema = d.schema;
$scope
.
form
=
d
.
form
;
//
$scope.form = d.form;
$scope
.
model
=
d
.
model
?
d
.
model
:
{};
//
$scope.model = d.model ? d.model : {};
$scope
.
initialModel
=
angular
.
copy
(
d
.
model
);
//
$scope.initialModel = angular.copy(d.model);
$scope
.
form
[
0
].
$asyncValidators
=
Generator
.
asyncValidators
;
//
$scope.form[0].$asyncValidators = Generator.asyncValidators;
$scope
.
form
.
push
(
//
$scope.form.push(
{
//
{
type
:
"submit"
,
//
type: "submit",
title
:
"Save"
//
title: "Save"
}
//
}
);
//
);
return
$scope
;
//
return $scope;
});
//
});
$scope
.
onSubmit
=
function
(
form
)
{
//
$scope.onSubmit = function (form) {
$scope
.
$broadcast
(
'schemaFormValidate'
);
//
$scope.$broadcast('schemaFormValidate');
if
(
form
.
$valid
)
{
//
if (form.$valid) {
Generator
.
submit
(
'add_staff'
,
$scope
);
//
Generator.submit('add_staff', $scope);
}
//
}
}
//
}
});
//
});
staff
.
controller
(
'StaffEditCtrl'
,
function
(
$scope
,
$http
,
$log
,
Generator
,
$routeParams
)
{
staff
.
controller
(
'StaffAddEditCtrl'
,
function
(
$scope
,
$http
,
$log
,
Generator
,
$routeParams
)
{
Generator
.
get_form
(
'edit_staff'
,
{
id
:
$routeParams
.
id
}).
then
(
function
(
d
)
{
var
form_params
=
{};
if
(
$routeParams
.
id
){
form_params
[
'id'
]
=
$routeParams
.
id
;
form_params
[
'cmd'
]
=
'edit_object'
;
}
else
{
form_params
[
'cmd'
]
=
'add_object'
;
}
Generator
.
get_form
(
'personel_duzenle_basitlestirilmis'
,
form_params
).
then
(
function
(
d
)
{
$scope
.
schema
=
d
.
schema
;
$scope
.
schema
=
d
.
schema
;
$scope
.
form
=
d
.
form
;
$scope
.
form
=
d
.
form
;
$scope
.
model
=
d
.
model
?
d
.
model
:
{};
$scope
.
model
=
d
.
model
?
d
.
model
:
{};
...
@@ -67,7 +75,7 @@ staff.controller('StaffEditCtrl', function ($scope, $http, $log, Generator, $rou
...
@@ -67,7 +75,7 @@ staff.controller('StaffEditCtrl', function ($scope, $http, $log, Generator, $rou
*/
*/
staff
.
controller
(
'StaffListCtrl'
,
function
(
$scope
,
$http
){
staff
.
controller
(
'StaffListCtrl'
,
function
(
$scope
,
$http
){
$http
.
get
(
'
http://127.0.0.1:3000/api/list_staff
'
).
then
(
function
(
res
){
$http
.
get
(
'
personel_duzenle_basitlestirilmis
'
).
then
(
function
(
res
){
$scope
.
staffs
=
res
.
data
;
$scope
.
staffs
=
res
.
data
;
})
})
});
});
...
...
app/zetalib/forms/form_service.js
View file @
13842038
...
@@ -16,19 +16,20 @@ form_generator.factory('Generator', function ($http, $q, $log, $timeout, RESTURL
...
@@ -16,19 +16,20 @@ form_generator.factory('Generator', function ($http, $q, $log, $timeout, RESTURL
return
form_items
;
return
form_items
;
};
};
generator
.
get_form
=
function
(
url
,
getParams
)
{
generator
.
get_form
=
function
(
url
,
getParams
)
{
if
(
getParams
)
{
//if (getParams) {
// if form for edit then url will be
// // if form for edit then url will be
var
params
=
""
;
// var params = "";
for
(
var
k
in
getParams
)
{
// for (var k in getParams) {
params
+=
k
+
"="
+
getParams
[
k
]
+
"&"
;
// params += k + "=" + getParams[k] + "&";
}
// }
var
formUrl
=
RESTURL
.
url
+
url
+
'?'
+
params
;
// var formUrl = RESTURL.url + url + '?' + params;
}
else
{
//} else {
// if form for create then url will be
// // if form for create then url will be
var
formUrl
=
RESTURL
.
url
+
url
;
// var formUrl = RESTURL.url + url;
}
//}
console
.
log
(
getParams
);
return
$http
return
$http
.
get
(
formUrl
)
.
post
(
RESTURL
.
url
+
url
,
data
=
getParams
)
.
then
(
function
(
res
)
{
.
then
(
function
(
res
)
{
if
(
res
.
status
==
200
)
{
if
(
res
.
status
==
200
)
{
// todo: remove 0 index with real api
// todo: remove 0 index with real api
...
...
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