change component location

This commit is contained in:
Pau 2022-11-25 08:23:57 +01:00
parent b6ff1d99b1
commit d47e7ffb16
6 changed files with 112 additions and 1 deletions

View File

@ -53,4 +53,3 @@ import './datalist';
import './contextmenu';
import './rating';
import './smart-table';
import './sendSms';

View File

@ -16,3 +16,4 @@ import './user-popover';
import './upload-photo';
import './bank-entity';
import './log';
import './sendSms';

View File

@ -0,0 +1,45 @@
<vn-dialog
vn-id="SMSDialog"
on-accept="$ctrl.onResponse()">
<tpl-body>
<section class="SMSDialog">
<h5 class="vn-py-sm" translate>Send SMS</h5>
<vn-horizontal>
<vn-textfield
vn-one
label="Destination"
ng-model="$ctrl.sms.destination"
required="true"
rule>
</vn-textfield>
</vn-horizontal>
<vn-horizontal>
<vn-textarea vn-one
vn-id="message"
label="Message"
ng-model="$ctrl.sms.message"
info="Special characters like accents counts as a multiple"
rows="5"
required="true"
rule>
</vn-textarea>
</vn-horizontal>
<vn-horizontal>
<span>
{{'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>
</vn-horizontal>
</section>
</tpl-body>
<tpl-buttons>
<input type="button" response="cancel" translate-attr="{value: 'Cancel'}"/>
<button response="accept" translate>Send</button>
</tpl-buttons>
</vn-dialog>

View File

@ -0,0 +1,52 @@
import ngModule from '../../module';
import './style.scss';
import Dialog from '../../../core/components/dialog';
export default class sendSmsDialog extends Dialog {
constructor($element, $scope, $http, $translate, vnApp) {
super($element, $scope, $http, $translate, vnApp);
new CustomEvent('openSmsDialog', {
detail: {
this: this
}
});
document.addEventListener('openSmsDialog', e => {
this.route = e.detail.route;
this.$.SMSDialog.show();
});
}
charactersRemaining() {
const element = this.sms.message;
const maxLength = 160;
return maxLength - element.length;
}
onResponse() {
try {
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 (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!'));
});
} catch (e) {
this.vnApp.showError(this.$t(e.message));
return false;
}
return true;
}
}
ngModule.vnComponent('vnSmsDialog', {
template: require('./index.html'),
controller: sendSmsDialog,
bindings: {
sms: '<',
}
});

View File

@ -0,0 +1,9 @@
Send SMS: Enviar SMS
Destination: Destinatario
Message: Mensaje
SMS sent!: ¡SMS enviado!
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
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

View File

@ -0,0 +1,5 @@
@import "variables";
.SMSDialog {
min-width: 400px
}