This commit is contained in:
parent
1c9964b902
commit
8f98082910
|
@ -11,10 +11,10 @@ export default class sendSmsDialog extends Dialog {
|
|||
this: this
|
||||
}
|
||||
});
|
||||
document.addEventListener('openSmsDialog', e => {
|
||||
this.route = e.detail.route;
|
||||
this.$.SMSDialog.show();
|
||||
});
|
||||
}
|
||||
|
||||
open() {
|
||||
this.$.SMSDialog.show();
|
||||
}
|
||||
|
||||
charactersRemaining() {
|
||||
|
@ -32,14 +32,11 @@ export default class sendSmsDialog extends Dialog {
|
|||
if (this.charactersRemaining() < 0)
|
||||
throw new Error(`The message it's too long`);
|
||||
|
||||
this.$http.post(this.route, this.sms).then(res => {
|
||||
this.vnApp.showMessage(this.$t('SMS sent!'));
|
||||
});
|
||||
return this.onSend({$sms: this.sms});
|
||||
} catch (e) {
|
||||
this.vnApp.showError(this.$t(e.message));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -48,5 +45,6 @@ ngModule.vnComponent('vnSmsDialog', {
|
|||
controller: sendSmsDialog,
|
||||
bindings: {
|
||||
sms: '<',
|
||||
onSend: '&',
|
||||
}
|
||||
});
|
||||
|
|
|
@ -115,6 +115,7 @@
|
|||
</vn-descriptor-content>
|
||||
<vn-sms-dialog
|
||||
vn-id="sms"
|
||||
on-send="$ctrl.onSmsSend($sms)"
|
||||
sms="$ctrl.newSMS">
|
||||
</vn-sms-dialog>
|
||||
<vn-worker-descriptor-popover
|
||||
|
|
|
@ -37,12 +37,12 @@ class Controller extends Descriptor {
|
|||
destination: this.$params.phone || client.mobile || client.phone,
|
||||
message: this.$params.message || ''
|
||||
};
|
||||
this.$.sms.open();
|
||||
}
|
||||
|
||||
const route = `Clients/${this.id}/sendSms`;
|
||||
|
||||
document.dispatchEvent(new CustomEvent('openSmsDialog', {
|
||||
detail: {route}
|
||||
}));
|
||||
onSmsSend(sms) {
|
||||
return this.$http.post(`Clients/${this.id}/sendSms`, sms)
|
||||
.then(() => this.vnApp.showSuccess(this.$t('SMS sent')));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -282,6 +282,7 @@
|
|||
<!-- Send SMS popup -->
|
||||
<vn-sms-dialog
|
||||
vn-id="sms"
|
||||
on-send="$ctrl.onSmsSend($sms)"
|
||||
sms="$ctrl.newSMS">
|
||||
</vn-sms-dialog>
|
||||
|
||||
|
|
|
@ -226,7 +226,6 @@ class Controller extends Section {
|
|||
}
|
||||
|
||||
showSMSDialog(params) {
|
||||
const route = `Tickets/${this.id}/sendSms`;
|
||||
const address = this.ticket.address;
|
||||
const client = this.ticket.client;
|
||||
const phone = this.$params.phone
|
||||
|
@ -241,9 +240,7 @@ class Controller extends Section {
|
|||
destination: phone
|
||||
}, params);
|
||||
|
||||
document.dispatchEvent(new CustomEvent('openSmsDialog', {
|
||||
detail: {route}
|
||||
}));
|
||||
this.$.sms.open();
|
||||
}
|
||||
|
||||
makeInvoice() {
|
||||
|
@ -298,6 +295,11 @@ class Controller extends Section {
|
|||
this.$state.go('ticket.card.sale', {id: refundTicket.id});
|
||||
});
|
||||
}
|
||||
|
||||
onSmsSend(sms) {
|
||||
return this.$http.post(`Tickets/${this.id}/sendSms`, sms)
|
||||
.then(() => this.vnApp.showSuccess(this.$t('SMS sent')));
|
||||
}
|
||||
}
|
||||
|
||||
Controller.$inject = ['$element', '$scope', 'vnReport', 'vnEmail'];
|
||||
|
|
Loading…
Reference in New Issue