opportunity.controller.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. angular.module('odoo')
  2. .controller('OpportunitiesController', function (
  3. $scope,
  4. $ionicActionSheet
  5. ) {
  6. $scope.stages = [
  7. {
  8. title: 'Nuevo'
  9. },
  10. {
  11. title: 'Muerta'
  12. },
  13. {
  14. title: 'Calificación'
  15. },
  16. {
  17. title: 'Propuesta'
  18. },
  19. {
  20. title: 'Negociación'
  21. },
  22. {
  23. title: 'Ganado'
  24. },
  25. {
  26. title: 'Perdido'
  27. }
  28. ];
  29. $scope.opportunities = [
  30. {
  31. name: 'Op. 1',
  32. stage: 'Nuevo'
  33. },
  34. {
  35. name: 'Op. 2',
  36. stage: 'Perdido'
  37. },
  38. {
  39. name: 'Op. 3',
  40. stage: 'Propuesta'
  41. },
  42. {
  43. name: 'Op. 1',
  44. stage: 'Nuevo'
  45. },
  46. {
  47. name: 'Op. 1',
  48. stage: 'Nuevo'
  49. },
  50. {
  51. name: 'Op. 1',
  52. stage: 'Nuevo'
  53. }
  54. ];
  55. $scope.title = 'Nuevo';
  56. $scope.loading = false;
  57. $scope.selected = -1;
  58. $scope.$on("$ionicSlides.sliderInitialized", function (event, data){
  59. $scope.slider = data.slider;
  60. });
  61. $scope.$on("$ionicSlides.slideChangeEnd", function (event, data) {
  62. console.log($scope.slider);
  63. $scope.stageChanged(data.slider.activeIndex);
  64. });
  65. /**
  66. * Change the state
  67. */
  68. $scope.changeStage = function (mode) {
  69. $scope.loading = true;
  70. if (mode) {
  71. $scope.slider.slideNext();
  72. } else {
  73. $scope.slider.slidePrev();
  74. }
  75. $scope.loading = false;
  76. }
  77. /**
  78. * Change stage name on title
  79. */
  80. $scope.stageChanged = function (index) {
  81. $scope.title = $scope.stages[index].title;
  82. $scope.$apply();
  83. }
  84. /**
  85. * Open the actionsheet action options
  86. */
  87. $scope.openOptions = function (index) {
  88. $scope.selected = index;
  89. $ionicActionSheet.show({
  90. titleText: 'Acciones',
  91. buttons: [
  92. {
  93. text: '<i class="icon ion-arrow-expand positive"></i> Abrir'
  94. },
  95. {
  96. text: '<i class="icon ion-forward positive"></i> Mover a'
  97. }
  98. ],
  99. destructiveText: '<i class="icon ion-trash-a assertive"></i> Eliminar',
  100. cancel: function() {
  101. $scope.customer = {};
  102. $scope.selected = -1;
  103. },
  104. buttonClicked: function(index) {
  105. switch (index) {
  106. case 0:
  107. $scope.show();
  108. break;
  109. case 1:
  110. $scope.addContact();
  111. break;
  112. default:
  113. $scope.show();
  114. }
  115. return true;
  116. },
  117. destructiveButtonClicked: function() {
  118. $scope.delete();
  119. return true;
  120. }
  121. });
  122. }
  123. });