[SALEOR-3090] Boolean attribute (#1157)

This commit is contained in:
Piotr Grundas 2021-06-20 01:13:16 +02:00 committed by GitHub
parent a114a39f45
commit a0dce99b5d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
78 changed files with 971 additions and 271 deletions

View file

@ -167,6 +167,7 @@ All notable, unreleased changes to this project will be documented in this file.
- Update product stock management to newest design - #515 by @dominik-zeglen
- Handle untracked products - #523 by @dominik-zeglen
- Display correct error if there were no graphql errors - #525 by @dominik-zeglen
- Add boolean attributes - #1157 by @piotrgrundas
## 2.0.0

View file

@ -953,6 +953,10 @@
"context": "attribute slug input field helper text",
"string": "This is used internally. Make sure you dont use spaces"
},
"src_dot_attributes_dot_components_dot_AttributeDetails_dot_boolean": {
"context": "boolean attribute type",
"string": "Boolean"
},
"src_dot_attributes_dot_components_dot_AttributeDetails_dot_distance": {
"context": "distance units type",
"string": "Distance"

View file

@ -519,6 +519,7 @@ input AttributeInput {
slug: String!
values: [String]
valuesRange: IntRangeInput
boolean: Boolean
}
enum AttributeInputTypeEnum {
@ -528,6 +529,7 @@ enum AttributeInputTypeEnum {
REFERENCE
NUMERIC
RICH_TEXT
BOOLEAN
}
type AttributeReorderValues {
@ -608,6 +610,7 @@ type AttributeValue implements Node {
reference: ID
file: File
richText: JSONString
boolean: Boolean
}
type AttributeValueBulkDelete {
@ -658,6 +661,7 @@ input AttributeValueInput {
contentType: String
references: [ID!]
richText: JSONString
boolean: Boolean
}
type AttributeValueTranslatableContent implements Node {

View file

@ -96,6 +96,10 @@ const AttributeDetails: React.FC<AttributeDetailsProps> = props => {
{
label: intl.formatMessage(inputTypeMessages.numeric),
value: AttributeInputTypeEnum.NUMERIC
},
{
label: intl.formatMessage(inputTypeMessages.boolean),
value: AttributeInputTypeEnum.BOOLEAN
}
];
const entityTypeChoices = [

View file

@ -69,6 +69,10 @@ export const inputTypeMessages = defineMessages({
numeric: {
defaultMessage: "Numeric",
description: "numeric attribute type"
},
boolean: {
defaultMessage: "Boolean",
description: "boolean attribute type"
}
});

View file

@ -1,5 +1,5 @@
import { Card, CardContent, TextField, Typography } from "@material-ui/core";
import { ATTRIBUTE_TYPES_WITH_DEDICATED_VALUES } from "@saleor/attributes/utils/data";
import { ATTRIBUTE_TYPES_WITH_CONFIGURABLE_FACED_NAVIGATION } from "@saleor/attributes/utils/data";
import CardSpacer from "@saleor/components/CardSpacer";
import CardTitle from "@saleor/components/CardTitle";
import ControlledCheckbox from "@saleor/components/ControlledCheckbox";
@ -78,13 +78,14 @@ const AttributeProperties: React.FC<AttributePropertiesProps> = ({
const formErrors = getFormErrors(["storefrontSearchPosition"], errors);
const dashboardProperties = ATTRIBUTE_TYPES_WITH_DEDICATED_VALUES.includes(
const dashboardProperties = ATTRIBUTE_TYPES_WITH_CONFIGURABLE_FACED_NAVIGATION.includes(
data.inputType
);
const storefrontFacetedNavigationProperties =
ATTRIBUTE_TYPES_WITH_DEDICATED_VALUES.includes(data.inputType) &&
data.type === AttributeTypeEnum.PRODUCT_TYPE;
ATTRIBUTE_TYPES_WITH_CONFIGURABLE_FACED_NAVIGATION.includes(
data.inputType
) && data.type === AttributeTypeEnum.PRODUCT_TYPE;
return (
<Card>

View file

@ -49,7 +49,8 @@ export const attribute: AttributeDetails_attribute = {
name: "John Doe",
reference: null,
slug: "john-doe",
richText: null
richText: null,
boolean: null
}
},
{
@ -62,7 +63,8 @@ export const attribute: AttributeDetails_attribute = {
name: "Milionare Pirate",
reference: null,
slug: "milionare-pirate",
richText: null
richText: null,
boolean: null
}
}
]
@ -81,6 +83,7 @@ export const attributes: Array<AttributeList_attributes_edges_node &
name: "Author",
slug: "author",
type: AttributeTypeEnum.PRODUCT_TYPE,
inputType: AttributeInputTypeEnum.DROPDOWN,
unit: null,
choices: {
__typename: "AttributeValueCountableConnection" as "AttributeValueCountableConnection",
@ -104,7 +107,8 @@ export const attributes: Array<AttributeList_attributes_edges_node &
slug: "john-doe",
sortOrder: 0,
value: "",
richText: null
richText: null,
boolean: null
}
},
{
@ -119,7 +123,8 @@ export const attributes: Array<AttributeList_attributes_edges_node &
slug: "milionare-pirate",
sortOrder: 1,
value: "",
richText: null
richText: null,
boolean: null
}
}
]
@ -136,6 +141,7 @@ export const attributes: Array<AttributeList_attributes_edges_node &
name: "Box Size",
slug: "box-size",
type: AttributeTypeEnum.PRODUCT_TYPE,
inputType: AttributeInputTypeEnum.DROPDOWN,
unit: null,
choices: {
__typename: "AttributeValueCountableConnection" as "AttributeValueCountableConnection",
@ -159,7 +165,8 @@ export const attributes: Array<AttributeList_attributes_edges_node &
slug: "100g",
sortOrder: 0,
value: "",
richText: null
richText: null,
boolean: null
}
},
{
@ -174,7 +181,8 @@ export const attributes: Array<AttributeList_attributes_edges_node &
slug: "250g",
sortOrder: 1,
value: "",
richText: null
richText: null,
boolean: null
}
},
{
@ -189,7 +197,8 @@ export const attributes: Array<AttributeList_attributes_edges_node &
slug: "500g",
sortOrder: 2,
value: "",
richText: null
richText: null,
boolean: null
}
},
{
@ -204,7 +213,8 @@ export const attributes: Array<AttributeList_attributes_edges_node &
slug: "1kg",
sortOrder: 3,
value: "",
richText: null
richText: null,
boolean: null
}
}
]
@ -221,6 +231,7 @@ export const attributes: Array<AttributeList_attributes_edges_node &
name: "Brand",
slug: "brand",
type: AttributeTypeEnum.PRODUCT_TYPE,
inputType: AttributeInputTypeEnum.DROPDOWN,
unit: null,
choices: {
__typename: "AttributeValueCountableConnection" as "AttributeValueCountableConnection",
@ -244,7 +255,8 @@ export const attributes: Array<AttributeList_attributes_edges_node &
slug: "saleor",
sortOrder: 0,
value: "",
richText: null
richText: null,
boolean: null
}
}
]
@ -261,6 +273,7 @@ export const attributes: Array<AttributeList_attributes_edges_node &
name: "Candy Box Size",
slug: "candy-box-size",
type: AttributeTypeEnum.PRODUCT_TYPE,
inputType: AttributeInputTypeEnum.DROPDOWN,
unit: null,
choices: {
__typename: "AttributeValueCountableConnection" as "AttributeValueCountableConnection",
@ -284,7 +297,8 @@ export const attributes: Array<AttributeList_attributes_edges_node &
slug: "100g",
sortOrder: 0,
value: "",
richText: null
richText: null,
boolean: null
}
},
{
@ -299,7 +313,8 @@ export const attributes: Array<AttributeList_attributes_edges_node &
slug: "250g",
sortOrder: 1,
value: "",
richText: null
richText: null,
boolean: null
}
},
{
@ -314,7 +329,8 @@ export const attributes: Array<AttributeList_attributes_edges_node &
slug: "500g",
sortOrder: 2,
value: "",
richText: null
richText: null,
boolean: null
}
}
]
@ -331,6 +347,7 @@ export const attributes: Array<AttributeList_attributes_edges_node &
name: "Coffee Genre",
slug: "coffee-genre",
type: AttributeTypeEnum.PRODUCT_TYPE,
inputType: AttributeInputTypeEnum.DROPDOWN,
unit: null,
choices: {
__typename: "AttributeValueCountableConnection" as "AttributeValueCountableConnection",
@ -354,7 +371,8 @@ export const attributes: Array<AttributeList_attributes_edges_node &
slug: "arabica",
sortOrder: 0,
value: "",
richText: null
richText: null,
boolean: null
}
},
{
@ -369,7 +387,8 @@ export const attributes: Array<AttributeList_attributes_edges_node &
slug: "robusta",
sortOrder: 1,
value: "",
richText: null
richText: null,
boolean: null
}
}
]
@ -386,6 +405,7 @@ export const attributes: Array<AttributeList_attributes_edges_node &
name: "Collar",
slug: "collar",
type: AttributeTypeEnum.PRODUCT_TYPE,
inputType: AttributeInputTypeEnum.DROPDOWN,
unit: null,
choices: {
__typename: "AttributeValueCountableConnection" as "AttributeValueCountableConnection",
@ -409,7 +429,8 @@ export const attributes: Array<AttributeList_attributes_edges_node &
slug: "round",
sortOrder: 0,
value: "",
richText: null
richText: null,
boolean: null
}
},
{
@ -424,7 +445,8 @@ export const attributes: Array<AttributeList_attributes_edges_node &
slug: "v-neck",
sortOrder: 1,
value: "",
richText: null
richText: null,
boolean: null
}
},
{
@ -439,7 +461,8 @@ export const attributes: Array<AttributeList_attributes_edges_node &
slug: "polo",
sortOrder: 2,
value: "",
richText: null
richText: null,
boolean: null
}
}
]
@ -456,6 +479,7 @@ export const attributes: Array<AttributeList_attributes_edges_node &
name: "Color",
slug: "color",
type: AttributeTypeEnum.PRODUCT_TYPE,
inputType: AttributeInputTypeEnum.DROPDOWN,
unit: null,
choices: {
__typename: "AttributeValueCountableConnection" as "AttributeValueCountableConnection",
@ -479,7 +503,8 @@ export const attributes: Array<AttributeList_attributes_edges_node &
slug: "blue",
sortOrder: 0,
value: "",
richText: null
richText: null,
boolean: null
}
},
{
@ -494,7 +519,8 @@ export const attributes: Array<AttributeList_attributes_edges_node &
slug: "white",
sortOrder: 1,
value: "",
richText: null
richText: null,
boolean: null
}
}
]
@ -511,6 +537,7 @@ export const attributes: Array<AttributeList_attributes_edges_node &
name: "Cover",
slug: "cover",
type: AttributeTypeEnum.PRODUCT_TYPE,
inputType: AttributeInputTypeEnum.DROPDOWN,
unit: null,
choices: {
__typename: "AttributeValueCountableConnection" as "AttributeValueCountableConnection",
@ -534,7 +561,8 @@ export const attributes: Array<AttributeList_attributes_edges_node &
slug: "soft",
sortOrder: 0,
value: "",
richText: null
richText: null,
boolean: null
}
},
{
@ -549,7 +577,8 @@ export const attributes: Array<AttributeList_attributes_edges_node &
slug: "hard",
sortOrder: 1,
value: "",
richText: null
richText: null,
boolean: null
}
},
{
@ -564,7 +593,8 @@ export const attributes: Array<AttributeList_attributes_edges_node &
slug: "middle-soft",
sortOrder: 2,
value: "",
richText: null
richText: null,
boolean: null
}
},
{
@ -579,7 +609,8 @@ export const attributes: Array<AttributeList_attributes_edges_node &
slug: "middle-hard",
sortOrder: 3,
value: "",
richText: null
richText: null,
boolean: null
}
},
{
@ -594,7 +625,8 @@ export const attributes: Array<AttributeList_attributes_edges_node &
slug: "middle",
sortOrder: 4,
value: "",
richText: null
richText: null,
boolean: null
}
},
{
@ -609,7 +641,8 @@ export const attributes: Array<AttributeList_attributes_edges_node &
slug: "very-hard",
sortOrder: 5,
value: "",
richText: null
richText: null,
boolean: null
}
}
]
@ -626,6 +659,7 @@ export const attributes: Array<AttributeList_attributes_edges_node &
name: "Flavor",
slug: "flavor",
type: AttributeTypeEnum.PRODUCT_TYPE,
inputType: AttributeInputTypeEnum.DROPDOWN,
unit: null,
choices: {
__typename: "AttributeValueCountableConnection" as "AttributeValueCountableConnection",
@ -649,7 +683,8 @@ export const attributes: Array<AttributeList_attributes_edges_node &
slug: "sour",
sortOrder: 0,
value: "",
richText: null
richText: null,
boolean: null
}
},
{
@ -664,7 +699,8 @@ export const attributes: Array<AttributeList_attributes_edges_node &
slug: "sweet",
sortOrder: 1,
value: "",
richText: null
richText: null,
boolean: null
}
}
]
@ -681,6 +717,7 @@ export const attributes: Array<AttributeList_attributes_edges_node &
name: "Language",
slug: "language",
type: AttributeTypeEnum.PRODUCT_TYPE,
inputType: AttributeInputTypeEnum.DROPDOWN,
unit: null,
choices: {
__typename: "AttributeValueCountableConnection" as "AttributeValueCountableConnection",
@ -704,7 +741,8 @@ export const attributes: Array<AttributeList_attributes_edges_node &
slug: "english",
sortOrder: 0,
value: "",
richText: null
richText: null,
boolean: null
}
},
{
@ -719,7 +757,8 @@ export const attributes: Array<AttributeList_attributes_edges_node &
slug: "pirate",
sortOrder: 1,
value: "",
richText: null
richText: null,
boolean: null
}
}
]
@ -736,6 +775,7 @@ export const attributes: Array<AttributeList_attributes_edges_node &
name: "Publisher",
slug: "publisher",
type: AttributeTypeEnum.PRODUCT_TYPE,
inputType: AttributeInputTypeEnum.DROPDOWN,
unit: null,
choices: {
__typename: "AttributeValueCountableConnection" as "AttributeValueCountableConnection",
@ -759,7 +799,8 @@ export const attributes: Array<AttributeList_attributes_edges_node &
slug: "mirumee-press",
sortOrder: 0,
value: "",
richText: null
richText: null,
boolean: null
}
},
{
@ -774,7 +815,8 @@ export const attributes: Array<AttributeList_attributes_edges_node &
slug: "saleor-publishing",
sortOrder: 1,
value: "",
richText: null
richText: null,
boolean: null
}
}
]
@ -792,6 +834,7 @@ export const attributes: Array<AttributeList_attributes_edges_node &
slug: "size",
type: AttributeTypeEnum.PRODUCT_TYPE,
unit: null,
inputType: AttributeInputTypeEnum.DROPDOWN,
choices: {
__typename: "AttributeValueCountableConnection" as "AttributeValueCountableConnection",
pageInfo: {
@ -814,7 +857,8 @@ export const attributes: Array<AttributeList_attributes_edges_node &
slug: "xs",
sortOrder: 0,
value: "",
richText: null
richText: null,
boolean: null
}
},
{
@ -829,7 +873,8 @@ export const attributes: Array<AttributeList_attributes_edges_node &
slug: "s",
sortOrder: 1,
value: "",
richText: null
richText: null,
boolean: null
}
},
{
@ -844,7 +889,8 @@ export const attributes: Array<AttributeList_attributes_edges_node &
slug: "m",
sortOrder: 2,
value: "",
richText: null
richText: null,
boolean: null
}
},
{
@ -859,7 +905,8 @@ export const attributes: Array<AttributeList_attributes_edges_node &
slug: "l",
sortOrder: 3,
value: "",
richText: null
richText: null,
boolean: null
}
},
{
@ -874,7 +921,8 @@ export const attributes: Array<AttributeList_attributes_edges_node &
slug: "xl",
sortOrder: 4,
value: "",
richText: null
richText: null,
boolean: null
}
},
{
@ -889,7 +937,8 @@ export const attributes: Array<AttributeList_attributes_edges_node &
slug: "xxl",
sortOrder: 5,
value: "",
richText: null
richText: null,
boolean: null
}
}
]

View file

@ -43,6 +43,7 @@ export interface AttributeDetails_attribute_choices_edges_node {
file: AttributeDetails_attribute_choices_edges_node_file | null;
reference: string | null;
richText: any | null;
boolean: boolean | null;
}
export interface AttributeDetails_attribute_choices_edges {
@ -67,10 +68,10 @@ export interface AttributeDetails_attribute {
filterableInDashboard: boolean;
filterableInStorefront: boolean;
unit: MeasurementUnitsEnum | null;
inputType: AttributeInputTypeEnum | null;
metadata: (AttributeDetails_attribute_metadata | null)[];
privateMetadata: (AttributeDetails_attribute_privateMetadata | null)[];
availableInGrid: boolean;
inputType: AttributeInputTypeEnum | null;
entityType: AttributeEntityTypeEnum | null;
storefrontSearchPosition: number;
valueRequired: boolean;

View file

@ -3,7 +3,7 @@
// @generated
// This file was automatically generated and should not be edited.
import { AttributeFilterInput, AttributeSortingInput, AttributeTypeEnum, MeasurementUnitsEnum } from "./../../types/globalTypes";
import { AttributeFilterInput, AttributeSortingInput, AttributeTypeEnum, MeasurementUnitsEnum, AttributeInputTypeEnum } from "./../../types/globalTypes";
// ====================================================
// GraphQL query operation: AttributeList
@ -19,6 +19,7 @@ export interface AttributeList_attributes_edges_node {
filterableInDashboard: boolean;
filterableInStorefront: boolean;
unit: MeasurementUnitsEnum | null;
inputType: AttributeInputTypeEnum | null;
}
export interface AttributeList_attributes_edges {

View file

@ -31,10 +31,10 @@ export interface AttributeUpdate_attributeUpdate_attribute {
filterableInDashboard: boolean;
filterableInStorefront: boolean;
unit: MeasurementUnitsEnum | null;
inputType: AttributeInputTypeEnum | null;
metadata: (AttributeUpdate_attributeUpdate_attribute_metadata | null)[];
privateMetadata: (AttributeUpdate_attributeUpdate_attribute_privateMetadata | null)[];
availableInGrid: boolean;
inputType: AttributeInputTypeEnum | null;
entityType: AttributeEntityTypeEnum | null;
storefrontSearchPosition: number;
valueRequired: boolean;

View file

@ -31,6 +31,7 @@ export interface AttributeValueCreate_attributeValueCreate_attribute_choices_edg
file: AttributeValueCreate_attributeValueCreate_attribute_choices_edges_node_file | null;
reference: string | null;
richText: any | null;
boolean: boolean | null;
}
export interface AttributeValueCreate_attributeValueCreate_attribute_choices_edges {

View file

@ -31,6 +31,7 @@ export interface AttributeValueDelete_attributeValueDelete_attribute_choices_edg
file: AttributeValueDelete_attributeValueDelete_attribute_choices_edges_node_file | null;
reference: string | null;
richText: any | null;
boolean: boolean | null;
}
export interface AttributeValueDelete_attributeValueDelete_attribute_choices_edges {

View file

@ -31,6 +31,7 @@ export interface AttributeValueUpdate_attributeValueUpdate_attribute_choices_edg
file: AttributeValueUpdate_attributeValueUpdate_attribute_choices_edges_node_file | null;
reference: string | null;
richText: any | null;
boolean: boolean | null;
}
export interface AttributeValueUpdate_attributeValueUpdate_attribute_choices_edges {

View file

@ -28,6 +28,12 @@ export const ATTRIBUTE_TYPES_WITH_DEDICATED_VALUES = [
AttributeInputTypeEnum.MULTISELECT
];
export const ATTRIBUTE_TYPES_WITH_CONFIGURABLE_FACED_NAVIGATION = [
AttributeInputTypeEnum.DROPDOWN,
AttributeInputTypeEnum.MULTISELECT,
AttributeInputTypeEnum.BOOLEAN
];
export interface AttributeReference {
label: string;
value: string;
@ -87,6 +93,9 @@ export function getSelectedAttributeValues(
case AttributeInputTypeEnum.NUMERIC:
return [attribute.values[0]?.name];
case AttributeInputTypeEnum.BOOLEAN:
return [attribute.values[0]?.boolean ?? "false"];
default:
return attribute.values.map(value => value.slug);
}

View file

@ -16,7 +16,8 @@ const attributes: FormsetData<AttributeInputData, string[]> = [
name: "Attribute 1 Value 1",
reference: null,
slug: "attr-1-v-1",
richText: null
richText: null,
boolean: null
}
]
},
@ -36,7 +37,8 @@ const attributes: FormsetData<AttributeInputData, string[]> = [
name: "Attribute 2 Value 1",
reference: null,
slug: "attr-2-v-1",
richText: null
richText: null,
boolean: null
},
{
__typename: "AttributeValue",
@ -45,7 +47,8 @@ const attributes: FormsetData<AttributeInputData, string[]> = [
name: "Attribute 2 Value 2",
reference: null,
slug: "attr-2-v-2",
richText: null
richText: null,
boolean: null
},
{
__typename: "AttributeValue",
@ -54,7 +57,8 @@ const attributes: FormsetData<AttributeInputData, string[]> = [
name: "Attribute 2 Value 3",
reference: null,
slug: "attr-2-v-3",
richText: null
richText: null,
boolean: null
}
]
},
@ -78,7 +82,8 @@ const attributes: FormsetData<AttributeInputData, string[]> = [
name: "File First Value",
reference: null,
slug: "file-first-value",
richText: null
richText: null,
boolean: null
}
]
},

View file

@ -177,44 +177,75 @@ interface AttributesArgs {
updatedFileAttributes: AttributeValueInput[];
}
function getFileInput(
attribute: AttributeInput,
updatedFileAttributes: AttributeValueInput[]
) {
const updatedFileAttribute = updatedFileAttributes.find(
attributeWithNewFile => attribute.id === attributeWithNewFile.id
);
if (updatedFileAttribute) {
return {
file: updatedFileAttribute.file,
id: updatedFileAttribute.id
};
}
return {
file: updatedFileAttribute.file,
id: updatedFileAttribute.id
};
}
function getReferenceInput(attribute: AttributeInput) {
return {
id: attribute.id,
references: attribute.value
};
}
function getRichTextInput(attribute: AttributeInput) {
return {
id: attribute.id,
richText: attribute.value[0]
};
}
function getBooleanInput(attribute: AttributeInput) {
return {
id: attribute.id,
boolean: JSON.parse(attribute.value[0] ?? "false")
};
}
function getDefaultInput(attribute: AttributeInput) {
return {
id: attribute.id,
values: attribute.value[0] === "" ? [] : attribute.value
};
}
export const prepareAttributesInput = ({
attributes,
updatedFileAttributes
}: AttributesArgs): AttributeValueInput[] =>
attributes.map(attribute => {
if (attribute.data.inputType === AttributeInputTypeEnum.FILE) {
const updatedFileAttribute = updatedFileAttributes.find(
attributeWithNewFile => attribute.id === attributeWithNewFile.id
);
if (updatedFileAttribute) {
return {
file: updatedFileAttribute.file,
id: updatedFileAttribute.id
};
}
return {
file:
attribute.data.selectedValues &&
attribute.data.selectedValues[0]?.file?.url,
id: attribute.id
};
switch (attribute.data.inputType) {
case AttributeInputTypeEnum.FILE:
return getFileInput(attribute, updatedFileAttributes);
case AttributeInputTypeEnum.REFERENCE:
return getReferenceInput(attribute);
case AttributeInputTypeEnum.RICH_TEXT:
return getRichTextInput(attribute);
case AttributeInputTypeEnum.BOOLEAN:
return getBooleanInput(attribute);
default:
return getDefaultInput(attribute);
}
if (attribute.data.inputType === AttributeInputTypeEnum.REFERENCE) {
return {
id: attribute.id,
references: attribute.value
};
}
if (attribute.data.inputType === AttributeInputTypeEnum.RICH_TEXT) {
return {
id: attribute.id,
richText: attribute.value[0]
};
}
return {
id: attribute.id,
values: attribute.value[0] === "" ? [] : attribute.value
};
});
export const handleUploadMultipleFiles = async (

View file

@ -206,6 +206,7 @@ const AttributeDetails: React.FC<AttributeDetailsProps> = ({ params }) => {
sortOrder: valueIndex,
value: null,
richText: null,
boolean: null,
...value
}
}))

View file

@ -14,6 +14,7 @@ import {
getSingleChoices,
getSingleDisplayValue
} from "@saleor/components/Attributes/utils";
import Checkbox from "@saleor/components/Checkbox";
import FileUploadField from "@saleor/components/FileUploadField";
import MultiAutocompleteSelectField from "@saleor/components/MultiAutocompleteSelectField";
import RichTextEditor from "@saleor/components/RichTextEditor";
@ -43,6 +44,10 @@ const useStyles = makeStyles(
() => ({
fileField: {
float: "right"
},
pullRight: {
display: "flex",
justifyContent: "flex-end"
}
}),
{ name: "AttributeRow" }
@ -193,6 +198,24 @@ const AttributeRow: React.FC<AttributeRowProps> = ({
/>
</BasicAttributeRow>
);
case AttributeInputTypeEnum.BOOLEAN:
return (
<BasicAttributeRow label={attribute.label}>
<div className={classes.pullRight}>
<Checkbox
disabled={disabled}
name={`attribute:${attribute.label}`}
onChange={event =>
onChange(attribute.id, JSON.stringify(event.target.checked))
}
checked={JSON.parse(attribute.value[0] ?? "false")}
className={classes.pullRight}
helperText={getErrorMessage(error, intl)}
error={!!error}
/>
</div>
</BasicAttributeRow>
);
default:
return (
<BasicAttributeRow label={attribute.label}>

View file

@ -9,7 +9,8 @@ const useStyles = makeStyles(
"&:last-of-type": {
paddingBottom: 0
},
padding: theme.spacing(2, 0)
padding: theme.spacing(2, 0),
wordBreak: "break-word"
},
attributeSectionLabel: {
alignItems: "center",

View file

@ -1,6 +1,7 @@
import {
AttributeEntityTypeEnum,
AttributeInputTypeEnum
AttributeInputTypeEnum,
MeasurementUnitsEnum
} from "@saleor/types/globalTypes";
import { AttributeInput } from "./Attributes";
@ -17,7 +18,8 @@ const DROPDOWN_ATTRIBUTE: AttributeInput = {
name: "Dropdown First Value",
reference: null,
slug: "dropdown-first-value",
richText: null
richText: null,
boolean: null
},
{
__typename: "AttributeValue",
@ -26,7 +28,8 @@ const DROPDOWN_ATTRIBUTE: AttributeInput = {
name: "Dropdown Second Value",
reference: null,
slug: "dropdown-second-value",
richText: null
richText: null,
boolean: null
}
]
},
@ -47,7 +50,8 @@ const MULTISELECT_ATTRIBUTE: AttributeInput = {
name: "Multiselect First Value",
reference: null,
slug: "multiselect-first-value",
richText: null
richText: null,
boolean: null
},
{
__typename: "AttributeValue",
@ -56,7 +60,8 @@ const MULTISELECT_ATTRIBUTE: AttributeInput = {
name: "Multiselect Second Value",
reference: null,
slug: "multiselect-second-value",
richText: null
richText: null,
boolean: null
},
{
__typename: "AttributeValue",
@ -65,7 +70,8 @@ const MULTISELECT_ATTRIBUTE: AttributeInput = {
name: "Multiselect Third Value",
reference: null,
slug: "multiselect-third-value",
richText: null
richText: null,
boolean: null
}
]
},
@ -90,7 +96,8 @@ const FILE_ATTRIBUTE: AttributeInput = {
name: "File First Value",
reference: null,
slug: "file-first-value",
richText: null
richText: null,
boolean: null
}
]
},
@ -126,7 +133,8 @@ const REFERENCE_ATTRIBUTE: AttributeInput = {
name: "References First Value",
reference: null,
slug: "references-first-value",
richText: null
richText: null,
boolean: null
},
{
__typename: "AttributeValue",
@ -135,7 +143,8 @@ const REFERENCE_ATTRIBUTE: AttributeInput = {
name: "References Second Value",
reference: null,
slug: "references-second-value",
richText: null
richText: null,
boolean: null
},
{
__typename: "AttributeValue",
@ -144,7 +153,8 @@ const REFERENCE_ATTRIBUTE: AttributeInput = {
name: "References Third Value",
reference: null,
slug: "references-third-value",
richText: null
richText: null,
boolean: null
}
]
},
@ -169,24 +179,11 @@ const RICH_TEXT_ATTRIBUTE: AttributeInput = {
time: 1617788754145,
blocks: [{ data: { text: "Some cool text" }, type: "paragraph" }],
version: "2.19.3"
})
}),
boolean: null
}
],
selectedValues: [
{
__typename: "AttributeValue",
file: null,
id: "asdfafd",
name: "Some cool text",
reference: null,
slug: "text",
richText: JSON.stringify({
time: 1617788754145,
blocks: [{ data: { text: "Some cool text" }, type: "paragraph" }],
version: "2.19.3"
})
}
]
selectedValues: []
},
id: "asdfafd",
label: "Text Attribute",
@ -197,14 +194,16 @@ const NUMERIC_ATTRIBUTE: AttributeInput = {
data: {
inputType: AttributeInputTypeEnum.NUMERIC,
isRequired: true,
unit: MeasurementUnitsEnum.CM,
values: [
{
__typename: "AttributeValue",
file: null,
id: "QXR0cmlidXRlVmFsdWU6MTAx",
name: "12cm",
name: "12",
reference: null,
richText: null,
boolean: null,
slug: "319_35"
}
]
@ -214,13 +213,36 @@ const NUMERIC_ATTRIBUTE: AttributeInput = {
value: []
};
const BOOLEAN_ATTRIBUTE: AttributeInput = {
data: {
inputType: AttributeInputTypeEnum.BOOLEAN,
isRequired: true,
values: [
{
__typename: "AttributeValue",
file: null,
id: "asdfasdfasdfasdf",
name: "Boolean Attribute: Yes",
reference: null,
richText: null,
boolean: true,
slug: "319_True"
}
]
},
id: "QXR0cmlidXRlOjMasdfasdf1",
label: "Boolean Attribute",
value: []
};
export const ATTRIBUTES: AttributeInput[] = [
DROPDOWN_ATTRIBUTE,
MULTISELECT_ATTRIBUTE,
FILE_ATTRIBUTE,
REFERENCE_ATTRIBUTE,
RICH_TEXT_ATTRIBUTE,
NUMERIC_ATTRIBUTE
NUMERIC_ATTRIBUTE,
BOOLEAN_ATTRIBUTE
];
export const ATTRIBUTES_SELECTED: AttributeInput[] = [
@ -249,10 +271,18 @@ export const ATTRIBUTES_SELECTED: AttributeInput[] = [
},
{
...RICH_TEXT_ATTRIBUTE,
value: [RICH_TEXT_ATTRIBUTE.data.values[0].richText]
data: {
...RICH_TEXT_ATTRIBUTE.data,
selectedValues: [RICH_TEXT_ATTRIBUTE.data.values[0]]
},
value: []
},
{
...NUMERIC_ATTRIBUTE,
value: [NUMERIC_ATTRIBUTE.data.values[0].name]
},
{
...BOOLEAN_ATTRIBUTE,
value: [JSON.stringify(BOOLEAN_ATTRIBUTE.data.values[0].boolean)]
}
];

View file

@ -1,24 +1,46 @@
import { Checkbox as MuiCheckbox } from "@material-ui/core";
import { CheckboxProps as MuiCheckboxProps } from "@material-ui/core/Checkbox";
import MuiCheckbox, {
CheckboxProps as MuiCheckboxProps
} from "@material-ui/core/Checkbox";
import FormHelperText from "@material-ui/core/FormHelperText";
import { makeStyles } from "@saleor/theme";
import React from "react";
const useStyles = makeStyles(
theme => ({
error: {
color: theme.palette.error.main
}
}),
{ name: "Checkbox" }
);
export type CheckboxProps = Omit<
MuiCheckboxProps,
"checkedIcon" | "color" | "icon" | "indeterminateIcon" | "classes" | "onClick"
> & {
disableClickPropagation?: boolean;
helperText?: string;
error?: boolean;
};
const Checkbox: React.FC<CheckboxProps> = props => {
const Checkbox: React.FC<CheckboxProps> = ({ helperText, error, ...props }) => {
const { disableClickPropagation, ...rest } = props;
const classes = useStyles();
return (
<MuiCheckbox
{...rest}
onClick={
disableClickPropagation ? event => event.stopPropagation() : undefined
}
/>
<>
<MuiCheckbox
{...rest}
onClick={
disableClickPropagation ? event => event.stopPropagation() : undefined
}
/>
{helperText && (
<FormHelperText classes={{ root: error && classes.error }}>
{helperText}
</FormHelperText>
)}
</>
);
};
Checkbox.displayName = "Checkbox";

View file

@ -42,8 +42,10 @@ const RichTextEditor: React.FC<RichTextEditorProps> = ({
holder: editorContainer.current,
logLevel: "ERROR" as LogLevels,
onChange: async api => {
const savedData = await api.saver.save();
onChange(savedData);
if (!api.readOnly) {
const savedData = await api.saver.save();
onChange(savedData);
}
},
onReady: () => {
// FIXME: This throws an error and is not working

View file

@ -15,6 +15,7 @@ export const attributeValueFragment = gql`
}
reference
richText
boolean
}
`;
@ -28,6 +29,7 @@ export const attributeFragment = gql`
filterableInDashboard
filterableInStorefront
unit
inputType
}
`;

View file

@ -31,10 +31,10 @@ export interface AttributeDetailsFragment {
filterableInDashboard: boolean;
filterableInStorefront: boolean;
unit: MeasurementUnitsEnum | null;
inputType: AttributeInputTypeEnum | null;
metadata: (AttributeDetailsFragment_metadata | null)[];
privateMetadata: (AttributeDetailsFragment_privateMetadata | null)[];
availableInGrid: boolean;
inputType: AttributeInputTypeEnum | null;
entityType: AttributeEntityTypeEnum | null;
storefrontSearchPosition: number;
valueRequired: boolean;

View file

@ -3,7 +3,7 @@
// @generated
// This file was automatically generated and should not be edited.
import { AttributeTypeEnum, MeasurementUnitsEnum } from "./../../types/globalTypes";
import { AttributeTypeEnum, MeasurementUnitsEnum, AttributeInputTypeEnum } from "./../../types/globalTypes";
// ====================================================
// GraphQL fragment: AttributeFragment
@ -19,4 +19,5 @@ export interface AttributeFragment {
filterableInDashboard: boolean;
filterableInStorefront: boolean;
unit: MeasurementUnitsEnum | null;
inputType: AttributeInputTypeEnum | null;
}

View file

@ -21,4 +21,5 @@ export interface AttributeValueFragment {
file: AttributeValueFragment_file | null;
reference: string | null;
richText: any | null;
boolean: boolean | null;
}

View file

@ -29,6 +29,7 @@ export interface AttributeValueListFragment_edges_node {
file: AttributeValueListFragment_edges_node_file | null;
reference: string | null;
richText: any | null;
boolean: boolean | null;
}
export interface AttributeValueListFragment_edges {

View file

@ -31,6 +31,7 @@ export interface PageAttributesFragment_attributes_attribute_choices_edges_node
file: PageAttributesFragment_attributes_attribute_choices_edges_node_file | null;
reference: string | null;
richText: any | null;
boolean: boolean | null;
}
export interface PageAttributesFragment_attributes_attribute_choices_edges {
@ -71,6 +72,7 @@ export interface PageAttributesFragment_attributes_values {
file: PageAttributesFragment_attributes_values_file | null;
reference: string | null;
richText: any | null;
boolean: boolean | null;
}
export interface PageAttributesFragment_attributes {
@ -101,6 +103,7 @@ export interface PageAttributesFragment_pageType_attributes_choices_edges_node {
file: PageAttributesFragment_pageType_attributes_choices_edges_node_file | null;
reference: string | null;
richText: any | null;
boolean: boolean | null;
}
export interface PageAttributesFragment_pageType_attributes_choices_edges {

View file

@ -31,6 +31,7 @@ export interface PageDetailsFragment_attributes_attribute_choices_edges_node {
file: PageDetailsFragment_attributes_attribute_choices_edges_node_file | null;
reference: string | null;
richText: any | null;
boolean: boolean | null;
}
export interface PageDetailsFragment_attributes_attribute_choices_edges {
@ -71,6 +72,7 @@ export interface PageDetailsFragment_attributes_values {
file: PageDetailsFragment_attributes_values_file | null;
reference: string | null;
richText: any | null;
boolean: boolean | null;
}
export interface PageDetailsFragment_attributes {
@ -101,6 +103,7 @@ export interface PageDetailsFragment_pageType_attributes_choices_edges_node {
file: PageDetailsFragment_pageType_attributes_choices_edges_node_file | null;
reference: string | null;
richText: any | null;
boolean: boolean | null;
}
export interface PageDetailsFragment_pageType_attributes_choices_edges {

View file

@ -3,7 +3,7 @@
// @generated
// This file was automatically generated and should not be edited.
import { AttributeTypeEnum, MeasurementUnitsEnum } from "./../../types/globalTypes";
import { AttributeTypeEnum, MeasurementUnitsEnum, AttributeInputTypeEnum } from "./../../types/globalTypes";
// ====================================================
// GraphQL fragment: PageTypeDetailsFragment
@ -31,6 +31,7 @@ export interface PageTypeDetailsFragment_attributes {
filterableInDashboard: boolean;
filterableInStorefront: boolean;
unit: MeasurementUnitsEnum | null;
inputType: AttributeInputTypeEnum | null;
}
export interface PageTypeDetailsFragment {

View file

@ -31,6 +31,7 @@ export interface Product_attributes_attribute_choices_edges_node {
file: Product_attributes_attribute_choices_edges_node_file | null;
reference: string | null;
richText: any | null;
boolean: boolean | null;
}
export interface Product_attributes_attribute_choices_edges {
@ -71,6 +72,7 @@ export interface Product_attributes_values {
file: Product_attributes_values_file | null;
reference: string | null;
richText: any | null;
boolean: boolean | null;
}
export interface Product_attributes {
@ -101,6 +103,7 @@ export interface Product_productType_variantAttributes_choices_edges_node {
file: Product_productType_variantAttributes_choices_edges_node_file | null;
reference: string | null;
richText: any | null;
boolean: boolean | null;
}
export interface Product_productType_variantAttributes_choices_edges {

View file

@ -3,7 +3,7 @@
// @generated
// This file was automatically generated and should not be edited.
import { AttributeTypeEnum, MeasurementUnitsEnum, WeightUnitsEnum } from "./../../types/globalTypes";
import { AttributeTypeEnum, MeasurementUnitsEnum, AttributeInputTypeEnum, WeightUnitsEnum } from "./../../types/globalTypes";
// ====================================================
// GraphQL fragment: ProductTypeDetailsFragment
@ -37,6 +37,7 @@ export interface ProductTypeDetailsFragment_productAttributes {
filterableInDashboard: boolean;
filterableInStorefront: boolean;
unit: MeasurementUnitsEnum | null;
inputType: AttributeInputTypeEnum | null;
}
export interface ProductTypeDetailsFragment_variantAttributes {
@ -49,6 +50,7 @@ export interface ProductTypeDetailsFragment_variantAttributes {
filterableInDashboard: boolean;
filterableInStorefront: boolean;
unit: MeasurementUnitsEnum | null;
inputType: AttributeInputTypeEnum | null;
}
export interface ProductTypeDetailsFragment_weight {

View file

@ -43,6 +43,7 @@ export interface ProductVariant_selectionAttributes_attribute_choices_edges_node
file: ProductVariant_selectionAttributes_attribute_choices_edges_node_file | null;
reference: string | null;
richText: any | null;
boolean: boolean | null;
}
export interface ProductVariant_selectionAttributes_attribute_choices_edges {
@ -83,6 +84,7 @@ export interface ProductVariant_selectionAttributes_values {
file: ProductVariant_selectionAttributes_values_file | null;
reference: string | null;
richText: any | null;
boolean: boolean | null;
}
export interface ProductVariant_selectionAttributes {
@ -113,6 +115,7 @@ export interface ProductVariant_nonSelectionAttributes_attribute_choices_edges_n
file: ProductVariant_nonSelectionAttributes_attribute_choices_edges_node_file | null;
reference: string | null;
richText: any | null;
boolean: boolean | null;
}
export interface ProductVariant_nonSelectionAttributes_attribute_choices_edges {
@ -153,6 +156,7 @@ export interface ProductVariant_nonSelectionAttributes_values {
file: ProductVariant_nonSelectionAttributes_values_file | null;
reference: string | null;
richText: any | null;
boolean: boolean | null;
}
export interface ProductVariant_nonSelectionAttributes {

View file

@ -31,6 +31,7 @@ export interface ProductVariantAttributesFragment_attributes_attribute_choices_e
file: ProductVariantAttributesFragment_attributes_attribute_choices_edges_node_file | null;
reference: string | null;
richText: any | null;
boolean: boolean | null;
}
export interface ProductVariantAttributesFragment_attributes_attribute_choices_edges {
@ -71,6 +72,7 @@ export interface ProductVariantAttributesFragment_attributes_values {
file: ProductVariantAttributesFragment_attributes_values_file | null;
reference: string | null;
richText: any | null;
boolean: boolean | null;
}
export interface ProductVariantAttributesFragment_attributes {
@ -101,6 +103,7 @@ export interface ProductVariantAttributesFragment_productType_variantAttributes_
file: ProductVariantAttributesFragment_productType_variantAttributes_choices_edges_node_file | null;
reference: string | null;
richText: any | null;
boolean: boolean | null;
}
export interface ProductVariantAttributesFragment_productType_variantAttributes_choices_edges {

View file

@ -31,6 +31,7 @@ export interface SelectedVariantAttributeFragment_attribute_choices_edges_node {
file: SelectedVariantAttributeFragment_attribute_choices_edges_node_file | null;
reference: string | null;
richText: any | null;
boolean: boolean | null;
}
export interface SelectedVariantAttributeFragment_attribute_choices_edges {
@ -71,6 +72,7 @@ export interface SelectedVariantAttributeFragment_values {
file: SelectedVariantAttributeFragment_values_file | null;
reference: string | null;
richText: any | null;
boolean: boolean | null;
}
export interface SelectedVariantAttributeFragment {

View file

@ -31,6 +31,7 @@ export interface VariantAttributeFragment_choices_edges_node {
file: VariantAttributeFragment_choices_edges_node_file | null;
reference: string | null;
richText: any | null;
boolean: boolean | null;
}
export interface VariantAttributeFragment_choices_edges {

View file

@ -16,8 +16,8 @@ const ChevronDown: React.FC = () => {
<path
d="M1 1L5 5L9 1"
stroke={isDark ? "#FAFAFA" : "#28234A"}
stroke-opacity="0.4"
stroke-width="2"
strokeOpacity="0.4"
strokeWidth="2"
/>
</svg>
);

View file

@ -1,5 +1,8 @@
/* eslint-disable sort-keys */
import { AttributeTypeEnum } from "@saleor/types/globalTypes";
import {
AttributeInputTypeEnum,
AttributeTypeEnum
} from "@saleor/types/globalTypes";
import { PageTypeDetails_pageType } from "./types/PageTypeDetails";
import { PageTypeList_pageTypes_edges_node } from "./types/PageTypeList";
@ -47,6 +50,7 @@ export const pageType: PageTypeDetails_pageType = {
filterableInDashboard: true,
filterableInStorefront: true,
type: AttributeTypeEnum.PAGE_TYPE,
inputType: AttributeInputTypeEnum.DROPDOWN,
unit: null
},
{
@ -58,6 +62,7 @@ export const pageType: PageTypeDetails_pageType = {
filterableInDashboard: true,
filterableInStorefront: true,
type: AttributeTypeEnum.PAGE_TYPE,
inputType: AttributeInputTypeEnum.DROPDOWN,
unit: null
},
{
@ -69,6 +74,7 @@ export const pageType: PageTypeDetails_pageType = {
filterableInDashboard: true,
filterableInStorefront: true,
type: AttributeTypeEnum.PAGE_TYPE,
inputType: AttributeInputTypeEnum.DROPDOWN,
unit: null
}
],

View file

@ -3,7 +3,7 @@
// @generated
// This file was automatically generated and should not be edited.
import { PageErrorCode, AttributeTypeEnum, MeasurementUnitsEnum } from "./../../types/globalTypes";
import { PageErrorCode, AttributeTypeEnum, MeasurementUnitsEnum, AttributeInputTypeEnum } from "./../../types/globalTypes";
// ====================================================
// GraphQL mutation operation: AssignPageAttribute
@ -37,6 +37,7 @@ export interface AssignPageAttribute_pageAttributeAssign_pageType_attributes {
filterableInDashboard: boolean;
filterableInStorefront: boolean;
unit: MeasurementUnitsEnum | null;
inputType: AttributeInputTypeEnum | null;
}
export interface AssignPageAttribute_pageAttributeAssign_pageType {

View file

@ -3,7 +3,7 @@
// @generated
// This file was automatically generated and should not be edited.
import { ReorderInput, PageErrorCode, AttributeTypeEnum, MeasurementUnitsEnum } from "./../../types/globalTypes";
import { ReorderInput, PageErrorCode, AttributeTypeEnum, MeasurementUnitsEnum, AttributeInputTypeEnum } from "./../../types/globalTypes";
// ====================================================
// GraphQL mutation operation: PageTypeAttributeReorder
@ -37,6 +37,7 @@ export interface PageTypeAttributeReorder_pageTypeReorderAttributes_pageType_att
filterableInDashboard: boolean;
filterableInStorefront: boolean;
unit: MeasurementUnitsEnum | null;
inputType: AttributeInputTypeEnum | null;
}
export interface PageTypeAttributeReorder_pageTypeReorderAttributes_pageType {

View file

@ -3,7 +3,7 @@
// @generated
// This file was automatically generated and should not be edited.
import { PageTypeCreateInput, PageErrorCode, AttributeTypeEnum, MeasurementUnitsEnum } from "./../../types/globalTypes";
import { PageTypeCreateInput, PageErrorCode, AttributeTypeEnum, MeasurementUnitsEnum, AttributeInputTypeEnum } from "./../../types/globalTypes";
// ====================================================
// GraphQL mutation operation: PageTypeCreate
@ -37,6 +37,7 @@ export interface PageTypeCreate_pageTypeCreate_pageType_attributes {
filterableInDashboard: boolean;
filterableInStorefront: boolean;
unit: MeasurementUnitsEnum | null;
inputType: AttributeInputTypeEnum | null;
}
export interface PageTypeCreate_pageTypeCreate_pageType {

View file

@ -3,7 +3,7 @@
// @generated
// This file was automatically generated and should not be edited.
import { AttributeTypeEnum, MeasurementUnitsEnum } from "./../../types/globalTypes";
import { AttributeTypeEnum, MeasurementUnitsEnum, AttributeInputTypeEnum } from "./../../types/globalTypes";
// ====================================================
// GraphQL query operation: PageTypeDetails
@ -31,6 +31,7 @@ export interface PageTypeDetails_pageType_attributes {
filterableInDashboard: boolean;
filterableInStorefront: boolean;
unit: MeasurementUnitsEnum | null;
inputType: AttributeInputTypeEnum | null;
}
export interface PageTypeDetails_pageType {

View file

@ -3,7 +3,7 @@
// @generated
// This file was automatically generated and should not be edited.
import { PageTypeUpdateInput, PageErrorCode, AttributeTypeEnum, MeasurementUnitsEnum } from "./../../types/globalTypes";
import { PageTypeUpdateInput, PageErrorCode, AttributeTypeEnum, MeasurementUnitsEnum, AttributeInputTypeEnum } from "./../../types/globalTypes";
// ====================================================
// GraphQL mutation operation: PageTypeUpdate
@ -37,6 +37,7 @@ export interface PageTypeUpdate_pageTypeUpdate_pageType_attributes {
filterableInDashboard: boolean;
filterableInStorefront: boolean;
unit: MeasurementUnitsEnum | null;
inputType: AttributeInputTypeEnum | null;
}
export interface PageTypeUpdate_pageTypeUpdate_pageType {

View file

@ -3,7 +3,7 @@
// @generated
// This file was automatically generated and should not be edited.
import { PageErrorCode, AttributeTypeEnum, MeasurementUnitsEnum } from "./../../types/globalTypes";
import { PageErrorCode, AttributeTypeEnum, MeasurementUnitsEnum, AttributeInputTypeEnum } from "./../../types/globalTypes";
// ====================================================
// GraphQL mutation operation: UnassignPageAttribute
@ -37,6 +37,7 @@ export interface UnassignPageAttribute_pageAttributeUnassign_pageType_attributes
filterableInDashboard: boolean;
filterableInStorefront: boolean;
unit: MeasurementUnitsEnum | null;
inputType: AttributeInputTypeEnum | null;
}
export interface UnassignPageAttribute_pageAttributeUnassign_pageType {

View file

@ -69,7 +69,8 @@ export const page: PageDetails_page = {
reference: null,
__typename: "AttributeValue",
file: null,
richText: null
richText: null,
boolean: null
}
},
{
@ -82,7 +83,8 @@ export const page: PageDetails_page = {
reference: null,
__typename: "AttributeValue",
file: null,
richText: null
richText: null,
boolean: null
}
},
{
@ -95,7 +97,8 @@ export const page: PageDetails_page = {
reference: null,
__typename: "AttributeValue",
file: null,
richText: null
richText: null,
boolean: null
}
}
]
@ -110,7 +113,8 @@ export const page: PageDetails_page = {
reference: null,
__typename: "AttributeValue",
file: null,
richText: null
richText: null,
boolean: null
}
],
__typename: "SelectedAttribute"
@ -144,7 +148,8 @@ export const page: PageDetails_page = {
reference: null,
__typename: "AttributeValue",
file: null,
richText: null
richText: null,
boolean: null
}
},
{
@ -157,7 +162,8 @@ export const page: PageDetails_page = {
reference: null,
__typename: "AttributeValue",
file: null,
richText: null
richText: null,
boolean: null
}
},
{
@ -170,7 +176,8 @@ export const page: PageDetails_page = {
reference: null,
__typename: "AttributeValue",
file: null,
richText: null
richText: null,
boolean: null
}
},
{
@ -183,7 +190,8 @@ export const page: PageDetails_page = {
reference: null,
__typename: "AttributeValue",
file: null,
richText: null
richText: null,
boolean: null
}
}
]
@ -198,7 +206,8 @@ export const page: PageDetails_page = {
reference: null,
__typename: "AttributeValue",
file: null,
richText: null
richText: null,
boolean: null
}
],
__typename: "SelectedAttribute"
@ -245,7 +254,8 @@ export const page: PageDetails_page = {
reference: null,
__typename: "AttributeValue",
file: null,
richText: null
richText: null,
boolean: null
}
},
{
@ -258,7 +268,8 @@ export const page: PageDetails_page = {
reference: null,
__typename: "AttributeValue",
file: null,
richText: null
richText: null,
boolean: null
}
},
{
@ -271,7 +282,8 @@ export const page: PageDetails_page = {
reference: null,
__typename: "AttributeValue",
file: null,
richText: null
richText: null,
boolean: null
}
}
]
@ -304,7 +316,8 @@ export const page: PageDetails_page = {
reference: null,
__typename: "AttributeValue",
file: null,
richText: null
richText: null,
boolean: null
}
},
{
@ -317,7 +330,8 @@ export const page: PageDetails_page = {
reference: null,
__typename: "AttributeValue",
file: null,
richText: null
richText: null,
boolean: null
}
},
{
@ -330,7 +344,8 @@ export const page: PageDetails_page = {
reference: null,
__typename: "AttributeValue",
file: null,
richText: null
richText: null,
boolean: null
}
},
{
@ -343,7 +358,8 @@ export const page: PageDetails_page = {
reference: null,
__typename: "AttributeValue",
file: null,
richText: null
richText: null,
boolean: null
}
}
]

View file

@ -31,6 +31,7 @@ export interface PageDetails_page_attributes_attribute_choices_edges_node {
file: PageDetails_page_attributes_attribute_choices_edges_node_file | null;
reference: string | null;
richText: any | null;
boolean: boolean | null;
}
export interface PageDetails_page_attributes_attribute_choices_edges {
@ -71,6 +72,7 @@ export interface PageDetails_page_attributes_values {
file: PageDetails_page_attributes_values_file | null;
reference: string | null;
richText: any | null;
boolean: boolean | null;
}
export interface PageDetails_page_attributes {
@ -101,6 +103,7 @@ export interface PageDetails_page_pageType_attributes_choices_edges_node {
file: PageDetails_page_pageType_attributes_choices_edges_node_file | null;
reference: string | null;
richText: any | null;
boolean: boolean | null;
}
export interface PageDetails_page_pageType_attributes_choices_edges {

View file

@ -31,6 +31,7 @@ export interface PageType_pageType_attributes_choices_edges_node {
file: PageType_pageType_attributes_choices_edges_node_file | null;
reference: string | null;
richText: any | null;
boolean: boolean | null;
}
export interface PageType_pageType_attributes_choices_edges {

View file

@ -38,6 +38,7 @@ export interface PageUpdate_pageUpdate_page_attributes_attribute_choices_edges_n
file: PageUpdate_pageUpdate_page_attributes_attribute_choices_edges_node_file | null;
reference: string | null;
richText: any | null;
boolean: boolean | null;
}
export interface PageUpdate_pageUpdate_page_attributes_attribute_choices_edges {
@ -78,6 +79,7 @@ export interface PageUpdate_pageUpdate_page_attributes_values {
file: PageUpdate_pageUpdate_page_attributes_values_file | null;
reference: string | null;
richText: any | null;
boolean: boolean | null;
}
export interface PageUpdate_pageUpdate_page_attributes {
@ -108,6 +110,7 @@ export interface PageUpdate_pageUpdate_page_pageType_attributes_choices_edges_no
file: PageUpdate_pageUpdate_page_pageType_attributes_choices_edges_node_file | null;
reference: string | null;
richText: any | null;
boolean: boolean | null;
}
export interface PageUpdate_pageUpdate_page_pageType_attributes_choices_edges {

View file

@ -46,7 +46,8 @@ export const attributes: ProductType_productType_productAttributes[] = [
sortOrder: 0,
type: "STRING",
value: "",
richText: null
richText: null,
boolean: null
}
},
{
@ -62,7 +63,8 @@ export const attributes: ProductType_productType_productAttributes[] = [
sortOrder: 1,
type: "STRING",
value: "",
richText: null
richText: null,
boolean: null
}
}
]
@ -102,7 +104,8 @@ export const attributes: ProductType_productType_productAttributes[] = [
sortOrder: 0,
type: "STRING",
value: "",
richText: null
richText: null,
boolean: null
}
},
{
@ -118,7 +121,8 @@ export const attributes: ProductType_productType_productAttributes[] = [
sortOrder: 1,
type: "STRING",
value: "",
richText: null
richText: null,
boolean: null
}
},
{
@ -134,7 +138,8 @@ export const attributes: ProductType_productType_productAttributes[] = [
sortOrder: 2,
type: "STRING",
value: "",
richText: null
richText: null,
boolean: null
}
},
{
@ -150,7 +155,8 @@ export const attributes: ProductType_productType_productAttributes[] = [
sortOrder: 3,
type: "STRING",
value: "",
richText: null
richText: null,
boolean: null
}
}
]
@ -190,7 +196,8 @@ export const attributes: ProductType_productType_productAttributes[] = [
sortOrder: 0,
type: "STRING",
value: "",
richText: null
richText: null,
boolean: null
}
}
]
@ -230,7 +237,8 @@ export const attributes: ProductType_productType_productAttributes[] = [
sortOrder: 0,
type: "STRING",
value: "",
richText: null
richText: null,
boolean: null
}
},
{
@ -246,7 +254,8 @@ export const attributes: ProductType_productType_productAttributes[] = [
sortOrder: 1,
type: "STRING",
value: "",
richText: null
richText: null,
boolean: null
}
},
{
@ -262,7 +271,8 @@ export const attributes: ProductType_productType_productAttributes[] = [
sortOrder: 2,
type: "STRING",
value: "",
richText: null
richText: null,
boolean: null
}
}
]
@ -302,7 +312,8 @@ export const attributes: ProductType_productType_productAttributes[] = [
sortOrder: 0,
type: "STRING",
value: "",
richText: null
richText: null,
boolean: null
}
},
{
@ -318,7 +329,8 @@ export const attributes: ProductType_productType_productAttributes[] = [
sortOrder: 1,
type: "STRING",
value: "",
richText: null
richText: null,
boolean: null
}
}
]
@ -358,7 +370,8 @@ export const attributes: ProductType_productType_productAttributes[] = [
sortOrder: 0,
type: "STRING",
value: "",
richText: null
richText: null,
boolean: null
}
},
{
@ -374,7 +387,8 @@ export const attributes: ProductType_productType_productAttributes[] = [
sortOrder: 1,
type: "STRING",
value: "",
richText: null
richText: null,
boolean: null
}
},
{
@ -390,7 +404,8 @@ export const attributes: ProductType_productType_productAttributes[] = [
sortOrder: 2,
type: "STRING",
value: "",
richText: null
richText: null,
boolean: null
}
}
]
@ -430,7 +445,8 @@ export const attributes: ProductType_productType_productAttributes[] = [
sortOrder: 0,
type: "STRING",
value: "",
richText: null
richText: null,
boolean: null
}
},
{
@ -446,7 +462,8 @@ export const attributes: ProductType_productType_productAttributes[] = [
sortOrder: 1,
type: "STRING",
value: "",
richText: null
richText: null,
boolean: null
}
}
]
@ -486,7 +503,8 @@ export const attributes: ProductType_productType_productAttributes[] = [
sortOrder: 0,
type: "STRING",
value: "",
richText: null
richText: null,
boolean: null
}
},
{
@ -502,7 +520,8 @@ export const attributes: ProductType_productType_productAttributes[] = [
sortOrder: 1,
type: "STRING",
value: "",
richText: null
richText: null,
boolean: null
}
},
{
@ -518,7 +537,8 @@ export const attributes: ProductType_productType_productAttributes[] = [
sortOrder: 2,
type: "STRING",
value: "",
richText: null
richText: null,
boolean: null
}
},
{
@ -534,7 +554,8 @@ export const attributes: ProductType_productType_productAttributes[] = [
sortOrder: 3,
type: "STRING",
value: "",
richText: null
richText: null,
boolean: null
}
},
{
@ -550,7 +571,8 @@ export const attributes: ProductType_productType_productAttributes[] = [
sortOrder: 4,
type: "STRING",
value: "",
richText: null
richText: null,
boolean: null
}
},
{
@ -566,7 +588,8 @@ export const attributes: ProductType_productType_productAttributes[] = [
sortOrder: 5,
type: "STRING",
value: "",
richText: null
richText: null,
boolean: null
}
}
]
@ -606,7 +629,8 @@ export const attributes: ProductType_productType_productAttributes[] = [
sortOrder: 0,
type: "STRING",
value: "",
richText: null
richText: null,
boolean: null
}
},
{
@ -622,7 +646,8 @@ export const attributes: ProductType_productType_productAttributes[] = [
sortOrder: 1,
type: "STRING",
value: "",
richText: null
richText: null,
boolean: null
}
}
]
@ -662,7 +687,8 @@ export const attributes: ProductType_productType_productAttributes[] = [
sortOrder: 0,
type: "STRING",
value: "",
richText: null
richText: null,
boolean: null
}
},
{
@ -678,7 +704,8 @@ export const attributes: ProductType_productType_productAttributes[] = [
sortOrder: 1,
type: "STRING",
value: "",
richText: null
richText: null,
boolean: null
}
}
]
@ -718,7 +745,8 @@ export const attributes: ProductType_productType_productAttributes[] = [
sortOrder: 0,
type: "STRING",
value: "",
richText: null
richText: null,
boolean: null
}
},
{
@ -734,7 +762,8 @@ export const attributes: ProductType_productType_productAttributes[] = [
sortOrder: 1,
type: "STRING",
value: "",
richText: null
richText: null,
boolean: null
}
}
]
@ -774,7 +803,8 @@ export const attributes: ProductType_productType_productAttributes[] = [
sortOrder: 0,
type: "STRING",
value: "",
richText: null
richText: null,
boolean: null
}
},
{
@ -790,7 +820,8 @@ export const attributes: ProductType_productType_productAttributes[] = [
sortOrder: 1,
type: "STRING",
value: "",
richText: null
richText: null,
boolean: null
}
},
{
@ -806,7 +837,8 @@ export const attributes: ProductType_productType_productAttributes[] = [
sortOrder: 2,
type: "STRING",
value: "",
richText: null
richText: null,
boolean: null
}
},
{
@ -822,7 +854,8 @@ export const attributes: ProductType_productType_productAttributes[] = [
sortOrder: 3,
type: "STRING",
value: "",
richText: null
richText: null,
boolean: null
}
},
{
@ -838,7 +871,8 @@ export const attributes: ProductType_productType_productAttributes[] = [
sortOrder: 4,
type: "STRING",
value: "",
richText: null
richText: null,
boolean: null
}
},
{
@ -854,7 +888,8 @@ export const attributes: ProductType_productType_productAttributes[] = [
sortOrder: 5,
type: "STRING",
value: "",
richText: null
richText: null,
boolean: null
}
}
]
@ -976,6 +1011,7 @@ export const productType: ProductTypeDetails_productType = {
name: "Author",
slug: "author",
type: AttributeTypeEnum.PRODUCT_TYPE,
inputType: AttributeInputTypeEnum.DROPDOWN,
visibleInStorefront: true,
unit: null
},
@ -987,6 +1023,7 @@ export const productType: ProductTypeDetails_productType = {
name: "Language",
slug: "language",
type: AttributeTypeEnum.PRODUCT_TYPE,
inputType: AttributeInputTypeEnum.DROPDOWN,
visibleInStorefront: true,
unit: null
},
@ -998,6 +1035,7 @@ export const productType: ProductTypeDetails_productType = {
name: "Publisher",
slug: "publisher",
type: AttributeTypeEnum.PRODUCT_TYPE,
inputType: AttributeInputTypeEnum.DROPDOWN,
visibleInStorefront: true,
unit: null
}

View file

@ -3,7 +3,7 @@
// @generated
// This file was automatically generated and should not be edited.
import { ProductAttributeAssignInput, AttributeTypeEnum, MeasurementUnitsEnum, WeightUnitsEnum } from "./../../types/globalTypes";
import { ProductAttributeAssignInput, AttributeTypeEnum, MeasurementUnitsEnum, AttributeInputTypeEnum, WeightUnitsEnum } from "./../../types/globalTypes";
// ====================================================
// GraphQL mutation operation: AssignProductAttribute
@ -43,6 +43,7 @@ export interface AssignProductAttribute_productAttributeAssign_productType_produ
filterableInDashboard: boolean;
filterableInStorefront: boolean;
unit: MeasurementUnitsEnum | null;
inputType: AttributeInputTypeEnum | null;
}
export interface AssignProductAttribute_productAttributeAssign_productType_variantAttributes {
@ -55,6 +56,7 @@ export interface AssignProductAttribute_productAttributeAssign_productType_varia
filterableInDashboard: boolean;
filterableInStorefront: boolean;
unit: MeasurementUnitsEnum | null;
inputType: AttributeInputTypeEnum | null;
}
export interface AssignProductAttribute_productAttributeAssign_productType_weight {

View file

@ -3,7 +3,7 @@
// @generated
// This file was automatically generated and should not be edited.
import { ReorderInput, ProductAttributeType, AttributeTypeEnum, MeasurementUnitsEnum, WeightUnitsEnum } from "./../../types/globalTypes";
import { ReorderInput, ProductAttributeType, AttributeTypeEnum, MeasurementUnitsEnum, AttributeInputTypeEnum, WeightUnitsEnum } from "./../../types/globalTypes";
// ====================================================
// GraphQL mutation operation: ProductTypeAttributeReorder
@ -43,6 +43,7 @@ export interface ProductTypeAttributeReorder_productTypeReorderAttributes_produc
filterableInDashboard: boolean;
filterableInStorefront: boolean;
unit: MeasurementUnitsEnum | null;
inputType: AttributeInputTypeEnum | null;
}
export interface ProductTypeAttributeReorder_productTypeReorderAttributes_productType_variantAttributes {
@ -55,6 +56,7 @@ export interface ProductTypeAttributeReorder_productTypeReorderAttributes_produc
filterableInDashboard: boolean;
filterableInStorefront: boolean;
unit: MeasurementUnitsEnum | null;
inputType: AttributeInputTypeEnum | null;
}
export interface ProductTypeAttributeReorder_productTypeReorderAttributes_productType_weight {

View file

@ -3,7 +3,7 @@
// @generated
// This file was automatically generated and should not be edited.
import { ProductTypeInput, AttributeTypeEnum, MeasurementUnitsEnum, WeightUnitsEnum } from "./../../types/globalTypes";
import { ProductTypeInput, AttributeTypeEnum, MeasurementUnitsEnum, AttributeInputTypeEnum, WeightUnitsEnum } from "./../../types/globalTypes";
// ====================================================
// GraphQL mutation operation: ProductTypeCreate
@ -43,6 +43,7 @@ export interface ProductTypeCreate_productTypeCreate_productType_productAttribut
filterableInDashboard: boolean;
filterableInStorefront: boolean;
unit: MeasurementUnitsEnum | null;
inputType: AttributeInputTypeEnum | null;
}
export interface ProductTypeCreate_productTypeCreate_productType_variantAttributes {
@ -55,6 +56,7 @@ export interface ProductTypeCreate_productTypeCreate_productType_variantAttribut
filterableInDashboard: boolean;
filterableInStorefront: boolean;
unit: MeasurementUnitsEnum | null;
inputType: AttributeInputTypeEnum | null;
}
export interface ProductTypeCreate_productTypeCreate_productType_weight {

View file

@ -3,7 +3,7 @@
// @generated
// This file was automatically generated and should not be edited.
import { AttributeTypeEnum, MeasurementUnitsEnum, WeightUnitsEnum } from "./../../types/globalTypes";
import { AttributeTypeEnum, MeasurementUnitsEnum, AttributeInputTypeEnum, WeightUnitsEnum } from "./../../types/globalTypes";
// ====================================================
// GraphQL query operation: ProductTypeDetails
@ -37,6 +37,7 @@ export interface ProductTypeDetails_productType_productAttributes {
filterableInDashboard: boolean;
filterableInStorefront: boolean;
unit: MeasurementUnitsEnum | null;
inputType: AttributeInputTypeEnum | null;
}
export interface ProductTypeDetails_productType_variantAttributes {
@ -49,6 +50,7 @@ export interface ProductTypeDetails_productType_variantAttributes {
filterableInDashboard: boolean;
filterableInStorefront: boolean;
unit: MeasurementUnitsEnum | null;
inputType: AttributeInputTypeEnum | null;
}
export interface ProductTypeDetails_productType_weight {

View file

@ -3,7 +3,7 @@
// @generated
// This file was automatically generated and should not be edited.
import { ProductTypeInput, AttributeTypeEnum, MeasurementUnitsEnum, WeightUnitsEnum } from "./../../types/globalTypes";
import { ProductTypeInput, AttributeTypeEnum, MeasurementUnitsEnum, AttributeInputTypeEnum, WeightUnitsEnum } from "./../../types/globalTypes";
// ====================================================
// GraphQL mutation operation: ProductTypeUpdate
@ -43,6 +43,7 @@ export interface ProductTypeUpdate_productTypeUpdate_productType_productAttribut
filterableInDashboard: boolean;
filterableInStorefront: boolean;
unit: MeasurementUnitsEnum | null;
inputType: AttributeInputTypeEnum | null;
}
export interface ProductTypeUpdate_productTypeUpdate_productType_variantAttributes {
@ -55,6 +56,7 @@ export interface ProductTypeUpdate_productTypeUpdate_productType_variantAttribut
filterableInDashboard: boolean;
filterableInStorefront: boolean;
unit: MeasurementUnitsEnum | null;
inputType: AttributeInputTypeEnum | null;
}
export interface ProductTypeUpdate_productTypeUpdate_productType_weight {

View file

@ -3,7 +3,7 @@
// @generated
// This file was automatically generated and should not be edited.
import { AttributeTypeEnum, MeasurementUnitsEnum, WeightUnitsEnum } from "./../../types/globalTypes";
import { AttributeTypeEnum, MeasurementUnitsEnum, AttributeInputTypeEnum, WeightUnitsEnum } from "./../../types/globalTypes";
// ====================================================
// GraphQL mutation operation: UnassignProductAttribute
@ -43,6 +43,7 @@ export interface UnassignProductAttribute_productAttributeUnassign_productType_p
filterableInDashboard: boolean;
filterableInStorefront: boolean;
unit: MeasurementUnitsEnum | null;
inputType: AttributeInputTypeEnum | null;
}
export interface UnassignProductAttribute_productAttributeUnassign_productType_variantAttributes {
@ -55,6 +56,7 @@ export interface UnassignProductAttribute_productAttributeUnassign_productType_v
filterableInDashboard: boolean;
filterableInStorefront: boolean;
unit: MeasurementUnitsEnum | null;
inputType: AttributeInputTypeEnum | null;
}
export interface UnassignProductAttribute_productAttributeUnassign_productType_weight {

View file

@ -1,9 +1,13 @@
import { IFilter } from "@saleor/components/Filter";
import { sectionNames } from "@saleor/intl";
import { commonMessages, sectionNames } from "@saleor/intl";
import { AutocompleteFilterOpts, FilterOpts, MinMax } from "@saleor/types";
import { StockAvailability } from "@saleor/types/globalTypes";
import {
AttributeInputTypeEnum,
StockAvailability
} from "@saleor/types/globalTypes";
import {
createAutocompleteField,
createBooleanField,
createOptionsField,
createPriceField
} from "@saleor/utils/filters/fields";
@ -24,6 +28,7 @@ export interface ProductListFilterOpts {
id: string;
name: string;
slug: string;
inputType: AttributeInputTypeEnum;
}
>;
attributeChoices: FilterOpts<string[]> & AutocompleteFilterOpts;
@ -67,7 +72,14 @@ const messages = defineMessages({
export function createFilterStructure(
intl: IntlShape,
opts: ProductListFilterOpts
): IFilter<ProductFilterKeys> {
): IFilter<string> {
const booleanAttributes = opts.attributes.filter(
({ inputType }) => inputType === AttributeInputTypeEnum.BOOLEAN
);
const defaultAttributes = opts.attributes.filter(
({ inputType }) => !inputType.includes(AttributeInputTypeEnum.BOOLEAN)
);
return [
{
...createOptionsField(
@ -150,7 +162,22 @@ export function createFilterStructure(
),
active: opts.productType.active
},
...opts.attributes.map(attr => ({
...booleanAttributes.map(attr => ({
...createBooleanField(
attr.slug,
attr.name,
Array.isArray(attr.value)
? undefined
: (attr.value as unknown) === "true",
{
positive: intl.formatMessage(commonMessages.yes),
negative: intl.formatMessage(commonMessages.no)
}
),
active: attr.active,
group: ProductFilterKeys.attributes
})),
...defaultAttributes.map(attr => ({
...createAutocompleteField(
attr.slug as any,
attr.name,

View file

@ -10,6 +10,7 @@ Object {
"slug": "val-1-1",
"value": Object {
"__typename": "AttributeValue",
"boolean": null,
"file": null,
"id": "val-1-1",
"name": "val-1-1",
@ -22,6 +23,7 @@ Object {
"slug": "val-1-7",
"value": Object {
"__typename": "AttributeValue",
"boolean": null,
"file": null,
"id": "val-1-7",
"name": "val-1-7",
@ -39,6 +41,7 @@ Object {
"slug": "val-2-2",
"value": Object {
"__typename": "AttributeValue",
"boolean": null,
"file": null,
"id": "val-2-2",
"name": "val-2-2",
@ -51,6 +54,7 @@ Object {
"slug": "val-2-4",
"value": Object {
"__typename": "AttributeValue",
"boolean": null,
"file": null,
"id": "val-2-4",
"name": "val-2-4",
@ -68,6 +72,7 @@ Object {
"slug": "val-4-1",
"value": Object {
"__typename": "AttributeValue",
"boolean": null,
"file": null,
"id": "val-4-1",
"name": "val-4-1",
@ -80,6 +85,7 @@ Object {
"slug": "val-4-5",
"value": Object {
"__typename": "AttributeValue",
"boolean": null,
"file": null,
"id": "val-4-5",
"name": "val-4-5",
@ -631,6 +637,7 @@ Object {
"slug": "val-1-1",
"value": Object {
"__typename": "AttributeValue",
"boolean": null,
"file": null,
"id": "val-1-1",
"name": "val-1-1",
@ -643,6 +650,7 @@ Object {
"slug": "val-1-7",
"value": Object {
"__typename": "AttributeValue",
"boolean": null,
"file": null,
"id": "val-1-7",
"name": "val-1-7",
@ -660,6 +668,7 @@ Object {
"slug": "val-2-2",
"value": Object {
"__typename": "AttributeValue",
"boolean": null,
"file": null,
"id": "val-2-2",
"name": "val-2-2",
@ -672,6 +681,7 @@ Object {
"slug": "val-2-4",
"value": Object {
"__typename": "AttributeValue",
"boolean": null,
"file": null,
"id": "val-2-4",
"name": "val-2-4",
@ -689,6 +699,7 @@ Object {
"slug": "val-4-1",
"value": Object {
"__typename": "AttributeValue",
"boolean": null,
"file": null,
"id": "val-4-1",
"name": "val-4-1",
@ -701,6 +712,7 @@ Object {
"slug": "val-4-5",
"value": Object {
"__typename": "AttributeValue",
"boolean": null,
"file": null,
"id": "val-4-5",
"name": "val-4-5",
@ -1252,6 +1264,7 @@ Object {
"slug": "val-1-1",
"value": Object {
"__typename": "AttributeValue",
"boolean": null,
"file": null,
"id": "val-1-1",
"name": "val-1-1",
@ -1264,6 +1277,7 @@ Object {
"slug": "val-1-7",
"value": Object {
"__typename": "AttributeValue",
"boolean": null,
"file": null,
"id": "val-1-7",
"name": "val-1-7",
@ -1281,6 +1295,7 @@ Object {
"slug": "val-2-2",
"value": Object {
"__typename": "AttributeValue",
"boolean": null,
"file": null,
"id": "val-2-2",
"name": "val-2-2",
@ -1293,6 +1308,7 @@ Object {
"slug": "val-2-4",
"value": Object {
"__typename": "AttributeValue",
"boolean": null,
"file": null,
"id": "val-2-4",
"name": "val-2-4",
@ -1310,6 +1326,7 @@ Object {
"slug": "val-4-1",
"value": Object {
"__typename": "AttributeValue",
"boolean": null,
"file": null,
"id": "val-4-1",
"name": "val-4-1",
@ -1322,6 +1339,7 @@ Object {
"slug": "val-4-5",
"value": Object {
"__typename": "AttributeValue",
"boolean": null,
"file": null,
"id": "val-4-5",
"name": "val-4-5",
@ -1373,6 +1391,7 @@ Object {
"slug": "val-1-1",
"value": Object {
"__typename": "AttributeValue",
"boolean": null,
"file": null,
"id": "val-1-1",
"name": "val-1-1",
@ -1385,6 +1404,7 @@ Object {
"slug": "val-1-7",
"value": Object {
"__typename": "AttributeValue",
"boolean": null,
"file": null,
"id": "val-1-7",
"name": "val-1-7",
@ -1402,6 +1422,7 @@ Object {
"slug": "val-2-2",
"value": Object {
"__typename": "AttributeValue",
"boolean": null,
"file": null,
"id": "val-2-2",
"name": "val-2-2",
@ -1414,6 +1435,7 @@ Object {
"slug": "val-2-4",
"value": Object {
"__typename": "AttributeValue",
"boolean": null,
"file": null,
"id": "val-2-4",
"name": "val-2-4",
@ -1431,6 +1453,7 @@ Object {
"slug": "val-4-1",
"value": Object {
"__typename": "AttributeValue",
"boolean": null,
"file": null,
"id": "val-4-1",
"name": "val-4-1",
@ -1443,6 +1466,7 @@ Object {
"slug": "val-4-5",
"value": Object {
"__typename": "AttributeValue",
"boolean": null,
"file": null,
"id": "val-4-5",
"name": "val-4-5",
@ -1945,6 +1969,7 @@ Object {
"slug": "val-1-1",
"value": Object {
"__typename": "AttributeValue",
"boolean": null,
"file": null,
"id": "val-1-1",
"name": "val-1-1",
@ -1957,6 +1982,7 @@ Object {
"slug": "val-1-7",
"value": Object {
"__typename": "AttributeValue",
"boolean": null,
"file": null,
"id": "val-1-7",
"name": "val-1-7",
@ -1974,6 +2000,7 @@ Object {
"slug": "val-2-2",
"value": Object {
"__typename": "AttributeValue",
"boolean": null,
"file": null,
"id": "val-2-2",
"name": "val-2-2",
@ -1986,6 +2013,7 @@ Object {
"slug": "val-2-4",
"value": Object {
"__typename": "AttributeValue",
"boolean": null,
"file": null,
"id": "val-2-4",
"name": "val-2-4",
@ -2003,6 +2031,7 @@ Object {
"slug": "val-4-1",
"value": Object {
"__typename": "AttributeValue",
"boolean": null,
"file": null,
"id": "val-4-1",
"name": "val-4-1",
@ -2015,6 +2044,7 @@ Object {
"slug": "val-4-5",
"value": Object {
"__typename": "AttributeValue",
"boolean": null,
"file": null,
"id": "val-4-5",
"name": "val-4-5",
@ -2472,6 +2502,7 @@ Object {
"slug": "val-1-1",
"value": Object {
"__typename": "AttributeValue",
"boolean": null,
"file": null,
"id": "val-1-1",
"name": "val-1-1",
@ -2484,6 +2515,7 @@ Object {
"slug": "val-1-7",
"value": Object {
"__typename": "AttributeValue",
"boolean": null,
"file": null,
"id": "val-1-7",
"name": "val-1-7",
@ -2501,6 +2533,7 @@ Object {
"slug": "val-2-2",
"value": Object {
"__typename": "AttributeValue",
"boolean": null,
"file": null,
"id": "val-2-2",
"name": "val-2-2",
@ -2513,6 +2546,7 @@ Object {
"slug": "val-2-4",
"value": Object {
"__typename": "AttributeValue",
"boolean": null,
"file": null,
"id": "val-2-4",
"name": "val-2-4",
@ -2530,6 +2564,7 @@ Object {
"slug": "val-4-1",
"value": Object {
"__typename": "AttributeValue",
"boolean": null,
"file": null,
"id": "val-4-1",
"name": "val-4-1",
@ -2542,6 +2577,7 @@ Object {
"slug": "val-4-5",
"value": Object {
"__typename": "AttributeValue",
"boolean": null,
"file": null,
"id": "val-4-5",
"name": "val-4-5",
@ -3044,6 +3080,7 @@ Object {
"slug": "val-1-1",
"value": Object {
"__typename": "AttributeValue",
"boolean": null,
"file": null,
"id": "val-1-1",
"name": "val-1-1",
@ -3056,6 +3093,7 @@ Object {
"slug": "val-1-7",
"value": Object {
"__typename": "AttributeValue",
"boolean": null,
"file": null,
"id": "val-1-7",
"name": "val-1-7",
@ -3073,6 +3111,7 @@ Object {
"slug": "val-2-2",
"value": Object {
"__typename": "AttributeValue",
"boolean": null,
"file": null,
"id": "val-2-2",
"name": "val-2-2",
@ -3085,6 +3124,7 @@ Object {
"slug": "val-2-4",
"value": Object {
"__typename": "AttributeValue",
"boolean": null,
"file": null,
"id": "val-2-4",
"name": "val-2-4",
@ -3102,6 +3142,7 @@ Object {
"slug": "val-4-1",
"value": Object {
"__typename": "AttributeValue",
"boolean": null,
"file": null,
"id": "val-4-1",
"name": "val-4-1",
@ -3114,6 +3155,7 @@ Object {
"slug": "val-4-5",
"value": Object {
"__typename": "AttributeValue",
"boolean": null,
"file": null,
"id": "val-4-5",
"name": "val-4-5",
@ -3533,6 +3575,7 @@ Object {
"slug": "val-1-1",
"value": Object {
"__typename": "AttributeValue",
"boolean": null,
"file": null,
"id": "val-1-1",
"name": "val-1-1",
@ -3545,6 +3588,7 @@ Object {
"slug": "val-1-7",
"value": Object {
"__typename": "AttributeValue",
"boolean": null,
"file": null,
"id": "val-1-7",
"name": "val-1-7",
@ -3562,6 +3606,7 @@ Object {
"slug": "val-2-2",
"value": Object {
"__typename": "AttributeValue",
"boolean": null,
"file": null,
"id": "val-2-2",
"name": "val-2-2",
@ -3574,6 +3619,7 @@ Object {
"slug": "val-2-4",
"value": Object {
"__typename": "AttributeValue",
"boolean": null,
"file": null,
"id": "val-2-4",
"name": "val-2-4",
@ -3591,6 +3637,7 @@ Object {
"slug": "val-4-1",
"value": Object {
"__typename": "AttributeValue",
"boolean": null,
"file": null,
"id": "val-4-1",
"name": "val-4-1",
@ -3603,6 +3650,7 @@ Object {
"slug": "val-4-5",
"value": Object {
"__typename": "AttributeValue",
"boolean": null,
"file": null,
"id": "val-4-5",
"name": "val-4-5",

View file

@ -29,7 +29,8 @@ export const attributes = [
slug: `val-1-${index + 1}`,
file: null,
reference: null,
richText: null
richText: null,
boolean: null
}
}))
},
@ -46,7 +47,8 @@ export const attributes = [
slug: `val-2-${index + 1}`,
file: null,
reference: null,
richText: null
richText: null,
boolean: null
}
}))
},
@ -63,7 +65,8 @@ export const attributes = [
slug: `val-3-${index + 1}`,
file: null,
reference: null,
richText: null
richText: null,
boolean: null
}
}))
},
@ -80,7 +83,8 @@ export const attributes = [
slug: `val-4-${index + 1}`,
file: null,
reference: null,
richText: null
richText: null,
boolean: null
}
}))
}

View file

@ -144,18 +144,16 @@ const VariantDetailsChannelsAvailabilityCard: React.FC<VariantDetailsChannelsAva
classes={summaryClasses}
data-test-id="channels-variant-availability-summary"
>
<>
<Typography variant="caption">
{intl.formatMessage(messages.subtitle, {
publishedInChannelsCount: publishedInChannelsListings.length,
availableChannelsCount: allAvailableChannelsListings.length
})}
</Typography>
</>
<Typography variant="caption">
{intl.formatMessage(messages.subtitle, {
publishedInChannelsCount: publishedInChannelsListings.length,
availableChannelsCount: allAvailableChannelsListings.length
})}
</Typography>
</ExpansionPanelSummary>
{channelListings.map(({ channel }) => (
<>
<React.Fragment key={channel.id}>
<Divider />
<CardContent>
<Typography
@ -170,7 +168,7 @@ const VariantDetailsChannelsAvailabilityCard: React.FC<VariantDetailsChannelsAva
{getItemSubtitle(channel.id)}
</Typography>
</CardContent>
</>
</React.Fragment>
))}
</ExpansionPanel>
</CardContainer>

View file

@ -50,7 +50,8 @@ export const product: (
name: "portals",
reference: null,
slug: "portals",
richText: null
richText: null,
boolean: null
}
},
{
@ -63,7 +64,8 @@ export const product: (
name: "Baht",
reference: null,
slug: "Baht",
richText: null
richText: null,
boolean: null
}
}
]
@ -77,7 +79,8 @@ export const product: (
name: "portals",
reference: null,
slug: "portals",
richText: null
richText: null,
boolean: null
}
]
},
@ -112,7 +115,8 @@ export const product: (
name: "payment",
reference: null,
slug: "payment",
richText: null
richText: null,
boolean: null
}
},
{
@ -125,7 +129,8 @@ export const product: (
name: "Auto Loan Account",
reference: null,
slug: "Auto-Loan-Account",
richText: null
richText: null,
boolean: null
}
},
{
@ -138,7 +143,8 @@ export const product: (
name: "Garden",
reference: null,
slug: "Garden",
richText: null
richText: null,
boolean: null
}
},
{
@ -151,7 +157,8 @@ export const product: (
name: "override",
reference: null,
slug: "override",
richText: null
richText: null,
boolean: null
}
}
]
@ -165,7 +172,8 @@ export const product: (
name: "Auto Loan Account",
reference: null,
slug: "Auto-Loan-Account",
richText: null
richText: null,
boolean: null
}
]
}
@ -360,7 +368,8 @@ export const product: (
name: "File First Value",
reference: null,
slug: "file-first-value",
richText: null
richText: null,
boolean: null
}
}
]
@ -397,7 +406,8 @@ export const product: (
name: "Black",
reference: null,
slug: "black",
richText: null
richText: null,
boolean: null
}
},
{
@ -410,7 +420,8 @@ export const product: (
name: "White",
reference: null,
slug: "white",
richText: null
richText: null,
boolean: null
}
}
]
@ -451,7 +462,8 @@ export const product: (
name: "File First Value",
reference: null,
slug: "file-first-value",
richText: null
richText: null,
boolean: null
}
}
]
@ -481,7 +493,8 @@ export const product: (
name: "Black",
reference: null,
slug: "black",
richText: null
richText: null,
boolean: null
}
},
{
@ -494,7 +507,8 @@ export const product: (
name: "White",
reference: null,
slug: "white",
richText: null
richText: null,
boolean: null
}
}
]
@ -953,7 +967,8 @@ export const products = (
name: "Pineapple",
reference: null,
slug: "pineapple",
richText: null
richText: null,
boolean: null
}
]
}
@ -1062,7 +1077,8 @@ export const products = (
name: "Coconut",
reference: null,
slug: "coconut",
richText: null
richText: null,
boolean: null
}
]
}
@ -1171,7 +1187,8 @@ export const products = (
name: "Apple",
reference: null,
slug: "apple",
richText: null
richText: null,
boolean: null
}
]
}
@ -1281,7 +1298,8 @@ export const products = (
name: "Orange",
reference: null,
slug: "orange",
richText: null
richText: null,
boolean: null
}
]
}
@ -1390,7 +1408,8 @@ export const products = (
name: "Banana",
reference: null,
slug: "banana",
richText: null
richText: null,
boolean: null
}
]
}
@ -1499,7 +1518,8 @@ export const products = (
name: "Bean",
reference: null,
slug: "bean",
richText: null
richText: null,
boolean: null
}
]
}
@ -1608,7 +1628,8 @@ export const products = (
name: "Carrot",
reference: null,
slug: "carrot",
richText: null
richText: null,
boolean: null
}
]
}
@ -1717,7 +1738,8 @@ export const products = (
name: "Sprouty",
reference: null,
slug: "sprouty",
richText: null
richText: null,
boolean: null
}
]
}
@ -1826,7 +1848,8 @@ export const products = (
name: "Cotton",
reference: null,
slug: "cotton",
richText: null
richText: null,
boolean: null
}
]
}
@ -1935,7 +1958,8 @@ export const products = (
name: "Cotton",
reference: null,
slug: "cotton",
richText: null
richText: null,
boolean: null
}
]
}
@ -2044,7 +2068,8 @@ export const products = (
name: "Cotton",
reference: null,
slug: "cotton",
richText: null
richText: null,
boolean: null
}
]
}
@ -2153,7 +2178,8 @@ export const products = (
name: "Cotton",
reference: null,
slug: "cotton",
richText: null
richText: null,
boolean: null
}
]
}
@ -2262,7 +2288,8 @@ export const products = (
name: "Cotton",
reference: null,
slug: "cotton",
richText: null
richText: null,
boolean: null
}
]
}
@ -2371,7 +2398,8 @@ export const products = (
name: "Cotton",
reference: null,
slug: "cotton",
richText: null
richText: null,
boolean: null
}
]
}
@ -2480,7 +2508,8 @@ export const products = (
name: "Cotton",
reference: null,
slug: "cotton",
richText: null
richText: null,
boolean: null
}
]
}
@ -2589,7 +2618,8 @@ export const products = (
name: "Cotton",
reference: null,
slug: "cotton",
richText: null
richText: null,
boolean: null
}
]
}
@ -2698,7 +2728,8 @@ export const products = (
name: "Cotton",
reference: null,
slug: "cotton",
richText: null
richText: null,
boolean: null
}
]
}
@ -2909,7 +2940,8 @@ export const variant = (placeholderImage: string): ProductVariant => ({
name: "File First Value",
reference: null,
slug: "file-first-value",
richText: null
richText: null,
boolean: null
}
}
]
@ -2927,7 +2959,8 @@ export const variant = (placeholderImage: string): ProductVariant => ({
name: "File First Value",
reference: null,
slug: "file-first-value",
richText: null
richText: null,
boolean: null
}
]
}
@ -3188,7 +3221,8 @@ export const variant = (placeholderImage: string): ProductVariant => ({
name: "portals",
reference: null,
slug: "portals",
richText: null
richText: null,
boolean: null
}
},
{
@ -3201,7 +3235,8 @@ export const variant = (placeholderImage: string): ProductVariant => ({
name: "Baht",
reference: null,
slug: "Baht",
richText: null
richText: null,
boolean: null
}
}
]
@ -3215,7 +3250,8 @@ export const variant = (placeholderImage: string): ProductVariant => ({
name: "portals",
reference: null,
slug: "portals",
richText: null
richText: null,
boolean: null
}
]
},
@ -3250,7 +3286,8 @@ export const variant = (placeholderImage: string): ProductVariant => ({
name: "payment",
reference: null,
slug: "payment",
richText: null
richText: null,
boolean: null
}
},
{
@ -3263,7 +3300,8 @@ export const variant = (placeholderImage: string): ProductVariant => ({
name: "Auto Loan Account",
reference: null,
slug: "Auto-Loan-Account",
richText: null
richText: null,
boolean: null
}
},
{
@ -3276,7 +3314,8 @@ export const variant = (placeholderImage: string): ProductVariant => ({
name: "Garden",
reference: null,
slug: "Garden",
richText: null
richText: null,
boolean: null
}
},
{
@ -3289,7 +3328,8 @@ export const variant = (placeholderImage: string): ProductVariant => ({
name: "override",
reference: null,
slug: "override",
richText: null
richText: null,
boolean: null
}
}
]
@ -3303,7 +3343,8 @@ export const variant = (placeholderImage: string): ProductVariant => ({
name: "Auto Loan Account",
reference: null,
slug: "Auto-Loan-Account",
richText: null
richText: null,
boolean: null
}
]
}

View file

@ -66,12 +66,14 @@ const initialProductFilterAttributesQuery = gql`
node {
id
name
inputType
slug
}
}
}
}
`;
export const useInitialProductFilterAttributesQuery = makeQuery<
InitialProductFilterAttributes,
never

View file

@ -31,6 +31,7 @@ export interface CreateMultipleVariantsData_product_attributes_attribute_choices
file: CreateMultipleVariantsData_product_attributes_attribute_choices_edges_node_file | null;
reference: string | null;
richText: any | null;
boolean: boolean | null;
}
export interface CreateMultipleVariantsData_product_attributes_attribute_choices_edges {
@ -71,6 +72,7 @@ export interface CreateMultipleVariantsData_product_attributes_values {
file: CreateMultipleVariantsData_product_attributes_values_file | null;
reference: string | null;
richText: any | null;
boolean: boolean | null;
}
export interface CreateMultipleVariantsData_product_attributes {
@ -101,6 +103,7 @@ export interface CreateMultipleVariantsData_product_productType_variantAttribute
file: CreateMultipleVariantsData_product_productType_variantAttributes_choices_edges_node_file | null;
reference: string | null;
richText: any | null;
boolean: boolean | null;
}
export interface CreateMultipleVariantsData_product_productType_variantAttributes_choices_edges {

View file

@ -3,6 +3,8 @@
// @generated
// This file was automatically generated and should not be edited.
import { AttributeInputTypeEnum } from "./../../types/globalTypes";
// ====================================================
// GraphQL query operation: InitialProductFilterAttributes
// ====================================================
@ -11,6 +13,7 @@ export interface InitialProductFilterAttributes_attributes_edges_node {
__typename: "Attribute";
id: string;
name: string | null;
inputType: AttributeInputTypeEnum | null;
slug: string | null;
}

View file

@ -31,6 +31,7 @@ export interface ProductDetails_product_attributes_attribute_choices_edges_node
file: ProductDetails_product_attributes_attribute_choices_edges_node_file | null;
reference: string | null;
richText: any | null;
boolean: boolean | null;
}
export interface ProductDetails_product_attributes_attribute_choices_edges {
@ -71,6 +72,7 @@ export interface ProductDetails_product_attributes_values {
file: ProductDetails_product_attributes_values_file | null;
reference: string | null;
richText: any | null;
boolean: boolean | null;
}
export interface ProductDetails_product_attributes {
@ -101,6 +103,7 @@ export interface ProductDetails_product_productType_variantAttributes_choices_ed
file: ProductDetails_product_productType_variantAttributes_choices_edges_node_file | null;
reference: string | null;
richText: any | null;
boolean: boolean | null;
}
export interface ProductDetails_product_productType_variantAttributes_choices_edges {

View file

@ -91,6 +91,7 @@ export interface ProductList_products_edges_node_attributes_values {
file: ProductList_products_edges_node_attributes_values_file | null;
reference: string | null;
richText: any | null;
boolean: boolean | null;
}
export interface ProductList_products_edges_node_attributes {

View file

@ -31,6 +31,7 @@ export interface ProductType_productType_productAttributes_choices_edges_node {
file: ProductType_productType_productAttributes_choices_edges_node_file | null;
reference: string | null;
richText: any | null;
boolean: boolean | null;
}
export interface ProductType_productType_productAttributes_choices_edges {

View file

@ -38,6 +38,7 @@ export interface ProductUpdate_productUpdate_product_attributes_attribute_choice
file: ProductUpdate_productUpdate_product_attributes_attribute_choices_edges_node_file | null;
reference: string | null;
richText: any | null;
boolean: boolean | null;
}
export interface ProductUpdate_productUpdate_product_attributes_attribute_choices_edges {
@ -78,6 +79,7 @@ export interface ProductUpdate_productUpdate_product_attributes_values {
file: ProductUpdate_productUpdate_product_attributes_values_file | null;
reference: string | null;
richText: any | null;
boolean: boolean | null;
}
export interface ProductUpdate_productUpdate_product_attributes {
@ -108,6 +110,7 @@ export interface ProductUpdate_productUpdate_product_productType_variantAttribut
file: ProductUpdate_productUpdate_product_productType_variantAttributes_choices_edges_node_file | null;
reference: string | null;
richText: any | null;
boolean: boolean | null;
}
export interface ProductUpdate_productUpdate_product_productType_variantAttributes_choices_edges {

View file

@ -50,6 +50,7 @@ export interface ProductVariantCreateData_product_productType_selectionVariantAt
file: ProductVariantCreateData_product_productType_selectionVariantAttributes_choices_edges_node_file | null;
reference: string | null;
richText: any | null;
boolean: boolean | null;
}
export interface ProductVariantCreateData_product_productType_selectionVariantAttributes_choices_edges {
@ -98,6 +99,7 @@ export interface ProductVariantCreateData_product_productType_nonSelectionVarian
file: ProductVariantCreateData_product_productType_nonSelectionVariantAttributes_choices_edges_node_file | null;
reference: string | null;
richText: any | null;
boolean: boolean | null;
}
export interface ProductVariantCreateData_product_productType_nonSelectionVariantAttributes_choices_edges {

View file

@ -43,6 +43,7 @@ export interface ProductVariantDetails_productVariant_selectionAttributes_attrib
file: ProductVariantDetails_productVariant_selectionAttributes_attribute_choices_edges_node_file | null;
reference: string | null;
richText: any | null;
boolean: boolean | null;
}
export interface ProductVariantDetails_productVariant_selectionAttributes_attribute_choices_edges {
@ -83,6 +84,7 @@ export interface ProductVariantDetails_productVariant_selectionAttributes_values
file: ProductVariantDetails_productVariant_selectionAttributes_values_file | null;
reference: string | null;
richText: any | null;
boolean: boolean | null;
}
export interface ProductVariantDetails_productVariant_selectionAttributes {
@ -113,6 +115,7 @@ export interface ProductVariantDetails_productVariant_nonSelectionAttributes_att
file: ProductVariantDetails_productVariant_nonSelectionAttributes_attribute_choices_edges_node_file | null;
reference: string | null;
richText: any | null;
boolean: boolean | null;
}
export interface ProductVariantDetails_productVariant_nonSelectionAttributes_attribute_choices_edges {
@ -153,6 +156,7 @@ export interface ProductVariantDetails_productVariant_nonSelectionAttributes_val
file: ProductVariantDetails_productVariant_nonSelectionAttributes_values_file | null;
reference: string | null;
richText: any | null;
boolean: boolean | null;
}
export interface ProductVariantDetails_productVariant_nonSelectionAttributes {

View file

@ -38,6 +38,7 @@ export interface SimpleProductUpdate_productUpdate_product_attributes_attribute_
file: SimpleProductUpdate_productUpdate_product_attributes_attribute_choices_edges_node_file | null;
reference: string | null;
richText: any | null;
boolean: boolean | null;
}
export interface SimpleProductUpdate_productUpdate_product_attributes_attribute_choices_edges {
@ -78,6 +79,7 @@ export interface SimpleProductUpdate_productUpdate_product_attributes_values {
file: SimpleProductUpdate_productUpdate_product_attributes_values_file | null;
reference: string | null;
richText: any | null;
boolean: boolean | null;
}
export interface SimpleProductUpdate_productUpdate_product_attributes {
@ -108,6 +110,7 @@ export interface SimpleProductUpdate_productUpdate_product_productType_variantAt
file: SimpleProductUpdate_productUpdate_product_productType_variantAttributes_choices_edges_node_file | null;
reference: string | null;
richText: any | null;
boolean: boolean | null;
}
export interface SimpleProductUpdate_productUpdate_product_productType_variantAttributes_choices_edges {
@ -375,6 +378,7 @@ export interface SimpleProductUpdate_productVariantUpdate_productVariant_selecti
file: SimpleProductUpdate_productVariantUpdate_productVariant_selectionAttributes_attribute_choices_edges_node_file | null;
reference: string | null;
richText: any | null;
boolean: boolean | null;
}
export interface SimpleProductUpdate_productVariantUpdate_productVariant_selectionAttributes_attribute_choices_edges {
@ -415,6 +419,7 @@ export interface SimpleProductUpdate_productVariantUpdate_productVariant_selecti
file: SimpleProductUpdate_productVariantUpdate_productVariant_selectionAttributes_values_file | null;
reference: string | null;
richText: any | null;
boolean: boolean | null;
}
export interface SimpleProductUpdate_productVariantUpdate_productVariant_selectionAttributes {
@ -445,6 +450,7 @@ export interface SimpleProductUpdate_productVariantUpdate_productVariant_nonSele
file: SimpleProductUpdate_productVariantUpdate_productVariant_nonSelectionAttributes_attribute_choices_edges_node_file | null;
reference: string | null;
richText: any | null;
boolean: boolean | null;
}
export interface SimpleProductUpdate_productVariantUpdate_productVariant_nonSelectionAttributes_attribute_choices_edges {
@ -485,6 +491,7 @@ export interface SimpleProductUpdate_productVariantUpdate_productVariant_nonSele
file: SimpleProductUpdate_productVariantUpdate_productVariant_nonSelectionAttributes_values_file | null;
reference: string | null;
richText: any | null;
boolean: boolean | null;
}
export interface SimpleProductUpdate_productVariantUpdate_productVariant_nonSelectionAttributes {
@ -706,6 +713,7 @@ export interface SimpleProductUpdate_productVariantStocksCreate_productVariant_s
file: SimpleProductUpdate_productVariantStocksCreate_productVariant_selectionAttributes_attribute_choices_edges_node_file | null;
reference: string | null;
richText: any | null;
boolean: boolean | null;
}
export interface SimpleProductUpdate_productVariantStocksCreate_productVariant_selectionAttributes_attribute_choices_edges {
@ -746,6 +754,7 @@ export interface SimpleProductUpdate_productVariantStocksCreate_productVariant_s
file: SimpleProductUpdate_productVariantStocksCreate_productVariant_selectionAttributes_values_file | null;
reference: string | null;
richText: any | null;
boolean: boolean | null;
}
export interface SimpleProductUpdate_productVariantStocksCreate_productVariant_selectionAttributes {
@ -776,6 +785,7 @@ export interface SimpleProductUpdate_productVariantStocksCreate_productVariant_n
file: SimpleProductUpdate_productVariantStocksCreate_productVariant_nonSelectionAttributes_attribute_choices_edges_node_file | null;
reference: string | null;
richText: any | null;
boolean: boolean | null;
}
export interface SimpleProductUpdate_productVariantStocksCreate_productVariant_nonSelectionAttributes_attribute_choices_edges {
@ -816,6 +826,7 @@ export interface SimpleProductUpdate_productVariantStocksCreate_productVariant_n
file: SimpleProductUpdate_productVariantStocksCreate_productVariant_nonSelectionAttributes_values_file | null;
reference: string | null;
richText: any | null;
boolean: boolean | null;
}
export interface SimpleProductUpdate_productVariantStocksCreate_productVariant_nonSelectionAttributes {
@ -1036,6 +1047,7 @@ export interface SimpleProductUpdate_productVariantStocksDelete_productVariant_s
file: SimpleProductUpdate_productVariantStocksDelete_productVariant_selectionAttributes_attribute_choices_edges_node_file | null;
reference: string | null;
richText: any | null;
boolean: boolean | null;
}
export interface SimpleProductUpdate_productVariantStocksDelete_productVariant_selectionAttributes_attribute_choices_edges {
@ -1076,6 +1088,7 @@ export interface SimpleProductUpdate_productVariantStocksDelete_productVariant_s
file: SimpleProductUpdate_productVariantStocksDelete_productVariant_selectionAttributes_values_file | null;
reference: string | null;
richText: any | null;
boolean: boolean | null;
}
export interface SimpleProductUpdate_productVariantStocksDelete_productVariant_selectionAttributes {
@ -1106,6 +1119,7 @@ export interface SimpleProductUpdate_productVariantStocksDelete_productVariant_n
file: SimpleProductUpdate_productVariantStocksDelete_productVariant_nonSelectionAttributes_attribute_choices_edges_node_file | null;
reference: string | null;
richText: any | null;
boolean: boolean | null;
}
export interface SimpleProductUpdate_productVariantStocksDelete_productVariant_nonSelectionAttributes_attribute_choices_edges {
@ -1146,6 +1160,7 @@ export interface SimpleProductUpdate_productVariantStocksDelete_productVariant_n
file: SimpleProductUpdate_productVariantStocksDelete_productVariant_nonSelectionAttributes_values_file | null;
reference: string | null;
richText: any | null;
boolean: boolean | null;
}
export interface SimpleProductUpdate_productVariantStocksDelete_productVariant_nonSelectionAttributes {
@ -1367,6 +1382,7 @@ export interface SimpleProductUpdate_productVariantStocksUpdate_productVariant_s
file: SimpleProductUpdate_productVariantStocksUpdate_productVariant_selectionAttributes_attribute_choices_edges_node_file | null;
reference: string | null;
richText: any | null;
boolean: boolean | null;
}
export interface SimpleProductUpdate_productVariantStocksUpdate_productVariant_selectionAttributes_attribute_choices_edges {
@ -1407,6 +1423,7 @@ export interface SimpleProductUpdate_productVariantStocksUpdate_productVariant_s
file: SimpleProductUpdate_productVariantStocksUpdate_productVariant_selectionAttributes_values_file | null;
reference: string | null;
richText: any | null;
boolean: boolean | null;
}
export interface SimpleProductUpdate_productVariantStocksUpdate_productVariant_selectionAttributes {
@ -1437,6 +1454,7 @@ export interface SimpleProductUpdate_productVariantStocksUpdate_productVariant_n
file: SimpleProductUpdate_productVariantStocksUpdate_productVariant_nonSelectionAttributes_attribute_choices_edges_node_file | null;
reference: string | null;
richText: any | null;
boolean: boolean | null;
}
export interface SimpleProductUpdate_productVariantStocksUpdate_productVariant_nonSelectionAttributes_attribute_choices_edges {
@ -1477,6 +1495,7 @@ export interface SimpleProductUpdate_productVariantStocksUpdate_productVariant_n
file: SimpleProductUpdate_productVariantStocksUpdate_productVariant_nonSelectionAttributes_values_file | null;
reference: string | null;
richText: any | null;
boolean: boolean | null;
}
export interface SimpleProductUpdate_productVariantStocksUpdate_productVariant_nonSelectionAttributes {

View file

@ -50,6 +50,7 @@ export interface VariantCreate_productVariantCreate_productVariant_selectionAttr
file: VariantCreate_productVariantCreate_productVariant_selectionAttributes_attribute_choices_edges_node_file | null;
reference: string | null;
richText: any | null;
boolean: boolean | null;
}
export interface VariantCreate_productVariantCreate_productVariant_selectionAttributes_attribute_choices_edges {
@ -90,6 +91,7 @@ export interface VariantCreate_productVariantCreate_productVariant_selectionAttr
file: VariantCreate_productVariantCreate_productVariant_selectionAttributes_values_file | null;
reference: string | null;
richText: any | null;
boolean: boolean | null;
}
export interface VariantCreate_productVariantCreate_productVariant_selectionAttributes {
@ -120,6 +122,7 @@ export interface VariantCreate_productVariantCreate_productVariant_nonSelectionA
file: VariantCreate_productVariantCreate_productVariant_nonSelectionAttributes_attribute_choices_edges_node_file | null;
reference: string | null;
richText: any | null;
boolean: boolean | null;
}
export interface VariantCreate_productVariantCreate_productVariant_nonSelectionAttributes_attribute_choices_edges {
@ -160,6 +163,7 @@ export interface VariantCreate_productVariantCreate_productVariant_nonSelectionA
file: VariantCreate_productVariantCreate_productVariant_nonSelectionAttributes_values_file | null;
reference: string | null;
richText: any | null;
boolean: boolean | null;
}
export interface VariantCreate_productVariantCreate_productVariant_nonSelectionAttributes {

View file

@ -50,6 +50,7 @@ export interface VariantUpdate_productVariantUpdate_productVariant_selectionAttr
file: VariantUpdate_productVariantUpdate_productVariant_selectionAttributes_attribute_choices_edges_node_file | null;
reference: string | null;
richText: any | null;
boolean: boolean | null;
}
export interface VariantUpdate_productVariantUpdate_productVariant_selectionAttributes_attribute_choices_edges {
@ -90,6 +91,7 @@ export interface VariantUpdate_productVariantUpdate_productVariant_selectionAttr
file: VariantUpdate_productVariantUpdate_productVariant_selectionAttributes_values_file | null;
reference: string | null;
richText: any | null;
boolean: boolean | null;
}
export interface VariantUpdate_productVariantUpdate_productVariant_selectionAttributes {
@ -120,6 +122,7 @@ export interface VariantUpdate_productVariantUpdate_productVariant_nonSelectionA
file: VariantUpdate_productVariantUpdate_productVariant_nonSelectionAttributes_attribute_choices_edges_node_file | null;
reference: string | null;
richText: any | null;
boolean: boolean | null;
}
export interface VariantUpdate_productVariantUpdate_productVariant_nonSelectionAttributes_attribute_choices_edges {
@ -160,6 +163,7 @@ export interface VariantUpdate_productVariantUpdate_productVariant_nonSelectionA
file: VariantUpdate_productVariantUpdate_productVariant_nonSelectionAttributes_values_file | null;
reference: string | null;
richText: any | null;
boolean: boolean | null;
}
export interface VariantUpdate_productVariantUpdate_productVariant_nonSelectionAttributes {
@ -381,6 +385,7 @@ export interface VariantUpdate_productVariantStocksUpdate_productVariant_selecti
file: VariantUpdate_productVariantStocksUpdate_productVariant_selectionAttributes_attribute_choices_edges_node_file | null;
reference: string | null;
richText: any | null;
boolean: boolean | null;
}
export interface VariantUpdate_productVariantStocksUpdate_productVariant_selectionAttributes_attribute_choices_edges {
@ -421,6 +426,7 @@ export interface VariantUpdate_productVariantStocksUpdate_productVariant_selecti
file: VariantUpdate_productVariantStocksUpdate_productVariant_selectionAttributes_values_file | null;
reference: string | null;
richText: any | null;
boolean: boolean | null;
}
export interface VariantUpdate_productVariantStocksUpdate_productVariant_selectionAttributes {
@ -451,6 +457,7 @@ export interface VariantUpdate_productVariantStocksUpdate_productVariant_nonSele
file: VariantUpdate_productVariantStocksUpdate_productVariant_nonSelectionAttributes_attribute_choices_edges_node_file | null;
reference: string | null;
richText: any | null;
boolean: boolean | null;
}
export interface VariantUpdate_productVariantStocksUpdate_productVariant_nonSelectionAttributes_attribute_choices_edges {
@ -491,6 +498,7 @@ export interface VariantUpdate_productVariantStocksUpdate_productVariant_nonSele
file: VariantUpdate_productVariantStocksUpdate_productVariant_nonSelectionAttributes_values_file | null;
reference: string | null;
richText: any | null;
boolean: boolean | null;
}
export interface VariantUpdate_productVariantStocksUpdate_productVariant_nonSelectionAttributes {

View file

@ -83,6 +83,7 @@ export function getFilterOpts(
id: attr.id,
name: attr.name,
slug: attr.slug,
inputType: attr.inputType,
value:
!!params.attributes && params.attributes[attr.slug]
? dedupeFilter(params.attributes[attr.slug])
@ -198,20 +199,35 @@ export function getFilterOpts(
};
}
function getFilteredAttributeValue(
params: ProductListUrlFilters
): Array<({ boolean: boolean } | { values: string[] }) & { slug: string }> {
return !!params.attributes
? Object.keys(params.attributes).map(key => {
const value = params.attributes[key];
const isMulti = isArray(params.attributes[key]);
const isBooleanValue =
!isMulti && ["true", "false"].includes((value as unknown) as string);
return {
slug: key,
...(isBooleanValue
? { boolean: JSON.parse((value as unknown) as string) }
: {
// It is possible for qs to parse values not as string[] but string
values: isMulti ? value : (([value] as unknown) as string[])
})
};
})
: null;
}
export function getFilterVariables(
params: ProductListUrlFilters,
channel: string | undefined
): ProductFilterInput {
return {
attributes: !!params.attributes
? Object.keys(params.attributes).map(key => ({
slug: key,
// It is possible for qs to parse values not as string[] but string
values: isArray(params.attributes[key])
? params.attributes[key]
: (([params.attributes[key]] as unknown) as string[])
}))
: null,
attributes: getFilteredAttributeValue(params),
categories: params.categories !== undefined ? params.categories : null,
channel: channel || null,
collections: params.collections !== undefined ? params.collections : null,

View file

@ -11,6 +11,7 @@ export const productListFilterOpts: ProductListFilterOpts = {
attributes: attributes.map(attr => ({
id: attr.id,
active: false,
inputType: attr.inputType,
name: attr.name,
slug: attr.slug,
value: [

View file

@ -21,6 +21,7 @@ export interface SearchAttributeValues_attribute_choices_edges_node {
file: SearchAttributeValues_attribute_choices_edges_node_file | null;
reference: string | null;
richText: any | null;
boolean: boolean | null;
}
export interface SearchAttributeValues_attribute_choices_edges {

View file

@ -61,7 +61,7 @@ exports[`Storyshots Attributes / Attributes default 1`] = `
<div
class="MuiTypography-root-id Attributes-expansionBarLabel-id MuiTypography-caption-id"
>
6 Attributes
7 Attributes
</div>
</div>
<button
@ -395,14 +395,23 @@ exports[`Storyshots Attributes / Attributes default 1`] = `
Value
</label>
<div
class="MuiInputBase-root-id MuiOutlinedInput-root-id MuiInputBase-fullWidth-id MuiInputBase-formControl-id"
class="MuiInputBase-root-id MuiOutlinedInput-root-id MuiInputBase-fullWidth-id MuiInputBase-formControl-id MuiInputBase-adornedEnd-id MuiOutlinedInput-adornedEnd-id"
>
<input
aria-invalid="false"
class="MuiInputBase-input-id MuiOutlinedInput-input-id"
class="MuiInputBase-input-id MuiOutlinedInput-input-id MuiInputBase-inputAdornedEnd-id MuiOutlinedInput-inputAdornedEnd-id"
name="attribute:Numeric Attribute"
type="number"
/>
<div
class="MuiInputAdornment-root-id MuiInputAdornment-positionEnd-id"
>
<div
class="MuiTypography-root-id MuiTypography-body1-id MuiTypography-colorTextSecondary-id"
>
cm
</div>
</div>
<fieldset
aria-hidden="true"
class="PrivateNotchedOutline-root-id MuiOutlinedInput-notchedOutline-id"
@ -419,6 +428,61 @@ exports[`Storyshots Attributes / Attributes default 1`] = `
</div>
</div>
</div>
<hr
class="Hr-root-id"
/>
<div
class="BasicAttributeRow-attributeSection-id Grid-root-id Grid-uniform-id"
>
<div
class="BasicAttributeRow-attributeSectionLabel-id"
data-test="attribute-label"
>
<div
class="MuiTypography-root-id MuiTypography-body1-id"
>
Boolean Attribute
</div>
</div>
<div
data-test="attribute-value"
>
<div
class="AttributeRow-pullRight-id"
>
<span
aria-disabled="false"
class="MuiButtonBase-root-id MuiIconButton-root-id PrivateSwitchBase-root-id MuiCheckbox-root-id MuiCheckbox-colorPrimary-id AttributeRow-pullRight-id MuiIconButton-colorPrimary-id"
>
<span
class="MuiIconButton-label-id"
>
<input
class="PrivateSwitchBase-input-id"
data-indeterminate="false"
name="attribute:Boolean Attribute"
type="checkbox"
/>
<svg
aria-hidden="true"
class="MuiSvgIcon-root-id"
focusable="false"
viewBox="0 0 24 24"
>
<rect
fill="none"
height="14"
stroke="currentColor"
width="14"
x="5"
y="5"
/>
</svg>
</span>
</span>
</div>
</div>
</div>
</div>
</div>
</div>
@ -461,7 +525,7 @@ exports[`Storyshots Attributes / Attributes disabled 1`] = `
<div
class="MuiTypography-root-id Attributes-expansionBarLabel-id MuiTypography-caption-id"
>
6 Attributes
7 Attributes
</div>
</div>
<button
@ -799,15 +863,24 @@ exports[`Storyshots Attributes / Attributes disabled 1`] = `
Value
</label>
<div
class="MuiInputBase-root-id MuiOutlinedInput-root-id MuiInputBase-disabled-id MuiOutlinedInput-disabled-id MuiInputBase-fullWidth-id MuiInputBase-formControl-id"
class="MuiInputBase-root-id MuiOutlinedInput-root-id MuiInputBase-disabled-id MuiOutlinedInput-disabled-id MuiInputBase-fullWidth-id MuiInputBase-formControl-id MuiInputBase-adornedEnd-id MuiOutlinedInput-adornedEnd-id"
>
<input
aria-invalid="false"
class="MuiInputBase-input-id MuiOutlinedInput-input-id MuiInputBase-disabled-id MuiOutlinedInput-disabled-id"
class="MuiInputBase-input-id MuiOutlinedInput-input-id MuiInputBase-disabled-id MuiOutlinedInput-disabled-id MuiInputBase-inputAdornedEnd-id MuiOutlinedInput-inputAdornedEnd-id"
disabled=""
name="attribute:Numeric Attribute"
type="number"
/>
<div
class="MuiInputAdornment-root-id MuiInputAdornment-positionEnd-id"
>
<div
class="MuiTypography-root-id MuiTypography-body1-id MuiTypography-colorTextSecondary-id"
>
cm
</div>
</div>
<fieldset
aria-hidden="true"
class="PrivateNotchedOutline-root-id MuiOutlinedInput-notchedOutline-id"
@ -824,6 +897,63 @@ exports[`Storyshots Attributes / Attributes disabled 1`] = `
</div>
</div>
</div>
<hr
class="Hr-root-id"
/>
<div
class="BasicAttributeRow-attributeSection-id Grid-root-id Grid-uniform-id"
>
<div
class="BasicAttributeRow-attributeSectionLabel-id"
data-test="attribute-label"
>
<div
class="MuiTypography-root-id MuiTypography-body1-id"
>
Boolean Attribute
</div>
</div>
<div
data-test="attribute-value"
>
<div
class="AttributeRow-pullRight-id"
>
<span
aria-disabled="true"
class="MuiButtonBase-root-id MuiIconButton-root-id PrivateSwitchBase-root-id MuiCheckbox-root-id MuiCheckbox-colorPrimary-id AttributeRow-pullRight-id PrivateSwitchBase-disabled-id MuiCheckbox-disabled-id MuiIconButton-colorPrimary-id MuiIconButton-disabled-id MuiButtonBase-disabled-id"
tabindex="-1"
>
<span
class="MuiIconButton-label-id"
>
<input
class="PrivateSwitchBase-input-id"
data-indeterminate="false"
disabled=""
name="attribute:Boolean Attribute"
type="checkbox"
/>
<svg
aria-hidden="true"
class="MuiSvgIcon-root-id"
focusable="false"
viewBox="0 0 24 24"
>
<rect
fill="none"
height="14"
stroke="currentColor"
width="14"
x="5"
y="5"
/>
</svg>
</span>
</span>
</div>
</div>
</div>
</div>
</div>
</div>
@ -866,7 +996,7 @@ exports[`Storyshots Attributes / Attributes selected 1`] = `
<div
class="MuiTypography-root-id Attributes-expansionBarLabel-id MuiTypography-caption-id"
>
6 Attributes
7 Attributes
</div>
</div>
<button
@ -1466,15 +1596,24 @@ exports[`Storyshots Attributes / Attributes selected 1`] = `
Value
</label>
<div
class="MuiInputBase-root-id MuiOutlinedInput-root-id MuiInputBase-fullWidth-id MuiInputBase-formControl-id"
class="MuiInputBase-root-id MuiOutlinedInput-root-id MuiInputBase-fullWidth-id MuiInputBase-formControl-id MuiInputBase-adornedEnd-id MuiOutlinedInput-adornedEnd-id"
>
<input
aria-invalid="false"
class="MuiInputBase-input-id MuiOutlinedInput-input-id"
class="MuiInputBase-input-id MuiOutlinedInput-input-id MuiInputBase-inputAdornedEnd-id MuiOutlinedInput-inputAdornedEnd-id"
name="attribute:Numeric Attribute"
type="number"
value="12cm"
value="12"
/>
<div
class="MuiInputAdornment-root-id MuiInputAdornment-positionEnd-id"
>
<div
class="MuiTypography-root-id MuiTypography-body1-id MuiTypography-colorTextSecondary-id"
>
cm
</div>
</div>
<fieldset
aria-hidden="true"
class="PrivateNotchedOutline-root-id MuiOutlinedInput-notchedOutline-id"
@ -1491,6 +1630,67 @@ exports[`Storyshots Attributes / Attributes selected 1`] = `
</div>
</div>
</div>
<hr
class="Hr-root-id"
/>
<div
class="BasicAttributeRow-attributeSection-id Grid-root-id Grid-uniform-id"
>
<div
class="BasicAttributeRow-attributeSectionLabel-id"
data-test="attribute-label"
>
<div
class="MuiTypography-root-id MuiTypography-body1-id"
>
Boolean Attribute
</div>
</div>
<div
data-test="attribute-value"
>
<div
class="AttributeRow-pullRight-id"
>
<span
aria-disabled="false"
class="MuiButtonBase-root-id MuiIconButton-root-id PrivateSwitchBase-root-id MuiCheckbox-root-id MuiCheckbox-colorPrimary-id AttributeRow-pullRight-id PrivateSwitchBase-checked-id MuiCheckbox-checked-id MuiIconButton-colorPrimary-id"
>
<span
class="MuiIconButton-label-id"
>
<input
checked=""
class="PrivateSwitchBase-input-id"
data-indeterminate="false"
name="attribute:Boolean Attribute"
type="checkbox"
/>
<svg
aria-hidden="true"
class="MuiSvgIcon-root-id"
focusable="false"
viewBox="0 0 24 24"
>
<rect
fill="currentColor"
height="14"
width="14"
x="5"
y="5"
/>
<path
clip-rule="evenodd"
d="M 16.7527 9.33783 L 10.86618 15.7595 L 8 12.32006 L 8.76822 11.67988 L 10.90204 14.24046 L 16.0155 8.66211 L 16.7527 9.33783 Z"
fill="white"
fill-rule="evenodd"
/>
</svg>
</span>
</span>
</div>
</div>
</div>
</div>
</div>
</div>

View file

@ -88,6 +88,7 @@ export enum AttributeErrorCode {
}
export enum AttributeInputTypeEnum {
BOOLEAN = "BOOLEAN",
DROPDOWN = "DROPDOWN",
FILE = "FILE",
MULTISELECT = "MULTISELECT",
@ -1127,6 +1128,7 @@ export interface AttributeInput {
slug: string;
values?: (string | null)[] | null;
valuesRange?: IntRangeInput | null;
boolean?: boolean | null;
}
export interface AttributeSortingInput {
@ -1162,6 +1164,7 @@ export interface AttributeValueInput {
contentType?: string | null;
references?: string[] | null;
richText?: any | null;
boolean?: boolean | null;
}
export interface AttributeValueTranslationInput {

View file

@ -6,7 +6,7 @@ async function handleFormSubmit<T>(
setChanged: (changed: boolean) => void
): Promise<boolean> {
const errors = await onSubmit(data);
const ok = errors.length === 0;
const ok = errors?.length === 0;
if (ok) {
setChanged(false);