Commit af684be843d2efb9db2e9dd28f6c4cbaa88a08f2
1 parent
1422345c1f
Exists in
master
Refactor para obtener los botones desde la base de datos.
Showing
3 changed files
with
20 additions
and
114 deletions
Show diff stats
src/js/controller.js
1 | angular.module('focaBotoneraPrincipal') | 1 | angular.module('focaBotoneraPrincipal') |
2 | .controller('focaBotoneraPrincipalController', [ | 2 | .controller('focaBotoneraPrincipalController', [ |
3 | '$scope', '$location', | 3 | '$scope', '$location', 'botones', |
4 | function($scope, $location) { | 4 | function($scope, $location, botones) { |
5 | // TODO: Tomar estos datos desde el servicio | ||
6 | $scope.botones = [ | ||
7 | { | ||
8 | texto: 'Abrir Turno', | ||
9 | clase: 'botonera-principal-abrir-turno', | ||
10 | accion: '/turno-apertura' | ||
11 | }, | ||
12 | { | ||
13 | texto: 'Cerrar Turno', | ||
14 | clase: 'botonera-principal-cerrar-turno', | ||
15 | accion: '/turno-cierre' | ||
16 | }, | ||
17 | { | ||
18 | texto: 'Nota Pedido', | ||
19 | clase: 'botonera-principal-nota-pedido', | ||
20 | accion: '/venta-nota-pedido/crear' | ||
21 | }, | ||
22 | { | ||
23 | texto: 'Seguimiento GPS', | ||
24 | clase: 'botonera-principal-seguimiento', | ||
25 | accion: '/admin-seguimiento' | ||
26 | }, | ||
27 | { | ||
28 | texto: '', | ||
29 | clase: 'botonera-principal-vacio', | ||
30 | accion: '/' | ||
31 | }, | ||
32 | { | ||
33 | texto: '', | ||
34 | clase: 'botonera-principal-vacio', | ||
35 | accion: '/' | ||
36 | }, | ||
37 | { | ||
38 | texto: '', | ||
39 | clase: 'botonera-principal-vacio', | ||
40 | accion: '/' | ||
41 | }, | ||
42 | { | ||
43 | texto: '', | ||
44 | clase: 'botonera-principal-vacio', | ||
45 | accion: '/' | ||
46 | }, | ||
47 | { | ||
48 | texto: '', | ||
49 | clase: 'botonera-principal-vacio', | ||
50 | accion: '/' | ||
51 | }, | ||
52 | { | ||
53 | texto: '', | ||
54 | clase: 'botonera-principal-vacio', | ||
55 | accion: '/' | ||
56 | }, | ||
57 | { | ||
58 | texto: '', | ||
59 | clase: 'botonera-principal-vacio', | ||
60 | accion: '/' | ||
61 | }, | ||
62 | { | ||
63 | texto: '', | ||
64 | clase: 'botonera-principal-vacio', | ||
65 | accion: '/' | ||
66 | }, | ||
67 | { | ||
68 | texto: '', | ||
69 | clase: 'botonera-principal-vacio', | ||
70 | accion: '/' | ||
71 | }, | ||
72 | { | ||
73 | texto: '', | ||
74 | clase: 'botonera-principal-vacio', | ||
75 | accion: '/' | ||
76 | }, | ||
77 | { | ||
78 | texto: '', | ||
79 | clase: 'botonera-principal-vacio', | ||
80 | accion: '/' | ||
81 | }, | ||
82 | { | ||
83 | texto: '', | ||
84 | clase: 'botonera-principal-vacio', | ||
85 | accion: '/' | ||
86 | }, | ||
87 | { | ||
88 | texto: '', | ||
89 | clase: 'botonera-principal-vacio', | ||
90 | accion: '/' | ||
91 | }, | ||
92 | { | ||
93 | texto: '', | ||
94 | clase: 'botonera-principal-vacio', | ||
95 | accion: '/' | ||
96 | }, | ||
97 | { | ||
98 | texto: '', | ||
99 | clase: 'botonera-principal-vacio', | ||
100 | accion: '/' | ||
101 | }, | ||
102 | { | ||
103 | texto: '', | ||
104 | clase: 'botonera-principal-vacio', | ||
105 | accion: '/' | ||
106 | }, | ||
107 | { | ||
108 | texto: '', | ||
109 | clase: 'botonera-principal-vacio', | ||
110 | accion: '/' | ||
111 | } | ||
112 | ]; | ||
113 | |||
114 | $scope.paginas = []; | 5 | $scope.paginas = []; |
115 | $scope.paginas.push($scope.botones.slice(0, 15)); | 6 | $scope.paginas.push(botones.data); |
116 | $scope.paginas.push($scope.botones.slice(15, 30)); | ||
117 | 7 | ||
118 | $scope.irA = function(accion) { | 8 | $scope.irA = function(accion) { |
119 | $location.path(accion); | 9 | $location.path(accion); |
120 | }; | 10 | }; |
121 | 11 | ||
122 | $scope.logout = function() { | 12 | $scope.logout = function() { |
123 | $location.path('/logout'); | 13 | $location.path('/logout'); |
124 | }; | 14 | }; |
125 | } | 15 | } |
126 | ]); | 16 | ]); |
127 | 17 |
src/js/route.js
1 | angular.module('focaBotoneraPrincipal') | 1 | angular.module('focaBotoneraPrincipal') |
2 | .config(['$routeProvider', function($routeProvider) { | 2 | .config(['$routeProvider', function($routeProvider) { |
3 | $routeProvider.when('/', { | 3 | $routeProvider.when('/', { |
4 | controller: 'focaBotoneraPrincipalController', | 4 | controller: 'focaBotoneraPrincipalController', |
5 | templateUrl: 'src/views/foca-botonera-principal.html' | 5 | templateUrl: 'src/views/foca-botonera-principal.html', |
6 | resolve: { | ||
7 | botones: ['focaBotoneraPrincipalService', function(focaBotoneraPrincipalService) { | ||
8 | return focaBotoneraPrincipalService.obtenerBotones(); | ||
9 | }] | ||
10 | } | ||
6 | }); | 11 | }); |
7 | }]); | 12 | }]); |
8 | 13 |
src/js/service.js
File was created | 1 | angular.module('focaBotoneraPrincipal') | |
2 | .service('focaBotoneraPrincipalService', [ | ||
3 | '$http', 'API_ENDPOINT', | ||
4 | function($http, API_ENDPOINT) { | ||
5 | return { | ||
6 | obtenerBotones: function() { | ||
7 | return $http.get(API_ENDPOINT.URL + '/boton'); | ||
8 | } | ||
9 | }; | ||
10 | } | ||
11 | ]); | ||
12 |