mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-17 21:35:50 +00:00
TN: Make add pet work without BirthDate
This commit is contained in:
parent
9dfcd77233
commit
a5fa3431e8
9 changed files with 45 additions and 39 deletions
|
@ -130,11 +130,11 @@
|
|||
<div class="col-md-4 col-md-offset-2">
|
||||
<div class="form-group">
|
||||
<label for="firstName">First Name</label>
|
||||
<input type="text" class="form-control" id="firstName" value="Maria">
|
||||
<input type="text" class="form-control" id="firstName" ng-model="currentOwner.firstName">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="lastName">Last Name</label>
|
||||
<input type="text" class="form-control" id="lastName" value="Rodriguez">
|
||||
<input type="text" class="form-control" id="lastName" ng-model="currentOwner.lastName">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="profileImg">Profile Photo</label>
|
||||
|
@ -156,15 +156,15 @@
|
|||
</div>
|
||||
<div class="form-group">
|
||||
<label for="address">Address</label>
|
||||
<input type="text" class="form-control" id="address" value="345 Maple St.">
|
||||
<input type="text" class="form-control" id="address" ng-model="currentOwner.address">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="city">City</label>
|
||||
<input type="text" class="form-control" id="city" value="Madison">
|
||||
<input type="text" class="form-control" id="city" ng-model="currentOwner.city">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="contactNumber">Contact Number</label>
|
||||
<input type="text" class="form-control" id="contactNumber" value="6085557683">
|
||||
<input type="text" class="form-control" id="contactNumber" ng-model="currentOwner.telephone">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="email">Email</label>
|
||||
|
@ -173,7 +173,7 @@
|
|||
</div>
|
||||
<div class="col-md-8 col-md-offset-2">
|
||||
<div class="form-group form-group-action">
|
||||
<button type="submit" class="btn btn-primary" data-toggle="modal" data-target="#editOwnerSuccessModal" data-dismiss="modal" aria-label="Close" ng-click="addOwner()">Update Owner</button>
|
||||
<button type="submit" class="btn btn-primary" data-toggle="modal" data-target="#editOwnerSuccessModal" data-dismiss="modal" aria-label="Close" ng-click="saveOwner()">Update Owner</button>
|
||||
<button class="btn btn-link" class="close" data-dismiss="modal" aria-label="Close">Cancel</button>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -37,8 +37,8 @@
|
|||
</div>
|
||||
<div class="form-group">
|
||||
<label for="type">Type</label>
|
||||
<select class="form-control" id="type" data-ng-model="currentPet.type">
|
||||
<option data-ng-repeat="type in petTypes" data-ng-value="type.id" data-ng-selected="currentPet.type.id == type.id" data-ng-bind="type.name"></option>
|
||||
<select class="form-control" id="type" data-ng-model="currentPet.type.id">
|
||||
<option data-ng-repeat="type in petTypes" data-ng-value="type.id" data-ng-bind="type.name"></option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group form-group-action">
|
||||
|
|
|
@ -9,30 +9,26 @@ var OwnerController = ['$scope','$state','Owner',function($scope,$state,Owner) {
|
|||
}];
|
||||
|
||||
var OwnerDetailsController = ['$scope','$rootScope','$stateParams','Owner', function($scope,$rootScope,$stateParams,Owner) {
|
||||
|
||||
|
||||
var currentId = $stateParams.id;
|
||||
var nextId = parseInt($stateParams.id) + 1;
|
||||
var prevId = parseInt($stateParams.id) - 1;
|
||||
|
||||
|
||||
$scope.prevOwner = Owner.get({id:prevId});
|
||||
$scope.nextOwner = Owner.get({id:nextId});
|
||||
$scope.currentOwner = Owner.get($stateParams);
|
||||
|
||||
|
||||
$scope.saveOwner = function(){
|
||||
owner = $scope.currentOwner;
|
||||
Owner.save(owner);
|
||||
}
|
||||
|
||||
$scope.setCurrentOwner = function() {
|
||||
$rootScope.currentOwner = $scope.currentOwner;
|
||||
}
|
||||
|
||||
|
||||
}];
|
||||
|
||||
var AddOwnerController = ['$scope','Owner', function($scope,Owner) {
|
||||
|
||||
|
||||
$scope.owner={id:0,pets:[]};
|
||||
|
||||
|
||||
$scope.addOwner = function(){
|
||||
Owner.save($scope.owner);
|
||||
}
|
||||
|
|
|
@ -59,13 +59,13 @@
|
|||
<!-- List group -->
|
||||
<ul class="list-group">
|
||||
<li class="list-group-item">
|
||||
<span class="glyphicon glyphicon-retweet" aria-hidden="true"></span>
|
||||
<span class="glyphicon glyphicon-retweet" aria-hidden="true"></span>
|
||||
<strong>Next Appointment:</strong> None</li>
|
||||
<li class="list-group-item">
|
||||
<span class="glyphicon glyphicon-road" aria-hidden="true"></span>
|
||||
<span class="glyphicon glyphicon-road" aria-hidden="true"></span>
|
||||
<strong>Last Visited:</strong> 02 Feb 2015</li>
|
||||
<li class="list-group-item">
|
||||
<span class="glyphicon glyphicon-calendar" aria-hidden="true"></span>
|
||||
<span class="glyphicon glyphicon-calendar" aria-hidden="true"></span>
|
||||
<strong>Due Date:</strong> 14 Mar 2015</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
@ -81,7 +81,7 @@
|
|||
<span class="glyphicon glyphicon-plus-sign" aria-hidden="true"></span> Add New Pet
|
||||
</a>
|
||||
<div class="pull-right action-item">
|
||||
View as
|
||||
View as
|
||||
<div class="btn-group">
|
||||
<a class="btn btn-default">
|
||||
<span class="glyphicon glyphicon-th" aria-hidden="true"></span>
|
||||
|
@ -127,4 +127,11 @@
|
|||
<li><a data-ui-sref="ownerDetails({id:nextOwner.id})">{{nextOwner.firstName + ' ' + nextOwner.lastName}}<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span></a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</section>
|
||||
</section>
|
||||
|
||||
<!-- Add Owner modal -->
|
||||
<data-ng-include src="'components/_partials/_modal_add_owner.html'"></data-ng-include>
|
||||
<!-- Add Pet modal -->
|
||||
<data-ng-include src="'components/_partials/_modal_add_pet.html'"></data-ng-include>
|
||||
<!-- Add Pet Visit modal -->
|
||||
<data-ng-include src="'components/_partials/_modal_add_pet_visit.html'"></data-ng-include>
|
|
@ -5,15 +5,23 @@ var PetController = ['$scope', 'Pet', function($scope, Pet) {
|
|||
scrollTop: $("#pets").offset().top
|
||||
}, 1000);
|
||||
});
|
||||
|
||||
|
||||
$scope.pets = Pet.query();
|
||||
|
||||
|
||||
}];
|
||||
|
||||
var AddPetController = ['$scope','$rootScope','PetType','Pet',function($scope,$rootScope,PetType,Pet) {
|
||||
var AddPetController = ['$scope','$rootScope','PetType','OwnerPet',function($scope,$rootScope,PetType,OwnerPet) {
|
||||
$scope.petTypes = PetType.query();
|
||||
|
||||
$scope.currentPet = {type:{}};
|
||||
|
||||
$scope.save = function(){
|
||||
Pet.$save($scope.currentPet);
|
||||
currentOwnerId = $scope.currentOwner.id;
|
||||
|
||||
for (i=0; i<$scope.petTypes.length; i++){
|
||||
if ($scope.petTypes[i].id == $scope.currentPet.type.id){
|
||||
$scope.currentPet.type.name = $scope.petTypes[i].name;
|
||||
}
|
||||
}
|
||||
OwnerPet.save({ownerId:currentOwnerId},$scope.currentPet);
|
||||
};
|
||||
}];
|
BIN
src/main/webapp/images/avatars/owner11.jpg
Normal file
BIN
src/main/webapp/images/avatars/owner11.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.2 KiB |
BIN
src/main/webapp/images/avatars/owner12.jpg
Normal file
BIN
src/main/webapp/images/avatars/owner12.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.1 KiB |
|
@ -21,12 +21,6 @@
|
|||
|
||||
<!-- Search modal -->
|
||||
<data-ng-include src="'components/_partials/_modal_search.html'"></data-ng-include>
|
||||
<!-- Add Owner modal -->
|
||||
<data-ng-include src="'components/_partials/_modal_add_owner.html'"></data-ng-include>
|
||||
<!-- Add Pet modal -->
|
||||
<data-ng-include src="'components/_partials/_modal_add_pet.html'"></data-ng-include>
|
||||
<!-- Add Pet Visit modal -->
|
||||
<data-ng-include src="'components/_partials/_modal_add_pet_visit.html'"></data-ng-include>
|
||||
|
||||
<!--<script src="http://code.jquery.com/jquery.js"></script>-->
|
||||
<script src="plugins/jquery/jquery-2.1.0.min.js"></script>
|
||||
|
@ -44,7 +38,7 @@
|
|||
<script src="js/lib/angular-cookies.js"></script>
|
||||
<script src="js/lib/angular-storage.js"></script>
|
||||
<script src="js/lib/angular-mocks.js"></script>
|
||||
|
||||
|
||||
<script src="services/services.js"></script>
|
||||
<script src="components/main/MainController.js"></script>
|
||||
<script src="components/veterinarians/VeterinarianController.js"></script>
|
||||
|
|
|
@ -9,9 +9,9 @@ app.constant('context', '/petclinic');
|
|||
app.config(['stateHelperProvider','$urlRouterProvider','$urlMatcherFactoryProvider',function(stateHelperProvider,$urlRouterProvider,$urlMatcherFactoryProvider) {
|
||||
|
||||
$urlRouterProvider.otherwise("/");
|
||||
|
||||
|
||||
$urlMatcherFactoryProvider.strictMode(false)
|
||||
|
||||
|
||||
stateHelperProvider.state({
|
||||
name: "landing",
|
||||
url: "/",
|
||||
|
@ -49,7 +49,7 @@ app.config(['stateHelperProvider','$urlRouterProvider','$urlMatcherFactoryProvid
|
|||
controller: "OwnerDetailsController",
|
||||
data: {requireLogin : true}
|
||||
});
|
||||
|
||||
|
||||
} ]);
|
||||
|
||||
/** Controllers **/
|
||||
|
@ -67,6 +67,7 @@ app.controller('SearchController', SearchController);
|
|||
/** Services **/
|
||||
app.factory('Owner', Owner);
|
||||
app.factory('Pet', Pet);
|
||||
app.factory('OwnerPet', OwnerPet);
|
||||
app.factory('Vet', Vet);
|
||||
app.factory('Visit', Visit);
|
||||
app.factory('PetType', PetType);
|
||||
|
@ -79,7 +80,7 @@ app.directive('scrollToTarget', function() {
|
|||
element.bind('click', function() {
|
||||
angular.element('html, body').stop().animate({
|
||||
scrollTop: angular.element(angular.element(element).attr('href')).offset().top - 20
|
||||
}, 1500);
|
||||
}, 1500);
|
||||
return false;
|
||||
});
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue