Add availableInGrid field

This commit is contained in:
dominik-zeglen 2019-08-12 15:08:16 +02:00
parent 19379c4cfa
commit 8fdf89c66f
12 changed files with 30 additions and 3 deletions

View file

@ -37,6 +37,7 @@ export interface AttributePageProps {
}
export interface AttributePageFormData {
availableInGrid: boolean;
filterableInDashboard: boolean;
inputType: AttributeInputTypeEnum;
filterableInStorefront: boolean;
@ -64,6 +65,7 @@ const AttributePage: React.FC<AttributePageProps> = ({
const initialForm: AttributePageFormData =
attribute === null
? {
availableInGrid: true,
filterableInDashboard: true,
filterableInStorefront: true,
inputType: AttributeInputTypeEnum.DROPDOWN,
@ -74,6 +76,7 @@ const AttributePage: React.FC<AttributePageProps> = ({
visibleInStorefront: true
}
: {
availableInGrid: maybe(() => attribute.availableInGrid, true),
filterableInDashboard: maybe(
() => attribute.filterableInDashboard,
true

View file

@ -105,6 +105,21 @@ const AttributeProperties: React.FC<AttributePropertiesProps> = ({
}
onChange={onChange}
/>
<FormSpacer />
<ControlledSwitch
name={"availableInGrid" as keyof AttributePageFormData}
checked={data.availableInGrid}
disabled={disabled}
label={i18n.t("Add to Column Options")}
secondLabel={
<Typography variant="caption">
{i18n.t(
"If enable this attribute can be used as a column in product table."
)}
</Typography>
}
onChange={onChange}
/>
</CardContent>
</Card>
);

View file

@ -2,10 +2,12 @@ import {
AttributeInputTypeEnum,
AttributeValueType
} from "@saleor/types/globalTypes";
import { AttributeDetailsFragment } from "./types/AttributeDetailsFragment";
import { AttributeList_attributes_edges_node } from "./types/AttributeList";
export const attribute = {
export const attribute: AttributeDetailsFragment = {
__typename: "Attribute" as "Attribute",
availableInGrid: true,
filterableInDashboard: false,
filterableInStorefront: true,
id: "UHJvZHVjdEF0dHJpYnV0ZTo5",
@ -20,7 +22,6 @@ export const attribute = {
id: "UHJvZHVjdEF0dHJpYnV0ZVZhbHVlOjI0",
name: "John Doe",
slug: "john-doe",
sortOrder: 0,
type: AttributeValueType.STRING,
value: ""
},
@ -29,7 +30,6 @@ export const attribute = {
id: "UHJvZHVjdEF0dHJpYnV0ZVZhbHVlOjI1",
name: "Milionare Pirate",
slug: "milionare-pirate",
sortOrder: 1,
type: AttributeValueType.STRING,
value: ""
}

View file

@ -22,6 +22,7 @@ export const attributeDetailsFragment = gql`
${attributeFragment}
fragment AttributeDetailsFragment on Attribute {
...AttributeFragment
availableInGrid
inputType
storefrontSearchPosition
valueRequired

View file

@ -31,6 +31,7 @@ export interface AttributeCreate_attributeCreate_attribute {
visibleInStorefront: boolean;
filterableInDashboard: boolean;
filterableInStorefront: boolean;
availableInGrid: boolean;
inputType: AttributeInputTypeEnum | null;
storefrontSearchPosition: number;
valueRequired: boolean;

View file

@ -25,6 +25,7 @@ export interface AttributeDetails_attribute {
visibleInStorefront: boolean;
filterableInDashboard: boolean;
filterableInStorefront: boolean;
availableInGrid: boolean;
inputType: AttributeInputTypeEnum | null;
storefrontSearchPosition: number;
valueRequired: boolean;

View file

@ -25,6 +25,7 @@ export interface AttributeDetailsFragment {
visibleInStorefront: boolean;
filterableInDashboard: boolean;
filterableInStorefront: boolean;
availableInGrid: boolean;
inputType: AttributeInputTypeEnum | null;
storefrontSearchPosition: number;
valueRequired: boolean;

View file

@ -31,6 +31,7 @@ export interface AttributeUpdate_attributeUpdate_attribute {
visibleInStorefront: boolean;
filterableInDashboard: boolean;
filterableInStorefront: boolean;
availableInGrid: boolean;
inputType: AttributeInputTypeEnum | null;
storefrontSearchPosition: number;
valueRequired: boolean;

View file

@ -31,6 +31,7 @@ export interface AttributeValueCreate_attributeValueCreate_attribute {
visibleInStorefront: boolean;
filterableInDashboard: boolean;
filterableInStorefront: boolean;
availableInGrid: boolean;
inputType: AttributeInputTypeEnum | null;
storefrontSearchPosition: number;
valueRequired: boolean;

View file

@ -31,6 +31,7 @@ export interface AttributeValueDelete_attributeValueDelete_attribute {
visibleInStorefront: boolean;
filterableInDashboard: boolean;
filterableInStorefront: boolean;
availableInGrid: boolean;
inputType: AttributeInputTypeEnum | null;
storefrontSearchPosition: number;
valueRequired: boolean;

View file

@ -31,6 +31,7 @@ export interface AttributeValueUpdate_attributeValueUpdate_attribute {
visibleInStorefront: boolean;
filterableInDashboard: boolean;
filterableInStorefront: boolean;
availableInGrid: boolean;
inputType: AttributeInputTypeEnum | null;
storefrontSearchPosition: number;
valueRequired: boolean;

View file

@ -161,6 +161,7 @@ export enum PermissionEnum {
MANAGE_MENUS = "MANAGE_MENUS",
MANAGE_ORDERS = "MANAGE_ORDERS",
MANAGE_PAGES = "MANAGE_PAGES",
MANAGE_PLUGINS = "MANAGE_PLUGINS",
MANAGE_PRODUCTS = "MANAGE_PRODUCTS",
MANAGE_SETTINGS = "MANAGE_SETTINGS",
MANAGE_SHIPPING = "MANAGE_SHIPPING",