Commit 47e72f4190b170522227965d35fad0032ec9f834
1 parent
20857569fd
Exists in
master
update aircraft, remove aircraft
Showing
3 changed files
with
147 additions
and
14 deletions
Show diff stats
app/views/updateFBODept/updateFBODept.controller.js
... | ... | @@ -6,6 +6,7 @@ |
6 | 6 | .controller('updateFBODeptController', function($scope, $stateParams, UpdateAllFBODept, UpdateAllFBO, FBOFlight) { |
7 | 7 | $scope.showPayments = true; |
8 | 8 | $scope.aircraft = {}; |
9 | + $scope.updateData = {}; | |
9 | 10 | var userProfileID = $stateParams.id; |
10 | 11 | UpdateAllFBODept.getALlFBOData(userProfileID).then(function(result) { |
11 | 12 | console.log(result) |
... | ... | @@ -25,10 +26,13 @@ |
25 | 26 | } |
26 | 27 | }) |
27 | 28 | |
28 | - UpdateAllFBODept.getAircrafts(userProfileID).then(function(response) { | |
29 | + getCrafts(); | |
30 | + function getCrafts(){ | |
31 | + UpdateAllFBODept.getAircrafts(userProfileID).then(function(response) { | |
29 | 32 | $scope.getCraftList = response; |
30 | - }) | |
31 | - | |
33 | + }) | |
34 | + } | |
35 | + | |
32 | 36 | UpdateAllFBODept.getPaymentMethod(userProfileID).then(function(response) { |
33 | 37 | $scope.paymentList = response; |
34 | 38 | |
... | ... | @@ -110,22 +114,16 @@ |
110 | 114 | FBOFlight.getModal(modelId).then(function(result) { |
111 | 115 | $scope.aircraftModalList = result; |
112 | 116 | $scope.aircraft.model = $scope.aircraftModalList[0]; |
113 | - | |
114 | 117 | }) |
115 | 118 | } |
116 | 119 | $scope.aircraftData = {}; |
117 | 120 | $scope.aircraftData.aircraftList = []; |
118 | - $scope.getCraftList = []; | |
119 | 121 | $scope.addAircraft = function(){ |
120 | 122 | $scope.aircraftData.aircraftList.push($scope.aircraft); |
121 | - console.log($scope.aircraftData.aircraftList) | |
122 | - if ($scope.getCraftList.indexOf($scope.aircraft) == -1) { | |
123 | - $scope.getCraftList.push($scope.aircraft); | |
124 | - | |
125 | - } | |
126 | 123 | |
127 | 124 | FBOFlight.addAircraft($scope.aircraftData).then(function(result) { |
128 | 125 | $('#myModal4').modal('hide'); |
126 | + getCrafts(); | |
129 | 127 | $scope.resetData(); |
130 | 128 | toastr.success('Created Successfully', { |
131 | 129 | closeButton: true |
... | ... | @@ -133,6 +131,57 @@ |
133 | 131 | }) |
134 | 132 | } |
135 | 133 | |
134 | + $scope.closeModal = function(){ | |
135 | + $("#myModal5").modal('hide'); | |
136 | + $scope.resetData(); | |
137 | + } | |
138 | + | |
139 | + $scope.update = function(airdata){ | |
140 | + console.log(airdata) | |
141 | + $scope.aircraft = airdata; | |
142 | + $scope.aircraft.accountId = $scope.user.account.id; | |
143 | + $("#myModal5").modal('show'); | |
144 | + FBOFlight.getModal($scope.aircraft.make).then(function(result) { | |
145 | + $scope.aircraftModalList = result; | |
146 | + | |
147 | + }) | |
148 | + } | |
149 | + | |
150 | + $scope.updatecraftData = {}; | |
151 | + $scope.updatecraftData.aircraftList = []; | |
152 | + $scope.updateAircraftData = {}; | |
153 | + | |
154 | + $scope.updateAircraft = function(updateAircraft){ | |
155 | + $scope.updateAircraftData.id = updateAircraft.id; | |
156 | + $scope.updateAircraftData.make = updateAircraft.make; | |
157 | + $scope.updateAircraftData.model = updateAircraft.model; | |
158 | + $scope.updateAircraftData.size = updateAircraft.size; | |
159 | + $scope.updateAircraftData.tail = updateAircraft.tail; | |
160 | + $scope.updateAircraftData.accountId = updateAircraft.accountId; | |
161 | + console.log($scope.updateAircraftData) | |
162 | + | |
163 | + $scope.updatecraftData.aircraftList.push($scope.updateAircraftData); | |
164 | + console.log($scope.updatecraftData.aircraftList) | |
165 | + | |
166 | + UpdateAllFBODept.updateAircraft($scope.updatecraftData).then(function(result) { | |
167 | + $('#myModal5').modal('hide'); | |
168 | + $scope.resetData(); | |
169 | + toastr.success('Updated Successfully', { | |
170 | + closeButton: true | |
171 | + }) | |
172 | + }) | |
173 | + } | |
174 | + | |
175 | + $scope.remove = function(data){ | |
176 | + console.log(data) | |
177 | + UpdateAllFBODept.removeAircraft(data.id).then(function(result) { | |
178 | + toastr.success(''+result.success+'', { | |
179 | + closeButton: true | |
180 | + }) | |
181 | + getCrafts(); | |
182 | + }) | |
183 | + } | |
184 | + | |
136 | 185 | $scope.resetData = function() { |
137 | 186 | $scope.aircraft = {}; |
138 | 187 | $scope.aircraft.accountId = $scope.user.account.id; | ... | ... |
app/views/updateFBODept/updateFBODept.html
... | ... | @@ -117,13 +117,13 @@ |
117 | 117 | </select> |
118 | 118 | </td> |
119 | 119 | <td style="width: 30%"> |
120 | - <select class="form-control"> | |
121 | - <option ng-repeat="model in aircraftModalList" ng-model="aircraft.model">{{model}}</option> | |
120 | + <select class="form-control" ng-model="aircraft.model"> | |
121 | + <option ng-repeat="model in aircraftModalList">{{model}}</option> | |
122 | 122 | </select> |
123 | 123 | </td> |
124 | 124 | <td style="width: 30%"> |
125 | - <select class="form-control"> | |
126 | - <option ng-repeat="size in aircraftSizeList" ng-model="aircraft.size">{{size}}</option> | |
125 | + <select class="form-control" ng-model="aircraft.size"> | |
126 | + <option ng-repeat="size in aircraftSizeList">{{size}}</option> | |
127 | 127 | </select> |
128 | 128 | </td> |
129 | 129 | </tr> |
... | ... | @@ -147,6 +147,7 @@ |
147 | 147 | <th>Make</th> |
148 | 148 | <th>Model</th> |
149 | 149 | <th>Size</th> |
150 | + <th>Actions</th> | |
150 | 151 | </tr> |
151 | 152 | </thead> |
152 | 153 | <tbody> |
... | ... | @@ -169,6 +170,10 @@ |
169 | 170 | <option>{{airData.size}}</option> |
170 | 171 | </select> |
171 | 172 | </td> |
173 | + <td> | |
174 | + <i style="margin-top: 10px;" class="fa fa-pencil" ng-click="update(airData)"></i> | |
175 | + <i class="fa fa-trash" ng-click="remove(airData)"></i> | |
176 | + </td> | |
172 | 177 | </tr> |
173 | 178 | </tbody> |
174 | 179 | </table> |
... | ... | @@ -177,6 +182,56 @@ |
177 | 182 | </div> |
178 | 183 | </div> |
179 | 184 | </div> |
185 | + <div class="modal inmodal" id="myModal5" tabindex="-1" role="dialog" aria-hidden="true"> | |
186 | + <div class="modal-dialog"> | |
187 | + <div class="modal-content animated fadeIn"> | |
188 | + <div class="modal-header"> | |
189 | + <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button> | |
190 | + <!-- <i class="fa fa-clock-o modal-icon"></i> --> | |
191 | + <h4 class="modal-title">Update Aircraft</h4> | |
192 | + <!-- <small>Lorem Ipsum is simply dummy text of the printing and typesetting industry.</small> --> | |
193 | + </div> | |
194 | + <div class="modal-body" style="padding: 15px;"> | |
195 | + <table class="table table-bordered table-hover table-striped"> | |
196 | + <thead> | |
197 | + <tr> | |
198 | + <th>Tail</th> | |
199 | + <th>Make</th> | |
200 | + <th>Model</th> | |
201 | + <th>Size</th> | |
202 | + </tr> | |
203 | + </thead> | |
204 | + <tbody> | |
205 | + <tr> | |
206 | + <td> | |
207 | + <input type="text" style="width:100px;" ng-model="aircraft.tail" class="form-control"> | |
208 | + </td> | |
209 | + <td style="width: 30%"> | |
210 | + <select class="form-control" ng-model="aircraft.make" ng-change="getModal()"> | |
211 | + <option ng-repeat="make in aircraftMakeList">{{make}}</option> | |
212 | + </select> | |
213 | + </td> | |
214 | + <td style="width: 30%"> | |
215 | + <select class="form-control" ng-model="aircraft.model"> | |
216 | + <option ng-repeat="model in aircraftModalList">{{model}}</option> | |
217 | + </select> | |
218 | + </td> | |
219 | + <td style="width: 30%"> | |
220 | + <select class="form-control" ng-model="aircraft.size"> | |
221 | + <option ng-repeat="size in aircraftSizeList">{{size}}</option> | |
222 | + </select> | |
223 | + </td> | |
224 | + </tr> | |
225 | + </tbody> | |
226 | + </table> | |
227 | + </div> | |
228 | + <div class="modal-footer"> | |
229 | + <button type="button" class="btn btn-white" ng-click="closeModal()">Close</button> | |
230 | + <button type="button" class="btn btn-primary" ng-click="updateAircraft(aircraft)">Save changes</button> | |
231 | + </div> | |
232 | + </div> | |
233 | + </div> | |
234 | + </div> | |
180 | 235 | <div class="col-lg-5"> |
181 | 236 | <div class="ibox float-e-margins"> |
182 | 237 | <div class="ibox-title"> | ... | ... |
app/views/updateFBODept/updateFBODept.service.js
... | ... | @@ -77,6 +77,35 @@ |
77 | 77 | return deferred.promise; |
78 | 78 | } |
79 | 79 | |
80 | + this.updateAircraft = function(data) { | |
81 | + | |
82 | + var deferred = $q.defer(); | |
83 | + $http({ | |
84 | + method : 'PUT', | |
85 | + url : BE.url +'/account/user/updateAircraft', | |
86 | + headers : {'Content-Type': 'application/json'}, | |
87 | + data: data | |
88 | + }) | |
89 | + .success(function(result) { | |
90 | + deferred.resolve(result); | |
91 | + }) | |
92 | + return deferred.promise; | |
93 | + } | |
94 | + | |
95 | + this.removeAircraft = function(id) { | |
96 | + | |
97 | + var deferred = $q.defer(); | |
98 | + $http({ | |
99 | + method : 'DELETE', | |
100 | + url : BE.url +'/account/user/airCraft/'+id, | |
101 | + headers : {'Content-Type': 'application/json'}, | |
102 | + }) | |
103 | + .success(function(result) { | |
104 | + deferred.resolve(result); | |
105 | + }) | |
106 | + return deferred.promise; | |
107 | + } | |
108 | + | |
80 | 109 | } |
81 | 110 | |
82 | 111 | })(); |
83 | 112 | \ No newline at end of file | ... | ... |