Commit bcdbf6b7e86aa853d82311983f6d318ef1fad328

Authored by Jose Pinto
Exists in master

Merge branch 'master' into 'master'

Master(efernandez)

See merge request !2
... ... @@ -17,9 +17,9 @@
17 17 "author": "",
18 18 "license": "ISC",
19 19 "devDependencies": {
20   - "angular": "^1.7.5",
  20 + "angular": "^1.7.7",
21 21 "angular-route": "^1.7.5",
22   - "bootstrap": "^4.2.1",
  22 + "bootstrap": "^4.3.1",
23 23 "gulp": "^3.9.1",
24 24 "gulp-angular-templatecache": "^2.2.6",
25 25 "gulp-clean": "^0.4.0",
... ... @@ -32,7 +32,7 @@
32 32 "gulp-uglify-es": "^1.0.4",
33 33 "jasmine-core": "^3.3.0",
34 34 "jquery": "^3.3.1",
35   - "jshint": "^2.9.7",
  35 + "jshint": "^2.10.1",
36 36 "pre-commit": "^1.2.2",
37 37 "pump": "^3.0.0"
38 38 }
src/js/controller.js
... ... @@ -5,12 +5,15 @@ angular.module('focaConfigurarTerminal')
5 5 '$location',
6 6 'focaConfigurarTerminalService',
7 7 'focaBotoneraLateralService',
  8 + 'focaModalService',
8 9 function(
9 10 $scope,
10 11 $timeout,
11 12 $location,
12 13 focaConfigurarTerminalService,
13   - focaBotoneraLateralService) {
  14 + focaBotoneraLateralService,
  15 + focaModalService) {
  16 +
14 17 $scope.now = new Date();
15 18 $scope.focused = 1;
16 19 $scope.terminal = {
... ... @@ -25,15 +28,46 @@ angular.module('focaConfigurarTerminal')
25 28 });
26 29  
27 30 $scope.guardar = function() {
  31 +
28 32 focaConfigurarTerminalService
29   - .configTerminal($scope.terminal)
30   - .then(function() {
31   - $location.path('/');
  33 + .nombreEmpresa()
  34 + .then(function(res) {
  35 +
  36 + var json = {
  37 + terminal: $scope.terminal,
  38 + empresa: res.data.NOM,
  39 + idEmpresa: res.data.idEmpresa
  40 + };
  41 +
  42 + focaConfigurarTerminalService
  43 + .guardarTerminalBase(json)
  44 + .then(terminalLocal)
  45 + .catch(function(err) {
  46 +
  47 + if(err.status === 404) {
  48 + focaModalService.alert('Empresa no configurada');
  49 + return;
  50 + }
  51 +
  52 + focaModalService
  53 + .alert('Hubo un error al dar de alta esta terminal');
  54 + });
  55 +
32 56 });
33 57 };
34 58  
35 59 $scope.next = function(key) {
  60 +
36 61 if(key === 13) $scope.focused ++;
37 62 };
  63 +
  64 + function terminalLocal() {
  65 + focaConfigurarTerminalService.configTerminal($scope.terminal).then(terminar);
  66 + }
  67 +
  68 + function terminar() {
  69 +
  70 + $location.path('/');
  71 + }
38 72 }
39 73 ]);
... ... @@ -3,6 +3,12 @@ angular.module('focaConfigurarTerminal')
3 3 return {
4 4 configTerminal: function(terminal) {
5 5 return $http.post(API_ENDPOINT.URL + '/config/terminal', terminal);
  6 + },
  7 + nombreEmpresa: function() {
  8 + return $http.get(API_ENDPOINT.URL + '/empresa/obtener/primera');
  9 + },
  10 + guardarTerminalBase: function(json) {
  11 + return $http.post(API_ENDPOINT.ENDPOINT_BASE + '/terminal/agregar', json);
6 12 }
7 13 };
8 14 }]);