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];
|
this.rightIcons = tClone[0];
|
||||||
}, null, 'rightIcons');
|
}, null, 'rightIcons');
|
||||||
}
|
}
|
||||||
|
this.input.addEventListener('keyup', e => {
|
||||||
|
if (e.key == "Escape") {
|
||||||
|
this._cancel();
|
||||||
}
|
}
|
||||||
set onChange(value) {
|
});
|
||||||
this.input.addEventListener('change', value);
|
this.input.addEventListener('focus', () => this.saveOldValue());
|
||||||
|
this.input.addEventListener('keyup', e => {
|
||||||
|
if (e.key == "Enter") {
|
||||||
|
this._accept();
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
_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) {
|
set leftIcons(value) {
|
||||||
for (let i = 0; i < value.children.length; i++) {
|
for (let i = 0; i < value.children.length; i++) {
|
||||||
this.element.querySelector('.leftIcons').appendChild(value.children[i]);
|
this.element.querySelector('.leftIcons').appendChild(value.children[i]);
|
||||||
|
@ -85,7 +111,8 @@ ngModule.component('vnTextfield', {
|
||||||
rule: '@?',
|
rule: '@?',
|
||||||
type: '@?',
|
type: '@?',
|
||||||
vnTabIndex: '@?',
|
vnTabIndex: '@?',
|
||||||
onChange: '&',
|
accept: '&',
|
||||||
|
cancel: '&',
|
||||||
unclearable: '<?'
|
unclearable: '<?'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
label="Discount"
|
label="Discount"
|
||||||
model="$ctrl.newDiscount"
|
model="$ctrl.newDiscount"
|
||||||
type="text"
|
type="text"
|
||||||
on-change="$ctrl.updateDiscount()">
|
accept="$ctrl.updateDiscount()">
|
||||||
<t-right-icons>
|
<t-right-icons>
|
||||||
<span class="filter">%</span>
|
<span class="filter">%</span>
|
||||||
</t-right-icons>
|
</t-right-icons>
|
||||||
|
|
|
@ -77,7 +77,7 @@
|
||||||
ng-show="sale.visible || sale.available"
|
ng-show="sale.visible || sale.available"
|
||||||
orange
|
orange
|
||||||
icon="warning"
|
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>
|
||||||
<vn-icon ng-show="sale.reserved" icon="icon-reserved"></vn-icon>
|
<vn-icon ng-show="sale.reserved" icon="icon-reserved"></vn-icon>
|
||||||
</vn-td>
|
</vn-td>
|
||||||
|
@ -96,7 +96,7 @@
|
||||||
<vn-td ng-if="$ctrl.isEditable" number>
|
<vn-td ng-if="$ctrl.isEditable" number>
|
||||||
<vn-textfield
|
<vn-textfield
|
||||||
model="sale.quantity"
|
model="sale.quantity"
|
||||||
on-change="$ctrl.updateQuantity(sale.id,sale.quantity)"
|
accept="$ctrl.updateQuantity(sale.id, sale.quantity)"
|
||||||
type="text">
|
type="text">
|
||||||
</vn-textfield>
|
</vn-textfield>
|
||||||
</vn-td>
|
</vn-td>
|
||||||
|
@ -227,7 +227,7 @@
|
||||||
label="Price"
|
label="Price"
|
||||||
model="$ctrl.editedPrice"
|
model="$ctrl.editedPrice"
|
||||||
type="text"
|
type="text"
|
||||||
on-change="$ctrl.updatePrice()">
|
accept="$ctrl.updatePrice()">
|
||||||
<t-right-icons>
|
<t-right-icons>
|
||||||
<span class="filter">€</span>
|
<span class="filter">€</span>
|
||||||
</t-right-icons>
|
</t-right-icons>
|
||||||
|
|
|
@ -286,7 +286,6 @@ class Controller {
|
||||||
this.vnApp.showSuccess(this.translate.instant('Data saved!'));
|
this.vnApp.showSuccess(this.translate.instant('Data saved!'));
|
||||||
}).catch(e => {
|
}).catch(e => {
|
||||||
this.vnApp.showError(this.translate.instant(e.data.error.message));
|
this.vnApp.showError(this.translate.instant(e.data.error.message));
|
||||||
this.$scope.model.refresh();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue