Fix label names in reference attributes (#1184)
* Fix label names in reference attributes * Update changelog
This commit is contained in:
parent
fb0e05538e
commit
8703c8d3c4
4 changed files with 31 additions and 6 deletions
|
@ -52,6 +52,7 @@ All notable, unreleased changes to this project will be documented in this file.
|
||||||
- Fix attribute values input display - #1156 by @orzechdev
|
- Fix attribute values input display - #1156 by @orzechdev
|
||||||
- Fix product type translations - #1163 by @orzechdev
|
- Fix product type translations - #1163 by @orzechdev
|
||||||
- Support staff only voucher - #1174 by @orzechdev
|
- Support staff only voucher - #1174 by @orzechdev
|
||||||
|
- Fix label names in reference attributes - #1184 by @orzechdev
|
||||||
|
|
||||||
# 2.11.1
|
# 2.11.1
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,11 @@ import {
|
||||||
AttributeInputTypeEnum,
|
AttributeInputTypeEnum,
|
||||||
AttributeValueInput
|
AttributeValueInput
|
||||||
} from "@saleor/types/globalTypes";
|
} from "@saleor/types/globalTypes";
|
||||||
import { mapNodeToChoice, mapPagesToChoices } from "@saleor/utils/maps";
|
import {
|
||||||
|
mapEdgesToItems,
|
||||||
|
mapNodeToChoice,
|
||||||
|
mapPagesToChoices
|
||||||
|
} from "@saleor/utils/maps";
|
||||||
import { MutationFetchResult } from "react-apollo";
|
import { MutationFetchResult } from "react-apollo";
|
||||||
|
|
||||||
import { AttributePageFormData } from "../components/AttributePage";
|
import { AttributePageFormData } from "../components/AttributePage";
|
||||||
|
@ -144,6 +148,20 @@ export const mergeAttributeValueDeleteErrors = (
|
||||||
return errors;
|
return errors;
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
export const mergeChoicesWithValues = (
|
||||||
|
attribute:
|
||||||
|
| ProductDetails_product_attributes
|
||||||
|
| PageDetails_page_attributes
|
||||||
|
| SelectedVariantAttributeFragment
|
||||||
|
) => {
|
||||||
|
const choices = mapEdgesToItems(attribute.attribute.choices);
|
||||||
|
const valuesToConcat = attribute.values.filter(
|
||||||
|
value => !choices.some(choice => choice.id === value.id)
|
||||||
|
);
|
||||||
|
|
||||||
|
return choices.concat(valuesToConcat);
|
||||||
|
};
|
||||||
|
|
||||||
export const mergeAttributeValues = (
|
export const mergeAttributeValues = (
|
||||||
attributeId: string,
|
attributeId: string,
|
||||||
attributeValues: string[],
|
attributeValues: string[],
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
import { getSelectedAttributeValues } from "@saleor/attributes/utils/data";
|
import {
|
||||||
|
getSelectedAttributeValues,
|
||||||
|
mergeChoicesWithValues
|
||||||
|
} from "@saleor/attributes/utils/data";
|
||||||
import { AttributeInput } from "@saleor/components/Attributes";
|
import { AttributeInput } from "@saleor/components/Attributes";
|
||||||
import { mapEdgesToItems } from "@saleor/utils/maps";
|
import { mapEdgesToItems } from "@saleor/utils/maps";
|
||||||
|
|
||||||
|
@ -16,7 +19,7 @@ export function getAttributeInputFromPage(
|
||||||
inputType: attribute.attribute.inputType,
|
inputType: attribute.attribute.inputType,
|
||||||
isRequired: attribute.attribute.valueRequired,
|
isRequired: attribute.attribute.valueRequired,
|
||||||
selectedValues: attribute.values,
|
selectedValues: attribute.values,
|
||||||
values: mapEdgesToItems(attribute.attribute.choices),
|
values: mergeChoicesWithValues(attribute),
|
||||||
unit: attribute.attribute.unit
|
unit: attribute.attribute.unit
|
||||||
},
|
},
|
||||||
id: attribute.attribute.id,
|
id: attribute.attribute.id,
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
import { getSelectedAttributeValues } from "@saleor/attributes/utils/data";
|
import {
|
||||||
|
getSelectedAttributeValues,
|
||||||
|
mergeChoicesWithValues
|
||||||
|
} from "@saleor/attributes/utils/data";
|
||||||
import { ChannelData } from "@saleor/channels/utils";
|
import { ChannelData } from "@saleor/channels/utils";
|
||||||
import {
|
import {
|
||||||
AttributeInput,
|
AttributeInput,
|
||||||
|
@ -52,7 +55,7 @@ export function getAttributeInputFromProduct(
|
||||||
inputType: attribute.attribute.inputType,
|
inputType: attribute.attribute.inputType,
|
||||||
isRequired: attribute.attribute.valueRequired,
|
isRequired: attribute.attribute.valueRequired,
|
||||||
selectedValues: attribute.values,
|
selectedValues: attribute.values,
|
||||||
values: mapEdgesToItems(attribute.attribute.choices),
|
values: mergeChoicesWithValues(attribute),
|
||||||
unit: attribute.attribute.unit
|
unit: attribute.attribute.unit
|
||||||
},
|
},
|
||||||
id: attribute.attribute.id,
|
id: attribute.attribute.id,
|
||||||
|
@ -109,7 +112,7 @@ export function getAttributeInputFromSelectedAttributes(
|
||||||
inputType: attribute.attribute.inputType,
|
inputType: attribute.attribute.inputType,
|
||||||
isRequired: attribute.attribute.valueRequired,
|
isRequired: attribute.attribute.valueRequired,
|
||||||
selectedValues: attribute.values,
|
selectedValues: attribute.values,
|
||||||
values: mapEdgesToItems(attribute.attribute.choices),
|
values: mergeChoicesWithValues(attribute),
|
||||||
unit: attribute.attribute.unit,
|
unit: attribute.attribute.unit,
|
||||||
variantAttributeScope
|
variantAttributeScope
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue