TN: Make add pet work without BirthDate

This commit is contained in:
Tony.Nguyen 2015-02-11 16:42:51 +08:00
parent 9dfcd77233
commit a5fa3431e8
9 changed files with 45 additions and 39 deletions

View file

@ -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>

View file

@ -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">

View file

@ -23,10 +23,6 @@ var OwnerDetailsController = ['$scope','$rootScope','$stateParams','Owner', func
Owner.save(owner);
}
$scope.setCurrentOwner = function() {
$rootScope.currentOwner = $scope.currentOwner;
}
}];
var AddOwnerController = ['$scope','Owner', function($scope,Owner) {

View file

@ -128,3 +128,10 @@
</ul>
</div>
</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>

View file

@ -10,10 +10,18 @@ var PetController = ['$scope', 'Pet', function($scope, Pet) {
}];
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);
};
}];

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

View file

@ -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>

View file

@ -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);