feat(medusa, admin-ui): add description field to product categories (#3768)
* feat(medusa): add description field to product categories * chore: set nullable to false * chore: added UI for description * chore: added codegen files
This commit is contained in:
1 parent
74c54a134d
commit
d533caa4c2
14 files changed
+107
-2
No files matched your search
@@ -103,6 +103,9 @@ export default async (req: Request, res: Response) => {
|
||||
* name:
|
||||
* type: string
|
||||
* description: The name to identify the Product Category by.
|
||||
* description:
|
||||
* type: string
|
||||
* description: An optional text field to describe the Product Category by.
|
||||
* handle:
|
||||
* type: string
|
||||
* description: An optional handle to be used in slugs, if none is provided we will kebab-case the title.
|
||||
|
||||
@@ -141,6 +141,7 @@ export const allowedAdminProductCategoryRelations = [
|
||||
export const defaultProductCategoryFields = [
|
||||
"id",
|
||||
"name",
|
||||
"description",
|
||||
"handle",
|
||||
"is_active",
|
||||
"is_internal",
|
||||
|
||||
@@ -103,6 +103,9 @@ export default async (req: Request, res: Response) => {
|
||||
* name:
|
||||
* type: string
|
||||
* description: The name to identify the Product Category by.
|
||||
* description:
|
||||
* type: string
|
||||
* description: An optional text field to describe the Product Category by.
|
||||
* handle:
|
||||
* type: string
|
||||
* description: A handle to be used in slugs.
|
||||
|
||||
@@ -54,6 +54,7 @@ export const defaultStoreCategoryScope = {
|
||||
export const defaultStoreProductCategoryFields = [
|
||||
"id",
|
||||
"name",
|
||||
"description",
|
||||
"handle",
|
||||
"parent_category_id",
|
||||
"created_at",
|
||||
@@ -64,6 +65,7 @@ export const defaultStoreProductCategoryFields = [
|
||||
export const allowedStoreProductCategoryFields = [
|
||||
"id",
|
||||
"name",
|
||||
"description",
|
||||
"handle",
|
||||
"parent_category_id",
|
||||
"created_at",
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
import { MigrationInterface, QueryRunner } from "typeorm"
|
||||
|
||||
export class addDescriptionToProductCategory1680857773272 implements MigrationInterface {
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "product_category" ADD COLUMN IF NOT EXISTS "description" TEXT NOT NULL DEFAULT ''`
|
||||
)
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "product_category" DROP COLUMN IF EXISTS "description"`
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,9 @@ export class ProductCategory extends BaseEntity {
|
||||
@Column()
|
||||
name: string
|
||||
|
||||
@Column({ nullable: false, default: '' })
|
||||
description: string
|
||||
|
||||
@Index({ unique: true })
|
||||
@Column({ nullable: false })
|
||||
handle: string
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
import { Transform } from "class-transformer"
|
||||
import { IsNotEmpty, IsOptional, IsString, IsBoolean } from "class-validator"
|
||||
import {
|
||||
IsNotEmpty,
|
||||
IsOptional,
|
||||
IsString,
|
||||
IsBoolean,
|
||||
ValidateIf,
|
||||
} from "class-validator"
|
||||
import { isDefined } from "medusa-core-utils"
|
||||
import { ProductCategory } from "../models"
|
||||
|
||||
export const tempReorderRank = 99999
|
||||
@@ -21,6 +28,11 @@ export type UpdateProductCategoryInput = ProductCategoryInput & {
|
||||
}
|
||||
|
||||
export class AdminProductCategoriesReqBase {
|
||||
@Transform(({ value }) => (value === "null" ? null : value))
|
||||
@ValidateIf((input) => isDefined(input.description))
|
||||
@IsString()
|
||||
description?: string
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
handle?: string
|
||||
|
||||
Reference in new issue
Block a user