feat: changeMultipleDiscount uses the same popover than changeDiscount

This commit is contained in:
Vicent Llopis 2022-10-14 14:29:21 +02:00
parent e3606c7273
commit 2455a11c26
2 changed files with 17 additions and 47 deletions

View File

@ -300,7 +300,7 @@
ng-model="$ctrl.manaCode">
</vn-radio>
</vn-vertical>
<div class="simulator">
<div class="simulator" ng-show="$ctrl.edit.sale">
<p class="simulatorTitle" translate>New price</p>
<p>
<strong>{{$ctrl.getNewPrice() | currency: 'EUR': 2}}</strong>
@ -321,32 +321,6 @@
</div>
</vn-popover>
<!-- Multiple discount dialog -->
<vn-dialog vn-id="editDiscountDialog"
on-open="$ctrl.getMana()"
message="Edit discount">
<tpl-body>
<vn-spinner class="vn-pa-xs"
ng-if="$ctrl.edit.mana == null"
enable="true">
</vn-spinner>
<div ng-if="$ctrl.edit.mana != null">
<div class="vn-pa-md">
<vn-input-number vn-focus
label="Discount"
ng-model="$ctrl.edit.discount"
on-change="$ctrl.changeMultipleDiscount()"
clear-disabled="true"
suffix="%">
</vn-input-number>
</div>
<section class="header vn-pa-md">
<span>Mana: <strong>{{::$ctrl.edit.mana | currency: 'EUR': 0}}</strong></span>
</section>
</div>
</tpl-body>
</vn-dialog>
<!-- Transfer Popover -->
<vn-popover vn-id="transfer">
<div class="vn-pa-lg transfer">
@ -490,7 +464,7 @@
</vn-item>
<vn-item translate
name="discount"
ng-click="$ctrl.showEditDiscountDialog($event)">
ng-click="$ctrl.showEditDiscountPopover($event, sale)">
Update discount
</vn-item>
<vn-item translate

View File

@ -243,24 +243,19 @@ class Controller extends Section {
showEditDiscountPopover(event, sale) {
if (this.isLocked) return;
if (sale) {
this.edit = {
discount: sale.discount,
sale: sale
};
this.$.editDiscount.show(event);
}
showEditDiscountDialog(event) {
if (this.isLocked) return;
} else {
this.edit = {
discount: null,
sales: this.selectedValidSales()
};
}
this.$.editDiscountDialog.show(event);
this.$.editDiscount.show(event);
}
changeDiscount() {
@ -282,7 +277,7 @@ class Controller extends Section {
if (newDiscount != null && hasChanges)
this.updateDiscount(sales);
this.$.editDiscountDialog.hide();
this.$.editDiscount.hide();
}
updateDiscount(sales) {
@ -303,7 +298,7 @@ class Controller extends Section {
}
getNewPrice() {
if (this.edit) {
if (this.edit.sale) {
const sale = this.edit.sale;
let newDiscount = sale.discount;
let newPrice = this.edit.price || sale.price;
@ -505,7 +500,8 @@ class Controller extends Section {
}
save() {
this.changeDiscount();
if (this.edit.sale) this.changeDiscount();
if (this.edit.sales) this.changeMultipleDiscount();
}
cancel() {