Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release: Add isactive and fix adminjs for categories (#1223) #1234

Merged
merged 1 commit into from
Jan 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions migration/1703804755642-addIsActiveToMainCategories.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { MigrationInterface, QueryRunner } from 'typeorm';

export class addIsActiveToMainCategories1703804755642
implements MigrationInterface
{
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`
ALTER TABLE main_category
ADD COLUMN IF NOT EXISTS "isActive" boolean DEFAULT true
`,
);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`
ALTER TABLE main_category
DROP "isActive"
`,
);
}
}
4 changes: 4 additions & 0 deletions src/entities/mainCategory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ export class MainCategory extends BaseEntity {
// ipfs link
banner: string;

@Field()
@Column({ default: true })
isActive: boolean;

@Field(type => [Category], { nullable: true })
@OneToMany(type => Category, category => category.mainCategory)
categories?: Category[];
Expand Down
5 changes: 3 additions & 2 deletions src/resolvers/categoryResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class CategoryResolver {
return this.categoryRepository
.createQueryBuilder('category')
.leftJoinAndSelect('category.mainCategory', 'mainCategory')
.where(`"isActive"=true`)
.where(`category."isActive"=true`)
.orderBy({
'category.name': 'ASC',
})
Expand All @@ -35,8 +35,9 @@ export class CategoryResolver {
.innerJoinAndSelect(
'mainCategory.categories',
'categories',
`"isActive"=true`,
`categories."isActive"=true`,
)
.where(`"mainCategory"."isActive"=true`)
.orderBy({
'mainCategory.title': 'ASC',
'categories.name': 'ASC',
Expand Down
10 changes: 8 additions & 2 deletions src/server/adminJs/tabs/categoryTab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,14 @@ export const categoryTab = {
value: {
isVisible: true,
},
mainCategory: {
isVisible: true,
mainCategoryId: {
isVisible: {
list: true,
filter: true,
show: true,
edit: true,
new: true,
},
},
},
},
Expand Down
3 changes: 3 additions & 0 deletions src/server/adminJs/tabs/mainCategoryTab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ export const mainCategoryTab = {
banner: {
isVisible: true,
},
isActive: {
isVisible: true,
},
slug: {
isVisible: true,
},
Expand Down
Loading