Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Add value required switch

dominik-zeglend9467d5d3936
diff --git a/saleor/static/dashboard-next/attributes/components/AttributeDetails/AttributeDetails.tsx b/saleor/static/dashboard-next/attributes/components/AttributeDetails/AttributeDetails.tsx
index 85840b2250..038f0fa65c 100644
--- a/saleor/static/dashboard-next/attributes/components/AttributeDetails/AttributeDetails.tsx
+++ b/saleor/static/dashboard-next/attributes/components/AttributeDetails/AttributeDetails.tsx
@@ -5,6 +5,7 @@ import React from "react";
import slugify from "slugify";
import CardTitle from "@saleor/components/CardTitle";
+import ControlledSwitch from "@saleor/components/ControlledSwitch";
import FormSpacer from "@saleor/components/FormSpacer";
import SingleSelectField from "@saleor/components/SingleSelectField";
import i18n from "@saleor/i18n";
@@ -81,6 +82,15 @@ const AttributeDetails: React.FC<AttributeDetailsProps> = ({
onChange={onChange}
value={data.inputType}
/>
+ <FormSpacer />
+ <ControlledSwitch
+ checked={data.valueRequired}
+ label={i18n.t("Value Required", {
+ context: "attribute must have value"
+ })}
+ name={"valueRequired" as keyof AttributePageFormData}
+ onChange={onChange}
+ />
</CardContent>
</Card>
);
diff --git a/saleor/static/dashboard-next/attributes/components/AttributePage/AttributePage.tsx b/saleor/static/dashboard-next/attributes/components/AttributePage/AttributePage.tsx
index 222c9e38f8..688495005a 100644
--- a/saleor/static/dashboard-next/attributes/components/AttributePage/AttributePage.tsx
+++ b/saleor/static/dashboard-next/attributes/components/AttributePage/AttributePage.tsx
@@ -43,6 +43,7 @@ export interface AttributePageFormData {
name: string;
slug: string;
storefrontSearchPosition: string;
+ valueRequired: boolean;
visibleInStorefront: boolean;
}
@@ -69,6 +70,7 @@ const AttributePage: React.FC<AttributePageProps> = ({
name: "",
slug: "",
storefrontSearchPosition: "",
+ valueRequired: false,
visibleInStorefront: false
}
: {
@@ -90,6 +92,7 @@ const AttributePage: React.FC<AttributePageProps> = ({
() => attribute.storefrontSearchPosition.toString(),
""
),
+ valueRequired: maybe(() => attribute.valueRequired, false),
visibleInStorefront: maybe(() => attribute.visibleInStorefront, false)
};
diff --git a/saleor/static/dashboard-next/attributes/fixtures.ts b/saleor/static/dashboard-next/attributes/fixtures.ts
index dd79b3f998..b55cfa1345 100644
--- a/saleor/static/dashboard-next/attributes/fixtures.ts
+++ b/saleor/static/dashboard-next/attributes/fixtures.ts
@@ -13,6 +13,7 @@ export const attribute = {
name: "Author",
slug: "author",
storefrontSearchPosition: 2,
+ valueRequired: true,
values: [
{
__typename: "AttributeValue" as "AttributeValue",
diff --git a/saleor/static/dashboard-next/attributes/queries.ts b/saleor/static/dashboard-next/attributes/queries.ts
index 2633cfb934..59112adc5d 100644
--- a/saleor/static/dashboard-next/attributes/queries.ts
+++ b/saleor/static/dashboard-next/attributes/queries.ts
@@ -24,6 +24,7 @@ export const attributeDetailsFragment = gql`
...AttributeFragment
inputType
storefrontSearchPosition
+ valueRequired
values {
id
name
diff --git a/saleor/static/dashboard-next/attributes/types/AttributeCreate.ts b/saleor/static/dashboard-next/attributes/types/AttributeCreate.ts
index ef230528cc..70262200a1 100644
--- a/saleor/static/dashboard-next/attributes/types/AttributeCreate.ts
+++ b/saleor/static/dashboard-next/attributes/types/AttributeCreate.ts
@@ -34,6 +34,7 @@ export interface AttributeCreate_attributeCreate_attribute {
filterableInStorefront: boolean | null;
inputType: AttributeInputTypeEnum | null;
storefrontSearchPosition: number | null;
+ valueRequired: boolean | null;
values: (AttributeCreate_attributeCreate_attribute_values | null)[] | null;
}
diff --git a/saleor/static/dashboard-next/attributes/types/AttributeDetails.ts b/saleor/static/dashboard-next/attributes/types/AttributeDetails.ts
index b392e31db8..8cb88f5f0a 100644
--- a/saleor/static/dashboard-next/attributes/types/AttributeDetails.ts
+++ b/saleor/static/dashboard-next/attributes/types/AttributeDetails.ts
@@ -28,6 +28,7 @@ export interface AttributeDetails_attribute {
filterableInStorefront: boolean | null;
inputType: AttributeInputTypeEnum | null;
storefrontSearchPosition: number | null;
+ valueRequired: boolean | null;
values: (AttributeDetails_attribute_values | null)[] | null;
}
diff --git a/saleor/static/dashboard-next/attributes/types/AttributeDetailsFragment.ts b/saleor/static/dashboard-next/attributes/types/AttributeDetailsFragment.ts
index a36c08232b..2e6c0136d3 100644
--- a/saleor/static/dashboard-next/attributes/types/AttributeDetailsFragment.ts
+++ b/saleor/static/dashboard-next/attributes/types/AttributeDetailsFragment.ts
@@ -28,5 +28,6 @@ export interface AttributeDetailsFragment {
filterableInStorefront: boolean | null;
inputType: AttributeInputTypeEnum | null;
storefrontSearchPosition: number | null;
+ valueRequired: boolean | null;
values: (AttributeDetailsFragment_values | null)[] | null;
}
diff --git a/saleor/static/dashboard-next/attributes/types/AttributeUpdate.ts b/saleor/static/dashboard-next/attributes/types/AttributeUpdate.ts
index 87a9e98ba0..422210ed94 100644
--- a/saleor/static/dashboard-next/attributes/types/AttributeUpdate.ts
+++ b/saleor/static/dashboard-next/attributes/types/AttributeUpdate.ts
@@ -34,6 +34,7 @@ export interface AttributeUpdate_attributeUpdate_attribute {
filterableInStorefront: boolean | null;
inputType: AttributeInputTypeEnum | null;
storefrontSearchPosition: number | null;
+ valueRequired: boolean | null;
values: (AttributeUpdate_attributeUpdate_attribute_values | null)[] | null;
}
diff --git a/saleor/static/dashboard-next/attributes/types/AttributeValueCreate.ts b/saleor/static/dashboard-next/attributes/types/AttributeValueCreate.ts
index a1e4fad0a5..a20a5d7468 100644
--- a/saleor/static/dashboard-next/attributes/types/AttributeValueCreate.ts
+++ b/saleor/static/dashboard-next/attributes/types/AttributeValueCreate.ts
@@ -34,6 +34,7 @@ export interface AttributeValueCreate_attributeValueCreate_attribute {
filterableInStorefront: boolean | null;
inputType: AttributeInputTypeEnum | null;
storefrontSearchPosition: number | null;
+ valueRequired: boolean | null;
values: (AttributeValueCreate_attributeValueCreate_attribute_values | null)[] | null;
}
diff --git a/saleor/static/dashboard-next/attributes/types/AttributeValueDelete.ts b/saleor/static/dashboard-next/attributes/types/AttributeValueDelete.ts
index 99c120dafc..12e5e1e986 100644
--- a/saleor/static/dashboard-next/attributes/types/AttributeValueDelete.ts
+++ b/saleor/static/dashboard-next/attributes/types/AttributeValueDelete.ts
@@ -34,6 +34,7 @@ export interface AttributeValueDelete_attributeValueDelete_attribute {
filterableInStorefront: boolean | null;
inputType: AttributeInputTypeEnum | null;
storefrontSearchPosition: number | null;
+ valueRequired: boolean | null;
values: (AttributeValueDelete_attributeValueDelete_attribute_values | null)[] | null;
}
diff --git a/saleor/static/dashboard-next/attributes/types/AttributeValueUpdate.ts b/saleor/static/dashboard-next/attributes/types/AttributeValueUpdate.ts
index 84184b83a6..545e46f402 100644
--- a/saleor/static/dashboard-next/attributes/types/AttributeValueUpdate.ts
+++ b/saleor/static/dashboard-next/attributes/types/AttributeValueUpdate.ts
@@ -34,6 +34,7 @@ export interface AttributeValueUpdate_attributeValueUpdate_attribute {
filterableInStorefront: boolean | null;
inputType: AttributeInputTypeEnum | null;
storefrontSearchPosition: number | null;
+ valueRequired: boolean | null;
values: (AttributeValueUpdate_attributeValueUpdate_attribute_values | null)[] | null;
}