Commit e9a2edf03381ab10d6d932f248d67df527ea9289
1 parent
32286a73a1
Exists in
master
update custom field
Showing
3 changed files
with
105 additions
and
11 deletions
Show diff stats
app/partials/viewCompany/viewCompany.controller.js
... | ... | @@ -19,13 +19,18 @@ |
19 | 19 | |
20 | 20 | var value = ""; |
21 | 21 | var companyId = $stateParams.id; |
22 | - ViewCompanyService.getCompany(companyId).then(function(result) { | |
23 | - $scope.companyData = result; | |
24 | - if(result.margin != null){ | |
25 | - $scope.companyData.masterMargin = result.margin.id; | |
26 | - } | |
27 | - $scope.showLoader = false; | |
28 | - }) | |
22 | + | |
23 | + getCompanyDetail(); | |
24 | + function getCompanyDetail(){ | |
25 | + ViewCompanyService.getCompany(companyId).then(function(result) { | |
26 | + $scope.companyData = result; | |
27 | + if(result.margin != null){ | |
28 | + $scope.companyData.masterMargin = result.margin.id; | |
29 | + } | |
30 | + $scope.showLoader = false; | |
31 | + }) | |
32 | + } | |
33 | + | |
29 | 34 | |
30 | 35 | $scope.changeCompanyStatus = function(){ |
31 | 36 | var statusData = "status=" + $scope.companyData.activate; |
... | ... | @@ -263,11 +268,55 @@ |
263 | 268 | |
264 | 269 | } |
265 | 270 | |
271 | + var newContactName = ""; | |
272 | + $scope.updateData = "" | |
273 | + $scope.showContact = function(data, value){ | |
274 | + $('#updateContact').css('display', 'block'); | |
275 | + $scope.updateData = data; | |
276 | + newContactName = value; | |
277 | + console.log($scope.updateData) | |
278 | + if($scope.updateData.email == null){ | |
279 | + $scope.updateData.content = data.contactNumber; | |
280 | + }else{ | |
281 | + $scope.updateData.content = data.email; | |
282 | + } | |
283 | + } | |
284 | + | |
285 | + $scope.acceptUpdateField = function(){ | |
286 | + console.log($scope.updateData) | |
287 | + if($scope.updateData.content == undefined){ | |
288 | + toastr.error('Please add some content', { | |
289 | + closeButton: true | |
290 | + }) | |
291 | + }else{ | |
292 | + if(newContactName == 'phone'){ | |
293 | + var updateCustomData = "companyId=" + companyId + "&contactNumber=" + $scope.updateData.content + "&contactId=" + $scope.updateData.id | |
294 | + + "&title=" + $scope.updateData.title; | |
295 | + }else{ | |
296 | + var updateCustomData = "companyId=" + companyId + "&email=" + $scope.updateData.content + "&contactId=" + $scope.updateData.id | |
297 | + + "&title=" + $scope.updateData.title; | |
298 | + } | |
299 | + ViewCompanyService.updateCustomField(updateCustomData).then(function(result) { | |
300 | + console.log(result) | |
301 | + if(result != null && result.success){ | |
302 | + $('#updateContact').css('display', 'none'); | |
303 | + getCompanyDetail(); | |
304 | + } | |
305 | + }) | |
306 | + } | |
307 | + } | |
308 | + | |
309 | + $scope.cancelUpdateField = function(){ | |
310 | + $('#updateContact').css('display', 'none'); | |
311 | + } | |
312 | + | |
266 | 313 | $scope.showEditTier2 = function(number){ |
267 | 314 | console.log(number) |
268 | 315 | $scope.contactNumber = number; |
269 | 316 | } |
270 | 317 | |
318 | + | |
319 | + | |
271 | 320 | var contactName = ''; |
272 | 321 | $scope.addCustom = function(value){ |
273 | 322 | console.log(value) |
... | ... | @@ -300,6 +349,7 @@ |
300 | 349 | console.log(result) |
301 | 350 | if(result != null && result.success){ |
302 | 351 | $('#customField').css('display', 'none'); |
352 | + getCompanyDetail(); | |
303 | 353 | } |
304 | 354 | }) |
305 | 355 | } | ... | ... |
app/partials/viewCompany/viewCompany.html
... | ... | @@ -200,21 +200,28 @@ |
200 | 200 | <input type="tel" style="width: 50%;" ng-hide="showAddress" ng-model="companyData.addressTwo" class="form-control" /> |
201 | 201 | </div> |
202 | 202 | |
203 | - <p ng-repeat="data in companyData.companyCustomContacts" ng-if="data.contactNumber != null"> | |
203 | + <!-- <p ng-repeat="data in companyData.companyCustomContacts" ng-if="data.contactNumber != null"> | |
204 | 204 | <i class="fa fa-phone" ng-hide="showEditContact"></i> |
205 | 205 | <span ng-hide="showEditContact">{{data.contactNumber}} </span> |
206 | 206 | <i ng-click="showEditContact = ! showEditContact" ng-hide="showEditContact" class="fa fa-pencil-square-o" aria-hidden="true"></i> |
207 | 207 | |
208 | 208 | <input type="tel" class="form-control" placeholder="min" ng-model="data.contactNumber" style="width: 50%;" ng-show="showEditContact"> |
209 | - <!-- <button ng-show="showEditContact">Save</button> --> | |
210 | 209 | <span ng-show="showEditContact"></br></span> |
210 | + </p> --> | |
211 | + <p ng-repeat="data in companyData.companyCustomContacts" ng-if="data.contactNumber != null"> | |
212 | + <i class="fa fa-phone" ng-hide="showEditContact"></i> | |
213 | + <span ng-hide="showEditContact">{{data.contactNumber}} </span> | |
214 | + <i ng-click="showContact(data, 'phone')" ng-hide="showEditContact" class="fa fa-pencil-square-o" aria-hidden="true"></i> | |
215 | + | |
216 | + <!-- <input type="tel" class="form-control" placeholder="min" ng-model="data.contactNumber" style="width: 50%;" ng-show="showEditContact"> | |
217 | + <span ng-show="showEditContact"></br></span> --> | |
211 | 218 | </p> |
212 | 219 | <p ng-repeat="data in companyData.companyCustomContacts" ng-if="data.email != null"> |
213 | 220 | <i class="fa fa-envelope" ng-hide="showEditEmail"></i> |
214 | 221 | <span ng-hide="showEditEmail">{{data.email}} </span> |
215 | - <i ng-click="showEditEmail = ! showEditEmail" ng-hide="showEditEmail" class="fa fa-pencil-square-o" aria-hidden="true"></i> | |
222 | + <i ng-click="showContact(data, 'email')" ng-hide="showEditEmail" class="fa fa-pencil-square-o" aria-hidden="true"></i> | |
216 | 223 | |
217 | - <input type="tel" style="width: 50%;" class="form-control" placeholder="min" ng-model="data.email" ng-show="showEditEmail"> | |
224 | + <!-- <input type="tel" style="width: 50%;" class="form-control" placeholder="min" ng-model="data.email" ng-show="showEditEmail"> --> | |
218 | 225 | </p> |
219 | 226 | </div> |
220 | 227 | <div class="new-add-select"> |
... | ... | @@ -707,6 +714,27 @@ |
707 | 714 | </div> |
708 | 715 | </div> |
709 | 716 | |
717 | +<div class="customConfirmPopBackdrop" id="updateContact"> | |
718 | + <div class="customModalInner" style="max-width: 400px;"> | |
719 | + <div class="customModelBody" style="border-radius: 5px 5px 0 0;"> | |
720 | + <div class="col-md-2"><img class="src-image" src="img/images.jpg"></div> | |
721 | + <div class="col-md-10"> | |
722 | + <form> | |
723 | + Title:<br> | |
724 | + <input type="text" name="firstname" ng-model="updateData.title"><br> | |
725 | + Content:<br> | |
726 | + <input type="text" name="lastname" ng-model="updateData.content"> | |
727 | + </form> | |
728 | + </div> | |
729 | + <div class="clearfix"></div> | |
730 | + </div> | |
731 | + <div class="customModelFooter text-right" style="border-radius: 0 0 5px 5px;"> | |
732 | + <button class="btn" style="padding: 4px 0; width: 80px;" ng-click="acceptUpdateField()">Accept</button> | |
733 | + <button class="btn" style="padding: 4px 0; width: 80px;" ng-click="cancelUpdateField()">Cancel</button> | |
734 | + </div> | |
735 | + </div> | |
736 | +</div> | |
737 | + | |
710 | 738 | <div class="myLoader" ng-show="showLoader"> |
711 | 739 | <img src="../img/hourglass.gif" width="50px;"> |
712 | 740 | </div> | ... | ... |
app/partials/viewCompany/viewCompany.service.js
... | ... | @@ -70,6 +70,22 @@ |
70 | 70 | return deferred.promise; |
71 | 71 | } |
72 | 72 | |
73 | + this.updateCustomField = function(data){ | |
74 | + var deferred = $q.defer(); | |
75 | + $http({ | |
76 | + method : 'PUT', | |
77 | + url : BASE_URL.url +'/company/custom/contacts', | |
78 | + data : data, | |
79 | + headers : {'Content-Type': 'application/json'}, | |
80 | + }) | |
81 | + .then(function (result){ | |
82 | + deferred.resolve(result.data); | |
83 | + },function (result){ | |
84 | + deferred.resolve(result.data); | |
85 | + }) | |
86 | + return deferred.promise; | |
87 | + } | |
88 | + | |
73 | 89 | this.addPrimaryContact = function(data){ |
74 | 90 | var deferred = $q.defer(); |
75 | 91 | $http({ | ... | ... |