2106 - Sms max length fix
gitea/salix/2106-sms_send_with_dots This commit looks good
Details
gitea/salix/2106-sms_send_with_dots This commit looks good
Details
This commit is contained in:
parent
09972f6597
commit
84bf95db13
|
@ -13,20 +13,27 @@
|
||||||
rule>
|
rule>
|
||||||
</vn-textfield>
|
</vn-textfield>
|
||||||
</vn-horizontal>
|
</vn-horizontal>
|
||||||
<vn-horizontal >
|
<vn-horizontal>
|
||||||
<vn-textarea vn-one
|
<vn-textarea vn-one
|
||||||
vn-id="message"
|
vn-id="message"
|
||||||
label="Message"
|
label="Message"
|
||||||
ng-model="$ctrl.sms.message"
|
ng-model="$ctrl.sms.message"
|
||||||
|
info="Special characters like accents counts as a multiple"
|
||||||
rows="5"
|
rows="5"
|
||||||
maxlength="160"
|
|
||||||
required="true"
|
required="true"
|
||||||
rule>
|
rule>
|
||||||
</vn-textarea>
|
</vn-textarea>
|
||||||
</vn-horizontal>
|
</vn-horizontal>
|
||||||
<vn-horizontal>
|
<vn-horizontal>
|
||||||
<span>
|
<span>
|
||||||
{{'Characters remaining' | translate}}: {{$ctrl.charactersRemaining()}}
|
{{'Characters remaining' | translate}}:
|
||||||
|
<vn-chip translate-attr="{title: 'Packing'}" ng-class="{
|
||||||
|
'colored': $ctrl.charactersRemaining() > 25,
|
||||||
|
'warning': $ctrl.charactersRemaining() <= 25,
|
||||||
|
'alert': $ctrl.charactersRemaining() < 0,
|
||||||
|
}">
|
||||||
|
{{$ctrl.charactersRemaining()}}
|
||||||
|
</vn-chip>
|
||||||
</span>
|
</span>
|
||||||
</vn-horizontal>
|
</vn-horizontal>
|
||||||
</section>
|
</section>
|
||||||
|
|
|
@ -17,13 +17,12 @@ class Controller extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
charactersRemaining() {
|
charactersRemaining() {
|
||||||
let elementMaxLength;
|
|
||||||
let textAreaLength;
|
|
||||||
const element = this.$scope.message;
|
const element = this.$scope.message;
|
||||||
|
const value = element.input.value;
|
||||||
|
|
||||||
textAreaLength = element.input.textLength;
|
const maxLength = 160;
|
||||||
elementMaxLength = element.maxlength;
|
const textAreaLength = new Blob([value]).size;
|
||||||
return elementMaxLength - textAreaLength;
|
return maxLength - textAreaLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
onResponse(response) {
|
onResponse(response) {
|
||||||
|
@ -33,6 +32,8 @@ class Controller extends Component {
|
||||||
throw new Error(`The destination can't be empty`);
|
throw new Error(`The destination can't be empty`);
|
||||||
if (!this.sms.message)
|
if (!this.sms.message)
|
||||||
throw new Error(`The message can't be empty`);
|
throw new Error(`The message can't be empty`);
|
||||||
|
if (this.charactersRemaining() < 0)
|
||||||
|
throw new Error(`The message it's too long`);
|
||||||
|
|
||||||
this.$http.post(`Clients/${this.$params.id}/sendSms`, this.sms).then(res => {
|
this.$http.post(`Clients/${this.$params.id}/sendSms`, this.sms).then(res => {
|
||||||
this.vnApp.showMessage(this.$translate.instant('SMS sent!'));
|
this.vnApp.showMessage(this.$translate.instant('SMS sent!'));
|
||||||
|
|
|
@ -15,6 +15,11 @@ describe('Client', () => {
|
||||||
controller = $componentController('vnClientSms', {$element, $scope});
|
controller = $componentController('vnClientSms', {$element, $scope});
|
||||||
controller.client = {id: 101};
|
controller.client = {id: 101};
|
||||||
controller.$params = {id: 101};
|
controller.$params = {id: 101};
|
||||||
|
controller.$scope.message = {
|
||||||
|
input: {
|
||||||
|
value: 'My SMS'
|
||||||
|
}
|
||||||
|
};
|
||||||
}));
|
}));
|
||||||
|
|
||||||
describe('onResponse()', () => {
|
describe('onResponse()', () => {
|
||||||
|
@ -56,14 +61,13 @@ describe('Client', () => {
|
||||||
it('should return the characters remaining in a element', () => {
|
it('should return the characters remaining in a element', () => {
|
||||||
controller.$scope.message = {
|
controller.$scope.message = {
|
||||||
input: {
|
input: {
|
||||||
textLength: 50
|
value: 'My message 0€'
|
||||||
},
|
}
|
||||||
maxlength: 150
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let result = controller.charactersRemaining();
|
let result = controller.charactersRemaining();
|
||||||
|
|
||||||
expect(result).toEqual(100);
|
expect(result).toEqual(145);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -4,4 +4,6 @@ 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 destination can't be empty: El destinatario no puede estar vacio
|
||||||
The message can't be empty: El mensaje no puede estar vacio
|
The message can't be empty: El mensaje no puede estar vacio
|
||||||
|
The message it's too long: El mensaje es demasiado largo
|
||||||
|
Special characters like accents counts as a multiple: Carácteres especiales como los acentos cuentan como varios
|
|
@ -18,15 +18,22 @@
|
||||||
vn-id="message"
|
vn-id="message"
|
||||||
label="Message"
|
label="Message"
|
||||||
ng-model="$ctrl.sms.message"
|
ng-model="$ctrl.sms.message"
|
||||||
|
info="Special characters like accents counts as a multiple"
|
||||||
rows="5"
|
rows="5"
|
||||||
maxlength="160"
|
|
||||||
required="true"
|
required="true"
|
||||||
rule>
|
rule>
|
||||||
</vn-textarea>
|
</vn-textarea>
|
||||||
</vn-horizontal>
|
</vn-horizontal>
|
||||||
<vn-horizontal>
|
<vn-horizontal>
|
||||||
<span>
|
<span>
|
||||||
{{'Characters remaining' | translate}}: {{$ctrl.charactersRemaining()}}
|
{{'Characters remaining' | translate}}:
|
||||||
|
<vn-chip translate-attr="{title: 'Packing'}" ng-class="{
|
||||||
|
'colored': $ctrl.charactersRemaining() > 25,
|
||||||
|
'warning': $ctrl.charactersRemaining() <= 25,
|
||||||
|
'alert': $ctrl.charactersRemaining() < 0,
|
||||||
|
}">
|
||||||
|
{{$ctrl.charactersRemaining()}}
|
||||||
|
</vn-chip>
|
||||||
</span>
|
</span>
|
||||||
</vn-horizontal>
|
</vn-horizontal>
|
||||||
</section>
|
</section>
|
||||||
|
|
|
@ -17,13 +17,12 @@ class Controller extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
charactersRemaining() {
|
charactersRemaining() {
|
||||||
let elementMaxLength;
|
|
||||||
let textAreaLength;
|
|
||||||
const element = this.$scope.message;
|
const element = this.$scope.message;
|
||||||
|
const value = element.input.value;
|
||||||
|
|
||||||
textAreaLength = element.input.textLength;
|
const maxLength = 160;
|
||||||
elementMaxLength = element.maxlength;
|
const textAreaLength = new Blob([value]).size;
|
||||||
return elementMaxLength - textAreaLength;
|
return maxLength - textAreaLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
onResponse(response) {
|
onResponse(response) {
|
||||||
|
@ -33,6 +32,8 @@ class Controller extends Component {
|
||||||
throw new Error(`The destination can't be empty`);
|
throw new Error(`The destination can't be empty`);
|
||||||
if (!this.sms.message)
|
if (!this.sms.message)
|
||||||
throw new Error(`The message can't be empty`);
|
throw new Error(`The message can't be empty`);
|
||||||
|
if (this.charactersRemaining() < 0)
|
||||||
|
throw new Error(`The message it's too long`);
|
||||||
|
|
||||||
this.$http.post(`Tickets/${this.$params.id}/sendSms`, this.sms).then(res => {
|
this.$http.post(`Tickets/${this.$params.id}/sendSms`, this.sms).then(res => {
|
||||||
this.vnApp.showMessage(this.$translate.instant('SMS sent!'));
|
this.vnApp.showMessage(this.$translate.instant('SMS sent!'));
|
||||||
|
|
|
@ -14,6 +14,11 @@ describe('Ticket', () => {
|
||||||
$element = angular.element('<vn-dialog></vn-dialog>');
|
$element = angular.element('<vn-dialog></vn-dialog>');
|
||||||
controller = $componentController('vnTicketSms', {$element, $scope});
|
controller = $componentController('vnTicketSms', {$element, $scope});
|
||||||
controller.$params = {id: 11};
|
controller.$params = {id: 11};
|
||||||
|
controller.$scope.message = {
|
||||||
|
input: {
|
||||||
|
value: 'My SMS'
|
||||||
|
}
|
||||||
|
};
|
||||||
}));
|
}));
|
||||||
|
|
||||||
describe('onResponse()', () => {
|
describe('onResponse()', () => {
|
||||||
|
@ -55,14 +60,13 @@ describe('Ticket', () => {
|
||||||
it('should return the characters remaining in a element', () => {
|
it('should return the characters remaining in a element', () => {
|
||||||
controller.$scope.message = {
|
controller.$scope.message = {
|
||||||
input: {
|
input: {
|
||||||
textLength: 50
|
value: 'My message 0€'
|
||||||
},
|
}
|
||||||
maxlength: 150
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let result = controller.charactersRemaining();
|
let result = controller.charactersRemaining();
|
||||||
|
|
||||||
expect(result).toEqual(100);
|
expect(result).toEqual(145);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -4,4 +4,6 @@ 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 destination can't be empty: El destinatario no puede estar vacio
|
||||||
The message can't be empty: El mensaje no puede estar vacio
|
The message can't be empty: El mensaje no puede estar vacio
|
||||||
|
The message it's too long: El mensaje es demasiado largo
|
||||||
|
Special characters like accents counts as a multiple: Carácteres especiales como los acentos cuentan como varios
|
Loading…
Reference in New Issue