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"> ng-model="$ctrl.manaCode">
</vn-radio> </vn-radio>
</vn-vertical> </vn-vertical>
<div class="simulator"> <div class="simulator" ng-show="$ctrl.edit.sale">
<p class="simulatorTitle" translate>New price</p> <p class="simulatorTitle" translate>New price</p>
<p> <p>
<strong>{{$ctrl.getNewPrice() | currency: 'EUR': 2}}</strong> <strong>{{$ctrl.getNewPrice() | currency: 'EUR': 2}}</strong>
@ -321,32 +321,6 @@
</div> </div>
</vn-popover> </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 --> <!-- Transfer Popover -->
<vn-popover vn-id="transfer"> <vn-popover vn-id="transfer">
<div class="vn-pa-lg transfer"> <div class="vn-pa-lg transfer">
@ -490,7 +464,7 @@
</vn-item> </vn-item>
<vn-item translate <vn-item translate
name="discount" name="discount"
ng-click="$ctrl.showEditDiscountDialog($event)"> ng-click="$ctrl.showEditDiscountPopover($event, sale)">
Update discount Update discount
</vn-item> </vn-item>
<vn-item translate <vn-item translate

View File

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