From 14bd970fbc1efa2fc7448dd702ebe086c3dc00f3 Mon Sep 17 00:00:00 2001 From: Carlos Jimenez Ruiz Date: Fri, 29 Mar 2019 10:51:02 +0100 Subject: [PATCH] =?UTF-8?q?#1265=20worker.pbx=20da=20error=20si=20no=20tie?= =?UTF-8?q?ne=20extensi=C3=B3n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- back/models/sip.js | 11 +++++++++++ loopback/locale/es.json | 4 +++- modules/worker/front/pbx/index.html | 7 ++----- modules/worker/front/pbx/index.js | 24 ++++++++++++++++++++++++ 4 files changed, 40 insertions(+), 6 deletions(-) create mode 100644 back/models/sip.js diff --git a/back/models/sip.js b/back/models/sip.js new file mode 100644 index 000000000..62ae1eff9 --- /dev/null +++ b/back/models/sip.js @@ -0,0 +1,11 @@ +module.exports = Self => { + // Validations + + Self.validatesUniquenessOf('extension', { + message: `The extension must be unique` + }); + + Self.validatesPresenceOf('secret', { + message: `The secret can't be blank` + }); +}; diff --git a/loopback/locale/es.json b/loopback/locale/es.json index d4f3733b0..a67926e6f 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -73,5 +73,7 @@ "Street cannot be empty": "Dirección no puede estar en blanco", "City cannot be empty": "Cuidad no puede estar en blanco", "Code cannot be blank": "Código no puede estar en blanco", - "You cannot remove this department": "No puedes eliminar este departamento" + "You cannot remove this department": "No puedes eliminar este departamento", + "The extension must be unique": "La extensión debe ser unica", + "The secret can't be blank": "La contraseña no puede estar en blanco" } \ No newline at end of file diff --git a/modules/worker/front/pbx/index.html b/modules/worker/front/pbx/index.html index 3fa8c9bd8..931cf70fc 100644 --- a/modules/worker/front/pbx/index.html +++ b/modules/worker/front/pbx/index.html @@ -1,11 +1,8 @@ - + data="$ctrl.worker.sip"> -
+ diff --git a/modules/worker/front/pbx/index.js b/modules/worker/front/pbx/index.js index 70dcc9aef..9e0cef8ec 100644 --- a/modules/worker/front/pbx/index.js +++ b/modules/worker/front/pbx/index.js @@ -1,7 +1,31 @@ import ngModule from '../module'; +class Controller { + constructor($scope, $http) { + this.$scope = $scope; + this.$http = $http; + } + + onSubmit() { + const sip = this.worker.sip; + const params = { + userFk: this.worker.userFk, + extension: sip.extension, + secret: sip.secret + }; + this.$scope.watcher.check(); + this.$http.patch('/api/Sips', params).then(() => { + this.$scope.watcher.updateOriginalData(); + this.$scope.watcher.notifySaved(); + }); + } +} + +Controller.$inject = ['$scope', '$http']; + ngModule.component('vnWorkerPbx', { template: require('./index.html'), + controller: Controller, bindings: { worker: '<' }