Theodo-UK / nestjs-admin

A generic administration interface for TypeORM entities
https://nestjs-admin.com
MIT License
536 stars 60 forks source link

Fields not being filtered out #176

Open kunall435 opened 4 years ago

kunall435 commented 4 years ago

I've made a class extending from the AdminEntity and added the fields array as given in the documentation but still on adding/changing properties, it shows me all the fields from the column.

import { JobEntity } from './../dashboard/job.entity';

export class UserAdmin extends AdminEntity {
    entity = JobEntity;
    listDisplay = ['title', 'isAprooved'];
    fields = ['title', 'isAprooved'];
}
Screenshot 2020-07-03 at 6 43 00 PM Screenshot 2020-07-03 at 6 44 55 PM

Is there something which I'm doing wrong?

maksimoancha commented 4 years ago

Did you register your UserAdmin class in AdminSite? If not, than you should do something like this:

import { JobEntity } from './../dashboard/job.entity';
import {
  DefaultAdminModule,
  DefaultAdminSite,
  AdminEntity,
  AdminUserEntity,
} from 'nestjs-admin';
import { Module } from '@nestjs/common';

export class UserAdmin extends AdminEntity {
  entity = JobEntity;
  listDisplay = ['title', 'isAprooved'];
  fields = ['title', 'isAprooved'];
}

@Module({
  imports: [DefaultAdminModule],
})
export class BackofficeModule {
  constructor(private readonly adminSite: DefaultAdminSite) {
    adminSite.register('Administration', AdminUserEntity);
    adminSite.register('UserAdministation', UserAdmin);
  }
}

And than just import BackofficeModule in your AppModule

kunall435 commented 4 years ago

Hey thanks for the super fast reply, yes definetly I've registered this one in the Module class

Also I've got the listDisplay paramter working correctly, I can only see the title and the isAprooved field in the display of jobs but while editing the job, its having some issues.


const coreModule = AdminCoreModuleFactory.createAdminCoreModule({});
const authModulezxc = AdminAuthModuleFactory.createAdminAuthModule({
    adminCoreModule: coreModule, // what admin module are you configuring authentication for
    credentialValidator: adminCredentialValidator, // how do you validate credentials
    imports: [TypeOrmModule.forFeature([UserEntity])], // what modules export the dependencies of the credentialValidator available
    providers: [], // additional providers that will be instanciated and exported by the AdminAuthModuleFactory
});

@Module({
    imports: [
        forwardRef(() => AuthModule),
        TypeOrmModule.forFeature([UserRepository]),
        coreModule,
        authModulezxc,
    ],
    controllers: [UserController],
    exports: [UserService, coreModule],
    providers: [UserService],
})
export class UserModule {
    constructor(private readonly _adminSite: DefaultAdminSite) {
        _adminSite.register('Jobs', UserAdmin);
    }
}
maksimoancha commented 4 years ago

Yeah...just have checked, and seem's like it's really don't work, as you said before - listDisplay and searchFields works fine, but fields doesn't.

kunall435 commented 4 years ago

Yeah, thanks for the confirmation. Can you please provide a fix for that?

maksimoancha commented 4 years ago

Oh, sorry, but I'm not a collaborator on this project xD Just like this admin panel

kunall435 commented 4 years ago

@williamdclt Can you help here?

dkam26 commented 4 years ago

@maksimoancha, did we get a fix for this?