2019-08-09 10:17:04 +00:00
|
|
|
|
import Card from "@material-ui/core/Card";
|
|
|
|
|
import CardContent from "@material-ui/core/CardContent";
|
|
|
|
|
import TextField from "@material-ui/core/TextField";
|
|
|
|
|
import Typography from "@material-ui/core/Typography";
|
|
|
|
|
import React from "react";
|
2019-08-16 11:47:30 +00:00
|
|
|
|
import { FormattedMessage, useIntl } from "react-intl";
|
2019-08-09 10:17:04 +00:00
|
|
|
|
|
|
|
|
|
import CardSpacer from "@saleor/components/CardSpacer";
|
|
|
|
|
import CardTitle from "@saleor/components/CardTitle";
|
2019-09-09 09:28:06 +00:00
|
|
|
|
import ControlledCheckbox from "@saleor/components/ControlledCheckbox";
|
2019-08-09 10:17:04 +00:00
|
|
|
|
import FormSpacer from "@saleor/components/FormSpacer";
|
|
|
|
|
import Hr from "@saleor/components/Hr";
|
2019-08-16 11:47:30 +00:00
|
|
|
|
import { commonMessages } from "@saleor/intl";
|
2020-03-11 09:56:04 +00:00
|
|
|
|
import { UserError } from "@saleor/types";
|
|
|
|
|
import { getFieldError } from "@saleor/utils/errors";
|
2019-08-09 10:17:04 +00:00
|
|
|
|
import { AttributePageFormData } from "../AttributePage";
|
|
|
|
|
|
|
|
|
|
export interface AttributePropertiesProps {
|
|
|
|
|
data: AttributePageFormData;
|
|
|
|
|
disabled: boolean;
|
2020-03-11 09:56:04 +00:00
|
|
|
|
errors: UserError[];
|
2019-08-09 10:17:04 +00:00
|
|
|
|
onChange: (event: React.ChangeEvent<any>) => void;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const AttributeProperties: React.FC<AttributePropertiesProps> = ({
|
|
|
|
|
data,
|
|
|
|
|
errors,
|
|
|
|
|
disabled,
|
|
|
|
|
onChange
|
2019-08-16 11:47:30 +00:00
|
|
|
|
}) => {
|
|
|
|
|
const intl = useIntl();
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Card>
|
|
|
|
|
<CardTitle title={intl.formatMessage(commonMessages.properties)} />
|
|
|
|
|
<CardContent>
|
|
|
|
|
{/* <Typography variant="subtitle1">
|
|
|
|
|
<FormattedMessage
|
|
|
|
|
defaultMessage="General Properties"
|
|
|
|
|
description="attribute general properties section"
|
2019-08-22 16:19:16 +00:00
|
|
|
|
|
2019-08-16 11:47:30 +00:00
|
|
|
|
/>
|
|
|
|
|
</Typography>
|
|
|
|
|
<Hr />
|
|
|
|
|
<CardSpacer />
|
|
|
|
|
<ControlledSwitch
|
|
|
|
|
name={"" as keyof AttributePageFormData}
|
|
|
|
|
checked={false}
|
|
|
|
|
disabled={disabled}
|
|
|
|
|
label={
|
|
|
|
|
<>
|
|
|
|
|
<FormattedMessage
|
|
|
|
|
defaultMessage="Variant Attribute"
|
|
|
|
|
description="attribute is variant-only"
|
2019-08-22 16:19:16 +00:00
|
|
|
|
|
2019-08-16 11:47:30 +00:00
|
|
|
|
/>
|
|
|
|
|
<Typography variant="caption">
|
|
|
|
|
<FormattedMessage
|
|
|
|
|
defaultMessage="If enabled, you'll be able to use this attribute to create product variants"
|
2019-08-22 16:19:16 +00:00
|
|
|
|
|
2019-08-16 11:47:30 +00:00
|
|
|
|
/>
|
|
|
|
|
</Typography>
|
|
|
|
|
</>
|
|
|
|
|
}
|
|
|
|
|
onChange={onChange}
|
|
|
|
|
/> */}
|
|
|
|
|
|
|
|
|
|
<Typography variant="subtitle1">
|
|
|
|
|
<FormattedMessage
|
|
|
|
|
defaultMessage="Storefront Properties"
|
|
|
|
|
description="attribute properties regarding storefront"
|
|
|
|
|
/>
|
|
|
|
|
</Typography>
|
|
|
|
|
<Hr />
|
2019-09-09 09:28:06 +00:00
|
|
|
|
<ControlledCheckbox
|
|
|
|
|
name={"filterableInStorefront" as keyof FormData}
|
2019-08-16 11:47:30 +00:00
|
|
|
|
label={intl.formatMessage({
|
2019-10-22 11:17:07 +00:00
|
|
|
|
defaultMessage: "Use in Faceted Navigation",
|
2019-08-22 16:19:16 +00:00
|
|
|
|
description: "attribute is filterable in storefront"
|
2019-08-16 11:47:30 +00:00
|
|
|
|
})}
|
2019-09-09 09:28:06 +00:00
|
|
|
|
checked={data.filterableInStorefront}
|
2019-08-16 11:47:30 +00:00
|
|
|
|
onChange={onChange}
|
2019-09-09 09:28:06 +00:00
|
|
|
|
disabled={disabled}
|
2019-08-16 11:47:30 +00:00
|
|
|
|
/>
|
2019-09-09 09:28:06 +00:00
|
|
|
|
<FormSpacer />
|
2019-08-16 11:47:30 +00:00
|
|
|
|
{data.filterableInStorefront && (
|
|
|
|
|
<TextField
|
|
|
|
|
disabled={disabled}
|
2020-03-11 09:56:04 +00:00
|
|
|
|
error={!!getFieldError(errors, "storefrontSearchPosition")}
|
2019-08-16 11:47:30 +00:00
|
|
|
|
fullWidth
|
2020-03-11 09:56:04 +00:00
|
|
|
|
helperText={
|
|
|
|
|
getFieldError(errors, "storefrontSearchPosition")?.message
|
|
|
|
|
}
|
2019-08-16 11:47:30 +00:00
|
|
|
|
name={"storefrontSearchPosition" as keyof AttributePageFormData}
|
|
|
|
|
label={intl.formatMessage({
|
|
|
|
|
defaultMessage: "Position in faceted navigation",
|
2019-08-22 16:19:16 +00:00
|
|
|
|
description: "attribute position in storefront filters"
|
2019-08-16 11:47:30 +00:00
|
|
|
|
})}
|
|
|
|
|
value={data.storefrontSearchPosition}
|
|
|
|
|
onChange={onChange}
|
|
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
<FormSpacer />
|
2019-09-09 09:28:06 +00:00
|
|
|
|
<ControlledCheckbox
|
|
|
|
|
name={"visibleInStorefront" as keyof FormData}
|
2019-08-16 11:47:30 +00:00
|
|
|
|
label={intl.formatMessage({
|
|
|
|
|
defaultMessage: "Visible on Product Page in Storefront",
|
2019-08-22 16:19:16 +00:00
|
|
|
|
description: "attribute"
|
2019-08-16 11:47:30 +00:00
|
|
|
|
})}
|
2019-09-09 09:28:06 +00:00
|
|
|
|
checked={data.visibleInStorefront}
|
2019-08-16 11:47:30 +00:00
|
|
|
|
onChange={onChange}
|
2019-09-09 09:28:06 +00:00
|
|
|
|
disabled={disabled}
|
2019-08-16 11:47:30 +00:00
|
|
|
|
/>
|
|
|
|
|
<CardSpacer />
|
|
|
|
|
<Typography variant="subtitle1">
|
|
|
|
|
<FormattedMessage
|
|
|
|
|
defaultMessage="Dashboard Properties"
|
|
|
|
|
description="attribute properties regarding dashboard"
|
|
|
|
|
/>
|
|
|
|
|
</Typography>
|
|
|
|
|
<Hr />
|
|
|
|
|
<CardSpacer />
|
2019-09-09 09:28:06 +00:00
|
|
|
|
<ControlledCheckbox
|
|
|
|
|
name={"filterableInDashboard" as keyof FormData}
|
|
|
|
|
label={
|
|
|
|
|
<>
|
|
|
|
|
<FormattedMessage
|
|
|
|
|
defaultMessage="Use in Filtering"
|
|
|
|
|
description="use attribute in filtering"
|
|
|
|
|
/>
|
|
|
|
|
<Typography variant="caption">
|
|
|
|
|
<FormattedMessage defaultMessage="If enabled, you’ll be able to use this attribute to filter products in product list." />
|
|
|
|
|
</Typography>
|
|
|
|
|
</>
|
2019-08-16 11:47:30 +00:00
|
|
|
|
}
|
2019-09-09 09:28:06 +00:00
|
|
|
|
checked={data.filterableInDashboard}
|
2019-08-16 11:47:30 +00:00
|
|
|
|
onChange={onChange}
|
2019-09-09 09:28:06 +00:00
|
|
|
|
disabled={disabled}
|
2019-08-16 11:47:30 +00:00
|
|
|
|
/>
|
|
|
|
|
<FormSpacer />
|
2019-09-09 09:28:06 +00:00
|
|
|
|
<ControlledCheckbox
|
|
|
|
|
name={"availableInGrid" as keyof FormData}
|
|
|
|
|
label={
|
|
|
|
|
<>
|
|
|
|
|
<FormattedMessage
|
|
|
|
|
defaultMessage="Add to Column Options"
|
|
|
|
|
description="add attribute as column in product list table"
|
|
|
|
|
/>
|
|
|
|
|
<Typography variant="caption">
|
2019-09-12 10:38:23 +00:00
|
|
|
|
<FormattedMessage defaultMessage="If enabled this attribute can be used as a column in product table." />
|
2019-09-09 09:28:06 +00:00
|
|
|
|
</Typography>
|
|
|
|
|
</>
|
2019-08-16 11:47:30 +00:00
|
|
|
|
}
|
2019-09-09 09:28:06 +00:00
|
|
|
|
checked={data.availableInGrid}
|
2019-08-09 10:17:04 +00:00
|
|
|
|
onChange={onChange}
|
2019-09-09 09:28:06 +00:00
|
|
|
|
disabled={disabled}
|
2019-08-09 10:17:04 +00:00
|
|
|
|
/>
|
2019-08-16 11:47:30 +00:00
|
|
|
|
</CardContent>
|
|
|
|
|
</Card>
|
|
|
|
|
);
|
|
|
|
|
};
|
2019-08-09 10:17:04 +00:00
|
|
|
|
AttributeProperties.displayName = "AttributeProperties";
|
|
|
|
|
export default AttributeProperties;
|