Просмотр исходного кода

fix(core): Improved feedback on FacetValue deletion confirmation

Include the FacetValue code as an extra verification point.
Michael Bromley 3 лет назад
Родитель
Сommit
03419cbe4a

+ 1 - 1
packages/core/e2e/facet.e2e-spec.ts

@@ -314,7 +314,7 @@ describe('Facet resolver', () => {
             expect(result1.deleteFacetValues).toEqual([
                 {
                     result: DeletionResult.NOT_DELETED,
-                    message: `The selected FacetValue is assigned to 1 Product, 1 ProductVariant`,
+                    message: `The FacetValue "compact" is assigned to 1 Product, 1 ProductVariant`,
                 },
             ]);
 

+ 3 - 3
packages/core/src/i18n/messages/de.json

@@ -70,7 +70,7 @@
     "NO_ACTIVE_ORDER_ERROR": "Es gibt keine aktive Bestellung in der aktuellen Sitzung",
     "NOTHING_TO_REFUND_ERROR": "Es gibt nichts zurückzuerstatten",
     "NOT_VERIFIED_ERROR": "Bitte bestätige deine E-Mail-Adresse, bevor du dich anmeldest",
-    "ORDER_LIMIT_ERROR": "Der Artikel konnte nicht hinzugefügt werden. Eine Bestellung kann maximal { maxItems } Artikel enthalten", 
+    "ORDER_LIMIT_ERROR": "Der Artikel konnte nicht hinzugefügt werden. Eine Bestellung kann maximal { maxItems } Artikel enthalten",
     "ORDER_MODIFICATION_ERROR": "Der Inhalt der Bestellung kann nur im Status \"AddingItems\" geändert werden",
     "ORDER_PAYMENT_STATE_ERROR": "Eine Zahlung kann nur im Status \"ArrangingPayment\" hinzugefügt werden",
     "ORDER_STATE_TRANSITION_ERROR": "Der Status der Bestellung kan nicht von \"{ fromState }\" zu \"{ toState }\" geändert werden",
@@ -108,9 +108,9 @@
     "facet-force-deleted": "Die Facette wurde gelöscht und ihre FacetValues wurden von {products, plural, =0 {} one {einem Produkt} other {# Produkten}}{both, select, both { und } single {}}{variants, plural, =0 {} one {einer Produktvariante} other {# Produktvariantem}} entfernt",
     "facet-used": "Die ausgewählte Facette enthält FacetValues, die {products, plural, =0 {} one {einem Produkt} other {# Produkten}}{both, select, both { und } single {}}{variants, plural, =0 {} one {einer Produktvariante} other {# Produktvarianten}} zugewiesen sind",
     "facet-value-force-deleted": "Der gewählte FacetValue wurde von {products, plural, =0 {} one {einem Produkt} other {# Produkten}}{both, select, both { und } single {}}{variants, plural, =0 {} one {einer Produktvariante} other {# Produktvarianten}} entfernt und gelöscht",
-    "facet-value-used": "Der gewählte FacetValue wurde {products, plural, =0 {} one {einem Produkt} other {# Produkten}}{both, select, both { und } single {}}{variants, plural, =0 {} one {einer Produktvariante} other {# Produktvarianten}} zugewiesen",
+    "facet-value-used": "Der FacetValue \"{ facetValueCode }\" wurde {products, plural, =0 {} one {einem Produkt} other {# Produkten}}{both, select, both { und } single {}}{variants, plural, =0 {} one {einer Produktvariante} other {# Produktvarianten}} zugewiesen",
     "payment-method-used-in-channels": "Die gewählte Zahlungsmethode wird von den folgenden Kanälen verwendet: { channelCodes }. Mit \"force: true\" wird sie von allen Kanälen entfernt.",
     "zone-used-in-channels": "Die ausgewählte Zone kann nicht gelöscht werden, da sie als Standard in den folgenden Kanälen verwendet wird: { channelCodes }",
     "zone-used-in-tax-rates": "Die ausgewählte Zone kann nicht gelöscht werden, da sie in den folgenden Steuersätzen verwendet wird: { taxRateNames }"
   }
-}
+}

+ 1 - 1
packages/core/src/i18n/messages/en.json

@@ -120,7 +120,7 @@
     "facet-force-deleted": "The Facet was deleted and its FacetValues were removed from {products, plural, =0 {} one {1 Product} other {# Products}}{both, select, both { , } single {}}{variants, plural, =0 {} one {1 ProductVariant} other {# ProductVariants}}",
     "facet-used": "The Facet \"{ facetCode }\" includes FacetValues which are assigned to {products, plural, =0 {} one {1 Product} other {# Products}}{both, select, both { , } single {}}{variants, plural, =0 {} one {1 ProductVariant} other {# ProductVariants}}",
     "facet-value-force-deleted": "The selected FacetValue was removed from {products, plural, =0 {} one {1 Product} other {# Products}}{both, select, both { , } single {}}{variants, plural, =0 {} one {1 ProductVariant} other {# ProductVariants}} and deleted",
-    "facet-value-used": "The selected FacetValue is assigned to {products, plural, =0 {} one {1 Product} other {# Products}}{both, select, both { , } single {}}{variants, plural, =0 {} one {1 ProductVariant} other {# ProductVariants}}",
+    "facet-value-used": "The FacetValue \"{ facetValueCode }\" is assigned to {products, plural, =0 {} one {1 Product} other {# Products}}{both, select, both { , } single {}}{variants, plural, =0 {} one {1 ProductVariant} other {# ProductVariants}}",
     "payment-method-used-in-channels": "The selected PaymentMethod is assigned to the following Channels: { channelCodes }. Set \"force: true\" to delete from all Channels.",
     "product-option-used": "Cannot delete the option \"{code}\" as it is being used by {count, plural, =0 {} one {1 ProductVariant} other {# ProductVariants}}",
     "zone-used-in-channels": "The selected Zone cannot be deleted as it used as a default in the following Channels: { channelCodes }",

+ 6 - 1
packages/core/src/service/services/facet-value.service.ts

@@ -144,11 +144,16 @@ export class FacetValueService {
 
         const isInUse = !!(productCount || variantCount);
         const both = !!(productCount && variantCount) ? 'both' : 'single';
-        const i18nVars = { products: productCount, variants: variantCount, both };
         let message = '';
         let result: DeletionResult;
 
         const facetValue = await this.connection.getEntityOrThrow(ctx, FacetValue, id);
+        const i18nVars = {
+            products: productCount,
+            variants: variantCount,
+            both,
+            facetValueCode: facetValue.code,
+        };
         // Create a new facetValue so that the id is still available
         // after deletion (the .remove() method sets it to undefined)
         const deletedFacetValue = new FacetValue(facetValue);