Advertisement
Guest User

Untitled

a guest
Sep 20th, 2017
424
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.90 KB | None | 0 0
  1. <table id="lista-compras" class="table table-striped">
  2. <thead>
  3. <tr>
  4. <th sortable="nombre" class="sortable">Nombre</th>
  5. <th sortable="dirreccion" class="sortable">Dirreccion</th>
  6. <th sortable="telefono" class="sortable">Telefono</th>
  7. <th width="15%"> </th>
  8. </tr>
  9. </thead>
  10. <tbody>
  11. <tr grid-item class="comprado-{{ item.comprado }}">
  12. <td ng-bind="item.nombre"></td>
  13. <td ng-bind="item.dirreccion"></td>
  14. <td ng-bind="item.telefono"></td>
  15. <td>
  16. <button class="btn btn-despegar btn-small edit" ng-click="editarItem($index)">
  17. <i class="fa fa-pencil-square-o" aria-hidden="true"></i>
  18. </button>
  19. <button class="btn btn-danger btn-small" ng-click="deleteItem($index)">
  20. <i class="fa fa-trash-o" aria-hidden="true"></i>
  21. </button>
  22. </td>
  23. </tr>
  24. </tbody>
  25. </table>
  26.  
  27. var app = angular.module('myModule', ['ui.bootstrap', 'dataGrid', 'pagination']);
  28. app.controller('ListaComprasController',['$scope','$anchorScroll',function($scope,$anchorScroll) {
  29. $scope.form = true;
  30. $scope.item = {};
  31. $scope.pagingOptions = {
  32. pageSizes: [5, 10, 20, 100],
  33. pageSize: 3,
  34. currentPage: 1
  35. };
  36.  
  37.  
  38. $scope.itens = [
  39. {nombre: 'Juan', telefono: 212122, descripcion: "Preuba 1",especialidades:"tarea",dirreccion:"Siempre Viva 920",horarioDesde:"19:00",horarioHasta:"22:00",telefonoCOM:"223123",emailCOM:"tesr@sdasad.com",namelastADM:"Asesores SA",mySerNameADM:"Laz",myphoneADM:22132133,namelast:"Sergio",myphoneCOM:656565,mySerNameCOM:"Rodriguez",emailADM:"tesr@sdasad.com",checkidem:true},
  40. {nombre: 'Juan Jose', telefono: 3410220, descripcion: "tadsasasdas",especialidades:"tarea",dirreccion:"San Martin 555",horarioDesde:"19:00",horarioHasta:"22:00",telefonoCOM:"223123",emailCOM:"tesr@sdasad.com",namelastADM:"Asesores SA",mySerNameADM:"Russef",myphoneADM:665+665656,namelast:"Lort",myphoneCOM:656565,mySerNameCOM:"Arenales",emailADM:"tesr@gmail.com",checkidem:true},
  41. {nombre: 'Pablo', telefono: 3410220, descripcion: "tadsasasdas",especialidades:"tarea",dirreccion:"Siis 64",horarioDesde:"19:00",horarioHasta:"22:00",telefonoCOM:"223123",emailCOM:"tesr@sdasad.com",namelastADM:"Paz SA",mySerNameADM:"Perez",myphoneADM:9899878745,namelast:"Matias",myphoneCOM:656565,mySerNameCOM:"Chico",emailADM:"delivery12@gmail.com",checkidem:true},
  42. {nombre: 'Paulo', telefono: 3410220, descripcion: "tadsasasdas",especialidades:"Horario",dirreccion:"Viaje 4",horarioDesde:"19:00",horarioHasta:"22:00",telefonoCOM:"223123",emailCOM:"tesr@sdasad.com",namelastADM:"Loren SA",mySerNameADM:"Matia",myphoneADM:9899878745,namelast:"Pablo",myphoneCOM:45654,mySerNameCOM:"Vaez",emailADM:"deliver231y@gmail.com",checkidem:true},
  43. {nombre: 'Jorge', telefono: 3410220, descripcion: "tadsasasdas",especialidades:"Venta",dirreccion:"Promo Viva 313",horarioDesde:"19:00",horarioHasta:"22:00",telefonoCOM:"223123",emailCOM:"tesr@sdasad.com",namelastADM:"Asesores SRL",mySerNameADM:"Sam",myphoneADM:689898,namelast:"Rodrigo",myphoneCOM:545646,mySerNameCOM:"Tare",emailADM:"delivery12@gmail.com",checkidem:true},
  44. {nombre: 'Juan Carlos', telefono: 212122, descripcion: "tadsasasdas",especialidades:"tarea",dirreccion:"Siempre Viva 131",horarioDesde:"19:00",horarioHasta:"22:00",telefonoCOM:"223123",emailCOM:"tesr@sdasad.com",namelastADM:"TIKI SA",mySerNameADM:"Per",myphoneADM:764876578,namelast:"Sergio",myphoneCOM:4515656,mySerNameCOM:"Stark",emailADM:"delivery23@gmail.com",checkidem:true}
  45. ];
  46. $scope.gridOptions = {
  47. data: $scope.itens, //required parameter - array with data
  48. //optional parameter - start sort options
  49. /*sort: {
  50. predicate: 'nombre',
  51. direction: 'asc'
  52. }*/
  53. };
  54. $scope.$watch(
  55. function() {
  56. return {
  57. currentPage: $scope.pagingOptions.currentPage,
  58. pageSize: $scope.pagingOptions.pageSize
  59. };
  60. },
  61. function(newVal, oldVal) {
  62. // Reset to page 1 when the page size changes
  63. if (newVal.pageSize !== oldVal.pageSize) {
  64. $scope.pagingOptions.currentPage = 1;
  65. }
  66.  
  67. //$scope.fillGrid($scope.pagingOptions.currentPage, $scope.pagingOptions.pageSize);
  68. },
  69. true);
  70. $scope.adicionaItem = function () {
  71. $scope.itens.push(
  72. {
  73. nombre: $scope.item.nombre,
  74. telefono: $scope.item.telefono,
  75. descripcion: $scope.item.descripcion,
  76. especialidades: $scope.item.especialidades,
  77. dirreccion: $scope.item.dirreccion,
  78. horarioDesde: $scope.item.horarioDesde,
  79. horarioHasta: $scope.item.horarioHasta,
  80. checkCom: $scope.item.checkCom,
  81. nombreCom: $scope.item.nombreCom,
  82. apellidoCom: $scope.item.apellidoCom,
  83. telefonoCom: $scope.item.telefonoCom,
  84. emailCom: $scope.item.emailCom
  85. }
  86. );
  87. $scope.item.produto = $scope.item.quantidade = '';
  88. toastr.success("Item adicionado com sucesso.");
  89. $scope.form = true;
  90. };
  91. $scope.addItem = function () {
  92. $scope.form = false;
  93. };
  94. $scope.editarItem = function(index){
  95. $scope.form = false;
  96. $scope.item = $scope.itens[index];
  97. $scope.edit = true;
  98. $scope.scroll = function () {
  99. $anchorScroll();
  100. };
  101. };
  102.  
  103. $scope.applyChanges = function(index){
  104. $scope.item = {};
  105. $scope.edit = false;
  106. $scope.form = true;
  107. toastr.success("Item alterado com sucesso.");
  108. };
  109. $scope.CancelarItem = function(index){
  110. $scope.edit = false;
  111. $scope.form = true;
  112. $scope.item = {};
  113. };
  114. $scope.deleteItem = function(row){
  115. var index = $scope.gridOptions.data.indexOf(row.entity);
  116. $scope.gridOptions.data.splice(index, 1);
  117. console.log(index);
  118. //$scope.itens.splice(index, 1);
  119. toastr.success("Item removido com sucesso.");
  120. };
  121. }]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement