Merge branch 'master' of https://gitea.verdnatura.es/verdnatura/salix into test
gitea/salix/test This commit looks good
Details
gitea/salix/test This commit looks good
Details
This commit is contained in:
commit
8ad2344735
|
@ -8,7 +8,9 @@
|
||||||
<vn-textfield
|
<vn-textfield
|
||||||
vn-one
|
vn-one
|
||||||
label="Destination"
|
label="Destination"
|
||||||
ng-model="$ctrl.sms.destination">
|
ng-model="$ctrl.sms.destination"
|
||||||
|
required="true"
|
||||||
|
rule>
|
||||||
</vn-textfield>
|
</vn-textfield>
|
||||||
</vn-horizontal>
|
</vn-horizontal>
|
||||||
<vn-horizontal >
|
<vn-horizontal >
|
||||||
|
@ -18,6 +20,7 @@
|
||||||
ng-model="$ctrl.sms.message"
|
ng-model="$ctrl.sms.message"
|
||||||
rows="5"
|
rows="5"
|
||||||
maxlength="160"
|
maxlength="160"
|
||||||
|
required="true"
|
||||||
rule>
|
rule>
|
||||||
</vn-textarea>
|
</vn-textarea>
|
||||||
</vn-horizontal>
|
</vn-horizontal>
|
||||||
|
|
|
@ -28,12 +28,23 @@ class Controller extends Component {
|
||||||
|
|
||||||
onResponse(response) {
|
onResponse(response) {
|
||||||
if (response === 'accept') {
|
if (response === 'accept') {
|
||||||
this.$http.post(`Clients/${this.$params.id}/sendSms`, this.sms).then(res => {
|
try {
|
||||||
this.vnApp.showMessage(this.$translate.instant('SMS sent!'));
|
if (!this.sms.destination)
|
||||||
|
throw new Error(`The destination can't be empty`);
|
||||||
|
if (!this.sms.message)
|
||||||
|
throw new Error(`The message can't be empty`);
|
||||||
|
|
||||||
if (res.data) this.emit('send', {response: res.data});
|
this.$http.post(`Clients/${this.$params.id}/sendSms`, this.sms).then(res => {
|
||||||
});
|
this.vnApp.showMessage(this.$translate.instant('SMS sent!'));
|
||||||
|
|
||||||
|
if (res.data) this.emit('send', {response: res.data});
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
this.vnApp.showError(this.$translate.instant(e.message));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,26 @@ describe('Client', () => {
|
||||||
|
|
||||||
expect(controller.vnApp.showMessage).toHaveBeenCalledWith('SMS sent!');
|
expect(controller.vnApp.showMessage).toHaveBeenCalledWith('SMS sent!');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should call onResponse without the destination and show an error snackbar', () => {
|
||||||
|
controller.sms = {destinationFk: 101, message: 'My SMS'};
|
||||||
|
|
||||||
|
spyOn(controller.vnApp, 'showError');
|
||||||
|
|
||||||
|
controller.onResponse('accept');
|
||||||
|
|
||||||
|
expect(controller.vnApp.showError).toHaveBeenCalledWith(`The destination can't be empty`);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should call onResponse without the message and show an error snackbar', () => {
|
||||||
|
controller.sms = {destinationFk: 101, destination: 222222222};
|
||||||
|
|
||||||
|
spyOn(controller.vnApp, 'showError');
|
||||||
|
|
||||||
|
controller.onResponse('accept');
|
||||||
|
|
||||||
|
expect(controller.vnApp.showError).toHaveBeenCalledWith(`The message can't be empty`);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('charactersRemaining()', () => {
|
describe('charactersRemaining()', () => {
|
||||||
|
|
|
@ -3,3 +3,5 @@ Destination: Destinatario
|
||||||
Message: Mensaje
|
Message: Mensaje
|
||||||
SMS sent!: ¡SMS enviado!
|
SMS sent!: ¡SMS enviado!
|
||||||
Characters remaining: Carácteres restantes
|
Characters remaining: Carácteres restantes
|
||||||
|
The destination can't be empty: El destinatario no puede estar vacio
|
||||||
|
The message can't be empty: El mensaje no puede estar vacio
|
|
@ -370,10 +370,10 @@
|
||||||
</vn-dialog>
|
</vn-dialog>
|
||||||
|
|
||||||
<!-- SMS Dialog -->
|
<!-- SMS Dialog -->
|
||||||
<vn-client-sms
|
<vn-ticket-sms
|
||||||
vn-id="sms"
|
vn-id="sms"
|
||||||
sms="$ctrl.newSMS">
|
sms="$ctrl.newSMS">
|
||||||
</vn-client-sms>
|
</vn-ticket-sms>
|
||||||
|
|
||||||
<vn-confirm
|
<vn-confirm
|
||||||
vn-id="delete-lines"
|
vn-id="delete-lines"
|
||||||
|
|
|
@ -8,7 +8,9 @@
|
||||||
<vn-textfield
|
<vn-textfield
|
||||||
vn-one
|
vn-one
|
||||||
label="Destination"
|
label="Destination"
|
||||||
ng-model="$ctrl.sms.destination">
|
ng-model="$ctrl.sms.destination"
|
||||||
|
required="true"
|
||||||
|
rule>
|
||||||
</vn-textfield>
|
</vn-textfield>
|
||||||
</vn-horizontal>
|
</vn-horizontal>
|
||||||
<vn-horizontal >
|
<vn-horizontal >
|
||||||
|
@ -18,6 +20,7 @@
|
||||||
ng-model="$ctrl.sms.message"
|
ng-model="$ctrl.sms.message"
|
||||||
rows="5"
|
rows="5"
|
||||||
maxlength="160"
|
maxlength="160"
|
||||||
|
required="true"
|
||||||
rule>
|
rule>
|
||||||
</vn-textarea>
|
</vn-textarea>
|
||||||
</vn-horizontal>
|
</vn-horizontal>
|
||||||
|
|
|
@ -28,12 +28,23 @@ class Controller extends Component {
|
||||||
|
|
||||||
onResponse(response) {
|
onResponse(response) {
|
||||||
if (response === 'accept') {
|
if (response === 'accept') {
|
||||||
this.$http.post(`Tickets/${this.$params.id}/sendSms`, this.sms).then(res => {
|
try {
|
||||||
this.vnApp.showMessage(this.$translate.instant('SMS sent!'));
|
if (!this.sms.destination)
|
||||||
|
throw new Error(`The destination can't be empty`);
|
||||||
|
if (!this.sms.message)
|
||||||
|
throw new Error(`The message can't be empty`);
|
||||||
|
|
||||||
if (res.data) this.emit('send', {response: res.data});
|
this.$http.post(`Tickets/${this.$params.id}/sendSms`, this.sms).then(res => {
|
||||||
});
|
this.vnApp.showMessage(this.$translate.instant('SMS sent!'));
|
||||||
|
|
||||||
|
if (res.data) this.emit('send', {response: res.data});
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
this.vnApp.showError(this.$translate.instant(e.message));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,26 @@ describe('Ticket', () => {
|
||||||
|
|
||||||
expect(controller.vnApp.showMessage).toHaveBeenCalledWith('SMS sent!');
|
expect(controller.vnApp.showMessage).toHaveBeenCalledWith('SMS sent!');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should call onResponse without the destination and show an error snackbar', () => {
|
||||||
|
controller.sms = {destinationFk: 101, message: 'My SMS'};
|
||||||
|
|
||||||
|
spyOn(controller.vnApp, 'showError');
|
||||||
|
|
||||||
|
controller.onResponse('accept');
|
||||||
|
|
||||||
|
expect(controller.vnApp.showError).toHaveBeenCalledWith(`The destination can't be empty`);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should call onResponse without the message and show an error snackbar', () => {
|
||||||
|
controller.sms = {destinationFk: 101, destination: 222222222};
|
||||||
|
|
||||||
|
spyOn(controller.vnApp, 'showError');
|
||||||
|
|
||||||
|
controller.onResponse('accept');
|
||||||
|
|
||||||
|
expect(controller.vnApp.showError).toHaveBeenCalledWith(`The message can't be empty`);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('charactersRemaining()', () => {
|
describe('charactersRemaining()', () => {
|
||||||
|
|
|
@ -3,3 +3,5 @@ Destination: Destinatario
|
||||||
Message: Mensaje
|
Message: Mensaje
|
||||||
SMS sent!: ¡SMS enviado!
|
SMS sent!: ¡SMS enviado!
|
||||||
Characters remaining: Carácteres restantes
|
Characters remaining: Carácteres restantes
|
||||||
|
The destination can't be empty: El destinatario no puede estar vacio
|
||||||
|
The message can't be empty: El mensaje no puede estar vacio
|
Loading…
Reference in New Issue