#1265 worker.pbx da error si no tiene extensión

This commit is contained in:
Carlos Jimenez Ruiz 2019-03-29 10:51:02 +01:00
parent 1d6aeae7de
commit 14bd970fbc
4 changed files with 40 additions and 6 deletions

11
back/models/sip.js Normal file
View File

@ -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`
});
};

View File

@ -73,5 +73,7 @@
"Street cannot be empty": "Dirección no puede estar en blanco", "Street cannot be empty": "Dirección no puede estar en blanco",
"City cannot be empty": "Cuidad 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", "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"
} }

View File

@ -1,11 +1,8 @@
<mg-ajax path="/api/Sips/{{patch.params.id}}" options="vnPatch"></mg-ajax>
<vn-watcher <vn-watcher
vn-id="watcher" vn-id="watcher"
data="$ctrl.worker.sip" data="$ctrl.worker.sip">
form="form"
save="patch">
</vn-watcher> </vn-watcher>
<form name="form" ng-submit="watcher.submit()" compact> <form name="form" ng-submit="$ctrl.onSubmit()" compact>
<vn-card pad-large> <vn-card pad-large>
<vn-vertical> <vn-vertical>
<vn-horizontal> <vn-horizontal>

View File

@ -1,7 +1,31 @@
import ngModule from '../module'; 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', { ngModule.component('vnWorkerPbx', {
template: require('./index.html'), template: require('./index.html'),
controller: Controller,
bindings: { bindings: {
worker: '<' worker: '<'
} }