Guest User

Untitled

a guest
Jan 18th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.79 KB | None | 0 0
  1. <div class="spacer input-group">
  2. <div class="input-group-addon">
  3. <span class="glyphicon glyphicon-search"></span>
  4. </div>
  5. <input type="text" ng-model="searchText" class="form-control" placeholder="Search name..." ng-change="search(searchText)"/>
  6. <div class="input-group-btn">
  7. <button class="btn btn-default" ng-click="razRecherche()">
  8. <span class="glyphicon glyphicon-remove"></span>
  9. </button>
  10. </div>
  11. </div>
  12.  
  13. <div>
  14. <div>HERE THE RADIO BUTTONS</div>
  15. </div>
  16.  
  17.  
  18. <div class="table-responsive" id="allContacts">
  19. <table ng-show="contacts.length" class="table table-striped table-hover spacer">
  20. <thead>
  21. <tr>
  22. <th class="colPerson">
  23. <a href="" ng-click="personsSort('PERSON')">Person</a>
  24. <span class="hSpacer" ng-class="cssChevronsTri('PERSON')"></span>
  25. </th>
  26. <th class="colCompany">
  27. <a href="" ng-click="personsSort('COMPANY')">Company</a>
  28. <span class="hSpacer" ng-class="cssChevronsTri('COMPANY')"></span>
  29. </th>
  30. <th class="colDescription">
  31. <a href="" ng-click="personsSort('REQUESTDESCRIPTION')">Description</a>
  32. <span class="hSpacer" ng-class="cssChevronsTri('REQUESTDESCRIPTION')"></span>
  33. </th>
  34. </tr>
  35. </thead>
  36.  
  37.  
  38. <tbody ng-repeat="contact in contacts | filter:searchText | orderBy:champTri:triDescendant">
  39. <tr class="clickable">
  40. <td class="colPerson" ng-click="selContact(contact,contact.ID)" ng-class="{sel:selIdx==$index}"><a href="#/view-contacts/{{contact.ID}}">{{contact.PERSON}}</a></td>
  41. <td class="colCompany" ng-click="selContact(contact,contact.ID)">{{contact.COMPANY}}</td>
  42. <td class="colDescription" ng-click="selContact(contact,contact.ID)">{{contact.REQUESTDESCRIPTION}}</td>
  43. </tr>
  44. </tbody>
  45. </table>
  46. </div>
  47.  
  48. app.controller('ctrlContacts', function ($scope, $timeout, ContactService){
  49.  
  50. $scope.search = function(searchText) {
  51. $scope.reloadPreviousSearch = false;
  52.  
  53. if (!searchText.length) {
  54. //alert("searchText empty");
  55. }
  56. if (searchText.length>2) {
  57.  
  58. $timeout(function () {
  59. // RETRIEVE DATA FROM JSON OBJECT OF THE SERVER SEVICE AND A DB QUERY - OK
  60. ContactService.fastSearch(searchText).success(function(contacts){
  61. console.log("query fastSearch OK");
  62. var length = contacts.length;
  63. $scope.loading = false;
  64.  
  65. if (length == 0) {
  66. $scope.searchButtonText = "No result";
  67. }else {
  68. $scope.searchButtonText = length + " results found";
  69. }
  70. // For the orderby date
  71. for (var i=0; i<length; i++) {
  72. if(contacts[i].REQUESTTRUEDATE!=""){
  73. contacts[i].REQUESTTRUEDATE = new Date(contacts[i].REQUESTTRUEDATE.replace(/-/g,"/"));
  74. }else{
  75. contacts[i].REQUESTTRUEDATE=null;
  76. }
  77. }
  78.  
  79. $scope.contacts = contacts;
  80. $scope.champTri='PERSON';
  81.  
  82. $scope.selIdx= -1;
  83.  
  84. $scope.selContact=function(contact,idx){
  85. $scope.selectedContact=contact;
  86. $scope.selIdx=idx;
  87. window.location="#/view-contacts/" + idx;
  88. }
  89.  
  90. $scope.isSelContact=function(contact){
  91. return $scope.selectedContact===contact;
  92. }
  93.  
  94. });
  95. }, 1000);
  96. }else{
  97. $scope.contacts=null;
  98. }
  99. }
  100.  
  101.  
  102. // SEARCH
  103.  
  104. $scope.searchText = null;
  105. $scope.razRecherche = function() {
  106. $scope.searchText = null;
  107. $scope.contacts=null;
  108. }
  109.  
  110. // SORT
  111.  
  112. $scope.champTri = null;
  113. $scope.triDescendant = false;
  114. $scope.personsSort = function(champ) {
  115. if ($scope.champTri == champ) {
  116. $scope.triDescendant = !$scope.triDescendant;
  117. } else {
  118. $scope.champTri = champ;
  119. $scope.triDescendant = false;
  120. }
  121. }
  122.  
  123. $scope.cssChevronsTri = function(champ) {
  124. return {
  125. glyphicon: $scope.champTri == champ,
  126. 'glyphicon-chevron-up' : $scope.champTri == champ && !$scope.triDescendant,
  127. 'glyphicon-chevron-down' : $scope.champTri == champ && $scope.triDescendant
  128. };
  129. }
  130.  
  131. });
Add Comment
Please, Sign In to add comment