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: '<' } diff --git a/package-lock.json b/package-lock.json index 3702498e9..3b85ba388 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10821,6 +10821,7 @@ "version": "1.1.11", "bundled": true, "dev": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -10993,6 +10994,7 @@ "version": "3.0.4", "bundled": true, "dev": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -16746,7 +16748,7 @@ }, "xmlbuilder": { "version": "9.0.7", - "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-9.0.7.tgz", + "resolved": "http://registry.npmjs.org/xmlbuilder/-/xmlbuilder-9.0.7.tgz", "integrity": "sha1-Ey7mPS7FVlxVfiD0wi35rKaGsQ0=" }, "xmlcreate": {