Skip to content

Commit

Permalink
NEXT-11859 - Add advanced list prices
Browse files Browse the repository at this point in the history
  • Loading branch information
taltholtmann authored and leichteckig committed Dec 18, 2020
1 parent bd3ebd6 commit 6f0b3fa
Show file tree
Hide file tree
Showing 15 changed files with 421 additions and 67 deletions.
14 changes: 14 additions & 0 deletions changelog/_unreleased/2020-12-17-advanced-list-prices.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
title: Advanced list prices
issue: NEXT-11859
flag: FEATURE_NEXT_10541
author: Timo Altholtmann
---
# Administration
* Added slot `additionalSettings` to `administration/src/app/component/data-grid/sw-data-grid-settings/sw-data-grid-settings.html.twig`
* Added block `sw_data_grid_settings_additional_settings` to `administration/src/app/component/data-grid/sw-data-grid-settings/sw-data-grid-settings.html.twig`
* Added block `sw_data_grid_settings_additional_settings_slot` to `administration/src/app/component/data-grid/sw-data-grid-settings/sw-data-grid-settings.html.twig`
* Added slot `additionalSettings` to `administration/src/app/component/data-grid/sw-data-grid/sw-data-grid.html.twig`
* Added block `sw_data_grid_settings_additional_settings` to `administration/src/app/component/data-grid/sw-data-grid/sw-data-grid.html.twig`
* Added block `sw_data_grid_settings_additional_settings` to `administration/src/app/component/data-grid/sw-data-grid/sw-data-grid.html.twig`
* Added block `sw_data_grid_settings_additional_settings_inner` to `administration/src/app/component/data-grid/sw-data-grid/sw-data-grid.html.twig`
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@
:label="$tc('global.sw-data-grid.labelSettingsPreviewImages')">
</sw-switch-field>
{% endblock %}

{% block sw_data_grid_settings_additional_settings %}
<slot name="additionalSettings">
{% block sw_data_grid_settings_additional_settings_slot %}{% endblock %}
</slot>
{% endblock %}
</div>
{% endblock %}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,13 @@
@change-preview-images="onChangePreviews"
@change-column-visibility="onChangeColumnVisibility"
@change-column-order="onChangeColumnOrder">
{% block sw_data_grid_settings_additional_settings %}
<template #additionalSettings>
{% block sw_data_grid_settings_additional_settings_inner %}
<slot name="additionalSettings"></slot>
{% endblock %}
</template>
{% endblock %}
</sw-data-grid-settings>
{% endblock %}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ Component.register('sw-list-price-field', {

return [{
gross: 0,
currencyId: this.currency.id,
currencyId: this.defaultPrice.currencyId ? this.defaultPrice.currencyId : this.currency.id,
linked: true,
net: 0
}];
Expand All @@ -136,6 +136,21 @@ Component.register('sw-list-price-field', {
this.$set(price, 'listPrice', newValue);
}
}
},

defaultListPrice() {
const price = this.defaultPrice.listPrice;

if (price) {
return price;
}

return {
currencyId: this.defaultPrice.currencyId ? this.defaultPrice.currencyId : this.currency.id,
gross: 0,
net: 0,
linked: true
};
}
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,41 @@
'sw-list-price-field__vertical': vertical
}">

{% block sw_list_price_field_price %}
<sw-price-field :price="price"
required
:compact="compact"
:disableSuffix="disableSuffix"
:taxRate="taxRate"
:error="error"
:disabled="disabled"
:enableInheritance="enableInheritance"
:label="label"
:currency="currency">
</sw-price-field>
{% endblock %}

{% block sw_list_price_field_list_price %}
<sw-price-field v-if="!hideListPrices"
:price="listPrice"
:taxRate="taxRate"
:disabled="disabled"
:grossLabel="$tc('global.sw-list-price-field.labelListPriceGross')"
:netLabel="$tc('global.sw-list-price-field.labelListPriceNet')"
:compact="compact"
:disableSuffix="disableSuffix"
:label="label"
:enableInheritance="enableInheritance"
class="sw-list-price-field__list-price"
@change="listPriceChanged"
:error="error"
:currency="currency">
</sw-price-field>
{% endblock %}
<div class="sw-list-price-field__price">
{% block sw_list_price_field_price %}
<sw-price-field :price="price"
required
:compact="compact"
:disableSuffix="disableSuffix"
:defaultPrice="defaultPrice"
:taxRate="taxRate"
:error="error"
:disabled="disabled"
:enableInheritance="enableInheritance"
:label="label"
:currency="currency">
</sw-price-field>
{% endblock %}
</div>
<div class="sw-list-price-field__list-price">
{% block sw_list_price_field_list_price %}
<sw-price-field v-if="!hideListPrices"
:price="listPrice"
:defaultPrice="defaultListPrice"
:taxRate="taxRate"
:disabled="disabled"
:grossLabel="$tc('global.sw-list-price-field.labelListPriceGross')"
:netLabel="$tc('global.sw-list-price-field.labelListPriceNet')"
:compact="compact"
:disableSuffix="disableSuffix"
:label="label"
:enableInheritance="enableInheritance"
class="sw-list-price-field__list-price"
@change="listPriceChanged"
:error="error"
:currency="currency">
</sw-price-field>
{% endblock %}
</div>
</div>
{% endblock %}
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,13 @@ Component.register('sw-maintain-currencies-modal', {
linked: this.defaultPrice.listPrice.linked,
net: this.convertPrice(this.defaultPrice.listPrice.net, currency)
};
} else {
price.listPrice = {
currencyId: currency.id,
gross: 0,
linked: true,
net: 0
};
}

// create new entry for currency in prices
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,16 @@ $sw-field--switch-color-error: $color-crimson;
}
}

&.sw-field--small {
label {
padding: 8px 10px;
}

.sw-field--switch__input {
padding: 8px 0;
}
}

&.sw-field--medium.sw-field--switch-bordered {
label {
padding: 11px 10px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@
"columnPrice": "Preis (brutto / netto)",
"contextMenuDuplicate": "Duplizieren",
"contextMenuDelete": "Löschen",
"settingShowListPrices": "Zeige Streichpreise",
"toolbarLabel": "Regeln"
},
"list": {
Expand Down Expand Up @@ -234,6 +235,7 @@
"advancedPricesNotExisting": "Für dieses Produkt existieren noch keine erweiterten Preise.",
"columnFrom": "Menge von ...",
"columnTo": "bis ...",
"columnType": "Typ",
"selectRule": "Bedingungsregel auswählen ...",
"advancedPricesInherited": "Dieses Produkt hat vererbte Preise vom Hauptprodukt.",
"linkAdvancedPricesOfParent": "Zeige die Preise des Hauptprodukts",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@
"columnPrice": "Price (gross / net)",
"contextMenuDuplicate": "Duplicate",
"contextMenuDelete": "Delete",
"settingShowListPrices": "Show list prices",
"toolbarLabel": "Rules"
},
"list": {
Expand Down Expand Up @@ -234,6 +235,7 @@
"advancedPricesNotExisting": "No advanced prices available for this product yet.",
"columnFrom": "Quantity from...",
"columnTo": "to...",
"columnType": "Type",
"selectRule": "Select a conditional rule...",
"advancedPricesInherited": "This product has inherited prices from its parent.",
"linkAdvancedPricesOfParent": "Show prices of parent product",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const { mapState, mapGetters } = Shopware.Component.getComponentHelper();
Component.register('sw-product-detail-context-prices', {
template,

inject: ['repositoryFactory', 'acl'],
inject: ['repositoryFactory', 'acl', 'feature'],

mixins: [
Mixin.getByName('notification')
Expand All @@ -18,7 +18,8 @@ Component.register('sw-product-detail-context-prices', {
return {
rules: [],
totalRules: 0,
isInherited: false
isInherited: false,
showListPrices: {}
};
},

Expand Down Expand Up @@ -128,13 +129,14 @@ Component.register('sw-product-detail-context-prices', {
allowResize: true,
primary: false,
rawData: false,
width: '250px'
width: '250px',
multiLine: true
};
});
},

pricesColumns() {
return [
const priceColumns = [
{
property: 'quantityStart',
label: 'sw-product.advancedPrices.columnFrom',
Expand All @@ -151,9 +153,22 @@ Component.register('sw-product-detail-context-prices', {
primary: true,
rawData: false,
width: '95px'
},
...this.currencyColumns
}
];

if (this.feature.isActive('FEATURE_NEXT_10541')) {
priceColumns.push({
property: 'type',
label: 'sw-product.advancedPrices.columnType',
visible: true,
// visible: false,
allowResize: true,
width: '95px',
multiLine: true
});
}

return [...priceColumns, ...this.currencyColumns];
}
},

Expand Down Expand Up @@ -224,7 +239,13 @@ Component.register('sw-product-detail-context-prices', {
currencyId: this.defaultCurrency.id,
gross: this.defaultPrice.gross,
linked: this.defaultPrice.linked,
net: this.defaultPrice.net
net: this.defaultPrice.net,
listPrice: {
currencyId: this.defaultCurrency.id,
gross: this.defaultPrice.listPrice ? this.defaultPrice.listPrice.gross : 0,
linked: this.defaultPrice.listPrice ? this.defaultPrice.listPrice.linked : true,
net: this.defaultPrice.listPrice ? this.defaultPrice.listPrice.net : 0
}
}];

this.product.prices.add(newPriceRule);
Expand Down Expand Up @@ -317,6 +338,13 @@ Component.register('sw-product-detail-context-prices', {
net: this.convertPrice(defaultPrice.net, currency)
};

newPrice.listPrice = {
currencyId: currency.id,
gross: defaultPrice.listPrice.gross ? this.convertPrice(defaultPrice.listPrice.gross, currency) : 0,
linked: defaultPrice.listPrice.linked ? defaultPrice.listPrice.linked : true,
net: defaultPrice.listPrice.net ? this.convertPrice(defaultPrice.listPrice.net, currency) : 0
};

// add price to rule.price
this.$set(rule.price, rule.price.length, newPrice);
},
Expand Down Expand Up @@ -369,7 +397,13 @@ Component.register('sw-product-detail-context-prices', {
currencyId: this.defaultCurrency.id,
gross: this.defaultPrice.gross,
linked: this.defaultPrice.linked,
net: this.defaultPrice.net
net: this.defaultPrice.net,
listPrice: {
currencyId: this.defaultCurrency.id,
gross: this.defaultPrice.listPrice ? this.defaultPrice.listPrice.gross : 0,
linked: this.defaultPrice.listPrice ? this.defaultPrice.listPrice.linked : true,
net: this.defaultPrice.listPrice ? this.defaultPrice.listPrice.net : 0
}
}];

this.product.prices.add(newPriceRule);
Expand Down
Loading

0 comments on commit 6f0b3fa

Please sign in to comment.