Skip to content

Commit

Permalink
fix(admin-ui): Display calculated price when custom price strategy used
Browse files Browse the repository at this point in the history
Relates to #2506
  • Loading branch information
michaelbromley committed Mar 4, 2024
1 parent b2cb011 commit 09c66fe
Show file tree
Hide file tree
Showing 25 changed files with 150 additions and 48 deletions.
67 changes: 38 additions & 29 deletions packages/admin-ui/i18n-coverage.json
Original file line number Diff line number Diff line change
@@ -1,90 +1,99 @@
{
"generatedOn": "2023-10-17T19:32:07.745Z",
"lastCommit": "97bc099006adda7449a7b63e72191c2bb7e7b4ed",

"generatedOn": "2024-03-04T16:07:38.832Z",
"lastCommit": "b2cb011f2bafcbd51c7542df4bf094cb2b823de2",
"translationStatus": {
"ar": {
"tokenCount": 761,
"tokenCount": 763,
"translatedCount": 761,
"percentage": 100
},
"cs": {
"tokenCount": 761,
"tokenCount": 763,
"translatedCount": 571,
"percentage": 75
},
"de": {
"tokenCount": 761,
"tokenCount": 763,
"translatedCount": 761,
"percentage": 100
},
"en": {
"tokenCount": 761,
"tokenCount": 763,
"translatedCount": 761,
"percentage": 100
},
"es": {
"tokenCount": 761,
"tokenCount": 763,
"translatedCount": 761,
"percentage": 100
},
"fa": {
"tokenCount": 761,
"translatedCount": 736,
"percentage": 97
"tokenCount": 763,
"translatedCount": 761,
"percentage": 100
},
"fr": {
"tokenCount": 761,
"tokenCount": 763,
"translatedCount": 758,
"percentage": 100
"percentage": 99
},
"he": {
"tokenCount": 761,
"tokenCount": 763,
"translatedCount": 761,
"percentage": 100
},
"it": {
"tokenCount": 761,
"hr": {
"tokenCount": 763,
"translatedCount": 760,
"percentage": 100
},
"it": {
"tokenCount": 763,
"translatedCount": 761,
"percentage": 100
},
"ne": {
"tokenCount": 761,
"translatedCount": 725,
"percentage": 95
"tokenCount": 763,
"translatedCount": 750,
"percentage": 98
},
"pl": {
"tokenCount": 761,
"tokenCount": 763,
"translatedCount": 400,
"percentage": 53
"percentage": 52
},
"pt_BR": {
"tokenCount": 761,
"tokenCount": 763,
"translatedCount": 760,
"percentage": 100
},
"pt_PT": {
"tokenCount": 761,
"tokenCount": 763,
"translatedCount": 609,
"percentage": 80
},
"ru": {
"tokenCount": 761,
"tokenCount": 763,
"translatedCount": 761,
"percentage": 100
},
"sv": {
"tokenCount": 763,
"translatedCount": 755,
"percentage": 99
},
"uk": {
"tokenCount": 761,
"translatedCount": 596,
"percentage": 78
"tokenCount": 763,
"translatedCount": 761,
"percentage": 100
},
"zh_Hans": {
"tokenCount": 761,
"tokenCount": 763,
"translatedCount": 541,
"percentage": 71
},
"zh_Hant": {
"tokenCount": 761,
"tokenCount": 763,
"translatedCount": 387,
"percentage": 51
}
Expand Down
2 changes: 2 additions & 0 deletions packages/admin-ui/src/lib/catalog/src/catalog.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ import { ProductVariantsEditorComponent } from './components/product-variants-ed
import { ProductVariantsTableComponent } from './components/product-variants-table/product-variants-table.component';
import { UpdateProductOptionDialogComponent } from './components/update-product-option-dialog/update-product-option-dialog.component';
import { VariantPriceDetailComponent } from './components/variant-price-detail/variant-price-detail.component';
import { VariantPriceStrategyDetailComponent } from './components/variant-price-strategy-detail/variant-price-strategy-detail.component';

const CATALOG_COMPONENTS = [
ProductListComponent,
Expand All @@ -76,6 +77,7 @@ const CATALOG_COMPONENTS = [
ApplyFacetDialogComponent,
AssetListComponent,
VariantPriceDetailComponent,
VariantPriceStrategyDetailComponent,
CollectionListComponent,
CollectionDetailComponent,
CollectionTreeComponent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,11 @@
[taxCategoryId]="detailForm.get('taxCategoryId')!.value"
/>
</div>
<vdr-variant-price-strategy-detail
[channelPriceIncludesTax]="channelPriceIncludesTax$ | async"
[channelDefaultCurrencyCode]="channelDefaultCurrencyCode"
[variant]="variant"
/>
<ng-container *ngIf="unusedCurrencyCodes$ | async as unusedCurrencyCodes">
<div *ngIf="unusedCurrencyCodes.length">
<vdr-dropdown>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<div *ngIf="calculatedPriceDiffersFromInputPrice()" class="price-strategy-detail">
<vdr-form-item
[label]="'catalog.calculated-price' | translate"
[tooltip]="'catalog.calculated-price-tooltip' | translate"
for="price"
>
</vdr-form-item>
<div class="form-grid mt-2">
<vdr-form-item [label]="'common.price' | translate">
{{ variant.price | localeCurrency : variant.currencyCode }}
</vdr-form-item>
<vdr-form-item [label]="'common.price-with-tax' | translate">
{{ variant.priceWithTax | localeCurrency : variant.currencyCode }}
</vdr-form-item>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
:host {
display: block;
}

.price-strategy-detail {
margin-top: calc(var(--space-unit)* 2);
padding-top: calc(var(--space-unit)* 2);
border-top: 1px solid var(--color-weight-150);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
import {
CurrencyCode,
ProductVariantDetailQueryProductVariantFragmentFragment,
} from '@vendure/admin-ui/core';

@Component({
selector: 'vdr-variant-price-strategy-detail',
templateUrl: './variant-price-strategy-detail.component.html',
styleUrls: ['./variant-price-strategy-detail.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class VariantPriceStrategyDetailComponent {
@Input() channelPriceIncludesTax: boolean;
@Input() variant: ProductVariantDetailQueryProductVariantFragmentFragment;
@Input() channelDefaultCurrencyCode: CurrencyCode;

calculatedPriceDiffersFromInputPrice(): boolean {
const defaultPrice =
this.variant.prices.find(p => p.currencyCode === this.channelDefaultCurrencyCode) ??
this.variant.prices[0];
if (!defaultPrice) {
return false;
}
if (this.channelPriceIncludesTax) {
return this.variant.priceWithTax !== defaultPrice.price;
} else {
return this.variant.price !== defaultPrice.price;
}
}
}
2 changes: 2 additions & 0 deletions packages/admin-ui/src/lib/static/i18n-messages/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@
"assign-variants-to-channel": "تعيين متغيرات المنتج للقناة",
"auto-update-option-variant-name": "تحديث أسماء ProductVariants تلقائيًا باستخدام هذا الخيار",
"auto-update-product-variant-name": "تحديث أسماء ProductVariants تلقائيًا",
"calculated-price": "السعر المحسوب",
"calculated-price-tooltip": "هناك عملية حساب سعر مخصصة تعديلها السعر المحدد أعلاه:",
"cannot-create-variants-without-options": "لا يمكن إنشاء متغيرات المنتج حتى يتم تحديد مجموعة خيارات مع خيارين على الأقل من المنتجات",
"channel-price-preview": "معاينة أسعار القناة",
"collection": "مجموعة",
Expand Down
2 changes: 2 additions & 0 deletions packages/admin-ui/src/lib/static/i18n-messages/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@
"assign-variants-to-channel": "Přiřadit varianty do kanálu",
"auto-update-option-variant-name": "Automaticky aktualizovat jména variant pomocí této",
"auto-update-product-variant-name": "Automaticky aktualizovat jména variant",
"calculated-price": "Vypočtená cena",
"calculated-price-tooltip": "Je zde konfigurován vlastní výpočet ceny, který upravuje cenu nastavenou výše:",
"cannot-create-variants-without-options": "",
"channel-price-preview": "Náhled ceny v kanálu",
"collection": "",
Expand Down
2 changes: 2 additions & 0 deletions packages/admin-ui/src/lib/static/i18n-messages/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@
"assign-variants-to-channel": "Produktvarianten Kanälen zuweisen",
"auto-update-option-variant-name": "Automatisch Namen der Optionsvariante aktualisieren",
"auto-update-product-variant-name": "Automatisch Namen der Produktvariante aktualisieren",
"calculated-price": "Berechneter Preis",
"calculated-price-tooltip": "Es ist eine benutzerdefinierte Preisberechnung konfiguriert, die den oben festgelegten Preis ändert:",
"cannot-create-variants-without-options": "Produktvarianten können erst dann angelegt werden, wenn eine Optionsgruppe mit mindestens zwei Produktoptionen definiert wurde.",
"channel-price-preview": "Kanal-Preisvorschau",
"collection": "Sammlung",
Expand Down
2 changes: 2 additions & 0 deletions packages/admin-ui/src/lib/static/i18n-messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@
"assign-variants-to-channel": "Assign product variants to channel",
"auto-update-option-variant-name": "Automatically update the names of ProductVariants using this option",
"auto-update-product-variant-name": "Automatically update the names of ProductVariants",
"calculated-price": "Calculated price",
"calculated-price-tooltip": "There is a custom price calculation configured which modifies the price set above:",
"cannot-create-variants-without-options": "Product variants cannot be created until an option group with at least two product options has been defined",
"channel-price-preview": "Channel price preview",
"collection": "Collection",
Expand Down
2 changes: 2 additions & 0 deletions packages/admin-ui/src/lib/static/i18n-messages/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@
"assign-variants-to-channel": "Asignar variantes de producto a canal de ventas",
"auto-update-option-variant-name": "Actualiza los nombres de las variantes de producto automáticamente usando esta opción",
"auto-update-product-variant-name": "Actualiza los nombres de las variantes de producto automáticamente",
"calculated-price": "Precio calculado",
"calculated-price-tooltip": "Hay una configuración de cálculo de precio personalizada que modifica el precio establecido arriba:",
"cannot-create-variants-without-options": "No se pueden crear variantes hasta que un grupo de opciones con al menos dos opciones se haya definido",
"channel-price-preview": "Vista previa de precio para el canal de ventas",
"collection": "Colección",
Expand Down
4 changes: 3 additions & 1 deletion packages/admin-ui/src/lib/static/i18n-messages/fa.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@
"assign-variants-to-channel": "تخصیص نوع محصول به کانال",
"auto-update-option-variant-name": "با استفاده از این گزینه نام نوع محصول را به صورت خودکار به روز کنید",
"auto-update-product-variant-name": "به‌روزرسانی خودکار نام‌های نوع محصول",
"calculated-price": "قیمت محاسبه شده",
"calculated-price-tooltip": "یک محاسبه قیمت سفارشی پیکربندی شده است که قیمت تنظیم شده بالا را اصلاح می کند:",
"cannot-create-variants-without-options": "تعریف نوع محصول تا زمانی که یک گروه از قابلیت با حداقل دو انتخاب تعریف نشده باشد امکان پذیر نیست",
"channel-price-preview": "پیش نمایش قیمت کانال",
"collection": "مجموعه",
Expand Down Expand Up @@ -792,4 +794,4 @@
"job-state-pending": "در انتظار",
"job-state-running": "در حال اجرا"
}
}
}
2 changes: 2 additions & 0 deletions packages/admin-ui/src/lib/static/i18n-messages/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@
"assign-variants-to-channel": "Attribuer une variation du produit au canal",
"auto-update-option-variant-name": "Mettre à jour automatiquement les noms de variations du produit en utilisant cette option",
"auto-update-product-variant-name": "Mettre à jour automatiquement les noms de variations du produit ",
"calculated-price": "Prix calculé",
"calculated-price-tooltip": "Il y a un calcul de prix personnalisé configuré qui modifie le prix défini ci-dessus :",
"cannot-create-variants-without-options": "Impossible de créer des variantes sans options",
"channel-price-preview": "Prévisualisation du prix du canal",
"collection": "Collection",
Expand Down
2 changes: 2 additions & 0 deletions packages/admin-ui/src/lib/static/i18n-messages/he.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@
"assign-variants-to-channel": "הקצה וריאנטים של מוצר לערוץ",
"auto-update-option-variant-name": "עדכן אוטומטית את שמות וריאנטים של המוצר באמצעות האפשרות הזאת",
"auto-update-product-variant-name": "עדכן אוטומטית את שמות וריאנטים של המוצר",
"calculated-price": "מחיר מחושב",
"calculated-price-tooltip": "יש חישוב מחיר מותאם אישית מוגדר שמשנה את המחיר שהוגדר למעלה:",
"cannot-create-variants-without-options": "לא ניתן ליצור וריאנטים של מוצר ללא הגדרת קבוצת אפשרויות עם לפחות שתי אפשרויות מוצר",
"channel-price-preview": "תצוגה מקדימה של מחיר הערוץ",
"collection": "אוסף",
Expand Down
2 changes: 2 additions & 0 deletions packages/admin-ui/src/lib/static/i18n-messages/hr.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@
"assign-variants-to-channel": "Dodijeli varijante proizvoda kanalu",
"auto-update-option-variant-name": "Automatski ažuriraj nazive varijanti proizvoda koristeći ovu opciju",
"auto-update-product-variant-name": "Automatski ažuriraj nazive varijanti proizvoda",
"calculated-price": "Izračunata cijena",
"calculated-price-tooltip": "Postoji prilagođeni izračun cijene koji mijenja gore postavljenu cijenu:",
"cannot-create-variants-without-options": "Nije moguće stvoriti varijante proizvoda dok nije definirana grupa opcija s najmanje dvije opcije proizvoda",
"channel-price-preview": "Pregled cijene za kanal",
"collection": "Kolekcija",
Expand Down
4 changes: 3 additions & 1 deletion packages/admin-ui/src/lib/static/i18n-messages/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@
"assign-variants-to-channel": "Assegna varianti al canale",
"auto-update-option-variant-name": "Aggiorna automaticamente i nomi delle Varianti utilizzando questa opzione",
"auto-update-product-variant-name": "Aggiorna automaticamente i nomi delle Varianti",
"calculated-price": "Prezzo calcolato",
"calculated-price-tooltip": "È configurato un calcolo del prezzo personalizzato che modifica il prezzo impostato sopra:",
"cannot-create-variants-without-options": "Le varianti di prodotto possono essere create solo se è stato definito un gruppo di opzioni con almeno due opzioni di prodotto.",
"channel-price-preview": "Anteprima prezzo canale",
"collection": "Collezione",
Expand Down Expand Up @@ -792,4 +794,4 @@
"job-state-pending": "In attesa",
"job-state-running": "In esecuzione"
}
}
}
4 changes: 3 additions & 1 deletion packages/admin-ui/src/lib/static/i18n-messages/ne.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@
"assign-variants-to-channel": "समान विविधताहरूलाई च्यानलमा लगाउनुहोस्",
"auto-update-option-variant-name": "विकल्प परिविकल्पको नाम आफ्नो आपदेट गर्नका लागि स्वचालित गर्नुहोस्",
"auto-update-product-variant-name": "समान विविधताका नाम आफ्नो आपदेट गर्नका लागि स्वचालित गर्नुहोस्",
"calculated-price": "गणना गरिएको मुल्य",
"calculated-price-tooltip": "उपर सेट गरिएको मूल्यलाई परिवर्तन गर्दछ जुन कस्टम मूल्य गणना गर्नुहोस्:",
"cannot-create-variants-without-options": "कम्ति दुई समान विकल्पसम्म विकल्प संग समावेश गरिएको पर्याप्त छेनपछि समान विविधता सिर्जना गर्न सकिदैन",
"channel-price-preview": "च्यानल मूल्य पूर्वावलोकन",
"collection": "",
Expand Down Expand Up @@ -792,4 +794,4 @@
"job-state-pending": "बाँकी",
"job-state-running": "चलिरहेको"
}
}
}
2 changes: 2 additions & 0 deletions packages/admin-ui/src/lib/static/i18n-messages/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@
"assign-variants-to-channel": "",
"auto-update-option-variant-name": "",
"auto-update-product-variant-name": "",
"calculated-price": "Obliczona cena",
"calculated-price-tooltip": "Istnieje skonfigurowane niestandardowe obliczenie ceny, które modyfikuje powyższą cenę:",
"cannot-create-variants-without-options": "",
"channel-price-preview": "Podgląd cen kanału",
"collection": "",
Expand Down
4 changes: 3 additions & 1 deletion packages/admin-ui/src/lib/static/i18n-messages/pt_BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@
"assign-variants-to-channel": "Atribuir variação ao canal",
"auto-update-option-variant-name": "Atualizar automaticamente os nomes das variações do produto usando esta opção",
"auto-update-product-variant-name": "Atualizar automaticamente os nomes das variações do produto",
"calculated-price": "Preço calculado",
"calculated-price-tooltip": "Há um cálculo de preço personalizado configurado que modifica o preço definido acima:",
"cannot-create-variants-without-options": "As variantes do produto não podem ser criadas até que um grupo de opções com pelo menos duas opções de produtos tenha sido definidas",
"channel-price-preview": "Visualizar preço do canal",
"collection": "Coleçāo",
Expand Down Expand Up @@ -792,4 +794,4 @@
"job-state-pending": "Pendente",
"job-state-running": "Em execução"
}
}
}
2 changes: 2 additions & 0 deletions packages/admin-ui/src/lib/static/i18n-messages/pt_PT.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@
"assign-variants-to-channel": "Atribuir variante ao canal",
"auto-update-option-variant-name": "Utilizar esta opção para actualizar automaticamente os nomes das variantes",
"auto-update-product-variant-name": "Actualizar automaticamente os nomes das variantes do produto",
"calculated-price": "Preço calculado",
"calculated-price-tooltip": "Existe um cálculo de preço personalizado configurado que modifica o preço definido acima:",
"cannot-create-variants-without-options": "",
"channel-price-preview": "Visualizar preço do canal",
"collection": "",
Expand Down
2 changes: 2 additions & 0 deletions packages/admin-ui/src/lib/static/i18n-messages/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@
"assign-variants-to-channel": "Добавить варианты товара в канал",
"auto-update-option-variant-name": "Автоматически обновлять названия вариантов товара с помощью этой опции",
"auto-update-product-variant-name": "Автоматически обновлять названия вариантов товара",
"calculated-price": "Рассчитанная цена",
"calculated-price-tooltip": "Настроен расчет цены, который изменяет указанную выше цену:",
"cannot-create-variants-without-options": "Невозможно создать варианты без опций",
"channel-price-preview": "Предварительный просмотр цен канала",
"collection": "Коллекция",
Expand Down
Loading

0 comments on commit 09c66fe

Please sign in to comment.