diff --git a/src/main/java/org/springframework/samples/petclinic/web/OwnerListResource.java b/src/main/java/org/springframework/samples/petclinic/web/OwnerListResource.java index 8054fc8f0..ae7782be9 100644 --- a/src/main/java/org/springframework/samples/petclinic/web/OwnerListResource.java +++ b/src/main/java/org/springframework/samples/petclinic/web/OwnerListResource.java @@ -17,17 +17,10 @@ package org.springframework.samples.petclinic.web; import java.util.Collection; -import javax.validation.Valid; - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.MediaType; import org.springframework.samples.petclinic.model.Owner; import org.springframework.samples.petclinic.service.ClinicService; -import org.springframework.validation.BindingResult; -import org.springframework.web.bind.WebDataBinder; -import org.springframework.web.bind.annotation.InitBinder; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; diff --git a/src/main/java/org/springframework/samples/petclinic/web/OwnerResource.java b/src/main/java/org/springframework/samples/petclinic/web/OwnerResource.java index 4fe3bb80d..966a8a43e 100644 --- a/src/main/java/org/springframework/samples/petclinic/web/OwnerResource.java +++ b/src/main/java/org/springframework/samples/petclinic/web/OwnerResource.java @@ -56,10 +56,8 @@ public class OwnerResource { } // TODO: should be improved so we have a single method parameter - @RequestMapping(value = "/owner/{ownerId}", method = RequestMethod.POST) + @RequestMapping(value = "/owner/{ownerId}", method = RequestMethod.PUT) public Owner updateOwner(@ModelAttribute Owner ownerModel, @RequestBody Owner ownerRequest) { - // seems like a workaround. I haven't found a proper way to inject to have @ModelAttribute pupulate object - // first and then have the delta come from @RequestBody ownerModel.setFirstName(ownerRequest.getFirstName()); ownerModel.setLastName(ownerRequest.getLastName()); ownerModel.setCity(ownerRequest.getCity()); diff --git a/src/main/webapp/index.html b/src/main/webapp/index.html index fd98c965a..7a0d87412 100644 --- a/src/main/webapp/index.html +++ b/src/main/webapp/index.html @@ -7,10 +7,9 @@ - - + @@ -19,11 +18,11 @@ -
+
-
+
-
+
diff --git a/src/main/webapp/scripts/app/app.js b/src/main/webapp/scripts/app/app.js index cb3c4b058..1be9626c0 100644 --- a/src/main/webapp/scripts/app/app.js +++ b/src/main/webapp/scripts/app/app.js @@ -7,40 +7,73 @@ angular.module('services', ['ngResource']); /* App Module */ var petClinicApp = angular.module('petClinicApp', [ - 'ngRoute', 'controllers', 'services' + 'ui.router', 'controllers', 'services' ]); -petClinicApp.config(['$routeProvider', - function($routeProvider) { - $routeProvider. - when('/', { - templateUrl: 'scripts/app/main/main.html', - controller: 'mainController' +petClinicApp.config(['$stateProvider', '$urlRouterProvider', function($stateProvider, $urlRouterProvider) { + $urlRouterProvider.otherwise('/'); + + $stateProvider + .state('app', { + url: '/', + controller: 'mainController', + views: { + 'header': { templateUrl: 'scripts/app/fragments/bodyHeader.html'}, + 'content': { templateUrl: 'scripts/app/main/main.html'}, + 'footer': { templateUrl: 'scripts/app/fragments/footer.html'} + } }). - when('/owner/search', { - templateUrl: 'scripts/app/owner/ownerSearchForm.html', - controller: 'ownerSearchController' + state('app.ownersearch', { + url: 'owner/search', + views: { + 'content@': { + templateUrl: 'scripts/app/owner/ownerSearchForm.html', + controller: 'ownerSearchController' + } + } + }). - when('/owner/list', { - templateUrl: 'scripts/app/owner/ownerList.html', - controller: 'ownerListController' - }). - when('/owner/:id/view', { - templateUrl: 'scripts/app/owner/ownerDetail.html', - controller: 'ownerDetailController' + state('app.ownerlist', { + url: 'owner/list', + views: { + 'content@': { + templateUrl: 'scripts/app/owner/ownerList.html', + controller: 'ownerListController' + } + } + }). - when('/owner/:id/edit', { - templateUrl: 'scripts/app/owner/ownerForm.html', - controller: 'ownerFormController' + state('app.ownerdetail', { + url: 'owner/:id', + views: { + 'content@': { + templateUrl: 'scripts/app/owner/ownerDetail.html', + controller: 'ownerDetailController' + } + } + }). - when('/vets', { - templateUrl: 'scripts/app/vet/vetList.html', - controller: 'vetController' - }). - otherwise({ - redirectTo: '/' + state('app.owneredit', { + url: 'owner/:id/edit', + views: { + 'content@': { + templateUrl: 'scripts/app/owner/ownerForm.html', + controller: 'ownerFormController' + } + } + + }). + state('app.vets', { + url: 'vets', + views: { + 'content@': { + templateUrl: 'scripts/app/vet/vetList.html', + controller: 'vetController' + } + } + }); }]); diff --git a/src/main/webapp/scripts/app/fragments/bodyHeader.html b/src/main/webapp/scripts/app/fragments/bodyHeader.html index 1cdf3a579..8bdf23977 100644 --- a/src/main/webapp/scripts/app/fragments/bodyHeader.html +++ b/src/main/webapp/scripts/app/fragments/bodyHeader.html @@ -3,15 +3,15 @@