Bug #412 en vez de anular la acción, se guardan los datos
This commit is contained in:
parent
07bb32d5f3
commit
e7f55054a0
|
@ -22,11 +22,37 @@ export default class Textfield extends Input {
|
|||
this.rightIcons = tClone[0];
|
||||
}, null, 'rightIcons');
|
||||
}
|
||||
this.input.addEventListener('keyup', e => {
|
||||
if (e.key == "Escape") {
|
||||
this._cancel();
|
||||
}
|
||||
});
|
||||
this.input.addEventListener('focus', () => this.saveOldValue());
|
||||
this.input.addEventListener('keyup', e => {
|
||||
if (e.key == "Enter") {
|
||||
this._accept();
|
||||
}
|
||||
});
|
||||
}
|
||||
set onChange(value) {
|
||||
this.input.addEventListener('change', value);
|
||||
_accept() {
|
||||
if (this.accept) {
|
||||
this.input.blur();
|
||||
this.accept();
|
||||
}
|
||||
}
|
||||
_cancel() {
|
||||
this.input.blur();
|
||||
this.input.value = this.oldValue;
|
||||
this.value = this.input.value;
|
||||
this.$.$apply();
|
||||
|
||||
if (this.cancel) {
|
||||
this.cancel();
|
||||
}
|
||||
}
|
||||
saveOldValue() {
|
||||
this.oldValue = this.input.value;
|
||||
}
|
||||
set leftIcons(value) {
|
||||
for (let i = 0; i < value.children.length; i++) {
|
||||
this.element.querySelector('.leftIcons').appendChild(value.children[i]);
|
||||
|
@ -85,7 +111,8 @@ ngModule.component('vnTextfield', {
|
|||
rule: '@?',
|
||||
type: '@?',
|
||||
vnTabIndex: '@?',
|
||||
onChange: '&',
|
||||
accept: '&',
|
||||
cancel: '&',
|
||||
unclearable: '<?'
|
||||
}
|
||||
});
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
label="Discount"
|
||||
model="$ctrl.newDiscount"
|
||||
type="text"
|
||||
on-change="$ctrl.updateDiscount()">
|
||||
accept="$ctrl.updateDiscount()">
|
||||
<t-right-icons>
|
||||
<span class="filter">%</span>
|
||||
</t-right-icons>
|
||||
|
|
|
@ -77,7 +77,7 @@
|
|||
ng-show="sale.visible || sale.available"
|
||||
orange
|
||||
icon="warning"
|
||||
vn-tooltip="Visible: {{::sale.visible}} <br> {{::$ctrl.translate.instant('Available')}} {{::sale.available}}">
|
||||
vn-tooltip="Visible: {{::sale.visible || 0}} <br> {{::$ctrl.translate.instant('Available')}} {{::sale.available || 0}}">
|
||||
</vn-icon>
|
||||
<vn-icon ng-show="sale.reserved" icon="icon-reserved"></vn-icon>
|
||||
</vn-td>
|
||||
|
@ -96,7 +96,7 @@
|
|||
<vn-td ng-if="$ctrl.isEditable" number>
|
||||
<vn-textfield
|
||||
model="sale.quantity"
|
||||
on-change="$ctrl.updateQuantity(sale.id,sale.quantity)"
|
||||
accept="$ctrl.updateQuantity(sale.id, sale.quantity)"
|
||||
type="text">
|
||||
</vn-textfield>
|
||||
</vn-td>
|
||||
|
@ -227,7 +227,7 @@
|
|||
label="Price"
|
||||
model="$ctrl.editedPrice"
|
||||
type="text"
|
||||
on-change="$ctrl.updatePrice()">
|
||||
accept="$ctrl.updatePrice()">
|
||||
<t-right-icons>
|
||||
<span class="filter">€</span>
|
||||
</t-right-icons>
|
||||
|
|
|
@ -286,7 +286,6 @@ class Controller {
|
|||
this.vnApp.showSuccess(this.translate.instant('Data saved!'));
|
||||
}).catch(e => {
|
||||
this.vnApp.showError(this.translate.instant(e.data.error.message));
|
||||
this.$scope.model.refresh();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue