Skip to content

Commit

Permalink
fix: filtering by enums
Browse files Browse the repository at this point in the history
  • Loading branch information
wojtek-krysiak committed Aug 3, 2020
1 parent 46c3600 commit da5d8ad
Show file tree
Hide file tree
Showing 6 changed files with 179 additions and 149 deletions.
8 changes: 4 additions & 4 deletions example-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"license": "MIT",
"scripts": {
"build": "tsc",
"start": "ts-node src/index.ts",
"start:dev": "concurrently \"yarn build --watch\" \"nodemon --ext '.js' --watch ../build --watch ./build --ignore 'cypress/**/*.js' node build/src/index.js\"",
"start": "node build/src/index.js",
"start:dev": "yarn build && concurrently \"yarn build --watch\" \"nodemon --ext '.js' --watch ../lib --watch ./build --ignore 'cypress/**/*.js' node build/src/index.js\"",
"cypress:open": "cypress open",
"cypress:run": "cypress run"
},
Expand All @@ -17,12 +17,12 @@
"cypress": "^4.11.0",
"nodemon": "^2.0.4",
"ts-node": "3.3.0",
"typescript": "3.3.3333"
"typescript": "3.9.7"
},
"dependencies": {
"@admin-bro/core": "^3.0.0-beta.4",
"@admin-bro/express": "^3.0.0-beta.1",
"@admin-bro/typeorm": "^1.0.0",
"@admin-bro/typeorm": "^1.0.1",
"express": "^4.17.1",
"express-formidable": "^1.2.0",
"express-session": "^1.17.1",
Expand Down
15 changes: 13 additions & 2 deletions example-app/src/entity/User.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { Entity, PrimaryGeneratedColumn, Column } from 'typeorm'
import { BaseEntity, Entity, PrimaryGeneratedColumn, Column } from 'typeorm'

export enum UserRoles {
DESIGNER = 'designer',
CLIENT = 'client'
}

@Entity()
export class User {
export class User extends BaseEntity {
@PrimaryGeneratedColumn()
id: number;

Expand All @@ -13,4 +18,10 @@ export class User {

@Column()
age: number;

@Column({
type: 'enum',
enum: UserRoles,
})
public role: UserRoles;
}
6 changes: 4 additions & 2 deletions example-app/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { createConnection } from 'typeorm'
import express from 'express'
import AdminBro from '@admin-bro/core'
import { buildRouter } from '@admin-bro/express'
import TypeormAdapter from '@admin-bro/typeorm'
import * as TypeormAdapter from '@admin-bro/typeorm'
import { User } from './entity/User'

AdminBro.registerAdapter(TypeormAdapter)
Expand All @@ -13,7 +13,9 @@ const PORT = 3000
const run = async () => {
await createConnection()
const app = express()
const admin = new AdminBro()
const admin = new AdminBro({
resources: [User],
})
const router = buildRouter(admin)

app.use(admin.options.rootPath, router)
Expand Down
8 changes: 7 additions & 1 deletion example-app/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"compilerOptions": {
"baseUrl": ".",
"outDir": "./build",
"target": "es6",
"esModuleInterop": true,
Expand All @@ -13,7 +14,12 @@
"types": ["cypress"],
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"strictPropertyInitialization": false
"strictPropertyInitialization": false,
"sourceMap": true,
"paths": {
"react": ["node_modules/@types/react"],
"@admin-bro/core": ["node_modules/@admin-bro/core"],
}
},
"include": [
"./src/**/*",
Expand Down
Loading

0 comments on commit da5d8ad

Please sign in to comment.