salix/modules/ticket/front/sms/index.js

49 lines
1.2 KiB
JavaScript
Raw Normal View History

2020-01-15 12:27:14 +00:00
import ngModule from '../module';
import Component from 'core/lib/component';
import './style.scss';
class Controller extends Component {
constructor($element, $scope, $http, $translate, vnApp) {
super($element, $scope);
this.$scope = $scope;
this.$http = $http;
this.$translate = $translate;
this.vnApp = vnApp;
}
open() {
this.$scope.SMSDialog.show();
}
charactersRemaining() {
let elementMaxLength;
let textAreaLength;
const element = this.$scope.message;
textAreaLength = element.input.textLength;
elementMaxLength = element.maxlength;
return elementMaxLength - textAreaLength;
}
onResponse(response) {
if (response === 'accept') {
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});
});
}
}
}
Controller.$inject = ['$element', '$scope', '$http', '$translate', 'vnApp'];
ngModule.component('vnTicketSms', {
template: require('./index.html'),
controller: Controller,
bindings: {
sms: '<',
}
});