Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
spring-petclinic-microservices
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sebastien Briot
spring-petclinic-microservices
Commits
7c131fd4
Commit
7c131fd4
authored
8 years ago
by
Dapeng
Browse files
Options
Downloads
Patches
Plain Diff
add simple error handler for OwnerController.js
parent
080f9e41
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/webapp/scripts/app/owner/OwnerController.js
+30
-20
30 additions, 20 deletions
src/main/webapp/scripts/app/owner/OwnerController.js
with
30 additions
and
20 deletions
src/main/webapp/scripts/app/owner/OwnerController.js
+
30
−
20
View file @
7c131fd4
...
...
@@ -12,8 +12,8 @@ function loadOwner($scope, $resource, $stateParams) {
*/
angular
.
module
(
'
controllers
'
).
controller
(
'
ownerSearchController
'
,
[
'
$scope
'
,
'
$state
'
,
function
(
$scope
,
$state
)
{
$scope
.
ownerSearchForm
=
{};
$scope
.
ownerSearchForm
=
{};
// form always needs to be initialised
// otherwise we can't read $scope.ownerSearchForm.lastName
...
...
@@ -27,13 +27,13 @@ angular.module('controllers').controller('ownerSearchController', ['$scope', '$s
*/
angular
.
module
(
'
controllers
'
).
controller
(
'
ownerListController
'
,
[
'
$scope
'
,
'
$resource
'
,
'
$stateParams
'
,
function
(
$scope
,
$resource
,
$stateParams
)
{
var
destUrl
=
'
/petclinic/owner/list?lastName=
'
;
if
(
angular
.
isDefined
(
$stateParams
.
lastName
))
{
destUrl
+=
$stateParams
.
lastName
;
}
var
ownerResource
=
$resource
(
destUrl
);
$scope
.
ownerList
=
ownerResource
.
query
();
$scope
.
ownerList
=
ownerResource
.
query
();
}]);
/*
...
...
@@ -50,33 +50,43 @@ angular.module('controllers').controller('ownerDetailController', ['$scope', '$r
*/
angular
.
module
(
'
controllers
'
).
controller
(
'
ownerFormController
'
,
[
'
$scope
'
,
'
$http
'
,
'
$resource
'
,
'
$stateParams
'
,
'
$state
'
,
function
(
$scope
,
$http
,
$resource
,
$stateParams
,
$state
)
{
$scope
.
submitOwnerForm
=
{};
$scope
.
submitOwnerForm
=
function
()
{
var
form
=
$scope
.
owner
;
// Creating a Javascript object
var
data
=
{
firstName
:
form
.
firstName
,
lastName
:
form
.
lastName
,
address
:
form
.
address
,
city
:
form
.
city
,
telephone
:
form
.
telephone
telephone
:
form
.
telephone
};
if
(
$state
.
current
.
name
==
'
app.owneredit
'
)
{
var
restUrl
=
"
/petclinic/owner/
"
+
$stateParams
.
id
;
$http
.
put
(
restUrl
,
data
);
$state
.
go
(
'
app.ownerlist
'
);
}
else
{
// in case of owner creation
var
restUrl
=
"
/petclinic/owner
"
;
$http
.
post
(
restUrl
,
data
);
$state
.
go
(
'
app.ownerlist
'
);
}
var
request
;
if
(
$state
.
current
.
name
==
'
app.owneredit
'
)
{
var
restUrl
=
"
/petclinic/owner/
"
+
$stateParams
.
id
;
request
=
$http
.
put
(
restUrl
,
data
);
}
else
{
// in case of owner creation
var
restUrl
=
"
/petclinic/owner
"
;
request
=
$http
.
post
(
restUrl
,
data
);
}
request
.
then
(
function
()
{
$state
.
go
(
'
app.ownerlist
'
);
},
function
(
response
)
{
var
error
=
response
.
data
;
alert
(
error
.
error
+
"
\r\n
"
+
error
.
errors
.
map
(
function
(
e
)
{
return
e
.
field
+
"
:
"
+
e
.
defaultMessage
;
}).
join
(
"
\r\n
"
));
});
}
if
(
$state
.
current
.
name
==
'
app.owneredit
'
)
{
loadOwner
(
$scope
,
$resource
,
$stateParams
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment