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
5043cc63
Commit
5043cc63
authored
Nov 03, 2015
by
Evren Kutar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
return to list page after save
save to linked model and reload page
parent
12e3097e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
21 deletions
+23
-21
crud_controller.js
app/components/crud/crud_controller.js
+4
-4
directives.js
app/shared/directives.js
+1
-1
form_service.js
app/zetalib/forms/form_service.js
+18
-16
No files found.
app/components/crud/crud_controller.js
View file @
5043cc63
...
@@ -38,7 +38,8 @@ crud.controller('CRUDAddEditCtrl', function ($scope, $rootScope, $location, $htt
...
@@ -38,7 +38,8 @@ 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
+
'/'
+
$scope
.
form_params
.
param
+
'/'
+
$scope
.
form_params
.
id
).
search
(
data
);
})
})
.
error
(
function
(
data
)
{
.
error
(
function
(
data
)
{
$scope
.
message
=
data
.
title
;
$scope
.
message
=
data
.
title
;
...
@@ -83,10 +84,9 @@ crud.controller('CRUDShowCtrl', function ($scope, $rootScope, $location, Generat
...
@@ -83,10 +84,9 @@ crud.controller('CRUDShowCtrl', function ($scope, $rootScope, $location, Generat
};
};
// call generator's get_single_item func
// 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 no data to show redirect to add/edit view
//if (res.data.nobjects[0] === "-1") {
//if (res.data.nobjects[0] === "-1") {
// $location.path('crud/' + $scope.form_params.model + '/' + $scope.form_params.param + '/' + $scope.form_params.
object_
id + '/edit');
// $location.path('crud/' + $scope.form_params.model + '/' + $scope.form_params.param + '/' + $scope.form_params.id + '/edit');
//}
//}
$scope
.
listobjects
=
{};
$scope
.
listobjects
=
{};
$scope
.
object
=
res
.
data
.
object
;
$scope
.
object
=
res
.
data
.
object
;
...
@@ -96,7 +96,7 @@ crud.controller('CRUDShowCtrl', function ($scope, $rootScope, $location, Generat
...
@@ -96,7 +96,7 @@ crud.controller('CRUDShowCtrl', function ($scope, $rootScope, $location, Generat
$scope
.
listobjects
[
key
]
=
value
;
$scope
.
listobjects
[
key
]
=
value
;
delete
$scope
.
object
[
key
];
delete
$scope
.
object
[
key
];
}
}
});
debugger
;
});
$scope
.
model
=
$routeParams
.
model
;
$scope
.
model
=
$routeParams
.
model
;
...
...
app/shared/directives.js
View file @
5043cc63
...
@@ -56,7 +56,7 @@ app.directive('headerNotification', function ($http, $rootScope, $interval, REST
...
@@ -56,7 +56,7 @@ app.directive('headerNotification', function ($http, $rootScope, $interval, REST
// when clicked mark as read notification
// when clicked mark as read notification
// it can be list of notifications
// it can be list of notifications
$scope
.
markAsRead
=
function
(
items
)
{
$scope
.
markAsRead
=
function
(
items
)
{
$http
.
post
(
RESTURL
.
url
+
"notify"
,
{
ignoreLoadingBar
:
true
,
read
:
items
})
$http
.
post
(
RESTURL
.
url
+
"notify"
,
{
ignoreLoadingBar
:
true
,
read
:
[
items
]
})
.
success
(
function
(
data
)
{
.
success
(
function
(
data
)
{
console
.
log
(
data
);
console
.
log
(
data
);
});
});
...
...
app/zetalib/forms/form_service.js
View file @
5043cc63
...
@@ -52,11 +52,17 @@ form_generator.factory('Generator', function ($http, $q, $timeout, RESTURL, Form
...
@@ -52,11 +52,17 @@ 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
(
v
,
k
)
{
angular
.
forEach
(
scope
.
schema
.
properties
,
function
(
v
,
k
)
{
// check if type is date and if type date found change it to string
// generically change _id fields model value
if
(
k
==
scope
.
form_params
.
param
)
{
scope
.
model
[
k
]
=
scope
.
form_params
.
id
;
scope
.
form
.
splice
(
scope
.
form
.
indexOf
(
k
),
1
);
return
;
}
if
(
v
.
type
===
'submit'
||
v
.
type
===
'button'
)
{
if
(
v
.
type
===
'submit'
||
v
.
type
===
'button'
)
{
//k.type = 'button';
debugger
;
scope
.
form
[
scope
.
form
.
indexOf
(
k
)]
=
{
scope
.
form
[
scope
.
form
.
indexOf
(
k
)]
=
{
type
:
v
.
type
,
type
:
v
.
type
,
title
:
v
.
title
,
title
:
v
.
title
,
...
@@ -64,6 +70,8 @@ form_generator.factory('Generator', function ($http, $q, $timeout, RESTURL, Form
...
@@ -64,6 +70,8 @@ form_generator.factory('Generator', function ($http, $q, $timeout, RESTURL, Form
};
};
}
}
// check if type is date and if type date found change it to string
if
(
v
.
type
===
'date'
)
{
if
(
v
.
type
===
'date'
)
{
v
.
type
=
'string'
;
v
.
type
=
'string'
;
scope
.
model
[
k
]
=
generator
.
dateformatter
(
scope
.
model
[
k
]);
scope
.
model
[
k
]
=
generator
.
dateformatter
(
scope
.
model
[
k
]);
...
@@ -98,7 +106,7 @@ form_generator.factory('Generator', function ($http, $q, $timeout, RESTURL, Form
...
@@ -98,7 +106,7 @@ form_generator.factory('Generator', function ($http, $q, $timeout, RESTURL, Form
if
(
v
.
type
===
'model'
)
{
if
(
v
.
type
===
'model'
)
{
var
formitem
=
scope
.
form
[
scope
.
form
.
indexOf
(
k
)];
var
formitem
=
scope
.
form
[
scope
.
form
.
indexOf
(
k
)];
var
modelscope
=
{
"url"
:
scope
.
url
,
"form_params"
:
{
model
:
v
.
model_name
,
param
:
scope
.
form_params
.
param
,
id
:
scope
.
form_params
.
id
}};
var
modelscope
=
{
"url"
:
scope
.
url
,
"form_params"
:
{
model
:
v
.
model_name
}};
formitem
=
{
formitem
=
{
type
:
"template"
,
type
:
"template"
,
...
@@ -183,16 +191,10 @@ form_generator.factory('Generator', function ($http, $q, $timeout, RESTURL, Form
...
@@ -183,16 +191,10 @@ form_generator.factory('Generator', function ($http, $q, $timeout, RESTURL, Form
}
}
// generically change _id fields model value
if
(
k
==
scope
.
form_params
.
param
)
{
debugger
;
scope
.
model
[
k
]
=
scope
.
form_params
.
id
;
scope
.
form
.
splice
(
scope
.
form
.
indexOf
(
k
),
1
);
}
});
});
console
.
log
(
scope
.
form
);
return
scope
;
return
scope
;
};
};
generator
.
dateformatter
=
function
(
formObject
)
{
generator
.
dateformatter
=
function
(
formObject
)
{
...
@@ -261,7 +263,6 @@ form_generator.factory('Generator', function ($http, $q, $timeout, RESTURL, Form
...
@@ -261,7 +263,6 @@ form_generator.factory('Generator', function ($http, $q, $timeout, RESTURL, Form
};
};
// custom form submit for custom submit buttons
// custom form submit for custom submit buttons
generator
.
genericSubmit
=
function
(
$scope
,
data
)
{
generator
.
genericSubmit
=
function
(
$scope
,
data
)
{
debugger
;
return
$http
.
post
(
generator
.
makePostUrl
(
$scope
),
data
);
return
$http
.
post
(
generator
.
makePostUrl
(
$scope
),
data
);
};
};
generator
.
submit
=
function
(
$scope
)
{
generator
.
submit
=
function
(
$scope
)
{
...
@@ -393,7 +394,7 @@ form_generator.directive('modalForNodes', function ($modal) {
...
@@ -393,7 +394,7 @@ form_generator.directive('modalForNodes', function ($modal) {
* @return: openmodal directive
* @return: openmodal directive
*/
*/
form_generator
.
directive
(
'addModalForLinkedModel'
,
function
(
$modal
,
Generator
)
{
form_generator
.
directive
(
'addModalForLinkedModel'
,
function
(
$modal
,
$route
,
Generator
)
{
return
{
return
{
link
:
function
(
scope
,
element
)
{
link
:
function
(
scope
,
element
)
{
element
.
on
(
'click'
,
function
()
{
element
.
on
(
'click'
,
function
()
{
...
@@ -405,7 +406,7 @@ form_generator.directive('addModalForLinkedModel', function ($modal, Generator)
...
@@ -405,7 +406,7 @@ form_generator.directive('addModalForLinkedModel', function ($modal, Generator)
resolve
:
{
resolve
:
{
items
:
function
()
{
items
:
function
()
{
return
Generator
.
get_form
({
return
Generator
.
get_form
({
url
:
'crud'
,
url
:
'crud
/
'
,
form_params
:
{
'model'
:
scope
.
form
.
model_name
,
"cmd"
:
"add"
}
form_params
:
{
'model'
:
scope
.
form
.
model_name
,
"cmd"
:
"add"
}
});
});
}
}
...
@@ -414,6 +415,7 @@ form_generator.directive('addModalForLinkedModel', function ($modal, Generator)
...
@@ -414,6 +415,7 @@ form_generator.directive('addModalForLinkedModel', function ($modal, Generator)
modalInstance
.
result
.
then
(
function
(
childmodel
,
key
)
{
modalInstance
.
result
.
then
(
function
(
childmodel
,
key
)
{
Generator
.
submit
(
childmodel
);
Generator
.
submit
(
childmodel
);
$route
.
reload
();
});
});
});
});
}
}
...
@@ -440,7 +442,7 @@ form_generator.directive('editModalForLinkedModel', function ($modal, Generator)
...
@@ -440,7 +442,7 @@ form_generator.directive('editModalForLinkedModel', function ($modal, Generator)
resolve
:
{
resolve
:
{
items
:
function
()
{
items
:
function
()
{
return
Generator
.
get_form
({
return
Generator
.
get_form
({
url
:
'crud'
,
url
:
'crud
/
'
,
form_params
:
{
'model'
:
scope
.
form
.
title
,
"cmd"
:
"add"
}
form_params
:
{
'model'
:
scope
.
form
.
title
,
"cmd"
:
"add"
}
});
});
}
}
...
...
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