Merge pull request #99 from mirumee/add/is-attribute-filterable-switch

Add switch to make attribute available in product list column selection
This commit is contained in:
Dominik Żegleń 2019-08-21 15:30:39 +02:00 committed by GitHub
commit f89ff798fe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 4051 additions and 4 deletions

View file

@ -7,3 +7,4 @@ All notable, unreleased changes to this project will be documented in this file.
- Add changelog and github issue/PR templates - #97 by @dominik-zeglen
- Update dependencies to suppress storybook build errors - #98 by @dominik-zeglen
- Fix configure menu section - #109 by @benekex2
- Add switch to make attribute available in product list as a column - #99 by @dominik-zeglen

View file

@ -4,7 +4,7 @@ module.exports = {
includes: ["src/**/*.ts", "src/**/*.tsx"],
name: "dashboard",
service: {
endpoint: "localhost:8000/graphql/",
localSchemaFile: "schema.graphql",
name: "saleor"
}
}

3711
schema.graphql Normal file

File diff suppressed because it is too large Load diff

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

@ -7058,6 +7058,57 @@ exports[`Storyshots Views / Attributes / Attribute details create 1`] = `
</div>
</span>
</label>
<div
class="FormSpacer-spacer-id"
/>
<label
class="MuiFormControlLabel-root-id"
>
<span
class="MuiSwitch-root-id"
>
<span
class="MuiButtonBase-root-id MuiIconButton-root-id MuiPrivateSwitchBase-root-id MuiSwitch-switchBase-id MuiSwitch-colorPrimary-id MuiPrivateSwitchBase-checked-id MuiSwitch-checked-id"
>
<span
class="MuiIconButton-label-id"
>
<span
class="MuiSwitch-icon-id MuiSwitch-iconChecked-id"
/>
<input
checked=""
class="MuiPrivateSwitchBase-input-id"
name="availableInGrid"
type="checkbox"
/>
</span>
</span>
<span
class="MuiSwitch-bar-id"
/>
</span>
<span
class="MuiTypography-root-id MuiTypography-body2-id MuiFormControlLabel-label-id"
>
<div
class="ControlledSwitch-label-id"
>
<span
class="ControlledSwitch-labelText-id"
>
Add to Column Options
</span>
<div>
<span
class="MuiTypography-root-id MuiTypography-caption-id"
>
If enable this attribute can be used as a column in product table.
</span>
</div>
</div>
</span>
</label>
</div>
</div>
</div>
@ -7741,6 +7792,57 @@ exports[`Storyshots Views / Attributes / Attribute details default 1`] = `
</div>
</span>
</label>
<div
class="FormSpacer-spacer-id"
/>
<label
class="MuiFormControlLabel-root-id"
>
<span
class="MuiSwitch-root-id"
>
<span
class="MuiButtonBase-root-id MuiIconButton-root-id MuiPrivateSwitchBase-root-id MuiSwitch-switchBase-id MuiSwitch-colorPrimary-id MuiPrivateSwitchBase-checked-id MuiSwitch-checked-id"
>
<span
class="MuiIconButton-label-id"
>
<span
class="MuiSwitch-icon-id MuiSwitch-iconChecked-id"
/>
<input
checked=""
class="MuiPrivateSwitchBase-input-id"
name="availableInGrid"
type="checkbox"
/>
</span>
</span>
<span
class="MuiSwitch-bar-id"
/>
</span>
<span
class="MuiTypography-root-id MuiTypography-body2-id MuiFormControlLabel-label-id"
>
<div
class="ControlledSwitch-label-id"
>
<span
class="ControlledSwitch-labelText-id"
>
Add to Column Options
</span>
<div>
<span
class="MuiTypography-root-id MuiTypography-caption-id"
>
If enable this attribute can be used as a column in product table.
</span>
</div>
</div>
</span>
</label>
</div>
</div>
</div>
@ -8434,6 +8536,57 @@ exports[`Storyshots Views / Attributes / Attribute details form errors 1`] = `
</div>
</span>
</label>
<div
class="FormSpacer-spacer-id"
/>
<label
class="MuiFormControlLabel-root-id"
>
<span
class="MuiSwitch-root-id"
>
<span
class="MuiButtonBase-root-id MuiIconButton-root-id MuiPrivateSwitchBase-root-id MuiSwitch-switchBase-id MuiSwitch-colorPrimary-id MuiPrivateSwitchBase-checked-id MuiSwitch-checked-id"
>
<span
class="MuiIconButton-label-id"
>
<span
class="MuiSwitch-icon-id MuiSwitch-iconChecked-id"
/>
<input
checked=""
class="MuiPrivateSwitchBase-input-id"
name="availableInGrid"
type="checkbox"
/>
</span>
</span>
<span
class="MuiSwitch-bar-id"
/>
</span>
<span
class="MuiTypography-root-id MuiTypography-body2-id MuiFormControlLabel-label-id"
>
<div
class="ControlledSwitch-label-id"
>
<span
class="ControlledSwitch-labelText-id"
>
Add to Column Options
</span>
<div>
<span
class="MuiTypography-root-id MuiTypography-caption-id"
>
If enable this attribute can be used as a column in product table.
</span>
</div>
</div>
</span>
</label>
</div>
</div>
</div>
@ -9061,6 +9214,59 @@ exports[`Storyshots Views / Attributes / Attribute details loading 1`] = `
</div>
</span>
</label>
<div
class="FormSpacer-spacer-id"
/>
<label
class="MuiFormControlLabel-root-id MuiFormControlLabel-disabled-id"
>
<span
class="MuiSwitch-root-id"
>
<span
class="MuiButtonBase-root-id MuiButtonBase-disabled-id MuiIconButton-root-id MuiIconButton-disabled-id MuiPrivateSwitchBase-root-id MuiSwitch-switchBase-id MuiSwitch-colorPrimary-id MuiPrivateSwitchBase-checked-id MuiSwitch-checked-id MuiPrivateSwitchBase-disabled-id MuiSwitch-disabled-id"
tabindex="-1"
>
<span
class="MuiIconButton-label-id"
>
<span
class="MuiSwitch-icon-id MuiSwitch-iconChecked-id"
/>
<input
checked=""
class="MuiPrivateSwitchBase-input-id"
disabled=""
name="availableInGrid"
type="checkbox"
/>
</span>
</span>
<span
class="MuiSwitch-bar-id"
/>
</span>
<span
class="MuiTypography-root-id MuiTypography-body2-id MuiFormControlLabel-label-id MuiFormControlLabel-disabled-id"
>
<div
class="ControlledSwitch-label-id"
>
<span
class="ControlledSwitch-labelText-id"
>
Add to Column Options
</span>
<div>
<span
class="MuiTypography-root-id MuiTypography-caption-id"
>
If enable this attribute can be used as a column in product table.
</span>
</div>
</div>
</span>
</label>
</div>
</div>
</div>
@ -9744,6 +9950,57 @@ exports[`Storyshots Views / Attributes / Attribute details multiple select input
</div>
</span>
</label>
<div
class="FormSpacer-spacer-id"
/>
<label
class="MuiFormControlLabel-root-id"
>
<span
class="MuiSwitch-root-id"
>
<span
class="MuiButtonBase-root-id MuiIconButton-root-id MuiPrivateSwitchBase-root-id MuiSwitch-switchBase-id MuiSwitch-colorPrimary-id MuiPrivateSwitchBase-checked-id MuiSwitch-checked-id"
>
<span
class="MuiIconButton-label-id"
>
<span
class="MuiSwitch-icon-id MuiSwitch-iconChecked-id"
/>
<input
checked=""
class="MuiPrivateSwitchBase-input-id"
name="availableInGrid"
type="checkbox"
/>
</span>
</span>
<span
class="MuiSwitch-bar-id"
/>
</span>
<span
class="MuiTypography-root-id MuiTypography-body2-id MuiFormControlLabel-label-id"
>
<div
class="ControlledSwitch-label-id"
>
<span
class="ControlledSwitch-labelText-id"
>
Add to Column Options
</span>
<div>
<span
class="MuiTypography-root-id MuiTypography-caption-id"
>
If enable this attribute can be used as a column in product table.
</span>
</div>
</div>
</span>
</label>
</div>
</div>
</div>
@ -10355,6 +10612,57 @@ exports[`Storyshots Views / Attributes / Attribute details no values 1`] = `
</div>
</span>
</label>
<div
class="FormSpacer-spacer-id"
/>
<label
class="MuiFormControlLabel-root-id"
>
<span
class="MuiSwitch-root-id"
>
<span
class="MuiButtonBase-root-id MuiIconButton-root-id MuiPrivateSwitchBase-root-id MuiSwitch-switchBase-id MuiSwitch-colorPrimary-id MuiPrivateSwitchBase-checked-id MuiSwitch-checked-id"
>
<span
class="MuiIconButton-label-id"
>
<span
class="MuiSwitch-icon-id MuiSwitch-iconChecked-id"
/>
<input
checked=""
class="MuiPrivateSwitchBase-input-id"
name="availableInGrid"
type="checkbox"
/>
</span>
</span>
<span
class="MuiSwitch-bar-id"
/>
</span>
<span
class="MuiTypography-root-id MuiTypography-body2-id MuiFormControlLabel-label-id"
>
<div
class="ControlledSwitch-label-id"
>
<span
class="ControlledSwitch-labelText-id"
>
Add to Column Options
</span>
<div>
<span
class="MuiTypography-root-id MuiTypography-caption-id"
>
If enable this attribute can be used as a column in product table.
</span>
</div>
</div>
</span>
</label>
</div>
</div>
</div>

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",