Skip to content

Commit

Permalink
add isactive and fix adminjs for categories (#1223) (#1234)
Browse files Browse the repository at this point in the history
  • Loading branch information
CarlosQ96 authored Jan 7, 2024
1 parent 3a7c89c commit 0a0bbe1
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 4 deletions.
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

0 comments on commit 0a0bbe1

Please sign in to comment.